Skip to content

Commit

Permalink
More log on sync pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
asdacap committed Dec 11, 2024
1 parent 6569082 commit 744691b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Nethermind.Blockchain.Receipts;
using Nethermind.Core.Test;
using Nethermind.Db;
using Nethermind.Logging;
using NUnit.Framework;

namespace Nethermind.Synchronization.Test;
Expand All @@ -17,7 +18,7 @@ public void WhenReceiptNotStore_SetLowestInsertedReceiptTo0()
SyncPointers pointers = new SyncPointers(new TestMemDb(), new TestMemColumnsDb<ReceiptsColumns>(), new ReceiptConfig()
{
StoreReceipts = false
});
}, LimboLogs.Instance);

pointers.LowestInsertedReceiptBlockNumber.Should().Be(0);
}
Expand Down
9 changes: 6 additions & 3 deletions src/Nethermind/Nethermind.Synchronization/SyncPointers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Nethermind.Core.Crypto;
using Nethermind.Core.Extensions;
using Nethermind.Db;
using Nethermind.Logging;
using Nethermind.Serialization.Rlp;

namespace Nethermind.Synchronization;
Expand Down Expand Up @@ -46,15 +47,17 @@ public long? LowestInsertedReceiptBlockNumber
}


public SyncPointers([KeyFilter(DbNames.Blocks)] IDb blocksDb, IColumnsDb<ReceiptsColumns> receiptsDb, IReceiptConfig receiptConfig)
public SyncPointers([KeyFilter(DbNames.Blocks)] IDb blocksDb, IColumnsDb<ReceiptsColumns> receiptsDb, IReceiptConfig receiptConfig, ILogManager logManager)
{
_blocksDb = blocksDb;
_defaultReceiptDbColumn = receiptsDb.GetColumnDb(ReceiptsColumns.Default);

ILogger logger = logManager.GetClassLogger<SyncPointers>();
LowestInsertedBodyNumber = _blocksDb[LowestInsertedBodyNumberDbEntryAddress]?.AsRlpValueContext().DecodeLong();
if (logger.IsDebug) logger.Debug($"Lowest inserted body number loaded to {LowestInsertedBodyNumber?.ToString() ?? "null"}");

byte[] lowestBytes = _defaultReceiptDbColumn.Get(Keccak.Zero);
_lowestInsertedReceiptBlock = lowestBytes is null ? (long?)null : new RlpStream(lowestBytes).DecodeLong();
LowestInsertedReceiptBlockNumber = _defaultReceiptDbColumn[Keccak.Zero.Bytes]?.AsRlpValueContext().DecodeLong();
if (logger.IsDebug) logger.Debug($"Lowest inserted receipt number loaded to {LowestInsertedReceiptBlockNumber?.ToString() ?? "null"}");

// When not storing receipt, set the lowest inserted receipt to 0 so that old receipt will finish immediately
if (!receiptConfig.StoreReceipts)
Expand Down

0 comments on commit 744691b

Please sign in to comment.