From 1cf11ae524a6aa14236636c3b3deb69c9bbed937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= Date: Mon, 13 Jan 2025 14:46:50 +0100 Subject: [PATCH 1/8] Add single block receipt miration functionality --- .../Receipts/IReceiptsMigration.cs | 2 +- .../Nethermind.Cli/Modules/DebugCliModule.cs | 4 +- .../Steps/Migrations/ReceiptMigration.cs | 54 +++++++++++++--- .../Modules/DebugModuleTests.cs | 7 ++- .../Modules/DebugModule/DebugBridge.cs | 9 ++- .../Modules/DebugModule/DebugRpcModule.cs | 4 +- .../Modules/DebugModule/IDebugBridge.cs | 2 +- .../Modules/DebugModule/IDebugRpcModule.cs | 2 +- .../Steps/Migrations/ReceiptMigrationTests.cs | 62 +++++++++++++++++++ 9 files changed, 125 insertions(+), 21 deletions(-) diff --git a/src/Nethermind/Nethermind.Blockchain/Receipts/IReceiptsMigration.cs b/src/Nethermind/Nethermind.Blockchain/Receipts/IReceiptsMigration.cs index 5944c305c36..27b7638201a 100644 --- a/src/Nethermind/Nethermind.Blockchain/Receipts/IReceiptsMigration.cs +++ b/src/Nethermind/Nethermind.Blockchain/Receipts/IReceiptsMigration.cs @@ -7,6 +7,6 @@ namespace Nethermind.Blockchain.Receipts { public interface IReceiptsMigration { - Task Run(long blockNumber); + Task Run(long blockNumber, bool migrateSingleBlock = false); } } diff --git a/src/Nethermind/Nethermind.Cli/Modules/DebugCliModule.cs b/src/Nethermind/Nethermind.Cli/Modules/DebugCliModule.cs index dfc6330f83f..c20fbd00713 100644 --- a/src/Nethermind/Nethermind.Cli/Modules/DebugCliModule.cs +++ b/src/Nethermind/Nethermind.Cli/Modules/DebugCliModule.cs @@ -93,9 +93,9 @@ public JsValue TraceTransactionInBlockByIndex(string rlp, int index, object opti } [CliFunction("debug", "migrateReceipts")] - public bool MigrateReceipts(long number) + public bool MigrateReceipts(long number, bool migrateSingleBlock = false) { - return NodeManager.Post("debug_migrateReceipts", number).Result; + return NodeManager.Post("debug_migrateReceipts", number, migrateSingleBlock).Result; } public DebugCliModule(ICliEngine cliEngine, INodeManager nodeManager) : base(cliEngine, nodeManager) diff --git a/src/Nethermind/Nethermind.Init/Steps/Migrations/ReceiptMigration.cs b/src/Nethermind/Nethermind.Init/Steps/Migrations/ReceiptMigration.cs index c77c0297f18..c5368e41d10 100644 --- a/src/Nethermind/Nethermind.Init/Steps/Migrations/ReceiptMigration.cs +++ b/src/Nethermind/Nethermind.Init/Steps/Migrations/ReceiptMigration.cs @@ -89,13 +89,13 @@ ILogManager logManager _progressLogger = new ProgressLogger("Receipts migration", logManager); } - public async Task Run(long blockNumber) + public async Task Run(long blockNumber, bool migrateSingleBlock = false) { _cancellationTokenSource?.Cancel(); - await (_migrationTask ?? Task.CompletedTask); + await(_migrationTask ?? Task.CompletedTask); _cancellationTokenSource = new CancellationTokenSource(); _receiptStorage.MigratedBlockNumber = Math.Min(Math.Max(_receiptStorage.MigratedBlockNumber, blockNumber), (_blockTree.Head?.Number ?? 0) + 1); - _migrationTask = DoRun(_cancellationTokenSource.Token); + _migrationTask = DoRun(_cancellationTokenSource.Token, migrateSingleBlock); return _receiptConfig.StoreReceipts && _receiptConfig.ReceiptsMigration; } public async Task Run(CancellationToken cancellationToken) @@ -110,7 +110,7 @@ public async Task Run(CancellationToken cancellationToken) } } - private async Task DoRun(CancellationToken cancellationToken) + private async Task DoRun(CancellationToken cancellationToken, bool migrateSingleBlock = false) { if (_receiptConfig.StoreReceipts) { @@ -123,30 +123,36 @@ await Wait.ForEventCondition( (arg) => CanMigrate(arg.Current)); } - RunIfNeeded(cancellationToken); + RunIfNeeded(cancellationToken, migrateSingleBlock); } } private static bool CanMigrate(SyncMode syncMode) => syncMode.NotSyncing(); - private void RunIfNeeded(CancellationToken cancellationToken) + private void RunIfNeeded(CancellationToken cancellationToken, bool migrateSingleBlock) { // Note, it start in decreasing order from this high number. long migrateToBlockNumber = _receiptStorage.MigratedBlockNumber == long.MaxValue ? _syncModeSelector.Current.NotSyncing() ? _blockTree.Head?.Number ?? 0 : _blockTree.BestKnownNumber - : _receiptStorage.MigratedBlockNumber - 1; + : migrateSingleBlock + ? _receiptStorage.MigratedBlockNumber + : _receiptStorage.MigratedBlockNumber - 1; + _toBlock = migrateToBlockNumber; _logger.Warn($"Running migration to {_toBlock}"); - if (_toBlock > 0) + if (_toBlock > 0 || migrateSingleBlock) { _stopwatch = Stopwatch.StartNew(); try { - RunMigration(cancellationToken); + if (migrateSingleBlock) + MigrateSingleBlock(_toBlock); + else + RunMigration(cancellationToken); } catch (Exception e) { @@ -225,6 +231,36 @@ private void RunMigration(CancellationToken token) } } + public void MigrateSingleBlock(long blockNumber) + { + ChainLevelInfo? level = _chainLevelInfoRepository.LoadLevel(blockNumber); + if (level?.MainChainBlock == null) + { + _logger.Warn($"Could not find main chain block for block #{blockNumber}."); + return; + } + Hash256 blockHash = level.MainChainBlock.BlockHash; + + Block? block = _blockTree.FindBlock(blockHash, BlockTreeLookupOptions.None); + if (block == null) + { + _logger.Debug($"Block #{blockNumber} not found in block tree, using empty block placeholder."); + block = GetMissingBlock(blockNumber, blockHash); + } + + _logger.Info($"Migrating receipts for block #{blockNumber}."); + MigrateBlock(block); + + if (ReferenceEquals(block, EmptyBlock)) + { + ReturnMissingBlock(block); + } + + _receiptsDb.Compact(); + _txIndexDb.Compact(); + _receiptsBlockDb.Compact(); + } + Block GetMissingBlock(long i, Hash256? blockHash) { if (_logger.IsDebug) _logger.Debug(GetLogMessage("warning", $"Block {i} not found. Logs will not be searchable for this block.")); diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/DebugModuleTests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/DebugModuleTests.cs index 0cea4e87063..277545a74de 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/DebugModuleTests.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/DebugModuleTests.cs @@ -389,12 +389,13 @@ public void Debug_traceCall_test() debugTraceCall.Should().BeEquivalentTo(expected); } - [Test] - public async Task Migrate_receipts() + [TestCase(false)] + [TestCase(true)] + public async Task Migrate_receipts(bool migrateSingleBlock) { debugBridge.MigrateReceipts(Arg.Any()).Returns(true); IDebugRpcModule rpcModule = new DebugRpcModule(LimboLogs.Instance, debugBridge, jsonRpcConfig, specProvider); - string response = await RpcTest.TestSerializedRequest(rpcModule, "debug_migrateReceipts", 100); + string response = await RpcTest.TestSerializedRequest(rpcModule, "debug_migrateReceipts", 100, migrateSingleBlock); Assert.That(response, Is.Not.Null); } diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs index df9dea1b87f..71f4b25c652 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs @@ -91,8 +91,13 @@ public DebugBridge( public void UpdateHeadBlock(Hash256 blockHash) => _blockTree.UpdateHeadBlock(blockHash); - public Task MigrateReceipts(long blockNumber) - => _receiptsMigration.Run(blockNumber + 1); // add 1 to make go from inclusive (better for API) to exclusive (better for internal) + public Task MigrateReceipts(long blockNumber, bool migrateSingleBlock = false) + { + if (migrateSingleBlock) + return _receiptsMigration.Run(blockNumber); + else + return _receiptsMigration.Run(blockNumber + 1); // add 1 to make go from inclusive (better for API) to exclusive (better for internal) + } public void InsertReceipts(BlockParameter blockParameter, TxReceipt[] txReceipts) { diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugRpcModule.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugRpcModule.cs index 1dfe1a5a6a7..5d0d6553a36 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugRpcModule.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugRpcModule.cs @@ -147,8 +147,8 @@ public ResultWrapper debug_traceTransactionInBlockByIndex(byte[ return ResultWrapper.Success(transactionTrace); } - public async Task> debug_migrateReceipts(long blockNumber) => - ResultWrapper.Success(await _debugBridge.MigrateReceipts(blockNumber)); + public async Task> debug_migrateReceipts(long blockNumber, bool migrateSingleBlock = false) => + ResultWrapper.Success(await _debugBridge.MigrateReceipts(blockNumber, migrateSingleBlock)); public Task> debug_insertReceipts(BlockParameter blockParameter, ReceiptForRpc[] receiptForRpc) { diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/IDebugBridge.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/IDebugBridge.cs index 9b8db38d2cf..f0f59d04728 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/IDebugBridge.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/IDebugBridge.cs @@ -31,7 +31,7 @@ public interface IDebugBridge ChainLevelInfo GetLevelInfo(long number); int DeleteChainSlice(long startNumber, bool force = false); void UpdateHeadBlock(Hash256 blockHash); - Task MigrateReceipts(long blockNumber); + Task MigrateReceipts(long blockNumber, bool migrateSingleBlock = false); void InsertReceipts(BlockParameter blockParameter, TxReceipt[] receipts); SyncReportSymmary GetCurrentSyncStage(); IEnumerable TraceBlockToFile(Hash256 blockHash, CancellationToken cancellationToken, GethTraceOptions? gethTraceOptions = null); diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/IDebugRpcModule.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/IDebugRpcModule.cs index f8c1129cddc..1326d7da557 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/IDebugRpcModule.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/IDebugRpcModule.cs @@ -85,7 +85,7 @@ public interface IDebugRpcModule : IRpcModule ResultWrapper debug_traceTransactionInBlockByIndex(byte[] blockRlp, int txIndex, GethTraceOptions options = null); [JsonRpcMethod(Description = "Sets the block number up to which receipts will be migrated to (Nethermind specific).")] - Task> debug_migrateReceipts(long blockNumber); + Task> debug_migrateReceipts(long blockNumber, bool migrateSingleBlock = false); [JsonRpcMethod(Description = "Insert receipts for the block after verifying receipts root correctness.")] Task> debug_insertReceipts(BlockParameter blockParameter, ReceiptForRpc[] receiptForRpc); diff --git a/src/Nethermind/Nethermind.Runner.Test/Ethereum/Steps/Migrations/ReceiptMigrationTests.cs b/src/Nethermind/Nethermind.Runner.Test/Ethereum/Steps/Migrations/ReceiptMigrationTests.cs index 2ed20142439..2c06fceca67 100644 --- a/src/Nethermind/Nethermind.Runner.Test/Ethereum/Steps/Migrations/ReceiptMigrationTests.cs +++ b/src/Nethermind/Nethermind.Runner.Test/Ethereum/Steps/Migrations/ReceiptMigrationTests.cs @@ -117,6 +117,68 @@ public async Task RunMigration(int? commandStartBlockNumber, long currentMigrate } } + [Test] + public async Task SingleBlockMigration_RestoresMissingReceipt() + { + IReceiptConfig receiptConfig = new ReceiptConfig + { + StoreReceipts = true, + ReceiptsMigration = true, + CompactReceiptStore = false + }; + + var blockTreeBuilder = Core.Test.Builders.Build.A.BlockTree().OfChainLength(3); + IBlockTree blockTree = blockTreeBuilder.TestObject; + IChainLevelInfoRepository chainLevelInfoRepository = blockTreeBuilder.ChainLevelInfoRepository; + + InMemoryReceiptStorage inMemoryReceiptStorage = new(true); + InMemoryReceiptStorage outMemoryReceiptStorage = new(true); + inMemoryReceiptStorage.MigratedBlockNumber = 0; + outMemoryReceiptStorage.MigratedBlockNumber = 0; + + Block blockToMigrate = blockTree.FindBlock(1); + TxReceipt receiptA = Core.Test.Builders.Build.A.Receipt.WithTransactionHash(TestItem.Keccaks[0]).TestObject; + TxReceipt receiptB = Core.Test.Builders.Build.A.Receipt.WithTransactionHash(TestItem.Keccaks[1]).TestObject; + + inMemoryReceiptStorage.Insert(blockToMigrate, new[] { receiptA, receiptB }); + + outMemoryReceiptStorage.Insert(blockToMigrate, new[] { receiptA }); + + TestMemColumnsDb receiptColumnDb = new(); + TestMemDb blocksDb = (TestMemDb)receiptColumnDb.GetColumnDb(ReceiptsColumns.Blocks); + TestMemDb txIndexDb = (TestMemDb)receiptColumnDb.GetColumnDb(ReceiptsColumns.Transactions); + + ISyncModeSelector syncModeSelector = Substitute.For(); + syncModeSelector.Current.Returns(SyncMode.WaitingForBlock); + + TestReceiptStorage testStorage = new TestReceiptStorage(inMemoryReceiptStorage, outMemoryReceiptStorage); + + var migration = new ReceiptMigration( + testStorage, + blockTree, + syncModeSelector, + chainLevelInfoRepository, + receiptConfig, + receiptColumnDb, + Substitute.For(), + LimboLogs.Instance + ); + + await migration.Run(1, migrateSingleBlock: true); + if (migration._migrationTask != null) + { + await migration._migrationTask; + } + + TxReceipt[] outReceipts = outMemoryReceiptStorage.Get(blockToMigrate, recover: false, recoverSender: false); + outReceipts.Length.Should().Be(2, "Both receipts (A & B) should be present after migration."); + + outReceipts.Should().Contain(receiptA) + .And.Contain(receiptB); + + outMemoryReceiptStorage.MigratedBlockNumber.Should().BeGreaterThanOrEqualTo(1); + } + private class TestReceiptStorage : IReceiptStorage { private readonly IReceiptStorage _inStorage; From abd8d396691756e2b1c5b38abdee937be6da5ee8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= Date: Mon, 13 Jan 2025 15:15:36 +0100 Subject: [PATCH 2/8] Improve test and add missing param pass --- .../Modules/DebugModule/DebugBridge.cs | 2 +- .../Steps/Migrations/ReceiptMigrationTests.cs | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs index 71f4b25c652..46020819e96 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs @@ -94,7 +94,7 @@ public DebugBridge( public Task MigrateReceipts(long blockNumber, bool migrateSingleBlock = false) { if (migrateSingleBlock) - return _receiptsMigration.Run(blockNumber); + return _receiptsMigration.Run(blockNumber, migrateSingleBlock); else return _receiptsMigration.Run(blockNumber + 1); // add 1 to make go from inclusive (better for API) to exclusive (better for internal) } diff --git a/src/Nethermind/Nethermind.Runner.Test/Ethereum/Steps/Migrations/ReceiptMigrationTests.cs b/src/Nethermind/Nethermind.Runner.Test/Ethereum/Steps/Migrations/ReceiptMigrationTests.cs index 2c06fceca67..1a730161d0a 100644 --- a/src/Nethermind/Nethermind.Runner.Test/Ethereum/Steps/Migrations/ReceiptMigrationTests.cs +++ b/src/Nethermind/Nethermind.Runner.Test/Ethereum/Steps/Migrations/ReceiptMigrationTests.cs @@ -136,7 +136,8 @@ public async Task SingleBlockMigration_RestoresMissingReceipt() inMemoryReceiptStorage.MigratedBlockNumber = 0; outMemoryReceiptStorage.MigratedBlockNumber = 0; - Block blockToMigrate = blockTree.FindBlock(1); + Block blockToMigrate = blockTree.FindBlock(2); + Block blockNotToMigrate = blockTree.FindBlock(1); TxReceipt receiptA = Core.Test.Builders.Build.A.Receipt.WithTransactionHash(TestItem.Keccaks[0]).TestObject; TxReceipt receiptB = Core.Test.Builders.Build.A.Receipt.WithTransactionHash(TestItem.Keccaks[1]).TestObject; @@ -144,6 +145,10 @@ public async Task SingleBlockMigration_RestoresMissingReceipt() outMemoryReceiptStorage.Insert(blockToMigrate, new[] { receiptA }); + inMemoryReceiptStorage.Insert(blockNotToMigrate, new[] { receiptA, receiptB }); + + outMemoryReceiptStorage.Insert(blockNotToMigrate, new[] { receiptA }); + TestMemColumnsDb receiptColumnDb = new(); TestMemDb blocksDb = (TestMemDb)receiptColumnDb.GetColumnDb(ReceiptsColumns.Blocks); TestMemDb txIndexDb = (TestMemDb)receiptColumnDb.GetColumnDb(ReceiptsColumns.Transactions); @@ -164,17 +169,21 @@ public async Task SingleBlockMigration_RestoresMissingReceipt() LimboLogs.Instance ); - await migration.Run(1, migrateSingleBlock: true); + await migration.Run(2, migrateSingleBlock: true); if (migration._migrationTask != null) { await migration._migrationTask; } - TxReceipt[] outReceipts = outMemoryReceiptStorage.Get(blockToMigrate, recover: false, recoverSender: false); - outReceipts.Length.Should().Be(2, "Both receipts (A & B) should be present after migration."); + TxReceipt[] outReceiptsMigrate = outMemoryReceiptStorage.Get(blockToMigrate, recover: false, recoverSender: false); + TxReceipt[] outReceiptsNotMigrate = outMemoryReceiptStorage.Get(blockNotToMigrate, recover: false, recoverSender: false); + outReceiptsMigrate.Length.Should().Be(2, "Both receipts (A & B) should be present after migration."); + outReceiptsNotMigrate.Length.Should().Be(1, "Only A receipt should be present after migration."); - outReceipts.Should().Contain(receiptA) + outReceiptsMigrate.Should().Contain(receiptA) .And.Contain(receiptB); + outReceiptsNotMigrate.Should().Contain(receiptA) + .And.NotContain(receiptB); outMemoryReceiptStorage.MigratedBlockNumber.Should().BeGreaterThanOrEqualTo(1); } From 21e6ce696693241fe321f545b25abef79db7ff36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= Date: Mon, 13 Jan 2025 17:16:33 +0100 Subject: [PATCH 3/8] add rpcDB improvements --- src/Nethermind/Nethermind.Db.Rpc/RpcDb.cs | 5 ++++- .../Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs | 6 ++++++ .../Nethermind.Runner/Properties/launchSettings.json | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Nethermind/Nethermind.Db.Rpc/RpcDb.cs b/src/Nethermind/Nethermind.Db.Rpc/RpcDb.cs index 98279f33c4a..a987ff0e2c9 100644 --- a/src/Nethermind/Nethermind.Db.Rpc/RpcDb.cs +++ b/src/Nethermind/Nethermind.Db.Rpc/RpcDb.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text.Json; using Nethermind.Core; using Nethermind.Core.Extensions; using Nethermind.JsonRpc; @@ -96,7 +97,9 @@ private byte[] GetThroughRpc(ReadOnlySpan key) byte[] value = null; if (response.Result is not null) { - value = Bytes.FromHexString((string)response.Result); + var jsonElement = (JsonElement)response.Result; + string rawHex = jsonElement.GetString(); + value = Bytes.FromHexString(rawHex); if (_recordDb is not null) { _recordDb[key] = value; diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs index 46020819e96..2235930b942 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs @@ -20,6 +20,7 @@ using Nethermind.Serialization.Rlp; using Nethermind.Synchronization.ParallelSync; using Nethermind.Synchronization.Reporting; +using Org.BouncyCastle.Asn1.Cms; namespace Nethermind.JsonRpc.Modules.DebugModule; @@ -61,6 +62,8 @@ public DebugBridge( IDb headersDb = dbProvider.HeadersDb ?? throw new ArgumentNullException(nameof(dbProvider.HeadersDb)); IDb codeDb = dbProvider.CodeDb ?? throw new ArgumentNullException(nameof(dbProvider.CodeDb)); IDb metadataDb = dbProvider.MetadataDb ?? throw new ArgumentNullException(nameof(dbProvider.MetadataDb)); + IDb blockNumbersDb = dbProvider.BlockNumbersDb ?? throw new ArgumentNullException(nameof(dbProvider.BlockNumbersDb)); + IDb bloomDb = dbProvider.BloomDb ?? throw new ArgumentNullException(nameof(dbProvider.BloomDb)); _dbMappings = new Dictionary(StringComparer.InvariantCultureIgnoreCase) { @@ -70,6 +73,9 @@ public DebugBridge( {DbNames.Headers, headersDb}, {DbNames.Metadata, metadataDb}, {DbNames.Code, codeDb}, + {DbNames.Blocks, blocksDb}, + {DbNames.BlockNumbers, blockNumbersDb}, + {DbNames.Bloom, bloomDb}, }; _blockStore = new BlockStore(blocksDb); diff --git a/src/Nethermind/Nethermind.Runner/Properties/launchSettings.json b/src/Nethermind/Nethermind.Runner/Properties/launchSettings.json index be22eda4499..6ef44b0f02a 100644 --- a/src/Nethermind/Nethermind.Runner/Properties/launchSettings.json +++ b/src/Nethermind/Nethermind.Runner/Properties/launchSettings.json @@ -30,7 +30,7 @@ }, "Gnosis": { "commandName": "Project", - "commandLineArgs": "-c gnosis --data-dir .data", + "commandLineArgs": "-c gnosis --data-dir .data --Init.DiagnosticMode=RpcDb --Init.RpcDbUrl=http://192.241.95.142:8545 --log DEBUG", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } From 08082647f7161bc29e28b849cc8a568dbe2be474 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= Date: Tue, 14 Jan 2025 13:02:45 +0100 Subject: [PATCH 4/8] Revert "Improve test and add missing param pass" This reverts commit abd8d396691756e2b1c5b38abdee937be6da5ee8. --- .../Modules/DebugModule/DebugBridge.cs | 2 +- .../Steps/Migrations/ReceiptMigrationTests.cs | 19 +++++-------------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs index 2235930b942..ebb34d34040 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs @@ -100,7 +100,7 @@ public DebugBridge( public Task MigrateReceipts(long blockNumber, bool migrateSingleBlock = false) { if (migrateSingleBlock) - return _receiptsMigration.Run(blockNumber, migrateSingleBlock); + return _receiptsMigration.Run(blockNumber); else return _receiptsMigration.Run(blockNumber + 1); // add 1 to make go from inclusive (better for API) to exclusive (better for internal) } diff --git a/src/Nethermind/Nethermind.Runner.Test/Ethereum/Steps/Migrations/ReceiptMigrationTests.cs b/src/Nethermind/Nethermind.Runner.Test/Ethereum/Steps/Migrations/ReceiptMigrationTests.cs index 1a730161d0a..2c06fceca67 100644 --- a/src/Nethermind/Nethermind.Runner.Test/Ethereum/Steps/Migrations/ReceiptMigrationTests.cs +++ b/src/Nethermind/Nethermind.Runner.Test/Ethereum/Steps/Migrations/ReceiptMigrationTests.cs @@ -136,8 +136,7 @@ public async Task SingleBlockMigration_RestoresMissingReceipt() inMemoryReceiptStorage.MigratedBlockNumber = 0; outMemoryReceiptStorage.MigratedBlockNumber = 0; - Block blockToMigrate = blockTree.FindBlock(2); - Block blockNotToMigrate = blockTree.FindBlock(1); + Block blockToMigrate = blockTree.FindBlock(1); TxReceipt receiptA = Core.Test.Builders.Build.A.Receipt.WithTransactionHash(TestItem.Keccaks[0]).TestObject; TxReceipt receiptB = Core.Test.Builders.Build.A.Receipt.WithTransactionHash(TestItem.Keccaks[1]).TestObject; @@ -145,10 +144,6 @@ public async Task SingleBlockMigration_RestoresMissingReceipt() outMemoryReceiptStorage.Insert(blockToMigrate, new[] { receiptA }); - inMemoryReceiptStorage.Insert(blockNotToMigrate, new[] { receiptA, receiptB }); - - outMemoryReceiptStorage.Insert(blockNotToMigrate, new[] { receiptA }); - TestMemColumnsDb receiptColumnDb = new(); TestMemDb blocksDb = (TestMemDb)receiptColumnDb.GetColumnDb(ReceiptsColumns.Blocks); TestMemDb txIndexDb = (TestMemDb)receiptColumnDb.GetColumnDb(ReceiptsColumns.Transactions); @@ -169,21 +164,17 @@ public async Task SingleBlockMigration_RestoresMissingReceipt() LimboLogs.Instance ); - await migration.Run(2, migrateSingleBlock: true); + await migration.Run(1, migrateSingleBlock: true); if (migration._migrationTask != null) { await migration._migrationTask; } - TxReceipt[] outReceiptsMigrate = outMemoryReceiptStorage.Get(blockToMigrate, recover: false, recoverSender: false); - TxReceipt[] outReceiptsNotMigrate = outMemoryReceiptStorage.Get(blockNotToMigrate, recover: false, recoverSender: false); - outReceiptsMigrate.Length.Should().Be(2, "Both receipts (A & B) should be present after migration."); - outReceiptsNotMigrate.Length.Should().Be(1, "Only A receipt should be present after migration."); + TxReceipt[] outReceipts = outMemoryReceiptStorage.Get(blockToMigrate, recover: false, recoverSender: false); + outReceipts.Length.Should().Be(2, "Both receipts (A & B) should be present after migration."); - outReceiptsMigrate.Should().Contain(receiptA) + outReceipts.Should().Contain(receiptA) .And.Contain(receiptB); - outReceiptsNotMigrate.Should().Contain(receiptA) - .And.NotContain(receiptB); outMemoryReceiptStorage.MigratedBlockNumber.Should().BeGreaterThanOrEqualTo(1); } From 3ba5d5dc08313590f42b52b69d0cc874f46664d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= Date: Tue, 14 Jan 2025 13:02:51 +0100 Subject: [PATCH 5/8] Revert "Add single block receipt miration functionality" This reverts commit 1cf11ae524a6aa14236636c3b3deb69c9bbed937. --- .../Receipts/IReceiptsMigration.cs | 2 +- .../Nethermind.Cli/Modules/DebugCliModule.cs | 4 +- .../Steps/Migrations/ReceiptMigration.cs | 54 +++------------- .../Modules/DebugModuleTests.cs | 7 +-- .../Modules/DebugModule/DebugBridge.cs | 9 +-- .../Modules/DebugModule/DebugRpcModule.cs | 4 +- .../Modules/DebugModule/IDebugBridge.cs | 2 +- .../Modules/DebugModule/IDebugRpcModule.cs | 2 +- .../Steps/Migrations/ReceiptMigrationTests.cs | 62 ------------------- 9 files changed, 21 insertions(+), 125 deletions(-) diff --git a/src/Nethermind/Nethermind.Blockchain/Receipts/IReceiptsMigration.cs b/src/Nethermind/Nethermind.Blockchain/Receipts/IReceiptsMigration.cs index 27b7638201a..5944c305c36 100644 --- a/src/Nethermind/Nethermind.Blockchain/Receipts/IReceiptsMigration.cs +++ b/src/Nethermind/Nethermind.Blockchain/Receipts/IReceiptsMigration.cs @@ -7,6 +7,6 @@ namespace Nethermind.Blockchain.Receipts { public interface IReceiptsMigration { - Task Run(long blockNumber, bool migrateSingleBlock = false); + Task Run(long blockNumber); } } diff --git a/src/Nethermind/Nethermind.Cli/Modules/DebugCliModule.cs b/src/Nethermind/Nethermind.Cli/Modules/DebugCliModule.cs index c20fbd00713..dfc6330f83f 100644 --- a/src/Nethermind/Nethermind.Cli/Modules/DebugCliModule.cs +++ b/src/Nethermind/Nethermind.Cli/Modules/DebugCliModule.cs @@ -93,9 +93,9 @@ public JsValue TraceTransactionInBlockByIndex(string rlp, int index, object opti } [CliFunction("debug", "migrateReceipts")] - public bool MigrateReceipts(long number, bool migrateSingleBlock = false) + public bool MigrateReceipts(long number) { - return NodeManager.Post("debug_migrateReceipts", number, migrateSingleBlock).Result; + return NodeManager.Post("debug_migrateReceipts", number).Result; } public DebugCliModule(ICliEngine cliEngine, INodeManager nodeManager) : base(cliEngine, nodeManager) diff --git a/src/Nethermind/Nethermind.Init/Steps/Migrations/ReceiptMigration.cs b/src/Nethermind/Nethermind.Init/Steps/Migrations/ReceiptMigration.cs index c5368e41d10..c77c0297f18 100644 --- a/src/Nethermind/Nethermind.Init/Steps/Migrations/ReceiptMigration.cs +++ b/src/Nethermind/Nethermind.Init/Steps/Migrations/ReceiptMigration.cs @@ -89,13 +89,13 @@ ILogManager logManager _progressLogger = new ProgressLogger("Receipts migration", logManager); } - public async Task Run(long blockNumber, bool migrateSingleBlock = false) + public async Task Run(long blockNumber) { _cancellationTokenSource?.Cancel(); - await(_migrationTask ?? Task.CompletedTask); + await (_migrationTask ?? Task.CompletedTask); _cancellationTokenSource = new CancellationTokenSource(); _receiptStorage.MigratedBlockNumber = Math.Min(Math.Max(_receiptStorage.MigratedBlockNumber, blockNumber), (_blockTree.Head?.Number ?? 0) + 1); - _migrationTask = DoRun(_cancellationTokenSource.Token, migrateSingleBlock); + _migrationTask = DoRun(_cancellationTokenSource.Token); return _receiptConfig.StoreReceipts && _receiptConfig.ReceiptsMigration; } public async Task Run(CancellationToken cancellationToken) @@ -110,7 +110,7 @@ public async Task Run(CancellationToken cancellationToken) } } - private async Task DoRun(CancellationToken cancellationToken, bool migrateSingleBlock = false) + private async Task DoRun(CancellationToken cancellationToken) { if (_receiptConfig.StoreReceipts) { @@ -123,36 +123,30 @@ await Wait.ForEventCondition( (arg) => CanMigrate(arg.Current)); } - RunIfNeeded(cancellationToken, migrateSingleBlock); + RunIfNeeded(cancellationToken); } } private static bool CanMigrate(SyncMode syncMode) => syncMode.NotSyncing(); - private void RunIfNeeded(CancellationToken cancellationToken, bool migrateSingleBlock) + private void RunIfNeeded(CancellationToken cancellationToken) { // Note, it start in decreasing order from this high number. long migrateToBlockNumber = _receiptStorage.MigratedBlockNumber == long.MaxValue ? _syncModeSelector.Current.NotSyncing() ? _blockTree.Head?.Number ?? 0 : _blockTree.BestKnownNumber - : migrateSingleBlock - ? _receiptStorage.MigratedBlockNumber - : _receiptStorage.MigratedBlockNumber - 1; - + : _receiptStorage.MigratedBlockNumber - 1; _toBlock = migrateToBlockNumber; _logger.Warn($"Running migration to {_toBlock}"); - if (_toBlock > 0 || migrateSingleBlock) + if (_toBlock > 0) { _stopwatch = Stopwatch.StartNew(); try { - if (migrateSingleBlock) - MigrateSingleBlock(_toBlock); - else - RunMigration(cancellationToken); + RunMigration(cancellationToken); } catch (Exception e) { @@ -231,36 +225,6 @@ private void RunMigration(CancellationToken token) } } - public void MigrateSingleBlock(long blockNumber) - { - ChainLevelInfo? level = _chainLevelInfoRepository.LoadLevel(blockNumber); - if (level?.MainChainBlock == null) - { - _logger.Warn($"Could not find main chain block for block #{blockNumber}."); - return; - } - Hash256 blockHash = level.MainChainBlock.BlockHash; - - Block? block = _blockTree.FindBlock(blockHash, BlockTreeLookupOptions.None); - if (block == null) - { - _logger.Debug($"Block #{blockNumber} not found in block tree, using empty block placeholder."); - block = GetMissingBlock(blockNumber, blockHash); - } - - _logger.Info($"Migrating receipts for block #{blockNumber}."); - MigrateBlock(block); - - if (ReferenceEquals(block, EmptyBlock)) - { - ReturnMissingBlock(block); - } - - _receiptsDb.Compact(); - _txIndexDb.Compact(); - _receiptsBlockDb.Compact(); - } - Block GetMissingBlock(long i, Hash256? blockHash) { if (_logger.IsDebug) _logger.Debug(GetLogMessage("warning", $"Block {i} not found. Logs will not be searchable for this block.")); diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/DebugModuleTests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/DebugModuleTests.cs index 277545a74de..0cea4e87063 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/DebugModuleTests.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/DebugModuleTests.cs @@ -389,13 +389,12 @@ public void Debug_traceCall_test() debugTraceCall.Should().BeEquivalentTo(expected); } - [TestCase(false)] - [TestCase(true)] - public async Task Migrate_receipts(bool migrateSingleBlock) + [Test] + public async Task Migrate_receipts() { debugBridge.MigrateReceipts(Arg.Any()).Returns(true); IDebugRpcModule rpcModule = new DebugRpcModule(LimboLogs.Instance, debugBridge, jsonRpcConfig, specProvider); - string response = await RpcTest.TestSerializedRequest(rpcModule, "debug_migrateReceipts", 100, migrateSingleBlock); + string response = await RpcTest.TestSerializedRequest(rpcModule, "debug_migrateReceipts", 100); Assert.That(response, Is.Not.Null); } diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs index ebb34d34040..f29c84d7b6f 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs @@ -97,13 +97,8 @@ public DebugBridge( public void UpdateHeadBlock(Hash256 blockHash) => _blockTree.UpdateHeadBlock(blockHash); - public Task MigrateReceipts(long blockNumber, bool migrateSingleBlock = false) - { - if (migrateSingleBlock) - return _receiptsMigration.Run(blockNumber); - else - return _receiptsMigration.Run(blockNumber + 1); // add 1 to make go from inclusive (better for API) to exclusive (better for internal) - } + public Task MigrateReceipts(long blockNumber) + => _receiptsMigration.Run(blockNumber + 1); // add 1 to make go from inclusive (better for API) to exclusive (better for internal) public void InsertReceipts(BlockParameter blockParameter, TxReceipt[] txReceipts) { diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugRpcModule.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugRpcModule.cs index 5d0d6553a36..1dfe1a5a6a7 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugRpcModule.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugRpcModule.cs @@ -147,8 +147,8 @@ public ResultWrapper debug_traceTransactionInBlockByIndex(byte[ return ResultWrapper.Success(transactionTrace); } - public async Task> debug_migrateReceipts(long blockNumber, bool migrateSingleBlock = false) => - ResultWrapper.Success(await _debugBridge.MigrateReceipts(blockNumber, migrateSingleBlock)); + public async Task> debug_migrateReceipts(long blockNumber) => + ResultWrapper.Success(await _debugBridge.MigrateReceipts(blockNumber)); public Task> debug_insertReceipts(BlockParameter blockParameter, ReceiptForRpc[] receiptForRpc) { diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/IDebugBridge.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/IDebugBridge.cs index f0f59d04728..9b8db38d2cf 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/IDebugBridge.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/IDebugBridge.cs @@ -31,7 +31,7 @@ public interface IDebugBridge ChainLevelInfo GetLevelInfo(long number); int DeleteChainSlice(long startNumber, bool force = false); void UpdateHeadBlock(Hash256 blockHash); - Task MigrateReceipts(long blockNumber, bool migrateSingleBlock = false); + Task MigrateReceipts(long blockNumber); void InsertReceipts(BlockParameter blockParameter, TxReceipt[] receipts); SyncReportSymmary GetCurrentSyncStage(); IEnumerable TraceBlockToFile(Hash256 blockHash, CancellationToken cancellationToken, GethTraceOptions? gethTraceOptions = null); diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/IDebugRpcModule.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/IDebugRpcModule.cs index 1326d7da557..f8c1129cddc 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/IDebugRpcModule.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/IDebugRpcModule.cs @@ -85,7 +85,7 @@ public interface IDebugRpcModule : IRpcModule ResultWrapper debug_traceTransactionInBlockByIndex(byte[] blockRlp, int txIndex, GethTraceOptions options = null); [JsonRpcMethod(Description = "Sets the block number up to which receipts will be migrated to (Nethermind specific).")] - Task> debug_migrateReceipts(long blockNumber, bool migrateSingleBlock = false); + Task> debug_migrateReceipts(long blockNumber); [JsonRpcMethod(Description = "Insert receipts for the block after verifying receipts root correctness.")] Task> debug_insertReceipts(BlockParameter blockParameter, ReceiptForRpc[] receiptForRpc); diff --git a/src/Nethermind/Nethermind.Runner.Test/Ethereum/Steps/Migrations/ReceiptMigrationTests.cs b/src/Nethermind/Nethermind.Runner.Test/Ethereum/Steps/Migrations/ReceiptMigrationTests.cs index 2c06fceca67..2ed20142439 100644 --- a/src/Nethermind/Nethermind.Runner.Test/Ethereum/Steps/Migrations/ReceiptMigrationTests.cs +++ b/src/Nethermind/Nethermind.Runner.Test/Ethereum/Steps/Migrations/ReceiptMigrationTests.cs @@ -117,68 +117,6 @@ public async Task RunMigration(int? commandStartBlockNumber, long currentMigrate } } - [Test] - public async Task SingleBlockMigration_RestoresMissingReceipt() - { - IReceiptConfig receiptConfig = new ReceiptConfig - { - StoreReceipts = true, - ReceiptsMigration = true, - CompactReceiptStore = false - }; - - var blockTreeBuilder = Core.Test.Builders.Build.A.BlockTree().OfChainLength(3); - IBlockTree blockTree = blockTreeBuilder.TestObject; - IChainLevelInfoRepository chainLevelInfoRepository = blockTreeBuilder.ChainLevelInfoRepository; - - InMemoryReceiptStorage inMemoryReceiptStorage = new(true); - InMemoryReceiptStorage outMemoryReceiptStorage = new(true); - inMemoryReceiptStorage.MigratedBlockNumber = 0; - outMemoryReceiptStorage.MigratedBlockNumber = 0; - - Block blockToMigrate = blockTree.FindBlock(1); - TxReceipt receiptA = Core.Test.Builders.Build.A.Receipt.WithTransactionHash(TestItem.Keccaks[0]).TestObject; - TxReceipt receiptB = Core.Test.Builders.Build.A.Receipt.WithTransactionHash(TestItem.Keccaks[1]).TestObject; - - inMemoryReceiptStorage.Insert(blockToMigrate, new[] { receiptA, receiptB }); - - outMemoryReceiptStorage.Insert(blockToMigrate, new[] { receiptA }); - - TestMemColumnsDb receiptColumnDb = new(); - TestMemDb blocksDb = (TestMemDb)receiptColumnDb.GetColumnDb(ReceiptsColumns.Blocks); - TestMemDb txIndexDb = (TestMemDb)receiptColumnDb.GetColumnDb(ReceiptsColumns.Transactions); - - ISyncModeSelector syncModeSelector = Substitute.For(); - syncModeSelector.Current.Returns(SyncMode.WaitingForBlock); - - TestReceiptStorage testStorage = new TestReceiptStorage(inMemoryReceiptStorage, outMemoryReceiptStorage); - - var migration = new ReceiptMigration( - testStorage, - blockTree, - syncModeSelector, - chainLevelInfoRepository, - receiptConfig, - receiptColumnDb, - Substitute.For(), - LimboLogs.Instance - ); - - await migration.Run(1, migrateSingleBlock: true); - if (migration._migrationTask != null) - { - await migration._migrationTask; - } - - TxReceipt[] outReceipts = outMemoryReceiptStorage.Get(blockToMigrate, recover: false, recoverSender: false); - outReceipts.Length.Should().Be(2, "Both receipts (A & B) should be present after migration."); - - outReceipts.Should().Contain(receiptA) - .And.Contain(receiptB); - - outMemoryReceiptStorage.MigratedBlockNumber.Should().BeGreaterThanOrEqualTo(1); - } - private class TestReceiptStorage : IReceiptStorage { private readonly IReceiptStorage _inStorage; From 33fef6d3311aff4435fafcf9f48837f248acd729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= Date: Tue, 14 Jan 2025 13:04:24 +0100 Subject: [PATCH 6/8] Adjust stateDb name --- .../Nethermind.Db/FullPruning/FullPruningInnerDbFactory.cs | 2 +- src/Nethermind/Nethermind.Runner/Properties/launchSettings.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nethermind/Nethermind.Db/FullPruning/FullPruningInnerDbFactory.cs b/src/Nethermind/Nethermind.Db/FullPruning/FullPruningInnerDbFactory.cs index 42edb7b34b6..54df51cfd16 100644 --- a/src/Nethermind/Nethermind.Db/FullPruning/FullPruningInnerDbFactory.cs +++ b/src/Nethermind/Nethermind.Db/FullPruning/FullPruningInnerDbFactory.cs @@ -59,7 +59,7 @@ private DbSettings GetRocksDbSettings(DbSettings originalSetting) bool firstDb = _index == -1; // if first DB, then we will put it into main directory and not use indexed subdirectory - string dbName = firstDb ? originalSetting.DbName : originalSetting.DbName + _index; + string dbName = originalSetting.DbName; string dbPath = firstDb ? originalSetting.DbPath : _fileSystem.Path.Combine(originalSetting.DbPath, _index.ToString()); DbSettings dbSettings = originalSetting.Clone(dbName, dbPath); dbSettings.CanDeleteFolder = !firstDb; // we cannot delete main db folder, only indexed subfolders diff --git a/src/Nethermind/Nethermind.Runner/Properties/launchSettings.json b/src/Nethermind/Nethermind.Runner/Properties/launchSettings.json index 6ef44b0f02a..be22eda4499 100644 --- a/src/Nethermind/Nethermind.Runner/Properties/launchSettings.json +++ b/src/Nethermind/Nethermind.Runner/Properties/launchSettings.json @@ -30,7 +30,7 @@ }, "Gnosis": { "commandName": "Project", - "commandLineArgs": "-c gnosis --data-dir .data --Init.DiagnosticMode=RpcDb --Init.RpcDbUrl=http://192.241.95.142:8545 --log DEBUG", + "commandLineArgs": "-c gnosis --data-dir .data", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } From 99249fba140be04a92731f0f1ff491ad490e5de6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= Date: Tue, 14 Jan 2025 13:29:11 +0100 Subject: [PATCH 7/8] Adjustments --- src/Nethermind/Nethermind.Db.Rpc/RpcDb.cs | 2 +- .../Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Nethermind/Nethermind.Db.Rpc/RpcDb.cs b/src/Nethermind/Nethermind.Db.Rpc/RpcDb.cs index a987ff0e2c9..9e3f0be0cc6 100644 --- a/src/Nethermind/Nethermind.Db.Rpc/RpcDb.cs +++ b/src/Nethermind/Nethermind.Db.Rpc/RpcDb.cs @@ -97,7 +97,7 @@ private byte[] GetThroughRpc(ReadOnlySpan key) byte[] value = null; if (response.Result is not null) { - var jsonElement = (JsonElement)response.Result; + JsonElement jsonElement = (JsonElement)response.Result; string rawHex = jsonElement.GetString(); value = Bytes.FromHexString(rawHex); if (_recordDb is not null) diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs index f29c84d7b6f..6e307532830 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugBridge.cs @@ -20,7 +20,6 @@ using Nethermind.Serialization.Rlp; using Nethermind.Synchronization.ParallelSync; using Nethermind.Synchronization.Reporting; -using Org.BouncyCastle.Asn1.Cms; namespace Nethermind.JsonRpc.Modules.DebugModule; From c9d2e9231341e4992714cd8489634d502df52896 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Chodo=C5=82a?= <43241881+kamilchodola@users.noreply.github.com> Date: Tue, 14 Jan 2025 14:30:37 +0100 Subject: [PATCH 8/8] Update src/Nethermind/Nethermind.Db.Rpc/RpcDb.cs Co-authored-by: Lukasz Rozmej --- src/Nethermind/Nethermind.Db.Rpc/RpcDb.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Nethermind/Nethermind.Db.Rpc/RpcDb.cs b/src/Nethermind/Nethermind.Db.Rpc/RpcDb.cs index 9e3f0be0cc6..6c6cc02ed1d 100644 --- a/src/Nethermind/Nethermind.Db.Rpc/RpcDb.cs +++ b/src/Nethermind/Nethermind.Db.Rpc/RpcDb.cs @@ -97,9 +97,7 @@ private byte[] GetThroughRpc(ReadOnlySpan key) byte[] value = null; if (response.Result is not null) { - JsonElement jsonElement = (JsonElement)response.Result; - string rawHex = jsonElement.GetString(); - value = Bytes.FromHexString(rawHex); + value = Bytes.FromHexString(response.Result.ToString()); if (_recordDb is not null) { _recordDb[key] = value;