From eef4fcb2faf5f338c5ba1772cf9c8b94aa8eb072 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Mon, 14 Oct 2024 19:57:30 +0300 Subject: [PATCH 1/5] Fix Eip4788 BeaconBlockRootHandler --- .../BeaconBlockRoot/BeaconBlockRootHandler.cs | 10 +++++----- .../BeaconBlockRoot/IBeaconBlockRootHandler.cs | 5 +++-- .../Nethermind.Consensus/Processing/BlockProcessor.cs | 4 ++-- .../EngineModuleTests.HelperFunctions.cs | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/BeaconBlockRootHandler.cs b/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/BeaconBlockRootHandler.cs index c464091ba49..6c8a4db51e2 100644 --- a/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/BeaconBlockRootHandler.cs +++ b/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/BeaconBlockRootHandler.cs @@ -1,7 +1,6 @@ // SPDX-FileCopyrightText: 2023 Demerzel Solutions Limited // SPDX-License-Identifier: LGPL-3.0-only -using System; using Nethermind.Core; using Nethermind.Core.Eip2930; using Nethermind.Core.Specs; @@ -9,13 +8,14 @@ using Nethermind.Evm.Tracing; using Nethermind.Evm.TransactionProcessing; using Nethermind.Int256; +using Nethermind.State; namespace Nethermind.Blockchain.BeaconBlockRoot; public class BeaconBlockRootHandler(ITransactionProcessor processor) : IBeaconBlockRootHandler { private const long GasLimit = 30_000_000L; - public (Address? toAddress, AccessList? accessList) BeaconRootsAccessList(Block block, IReleaseSpec spec, bool includeStorageCells = true) + public (Address? toAddress, AccessList? accessList) BeaconRootsAccessList(Block block, IReleaseSpec spec, IWorldState stateProvider, bool includeStorageCells = true) { BlockHeader? header = block.Header; bool canInsertBeaconRoot = spec.IsBeaconBlockRootAvailable @@ -26,7 +26,7 @@ public class BeaconBlockRootHandler(ITransactionProcessor processor) : IBeaconBl spec.Eip4788ContractAddress ?? Eip4788Constants.BeaconRootsAddress : null; - if (eip4788ContractAddress is null) + if (eip4788ContractAddress is null || !stateProvider.AccountExists(eip4788ContractAddress)) { return (null, null); } @@ -42,9 +42,9 @@ public class BeaconBlockRootHandler(ITransactionProcessor processor) : IBeaconBl return (eip4788ContractAddress, builder.Build()); } - public void StoreBeaconRoot(Block block, IReleaseSpec spec) + public void StoreBeaconRoot(Block block, IReleaseSpec spec, IWorldState stateProvider) { - (Address? toAddress, AccessList? accessList) = BeaconRootsAccessList(block, spec, includeStorageCells: false); + (Address? toAddress, AccessList? accessList) = BeaconRootsAccessList(block, spec, stateProvider, includeStorageCells: false); if (toAddress is not null) { diff --git a/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/IBeaconBlockRootHandler.cs b/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/IBeaconBlockRootHandler.cs index d6e3ec0f5ed..5c217ddfa78 100644 --- a/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/IBeaconBlockRootHandler.cs +++ b/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/IBeaconBlockRootHandler.cs @@ -4,10 +4,11 @@ using Nethermind.Core; using Nethermind.Core.Eip2930; using Nethermind.Core.Specs; +using Nethermind.State; namespace Nethermind.Blockchain.BeaconBlockRoot; public interface IBeaconBlockRootHandler { - (Address? toAddress, AccessList? accessList) BeaconRootsAccessList(Block block, IReleaseSpec spec, bool includeStorageCells = true); - void StoreBeaconRoot(Block block, IReleaseSpec spec); + (Address? toAddress, AccessList? accessList) BeaconRootsAccessList(Block block, IReleaseSpec spec, IWorldState stateProvider, bool includeStorageCells = true); + void StoreBeaconRoot(Block block, IReleaseSpec spec, IWorldState stateProvider); } diff --git a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs index a152ed5e551..270108c508f 100644 --- a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs +++ b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs @@ -125,7 +125,7 @@ the previous head state.*/ if (!skipPrewarming) { using CancellationTokenSource cancellationTokenSource = new(); - (_, AccessList? accessList) = _beaconBlockRootHandler.BeaconRootsAccessList(suggestedBlock, _specProvider.GetSpec(suggestedBlock.Header)); + (_, AccessList? accessList) = _beaconBlockRootHandler.BeaconRootsAccessList(suggestedBlock, _specProvider.GetSpec(suggestedBlock.Header), _stateProvider); preWarmTask = preWarmer.PreWarmCaches(suggestedBlock, preBlockStateRoot, accessList, cancellationTokenSource.Token); (processedBlock, receipts) = ProcessOne(suggestedBlock, options, blockTracer); // Block is processed, we can cancel the prewarm task @@ -345,7 +345,7 @@ private void StoreBeaconRoot(Block block, IReleaseSpec spec) { try { - _beaconBlockRootHandler.StoreBeaconRoot(block, spec); + _beaconBlockRootHandler.StoreBeaconRoot(block, spec, _stateProvider); } catch (Exception e) { diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.HelperFunctions.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.HelperFunctions.cs index 2de5457185a..a80b046c262 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.HelperFunctions.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.HelperFunctions.cs @@ -154,7 +154,7 @@ private static ExecutionPayloadV4 CreateBlockRequestV4(MergeTestBlockchain chain blockRequestV4.TryGetBlock(out Block? block); var beaconBlockRootHandler = new BeaconBlockRootHandler(chain.TxProcessor); - beaconBlockRootHandler.StoreBeaconRoot(block!, chain.SpecProvider.GetSpec(block!.Header)); + beaconBlockRootHandler.StoreBeaconRoot(block!, chain.SpecProvider.GetSpec(block!.Header), chain.WorldStateManager.GlobalWorldState); Snapshot before = chain.State.TakeSnapshot(); var blockHashStore = new BlockhashStore(chain.SpecProvider, chain.State); blockHashStore.ApplyBlockhashStateChanges(block!.Header); From e6b5585bd8a22188a16f0f8474fcee883f397705 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Tue, 15 Oct 2024 14:33:42 +0300 Subject: [PATCH 2/5] add BeaconBlockRootHandlerTests --- .../BeaconBlockRootHandlerTests.cs | 156 ++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 src/Nethermind/Nethermind.Blockchain.Test/BeaconBlockRootHandlerTests.cs diff --git a/src/Nethermind/Nethermind.Blockchain.Test/BeaconBlockRootHandlerTests.cs b/src/Nethermind/Nethermind.Blockchain.Test/BeaconBlockRootHandlerTests.cs new file mode 100644 index 00000000000..0e7848bc412 --- /dev/null +++ b/src/Nethermind/Nethermind.Blockchain.Test/BeaconBlockRootHandlerTests.cs @@ -0,0 +1,156 @@ +// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited +// SPDX-License-Identifier: LGPL-3.0-only + +using Nethermind.Blockchain.BeaconBlockRoot; +using Nethermind.Core; +using Nethermind.Core.Crypto; +using Nethermind.Core.Eip2930; +using Nethermind.Core.Test.Builders; +using Nethermind.Crypto; +using Nethermind.Evm; +using Nethermind.Evm.Tracing; +using Nethermind.Evm.TransactionProcessing; +using Nethermind.Int256; +using Nethermind.Specs.Forks; +using Nethermind.State; +using NSubstitute; +using NUnit.Framework; + +namespace Nethermind.Blockchain.Test; + +public class BeaconBlockRootHandlerTests +{ + private BeaconBlockRootHandler _beaconBlockRootHandler; + private ITransactionProcessor _transactionProcessor; + private IWorldState _worldState; + + [SetUp] + public void Setup() + { + _worldState = Substitute.For(); + _transactionProcessor = Substitute.For(); + _beaconBlockRootHandler = new BeaconBlockRootHandler(_transactionProcessor); + } + + [Test] + public void Test_BeaconRootsAccessList_IsBeaconBlockRootAvailableFalse() + { + BlockHeader header = Build.A.BlockHeader.WithNumber(1).WithParentBeaconBlockRoot(Hash256.Zero).TestObject; + Block block = Build.A.Block.WithHeader(header).TestObject; + _worldState.AccountExists(Arg.Any
()).Returns(true); + + (Address? toAddress, AccessList? accessList) result = _beaconBlockRootHandler + .BeaconRootsAccessList(block, Shanghai.Instance, _worldState); + + Assert.That(result.accessList, Is.Null); + Assert.That(result.toAddress, Is.Null); + } + + [Test] + public void Test_BeaconRootsAccessList_HeaderIsGenesis() + { + BlockHeader header = Build.A.BlockHeader.WithParentBeaconBlockRoot(Hash256.Zero).TestObject; + Block block = Build.A.Block.WithHeader(header).TestObject; + _worldState.AccountExists(Arg.Any
()).Returns(true); + + (Address? toAddress, AccessList? accessList) result = _beaconBlockRootHandler + .BeaconRootsAccessList(block, Cancun.Instance, _worldState); + + Assert.That(result.accessList, Is.Null); + Assert.That(result.toAddress, Is.Null); + } + + [Test] + public void Test_BeaconRootsAccessList_ParentBeaconBlockRootIsNull() + { + BlockHeader header = Build.A.BlockHeader.WithNumber(1).TestObject; + Block block = Build.A.Block.WithHeader(header).TestObject; + _worldState.AccountExists(Arg.Any
()).Returns(true); + + (Address? toAddress, AccessList? accessList) result = _beaconBlockRootHandler + .BeaconRootsAccessList(block, Cancun.Instance, _worldState); + + Assert.That(result.accessList, Is.Null); + Assert.That(result.toAddress, Is.Null); + } + + [Test] + public void Test_BeaconRootsAccessList_canInsertBeaconRootIsTrue_AccountNotExist() + { + BlockHeader header = Build.A.BlockHeader.WithNumber(1).WithParentBeaconBlockRoot(Hash256.Zero).TestObject; + Block block = Build.A.Block.WithHeader(header).TestObject; + _worldState.AccountExists(Arg.Any
()).Returns(false); + + (Address? toAddress, AccessList? accessList) result = _beaconBlockRootHandler + .BeaconRootsAccessList(block, Cancun.Instance, _worldState); + + Assert.That(result.accessList, Is.Null); + Assert.That(result.toAddress, Is.Null); + } + + [Test] + public void Test_BeaconRootsAccessList_canInsertBeaconRootIsTrue_AccountExists() + { + BlockHeader header = Build.A.BlockHeader.WithNumber(1).WithParentBeaconBlockRoot(Hash256.Zero).TestObject; + Block block = Build.A.Block.WithHeader(header).TestObject; + _worldState.AccountExists(Arg.Any
()).Returns(true); + + (Address? toAddress, AccessList? accessList) result = _beaconBlockRootHandler + .BeaconRootsAccessList(block, Cancun.Instance, _worldState); + + Assert.That(result.accessList, Is.Not.Null); + Assert.That(result.accessList.Count.AddressesCount, Is.EqualTo(1)); + Assert.That(result.accessList.Count.StorageKeysCount, Is.EqualTo(1)); + } + + [Test] + public void Test_BeaconRootsAccessList_canInsertBeaconRootIsTrue_AccountExists_IncludeStorageCellsIsFalse() + { + BlockHeader header = Build.A.BlockHeader.WithNumber(1).WithParentBeaconBlockRoot(Hash256.Zero).TestObject; + Block block = Build.A.Block.WithHeader(header).TestObject; + _worldState.AccountExists(Arg.Any
()).Returns(true); + + (Address? toAddress, AccessList? accessList) result = _beaconBlockRootHandler + .BeaconRootsAccessList(block, Cancun.Instance, _worldState, false); + + Assert.That(result.accessList, Is.Not.Null); + Assert.That(result.accessList.Count.AddressesCount, Is.EqualTo(1)); + Assert.That(result.accessList.Count.StorageKeysCount, Is.EqualTo(0)); + } + + [Test] + public void Test_StoreBeaconRoot_AccessListIsNull() + { + BlockHeader header = Build.A.BlockHeader.TestObject; + Block block = Build.A.Block.WithHeader(header).TestObject; + + _beaconBlockRootHandler.StoreBeaconRoot(block, Cancun.Instance, _worldState); + + _transactionProcessor.DidNotReceive().Execute(Arg.Any(), Arg.Any(), Arg.Any()); + } + + [Test] + public void Test_StoreBeaconRoot_AccessListNotNull() + { + BlockHeader header = Build.A.BlockHeader.WithNumber(1).WithParentBeaconBlockRoot(Hash256.Zero).TestObject; + Block block = Build.A.Block.WithHeader(header).TestObject; + _worldState.AccountExists(Arg.Any
()).Returns(true); + + _beaconBlockRootHandler.StoreBeaconRoot(block, Cancun.Instance, _worldState); + + Transaction transaction = new() + { + Value = UInt256.Zero, + Data = header.ParentBeaconBlockRoot!.Bytes.ToArray(), + To = Eip4788Constants.BeaconRootsAddress, + SenderAddress = Address.SystemUser, + GasLimit = 30_000_000L, + GasPrice = UInt256.Zero, + AccessList = new AccessList.Builder().AddAddress(Eip4788Constants.BeaconRootsAddress).Build() + }; + + transaction.Hash = transaction.CalculateHash(); + _transactionProcessor.Received().Execute(Arg.Is(t => + t.Hash == transaction.Hash), header, NullTxTracer.Instance); + } +} From c8f0aba60531a20408c3bdd2819656ef7b5659cd Mon Sep 17 00:00:00 2001 From: yerke26 Date: Sun, 20 Oct 2024 21:09:27 +0600 Subject: [PATCH 3/5] pass worldState to BeaconBlockRootHandler constructor --- .../AuraBlockProcessorTests.cs | 2 +- .../AuRaContractGasLimitOverrideTests.cs | 2 +- .../Transactions/TxCertifierFilterTests.cs | 2 +- .../Transactions/TxPermissionFilterTest.cs | 2 +- .../BeaconBlockRootHandlerTests.cs | 18 +++++++++--------- .../BlockProcessorTests.cs | 4 ++-- .../Producers/DevBlockproducerTests.cs | 2 +- .../Nethermind.Blockchain.Test/ReorgTests.cs | 2 +- .../BeaconBlockRoot/BeaconBlockRootHandler.cs | 8 ++++---- .../BeaconBlockRoot/IBeaconBlockRootHandler.cs | 4 ++-- .../CliqueBlockProducerTests.cs | 4 ++-- .../InitializeBlockchainAuRa.cs | 2 +- .../StartBlockProducerAuRa.cs | 2 +- .../CliquePlugin.cs | 2 +- .../NethDevPlugin.cs | 2 +- .../Processing/BlockProcessor.cs | 4 ++-- .../Processing/ReadOnlyChainProcessingEnv.cs | 2 +- .../Producers/BlockProducerEnvFactory.cs | 2 +- .../Blockchain/TestBlockchain.cs | 5 ++--- .../SimulateReadOnlyBlocksProcessingEnv.cs | 2 +- .../Steps/InitializeBlockchain.cs | 2 +- .../Modules/Trace/ParityStyleTracerTests.cs | 2 +- .../AuRaMergeEngineModuleTests.cs | 2 +- .../AuRaMergeBlockProducerEnvFactory.cs | 2 +- .../InitializeBlockchainAuRaMerge.cs | 2 +- .../EngineModuleTests.HelperFunctions.cs | 4 ++-- .../EngineModuleTests.Setup.cs | 2 +- .../InitializeBlockchainOptimism.cs | 2 +- .../OptimismBlockProducerEnvFactory.cs | 2 +- .../ReadOnlyChainProcessingEnv.cs | 2 +- .../SyncThreadTests.cs | 4 ++-- src/tests | 2 +- 32 files changed, 50 insertions(+), 51 deletions(-) diff --git a/src/Nethermind/Nethermind.AuRa.Test/AuraBlockProcessorTests.cs b/src/Nethermind/Nethermind.AuRa.Test/AuraBlockProcessorTests.cs index 5ca0f63f74d..2da9aabbc1c 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/AuraBlockProcessorTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/AuraBlockProcessorTests.cs @@ -158,7 +158,7 @@ void Process(AuRaBlockProcessor auRaBlockProcessor, int blockNumber, Hash256 sta new BlockProcessor.BlockValidationTransactionsExecutor(transactionProcessor, stateProvider), stateProvider, NullReceiptStorage.Instance, - new BeaconBlockRootHandler(transactionProcessor), + new BeaconBlockRootHandler(transactionProcessor, stateProvider), LimboLogs.Instance, Substitute.For(), new WithdrawalProcessor(stateProvider, LimboLogs.Instance), diff --git a/src/Nethermind/Nethermind.AuRa.Test/Contract/AuRaContractGasLimitOverrideTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Contract/AuRaContractGasLimitOverrideTests.cs index bcbe3b8be48..6f2f7b13d6d 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Contract/AuRaContractGasLimitOverrideTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Contract/AuRaContractGasLimitOverrideTests.cs @@ -97,7 +97,7 @@ protected override BlockProcessor CreateBlockProcessor() new BlockProcessor.BlockValidationTransactionsExecutor(TxProcessor, State), State, ReceiptStorage, - new BeaconBlockRootHandler(TxProcessor), + new BeaconBlockRootHandler(TxProcessor, State), LimboLogs.Instance, BlockTree, NullWithdrawalProcessor.Instance, diff --git a/src/Nethermind/Nethermind.AuRa.Test/Transactions/TxCertifierFilterTests.cs b/src/Nethermind/Nethermind.AuRa.Test/Transactions/TxCertifierFilterTests.cs index c754ce285f8..cda399944da 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Transactions/TxCertifierFilterTests.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Transactions/TxCertifierFilterTests.cs @@ -154,7 +154,7 @@ protected override BlockProcessor CreateBlockProcessor() new BlockProcessor.BlockValidationTransactionsExecutor(TxProcessor, State), State, ReceiptStorage, - new BeaconBlockRootHandler(TxProcessor), + new BeaconBlockRootHandler(TxProcessor, State), LimboLogs.Instance, BlockTree, NullWithdrawalProcessor.Instance, diff --git a/src/Nethermind/Nethermind.AuRa.Test/Transactions/TxPermissionFilterTest.cs b/src/Nethermind/Nethermind.AuRa.Test/Transactions/TxPermissionFilterTest.cs index de6de6eb464..da04745095f 100644 --- a/src/Nethermind/Nethermind.AuRa.Test/Transactions/TxPermissionFilterTest.cs +++ b/src/Nethermind/Nethermind.AuRa.Test/Transactions/TxPermissionFilterTest.cs @@ -296,7 +296,7 @@ protected override BlockProcessor CreateBlockProcessor() new BlockProcessor.BlockValidationTransactionsExecutor(TxProcessor, State), State, ReceiptStorage, - new BeaconBlockRootHandler(TxProcessor), + new BeaconBlockRootHandler(TxProcessor, State), LimboLogs.Instance, BlockTree, NullWithdrawalProcessor.Instance, diff --git a/src/Nethermind/Nethermind.Blockchain.Test/BeaconBlockRootHandlerTests.cs b/src/Nethermind/Nethermind.Blockchain.Test/BeaconBlockRootHandlerTests.cs index 0e7848bc412..8f3e5461c7d 100644 --- a/src/Nethermind/Nethermind.Blockchain.Test/BeaconBlockRootHandlerTests.cs +++ b/src/Nethermind/Nethermind.Blockchain.Test/BeaconBlockRootHandlerTests.cs @@ -29,7 +29,7 @@ public void Setup() { _worldState = Substitute.For(); _transactionProcessor = Substitute.For(); - _beaconBlockRootHandler = new BeaconBlockRootHandler(_transactionProcessor); + _beaconBlockRootHandler = new BeaconBlockRootHandler(_transactionProcessor, _worldState); } [Test] @@ -40,7 +40,7 @@ public void Test_BeaconRootsAccessList_IsBeaconBlockRootAvailableFalse() _worldState.AccountExists(Arg.Any
()).Returns(true); (Address? toAddress, AccessList? accessList) result = _beaconBlockRootHandler - .BeaconRootsAccessList(block, Shanghai.Instance, _worldState); + .BeaconRootsAccessList(block, Shanghai.Instance); Assert.That(result.accessList, Is.Null); Assert.That(result.toAddress, Is.Null); @@ -54,7 +54,7 @@ public void Test_BeaconRootsAccessList_HeaderIsGenesis() _worldState.AccountExists(Arg.Any
()).Returns(true); (Address? toAddress, AccessList? accessList) result = _beaconBlockRootHandler - .BeaconRootsAccessList(block, Cancun.Instance, _worldState); + .BeaconRootsAccessList(block, Cancun.Instance); Assert.That(result.accessList, Is.Null); Assert.That(result.toAddress, Is.Null); @@ -68,7 +68,7 @@ public void Test_BeaconRootsAccessList_ParentBeaconBlockRootIsNull() _worldState.AccountExists(Arg.Any
()).Returns(true); (Address? toAddress, AccessList? accessList) result = _beaconBlockRootHandler - .BeaconRootsAccessList(block, Cancun.Instance, _worldState); + .BeaconRootsAccessList(block, Cancun.Instance); Assert.That(result.accessList, Is.Null); Assert.That(result.toAddress, Is.Null); @@ -82,7 +82,7 @@ public void Test_BeaconRootsAccessList_canInsertBeaconRootIsTrue_AccountNotExist _worldState.AccountExists(Arg.Any
()).Returns(false); (Address? toAddress, AccessList? accessList) result = _beaconBlockRootHandler - .BeaconRootsAccessList(block, Cancun.Instance, _worldState); + .BeaconRootsAccessList(block, Cancun.Instance); Assert.That(result.accessList, Is.Null); Assert.That(result.toAddress, Is.Null); @@ -96,7 +96,7 @@ public void Test_BeaconRootsAccessList_canInsertBeaconRootIsTrue_AccountExists() _worldState.AccountExists(Arg.Any
()).Returns(true); (Address? toAddress, AccessList? accessList) result = _beaconBlockRootHandler - .BeaconRootsAccessList(block, Cancun.Instance, _worldState); + .BeaconRootsAccessList(block, Cancun.Instance); Assert.That(result.accessList, Is.Not.Null); Assert.That(result.accessList.Count.AddressesCount, Is.EqualTo(1)); @@ -111,7 +111,7 @@ public void Test_BeaconRootsAccessList_canInsertBeaconRootIsTrue_AccountExists_I _worldState.AccountExists(Arg.Any
()).Returns(true); (Address? toAddress, AccessList? accessList) result = _beaconBlockRootHandler - .BeaconRootsAccessList(block, Cancun.Instance, _worldState, false); + .BeaconRootsAccessList(block, Cancun.Instance, false); Assert.That(result.accessList, Is.Not.Null); Assert.That(result.accessList.Count.AddressesCount, Is.EqualTo(1)); @@ -124,7 +124,7 @@ public void Test_StoreBeaconRoot_AccessListIsNull() BlockHeader header = Build.A.BlockHeader.TestObject; Block block = Build.A.Block.WithHeader(header).TestObject; - _beaconBlockRootHandler.StoreBeaconRoot(block, Cancun.Instance, _worldState); + _beaconBlockRootHandler.StoreBeaconRoot(block, Cancun.Instance); _transactionProcessor.DidNotReceive().Execute(Arg.Any(), Arg.Any(), Arg.Any()); } @@ -136,7 +136,7 @@ public void Test_StoreBeaconRoot_AccessListNotNull() Block block = Build.A.Block.WithHeader(header).TestObject; _worldState.AccountExists(Arg.Any
()).Returns(true); - _beaconBlockRootHandler.StoreBeaconRoot(block, Cancun.Instance, _worldState); + _beaconBlockRootHandler.StoreBeaconRoot(block, Cancun.Instance); Transaction transaction = new() { diff --git a/src/Nethermind/Nethermind.Blockchain.Test/BlockProcessorTests.cs b/src/Nethermind/Nethermind.Blockchain.Test/BlockProcessorTests.cs index 60c7c37b66e..a9c11d23a2d 100644 --- a/src/Nethermind/Nethermind.Blockchain.Test/BlockProcessorTests.cs +++ b/src/Nethermind/Nethermind.Blockchain.Test/BlockProcessorTests.cs @@ -50,7 +50,7 @@ public void Prepared_block_contains_author_field() stateProvider, NullReceiptStorage.Instance, transactionProcessor, - new BeaconBlockRootHandler(transactionProcessor), + new BeaconBlockRootHandler(transactionProcessor, stateProvider), Substitute.For(), LimboLogs.Instance); @@ -81,7 +81,7 @@ public void Recovers_state_on_cancel() stateProvider, NullReceiptStorage.Instance, transactionProcessor, - new BeaconBlockRootHandler(transactionProcessor), + new BeaconBlockRootHandler(transactionProcessor, stateProvider), Substitute.For(), LimboLogs.Instance); diff --git a/src/Nethermind/Nethermind.Blockchain.Test/Producers/DevBlockproducerTests.cs b/src/Nethermind/Nethermind.Blockchain.Test/Producers/DevBlockproducerTests.cs index 096dcd6db9a..1453c55dadd 100644 --- a/src/Nethermind/Nethermind.Blockchain.Test/Producers/DevBlockproducerTests.cs +++ b/src/Nethermind/Nethermind.Blockchain.Test/Producers/DevBlockproducerTests.cs @@ -76,7 +76,7 @@ public void Test() stateProvider, NullReceiptStorage.Instance, txProcessor, - new BeaconBlockRootHandler(txProcessor), + new BeaconBlockRootHandler(txProcessor, stateProvider), new BlockhashStore(specProvider, stateProvider), LimboLogs.Instance); BlockchainProcessor blockchainProcessor = new( diff --git a/src/Nethermind/Nethermind.Blockchain.Test/ReorgTests.cs b/src/Nethermind/Nethermind.Blockchain.Test/ReorgTests.cs index 88274cfd17b..0f87b9ea846 100644 --- a/src/Nethermind/Nethermind.Blockchain.Test/ReorgTests.cs +++ b/src/Nethermind/Nethermind.Blockchain.Test/ReorgTests.cs @@ -78,7 +78,7 @@ public void Setup() stateProvider, NullReceiptStorage.Instance, transactionProcessor, - new BeaconBlockRootHandler(transactionProcessor), + new BeaconBlockRootHandler(transactionProcessor, stateProvider), new BlockhashStore(MainnetSpecProvider.Instance, stateProvider), LimboLogs.Instance); _blockchainProcessor = new BlockchainProcessor( diff --git a/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/BeaconBlockRootHandler.cs b/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/BeaconBlockRootHandler.cs index 6c8a4db51e2..a9a519e4492 100644 --- a/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/BeaconBlockRootHandler.cs +++ b/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/BeaconBlockRootHandler.cs @@ -11,11 +11,11 @@ using Nethermind.State; namespace Nethermind.Blockchain.BeaconBlockRoot; -public class BeaconBlockRootHandler(ITransactionProcessor processor) : IBeaconBlockRootHandler +public class BeaconBlockRootHandler(ITransactionProcessor processor, IWorldState stateProvider) : IBeaconBlockRootHandler { private const long GasLimit = 30_000_000L; - public (Address? toAddress, AccessList? accessList) BeaconRootsAccessList(Block block, IReleaseSpec spec, IWorldState stateProvider, bool includeStorageCells = true) + public (Address? toAddress, AccessList? accessList) BeaconRootsAccessList(Block block, IReleaseSpec spec, bool includeStorageCells = true) { BlockHeader? header = block.Header; bool canInsertBeaconRoot = spec.IsBeaconBlockRootAvailable @@ -42,9 +42,9 @@ public class BeaconBlockRootHandler(ITransactionProcessor processor) : IBeaconBl return (eip4788ContractAddress, builder.Build()); } - public void StoreBeaconRoot(Block block, IReleaseSpec spec, IWorldState stateProvider) + public void StoreBeaconRoot(Block block, IReleaseSpec spec) { - (Address? toAddress, AccessList? accessList) = BeaconRootsAccessList(block, spec, stateProvider, includeStorageCells: false); + (Address? toAddress, AccessList? accessList) = BeaconRootsAccessList(block, spec, includeStorageCells: false); if (toAddress is not null) { diff --git a/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/IBeaconBlockRootHandler.cs b/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/IBeaconBlockRootHandler.cs index 5c217ddfa78..05aea2133ea 100644 --- a/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/IBeaconBlockRootHandler.cs +++ b/src/Nethermind/Nethermind.Blockchain/BeaconBlockRoot/IBeaconBlockRootHandler.cs @@ -9,6 +9,6 @@ namespace Nethermind.Blockchain.BeaconBlockRoot; public interface IBeaconBlockRootHandler { - (Address? toAddress, AccessList? accessList) BeaconRootsAccessList(Block block, IReleaseSpec spec, IWorldState stateProvider, bool includeStorageCells = true); - void StoreBeaconRoot(Block block, IReleaseSpec spec, IWorldState stateProvider); + (Address? toAddress, AccessList? accessList) BeaconRootsAccessList(Block block, IReleaseSpec spec, bool includeStorageCells = true); + void StoreBeaconRoot(Block block, IReleaseSpec spec); } diff --git a/src/Nethermind/Nethermind.Clique.Test/CliqueBlockProducerTests.cs b/src/Nethermind/Nethermind.Clique.Test/CliqueBlockProducerTests.cs index 83e2f3b5372..1a56439105b 100644 --- a/src/Nethermind/Nethermind.Clique.Test/CliqueBlockProducerTests.cs +++ b/src/Nethermind/Nethermind.Clique.Test/CliqueBlockProducerTests.cs @@ -140,7 +140,7 @@ public On CreateNode(PrivateKey privateKey, bool withGenesisAlreadyProcessed = f stateProvider, NullReceiptStorage.Instance, transactionProcessor, - new BeaconBlockRootHandler(transactionProcessor), + new BeaconBlockRootHandler(transactionProcessor, stateProvider), new BlockhashStore(goerliSpecProvider, stateProvider), nodeLogManager); @@ -161,7 +161,7 @@ public On CreateNode(PrivateKey privateKey, bool withGenesisAlreadyProcessed = f minerStateProvider, NullReceiptStorage.Instance, minerTransactionProcessor, - new BeaconBlockRootHandler(minerTransactionProcessor), + new BeaconBlockRootHandler(minerTransactionProcessor, minerStateProvider), new BlockhashStore(goerliSpecProvider, minerStateProvider), nodeLogManager); diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/InitializeBlockchainAuRa.cs b/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/InitializeBlockchainAuRa.cs index d2a3952e8f0..cf7ac81bbc7 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/InitializeBlockchainAuRa.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/InitializeBlockchainAuRa.cs @@ -108,7 +108,7 @@ protected virtual AuRaBlockProcessor NewAuraBlockProcessor(ITxFilter txFilter, B new BlockProcessor.BlockValidationTransactionsExecutor(_api.TransactionProcessor, worldState), worldState, _api.ReceiptStorage!, - new BeaconBlockRootHandler(_api.TransactionProcessor!), + new BeaconBlockRootHandler(_api.TransactionProcessor!, worldState), _api.LogManager, _api.BlockTree!, NullWithdrawalProcessor.Instance, diff --git a/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/StartBlockProducerAuRa.cs b/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/StartBlockProducerAuRa.cs index 5fa09b539d8..2b3d2d5578e 100644 --- a/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/StartBlockProducerAuRa.cs +++ b/src/Nethermind/Nethermind.Consensus.AuRa/InitializationSteps/StartBlockProducerAuRa.cs @@ -155,7 +155,7 @@ private BlockProcessor CreateBlockProcessor(IReadOnlyTxProcessingScope changeabl _api.BlockProducerEnvFactory.TransactionsExecutorFactory.Create(changeableTxProcessingEnv), changeableTxProcessingEnv.WorldState, _api.ReceiptStorage, - new BeaconBlockRootHandler(changeableTxProcessingEnv.TransactionProcessor), + new BeaconBlockRootHandler(changeableTxProcessingEnv.TransactionProcessor, changeableTxProcessingEnv.WorldState), _api.LogManager, _api.BlockTree, NullWithdrawalProcessor.Instance, diff --git a/src/Nethermind/Nethermind.Consensus.Clique/CliquePlugin.cs b/src/Nethermind/Nethermind.Consensus.Clique/CliquePlugin.cs index 9167e80f900..153a2941487 100644 --- a/src/Nethermind/Nethermind.Consensus.Clique/CliquePlugin.cs +++ b/src/Nethermind/Nethermind.Consensus.Clique/CliquePlugin.cs @@ -113,7 +113,7 @@ public IBlockProducer InitBlockProducer(ITxSource? additionalTxSource = null) scope.WorldState, NullReceiptStorage.Instance, getFromApi.TransactionProcessor, - new BeaconBlockRootHandler(scope.TransactionProcessor), + new BeaconBlockRootHandler(scope.TransactionProcessor, scope.WorldState), new BlockhashStore(getFromApi.SpecProvider, scope.WorldState), getFromApi.LogManager, new BlockProductionWithdrawalProcessor(new WithdrawalProcessor(scope.WorldState, getFromApi.LogManager))); diff --git a/src/Nethermind/Nethermind.Consensus.Ethash/NethDevPlugin.cs b/src/Nethermind/Nethermind.Consensus.Ethash/NethDevPlugin.cs index 215ae44e976..7c1be4c3c90 100644 --- a/src/Nethermind/Nethermind.Consensus.Ethash/NethDevPlugin.cs +++ b/src/Nethermind/Nethermind.Consensus.Ethash/NethDevPlugin.cs @@ -83,7 +83,7 @@ public IBlockProducer InitBlockProducer(ITxSource? additionalTxSource = null) scope.WorldState, NullReceiptStorage.Instance, scope.TransactionProcessor, - new BeaconBlockRootHandler(scope.TransactionProcessor), + new BeaconBlockRootHandler(scope.TransactionProcessor, scope.WorldState), new BlockhashStore(getFromApi.SpecProvider, scope.WorldState), getFromApi.LogManager); diff --git a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs index 270108c508f..a152ed5e551 100644 --- a/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs +++ b/src/Nethermind/Nethermind.Consensus/Processing/BlockProcessor.cs @@ -125,7 +125,7 @@ the previous head state.*/ if (!skipPrewarming) { using CancellationTokenSource cancellationTokenSource = new(); - (_, AccessList? accessList) = _beaconBlockRootHandler.BeaconRootsAccessList(suggestedBlock, _specProvider.GetSpec(suggestedBlock.Header), _stateProvider); + (_, AccessList? accessList) = _beaconBlockRootHandler.BeaconRootsAccessList(suggestedBlock, _specProvider.GetSpec(suggestedBlock.Header)); preWarmTask = preWarmer.PreWarmCaches(suggestedBlock, preBlockStateRoot, accessList, cancellationTokenSource.Token); (processedBlock, receipts) = ProcessOne(suggestedBlock, options, blockTracer); // Block is processed, we can cancel the prewarm task @@ -345,7 +345,7 @@ private void StoreBeaconRoot(Block block, IReleaseSpec spec) { try { - _beaconBlockRootHandler.StoreBeaconRoot(block, spec, _stateProvider); + _beaconBlockRootHandler.StoreBeaconRoot(block, spec); } catch (Exception e) { diff --git a/src/Nethermind/Nethermind.Consensus/Processing/ReadOnlyChainProcessingEnv.cs b/src/Nethermind/Nethermind.Consensus/Processing/ReadOnlyChainProcessingEnv.cs index 0b278165205..97954e1ed5c 100644 --- a/src/Nethermind/Nethermind.Consensus/Processing/ReadOnlyChainProcessingEnv.cs +++ b/src/Nethermind/Nethermind.Consensus/Processing/ReadOnlyChainProcessingEnv.cs @@ -69,7 +69,7 @@ IBlockProcessor.IBlockTransactionsExecutor transactionsExecutor scope.WorldState, receiptStorage, scope.TransactionProcessor, - new BeaconBlockRootHandler(scope.TransactionProcessor), + new BeaconBlockRootHandler(scope.TransactionProcessor, scope.WorldState), new BlockhashStore(specProvider, scope.WorldState), logManager); } diff --git a/src/Nethermind/Nethermind.Consensus/Producers/BlockProducerEnvFactory.cs b/src/Nethermind/Nethermind.Consensus/Producers/BlockProducerEnvFactory.cs index f896766bfbd..85e5697a8be 100644 --- a/src/Nethermind/Nethermind.Consensus/Producers/BlockProducerEnvFactory.cs +++ b/src/Nethermind/Nethermind.Consensus/Producers/BlockProducerEnvFactory.cs @@ -155,7 +155,7 @@ protected virtual BlockProcessor CreateBlockProcessor( readOnlyTxProcessingEnv.WorldState, receiptStorage, readOnlyTxProcessingEnv.TransactionProcessor, - new BeaconBlockRootHandler(readOnlyTxProcessingEnv.TransactionProcessor), + new BeaconBlockRootHandler(readOnlyTxProcessingEnv.TransactionProcessor, readOnlyTxProcessingEnv.WorldState), new BlockhashStore(_specProvider, readOnlyTxProcessingEnv.WorldState), logManager, new BlockProductionWithdrawalProcessor(new WithdrawalProcessor(readOnlyTxProcessingEnv.WorldState, logManager)), diff --git a/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs b/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs index 2af6892ee13..fb5118b4861 100644 --- a/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs +++ b/src/Nethermind/Nethermind.Core.Test/Blockchain/TestBlockchain.cs @@ -200,7 +200,7 @@ protected virtual async Task Build(ISpecProvider? specProvider = HeaderValidator = new HeaderValidator(BlockTree, Always.Valid, SpecProvider, LogManager); _canonicalityMonitor ??= new ReceiptCanonicalityMonitor(ReceiptStorage, LogManager); - BeaconBlockRootHandler = new BeaconBlockRootHandler(TxProcessor); + BeaconBlockRootHandler = new BeaconBlockRootHandler(TxProcessor, State); BlockValidator = new BlockValidator( new TxValidator(SpecProvider.ChainId), @@ -216,7 +216,6 @@ protected virtual async Task Build(ISpecProvider? specProvider = BloomStorage bloomStorage = new(new BloomConfig(), new MemDb(), new InMemoryDictionaryFileStoreFactory()); ReceiptsRecovery receiptsRecovery = new(new EthereumEcdsa(SpecProvider.ChainId), SpecProvider); LogFinder = new LogFinder(BlockTree, ReceiptStorage, ReceiptStorage, bloomStorage, LimboLogs.Instance, receiptsRecovery); - BeaconBlockRootHandler = new BeaconBlockRootHandler(TxProcessor); BlockProcessor = CreateBlockProcessor(); BlockchainProcessor chainProcessor = new(BlockTree, BlockProcessor, BlockPreprocessorStep, StateReader, LogManager, Consensus.Processing.BlockchainProcessor.Options.Default); @@ -390,7 +389,7 @@ protected virtual IBlockProcessor CreateBlockProcessor() => State, ReceiptStorage, TxProcessor, - new BeaconBlockRootHandler(TxProcessor), + new BeaconBlockRootHandler(TxProcessor, State), new BlockhashStore(SpecProvider, State), LogManager, preWarmer: CreateBlockCachePreWarmer(), diff --git a/src/Nethermind/Nethermind.Facade/Simulate/SimulateReadOnlyBlocksProcessingEnv.cs b/src/Nethermind/Nethermind.Facade/Simulate/SimulateReadOnlyBlocksProcessingEnv.cs index 5196c1850ac..c86b147817e 100644 --- a/src/Nethermind/Nethermind.Facade/Simulate/SimulateReadOnlyBlocksProcessingEnv.cs +++ b/src/Nethermind/Nethermind.Facade/Simulate/SimulateReadOnlyBlocksProcessingEnv.cs @@ -115,7 +115,7 @@ public IBlockProcessor GetProcessor(bool validate, UInt256? blobBaseFeeOverride) StateProvider, NullReceiptStorage.Instance, _transactionProcessor, - new BeaconBlockRootHandler(_transactionProcessor), + new BeaconBlockRootHandler(_transactionProcessor, StateProvider), new BlockhashStore(SpecProvider, StateProvider), _logManager); } diff --git a/src/Nethermind/Nethermind.Init/Steps/InitializeBlockchain.cs b/src/Nethermind/Nethermind.Init/Steps/InitializeBlockchain.cs index 92aea789e83..630809f8b53 100644 --- a/src/Nethermind/Nethermind.Init/Steps/InitializeBlockchain.cs +++ b/src/Nethermind/Nethermind.Init/Steps/InitializeBlockchain.cs @@ -238,7 +238,7 @@ protected virtual BlockProcessor CreateBlockProcessor(BlockCachePreWarmer? preWa worldState, _api.ReceiptStorage, _api.TransactionProcessor, - new BeaconBlockRootHandler(_api.TransactionProcessor), + new BeaconBlockRootHandler(_api.TransactionProcessor, worldState), new BlockhashStore(_api.SpecProvider!, worldState), _api.LogManager, preWarmer: preWarmer diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Trace/ParityStyleTracerTests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Trace/ParityStyleTracerTests.cs index f9b10675107..1c4023f547f 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Trace/ParityStyleTracerTests.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/Trace/ParityStyleTracerTests.cs @@ -73,7 +73,7 @@ public void Setup() stateProvider, NullReceiptStorage.Instance, transactionProcessor, - new BeaconBlockRootHandler(transactionProcessor), + new BeaconBlockRootHandler(transactionProcessor, stateProvider), new BlockhashStore(specProvider, stateProvider), LimboLogs.Instance); diff --git a/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs b/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs index b2d1e4c26ab..663c941b485 100644 --- a/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs +++ b/src/Nethermind/Nethermind.Merge.AuRa.Test/AuRaMergeEngineModuleTests.cs @@ -153,7 +153,7 @@ protected override IBlockProcessor CreateBlockProcessor() State, ReceiptStorage, TxProcessor, - new BeaconBlockRootHandler(TxProcessor), + new BeaconBlockRootHandler(TxProcessor, State), new BlockhashStore(SpecProvider, State), LogManager, WithdrawalProcessor, diff --git a/src/Nethermind/Nethermind.Merge.AuRa/AuRaMergeBlockProducerEnvFactory.cs b/src/Nethermind/Nethermind.Merge.AuRa/AuRaMergeBlockProducerEnvFactory.cs index 741930723bf..faf77f16d32 100644 --- a/src/Nethermind/Nethermind.Merge.AuRa/AuRaMergeBlockProducerEnvFactory.cs +++ b/src/Nethermind/Nethermind.Merge.AuRa/AuRaMergeBlockProducerEnvFactory.cs @@ -75,7 +75,7 @@ protected override BlockProcessor CreateBlockProcessor( TransactionsExecutorFactory.Create(readOnlyTxProcessingEnv), readOnlyTxProcessingEnv.WorldState, receiptStorage, - new BeaconBlockRootHandler(readOnlyTxProcessingEnv.TransactionProcessor), + new BeaconBlockRootHandler(readOnlyTxProcessingEnv.TransactionProcessor, readOnlyTxProcessingEnv.WorldState), logManager, _blockTree, new Consensus.Withdrawals.BlockProductionWithdrawalProcessor( diff --git a/src/Nethermind/Nethermind.Merge.AuRa/InitializationSteps/InitializeBlockchainAuRaMerge.cs b/src/Nethermind/Nethermind.Merge.AuRa/InitializationSteps/InitializeBlockchainAuRaMerge.cs index d37d4fb9b1a..6fec278699c 100644 --- a/src/Nethermind/Nethermind.Merge.AuRa/InitializationSteps/InitializeBlockchainAuRaMerge.cs +++ b/src/Nethermind/Nethermind.Merge.AuRa/InitializationSteps/InitializeBlockchainAuRaMerge.cs @@ -43,7 +43,7 @@ protected override AuRaBlockProcessor NewAuraBlockProcessor(ITxFilter txFilter, new BlockProcessor.BlockValidationTransactionsExecutor(transactionProcessor, worldState), worldState, _api.ReceiptStorage!, - new BeaconBlockRootHandler(transactionProcessor), + new BeaconBlockRootHandler(transactionProcessor, worldState), _api.LogManager, _api.BlockTree!, new AuraWithdrawalProcessor(withdrawalContractFactory.Create(transactionProcessor), _api.LogManager), diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.HelperFunctions.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.HelperFunctions.cs index a80b046c262..abfce411741 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.HelperFunctions.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.HelperFunctions.cs @@ -153,8 +153,8 @@ private static ExecutionPayloadV4 CreateBlockRequestV4(MergeTestBlockchain chain ExecutionPayloadV4 blockRequestV4 = CreateBlockRequestInternal(parent, miner, withdrawals, blobGasUsed, excessBlobGas, transactions: transactions, parentBeaconBlockRoot: parentBeaconBlockRoot, requests: requests); blockRequestV4.TryGetBlock(out Block? block); - var beaconBlockRootHandler = new BeaconBlockRootHandler(chain.TxProcessor); - beaconBlockRootHandler.StoreBeaconRoot(block!, chain.SpecProvider.GetSpec(block!.Header), chain.WorldStateManager.GlobalWorldState); + var beaconBlockRootHandler = new BeaconBlockRootHandler(chain.TxProcessor, chain.WorldStateManager.GlobalWorldState); + beaconBlockRootHandler.StoreBeaconRoot(block!, chain.SpecProvider.GetSpec(block!.Header)); Snapshot before = chain.State.TakeSnapshot(); var blockHashStore = new BlockhashStore(chain.SpecProvider, chain.State); blockHashStore.ApplyBlockhashStateChanges(block!.Header); diff --git a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.Setup.cs b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.Setup.cs index a95d1a9479b..cffbfafb516 100644 --- a/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.Setup.cs +++ b/src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.Setup.cs @@ -255,7 +255,7 @@ protected override IBlockProcessor CreateBlockProcessor() State, ReceiptStorage, TxProcessor, - new BeaconBlockRootHandler(TxProcessor), + new BeaconBlockRootHandler(TxProcessor, State), new BlockhashStore(SpecProvider, State), LogManager, WithdrawalProcessor, diff --git a/src/Nethermind/Nethermind.Optimism/InitializeBlockchainOptimism.cs b/src/Nethermind/Nethermind.Optimism/InitializeBlockchainOptimism.cs index d4bbd47eed1..c481446873e 100644 --- a/src/Nethermind/Nethermind.Optimism/InitializeBlockchainOptimism.cs +++ b/src/Nethermind/Nethermind.Optimism/InitializeBlockchainOptimism.cs @@ -90,7 +90,7 @@ protected override BlockProcessor CreateBlockProcessor(BlockCachePreWarmer? preW api.ReceiptStorage, transactionProcessor, new BlockhashStore(api.SpecProvider, api.WorldState), - new BeaconBlockRootHandler(transactionProcessor), + new BeaconBlockRootHandler(transactionProcessor, api.WorldState), api.LogManager, api.SpecHelper, contractRewriter, diff --git a/src/Nethermind/Nethermind.Optimism/OptimismBlockProducerEnvFactory.cs b/src/Nethermind/Nethermind.Optimism/OptimismBlockProducerEnvFactory.cs index 88ee38dd5e3..3056aa4fbad 100644 --- a/src/Nethermind/Nethermind.Optimism/OptimismBlockProducerEnvFactory.cs +++ b/src/Nethermind/Nethermind.Optimism/OptimismBlockProducerEnvFactory.cs @@ -89,7 +89,7 @@ protected override BlockProcessor CreateBlockProcessor( receiptStorage, readOnlyTxProcessingEnv.TransactionProcessor, new BlockhashStore(specProvider, readOnlyTxProcessingEnv.WorldState), - new BeaconBlockRootHandler(readOnlyTxProcessingEnv.TransactionProcessor), + new BeaconBlockRootHandler(readOnlyTxProcessingEnv.TransactionProcessor, readOnlyTxProcessingEnv.WorldState), logManager, _specHelper, new Create2DeployerContractRewriter(_specHelper, _specProvider, _blockTree), diff --git a/src/Nethermind/Nethermind.Optimism/ReadOnlyChainProcessingEnv.cs b/src/Nethermind/Nethermind.Optimism/ReadOnlyChainProcessingEnv.cs index 3e1e3cbe011..05e6b898ffe 100644 --- a/src/Nethermind/Nethermind.Optimism/ReadOnlyChainProcessingEnv.cs +++ b/src/Nethermind/Nethermind.Optimism/ReadOnlyChainProcessingEnv.cs @@ -65,7 +65,7 @@ IBlockProcessor.IBlockTransactionsExecutor transactionsExecutor receiptStorage, scope.TransactionProcessor, new BlockhashStore(specProvider, scope.WorldState), - new BeaconBlockRootHandler(scope.TransactionProcessor), + new BeaconBlockRootHandler(scope.TransactionProcessor, scope.WorldState), logManager, opSpecHelper, contractRewriter, diff --git a/src/Nethermind/Nethermind.Synchronization.Test/SyncThreadTests.cs b/src/Nethermind/Nethermind.Synchronization.Test/SyncThreadTests.cs index c86dfbb240b..629432766c4 100644 --- a/src/Nethermind/Nethermind.Synchronization.Test/SyncThreadTests.cs +++ b/src/Nethermind/Nethermind.Synchronization.Test/SyncThreadTests.cs @@ -303,7 +303,7 @@ private SyncTestContext CreateSyncManager(int index) stateProvider, receiptStorage, txProcessor, - new BeaconBlockRootHandler(txProcessor), + new BeaconBlockRootHandler(txProcessor, stateProvider), new BlockhashStore(specProvider, stateProvider), logManager); @@ -327,7 +327,7 @@ private SyncTestContext CreateSyncManager(int index) devState, receiptStorage, devTxProcessor, - new BeaconBlockRootHandler(devTxProcessor), + new BeaconBlockRootHandler(devTxProcessor, devState), new BlockhashStore(specProvider, devState), logManager); diff --git a/src/tests b/src/tests index 8c215d6b56f..92010754908 160000 --- a/src/tests +++ b/src/tests @@ -1 +1 @@ -Subproject commit 8c215d6b56fed36501d04c165093357f102de2ac +Subproject commit 9201075490807f58811078e9bb5ec895b4ac01a5 From ad34ceb92dcc231549d1aa457fceaf834dd2b482 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Sun, 20 Oct 2024 21:13:11 +0600 Subject: [PATCH 4/5] revert tests --- src/tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests b/src/tests index 92010754908..8c215d6b56f 160000 --- a/src/tests +++ b/src/tests @@ -1 +1 @@ -Subproject commit 9201075490807f58811078e9bb5ec895b4ac01a5 +Subproject commit 8c215d6b56fed36501d04c165093357f102de2ac From 4e6fea9eea036c17ca225d396596635371966ad0 Mon Sep 17 00:00:00 2001 From: yerke26 Date: Sun, 20 Oct 2024 21:17:56 +0600 Subject: [PATCH 5/5] fix Benchmarks --- src/Nethermind/Ethereum.Test.Base/BlockchainTestBase.cs | 2 +- .../Nethermind.JsonRpc.Benchmark/EthModuleBenchmarks.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Nethermind/Ethereum.Test.Base/BlockchainTestBase.cs b/src/Nethermind/Ethereum.Test.Base/BlockchainTestBase.cs index fe5fb25c019..66df7e618ee 100644 --- a/src/Nethermind/Ethereum.Test.Base/BlockchainTestBase.cs +++ b/src/Nethermind/Ethereum.Test.Base/BlockchainTestBase.cs @@ -171,7 +171,7 @@ protected async Task RunTest(BlockchainTest test, Stopwatch? stateProvider, receiptStorage, transactionProcessor, - new BeaconBlockRootHandler(transactionProcessor), + new BeaconBlockRootHandler(transactionProcessor, stateProvider), new BlockhashStore(specProvider, stateProvider), _logManager); diff --git a/src/Nethermind/Nethermind.JsonRpc.Benchmark/EthModuleBenchmarks.cs b/src/Nethermind/Nethermind.JsonRpc.Benchmark/EthModuleBenchmarks.cs index 885496c6812..02a8abacccd 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Benchmark/EthModuleBenchmarks.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Benchmark/EthModuleBenchmarks.cs @@ -104,7 +104,7 @@ TransactionProcessor transactionProcessor stateProvider, NullReceiptStorage.Instance, transactionProcessor, - new BeaconBlockRootHandler(transactionProcessor), + new BeaconBlockRootHandler(transactionProcessor, stateProvider), new BlockhashStore(specProvider, stateProvider), LimboLogs.Instance);