diff --git a/src/Nethermind b/src/Nethermind index 7e4122189..6b9f037be 160000 --- a/src/Nethermind +++ b/src/Nethermind @@ -1 +1 @@ -Subproject commit 7e4122189dfdf012bbaaabb6520fd1d71e198127 +Subproject commit 6b9f037bece6840a8bcad6d5a79af6f87bb60a92 diff --git a/src/Nethermind.Arbitrum.Test/BlockProcessing/BlockProcessorTests.cs b/src/Nethermind.Arbitrum.Test/BlockProcessing/BlockProcessorTests.cs index 8f0a0d8df..401951a08 100644 --- a/src/Nethermind.Arbitrum.Test/BlockProcessing/BlockProcessorTests.cs +++ b/src/Nethermind.Arbitrum.Test/BlockProcessing/BlockProcessorTests.cs @@ -8,6 +8,7 @@ using Nethermind.Arbitrum.Test.Precompiles; using Nethermind.Blockchain.Tracing; using Nethermind.Consensus.Processing; +using Nethermind.Consensus.Producers; using Nethermind.Core; using Nethermind.Core.Crypto; using Nethermind.Core.Test.Builders; @@ -89,6 +90,9 @@ public void ProcessTransactions_SubmitRetryable_CreatesRetryTx() IWorldState worldState = chain.WorldStateManager.GlobalWorldState; using var dispose = worldState.BeginScope(chain.BlockTree.Head!.Header); + BlockToProduce blockToProduce = new BlockToProduce(newBlock.Header, newBlock.Transactions, [], + null); + var arbosState = ArbosState.OpenArbosState(worldState, new SystemBurner(), LimboLogs.Instance.GetLogger("arbosState")); newBlock.Header.BaseFeePerGas = arbosState.L2PricingState.BaseFeeWeiStorage.Get(); @@ -101,9 +105,9 @@ public void ProcessTransactions_SubmitRetryable_CreatesRetryTx() }; var blockTracer = new BlockReceiptsTracer(); - blockTracer.StartNewBlockTrace(newBlock); + blockTracer.StartNewBlockTrace(blockToProduce); - chain.BlockProcessor.ProcessOne(newBlock, ProcessingOptions.ProducingBlock, blockTracer, chain.SpecProvider.GenesisSpec); + chain.BlockProcessor.ProcessOne(blockToProduce, ProcessingOptions.ProducingBlock, blockTracer, chain.SpecProvider.GenesisSpec); blockTracer.EndBlockTrace(); diff --git a/src/Nethermind.Arbitrum.Test/BlockProcessing/BlockProducerTests.cs b/src/Nethermind.Arbitrum.Test/BlockProcessing/BlockProducerTests.cs index 3cd6b36c9..c7980c15b 100644 --- a/src/Nethermind.Arbitrum.Test/BlockProcessing/BlockProducerTests.cs +++ b/src/Nethermind.Arbitrum.Test/BlockProcessing/BlockProducerTests.cs @@ -87,14 +87,18 @@ public void BuildBlock_SignedTransaction_RecoversSenderAddressFromSignature() }; ArbitrumRpcTestBlockchain chain = ArbitrumRpcTestBlockchain.CreateDefault(preConfigurer); - using var dispose = chain.WorldStateManager.GlobalWorldState.BeginScope(chain.BlockTree.Head!.Header); - ArbosState arbosState = ArbosState.OpenArbosState(chain.WorldStateManager.GlobalWorldState, - new SystemBurner(), LimboNoErrorLogger.Instance); + UInt256 gasPrice = UInt256.Zero; + using (chain.WorldStateManager.GlobalWorldState.BeginScope(chain.BlockTree.Head!.Header)) + { + ArbosState arbosState = ArbosState.OpenArbosState(chain.WorldStateManager.GlobalWorldState, + new SystemBurner(), LimboNoErrorLogger.Instance); + gasPrice = arbosState.L2PricingState.BaseFeeWeiStorage.Get(); + } var ethereumEcdsa = new EthereumEcdsa(chain.SpecProvider.ChainId); Transaction transaction = Build.A.Transaction .WithGasLimit(GasCostOf.Transaction) - .WithGasPrice(arbosState.L2PricingState.BaseFeeWeiStorage.Get()) + .WithGasPrice(gasPrice) .WithNonce(0) .WithValue(1.Ether()) .To(TestItem.AddressB) diff --git a/src/Nethermind.Arbitrum.Test/Config/ArbitrumChainSpecProviderTests.cs b/src/Nethermind.Arbitrum.Test/Config/ArbitrumChainSpecProviderTests.cs index 42f0d3307..3155d4f98 100644 --- a/src/Nethermind.Arbitrum.Test/Config/ArbitrumChainSpecProviderTests.cs +++ b/src/Nethermind.Arbitrum.Test/Config/ArbitrumChainSpecProviderTests.cs @@ -26,7 +26,7 @@ public void ChainSpecProvider_SeveralLifetimeScopes_OneSpecProviderPerScope() chainSpec.EngineChainSpecParametersProvider.GetChainSpecParameters(); engineParameters.InitialArbOSVersion = 10; - ArbitrumModule module = new(chainSpec); + ArbitrumModule module = new(chainSpec, new BlocksConfig()); ContainerBuilder containerBuilder = new(); containerBuilder.AddModule(new TestNethermindModule(new ConfigProvider(), chainSpec)); @@ -84,7 +84,7 @@ public void ChainSpecProvider_WhenArbOSVersionChanges_ReturnsCorrectSpec() { ChainSpec chainSpec = FullChainSimulationChainSpecProvider.Create(); - ArbitrumModule module = new(chainSpec); + ArbitrumModule module = new(chainSpec, new BlocksConfig()); ContainerBuilder containerBuilder = new(); //explicitly state we won't use TestSpecProvider diff --git a/src/Nethermind.Arbitrum.Test/Infrastructure/ArbitrumRpcTestBlockchain.cs b/src/Nethermind.Arbitrum.Test/Infrastructure/ArbitrumRpcTestBlockchain.cs index 311f6644c..fb91fe3ad 100644 --- a/src/Nethermind.Arbitrum.Test/Infrastructure/ArbitrumRpcTestBlockchain.cs +++ b/src/Nethermind.Arbitrum.Test/Infrastructure/ArbitrumRpcTestBlockchain.cs @@ -251,6 +251,7 @@ private static ArbitrumRpcTestBlockchain CreateInternal(ArbitrumRpcTestBlockchai chain.Container.Resolve(), new Nethermind.Arbitrum.Config.VerifyBlockHashConfig(), // Disabled for tests new Nethermind.Serialization.Json.EthereumJsonSerializer(), + chain.Container.Resolve(), null) // No ProcessExitSource in tests .Create()); diff --git a/src/Nethermind.Arbitrum.Test/Infrastructure/ArbitrumTestBlockchainBase.cs b/src/Nethermind.Arbitrum.Test/Infrastructure/ArbitrumTestBlockchainBase.cs index 20c755445..1787f89cd 100644 --- a/src/Nethermind.Arbitrum.Test/Infrastructure/ArbitrumTestBlockchainBase.cs +++ b/src/Nethermind.Arbitrum.Test/Infrastructure/ArbitrumTestBlockchainBase.cs @@ -137,6 +137,9 @@ protected virtual ArbitrumTestBlockchainBase Build(Action? con JsonSerializer = new EthereumJsonSerializer(); IConfigProvider configProvider = new ConfigProvider(arbitrumConfig); + //it's a mess... but we need to ensure that both configs are in sync + configProvider.GetConfig().BuildBlocksOnMainState = true; + this.BlocksConfig.BuildBlocksOnMainState = true; ContainerBuilder builder = ConfigureContainer(new ContainerBuilder(), configProvider); configurer?.Invoke(builder); @@ -163,22 +166,14 @@ protected virtual ArbitrumTestBlockchainBase Build(Action? con TransactionComparerProvider transactionComparerProvider = new(Dependencies.SpecProvider, BlockFinder); BlockProducer = CreateTestBlockProducer(Dependencies.Sealer, transactionComparerProvider); + BlockProducerRunner = new StandardBlockProducerRunner(BlockProductionTrigger, BlockTree, BlockProducer); + _ = new NonProcessingProducedBlockSuggester(BlockTree, BlockProducerRunner); BlockProducerRunner.Start(); - Suggester = new ProducedBlockSuggester(BlockTree, BlockProducerRunner); - RegisterTransactionDecoders(); Cts = AutoCancelTokenSource.ThatCancelAfter(TimeSpan.FromMilliseconds(TestTimout)); - //TestUtil = new TestBlockchainUtil( - // BlockProducerRunner, - // BlockProductionTrigger, - // Timestamper, - // BlockTree, - // TxPool, - // 1 - //); Configuration testConfig = Container.Resolve(); IWorldState worldState = WorldStateManager.GlobalWorldState; @@ -277,7 +272,7 @@ protected virtual ContainerBuilder ConfigureContainer(ContainerBuilder builder, return builder .AddModule(new PseudoNethermindModule(ChainSpec, configProvider, LimboLogs.Instance)) .AddModule(new TestEnvironmentModule(TestItem.PrivateKeyA, Random.Shared.Next().ToString())) - .AddModule(new ArbitrumModule(ChainSpec)) + .AddModule(new ArbitrumModule(ChainSpec, configProvider.GetConfig())) .AddSingleton(new MemDbFactory()) .AddSingleton(FullChainSimulationSpecProvider.Instance) .AddSingleton() @@ -287,7 +282,6 @@ protected virtual ContainerBuilder ConfigureContainer(ContainerBuilder builder, .AddDecorator() .AddSingleton() - .AddSingleton() .AddSingleton() .AddDecorator() diff --git a/src/Nethermind.Arbitrum.Test/Rpc/ArbitrumRpcModuleTests.cs b/src/Nethermind.Arbitrum.Test/Rpc/ArbitrumRpcModuleTests.cs index 23948d956..ec06331ef 100644 --- a/src/Nethermind.Arbitrum.Test/Rpc/ArbitrumRpcModuleTests.cs +++ b/src/Nethermind.Arbitrum.Test/Rpc/ArbitrumRpcModuleTests.cs @@ -31,7 +31,7 @@ public abstract class ArbitrumRpcModuleTests private const ulong GenesisBlockNum = 1000UL; private ArbitrumBlockTreeInitializer _initializer = null!; - private Mock _blockConfigMock = null!; + private IBlocksConfig _blockConfig = null!; private Mock _blockTreeMock = null!; private Mock _triggerMock = null!; private ArbitrumRpcTxSource _txSource = null!; @@ -47,7 +47,8 @@ public abstract class ArbitrumRpcModuleTests public void Setup() { _worldStateManagerMock = new Mock(); - _blockConfigMock = new Mock(); + _blockConfig = new BlocksConfig(); + _blockConfig.BuildBlocksOnMainState = true; _blockTreeMock = new Mock(); _triggerMock = new Mock(); _logManager = LimboLogs.Instance; @@ -60,7 +61,7 @@ public void Setup() _specHelper.Object, _worldStateManagerMock.Object, _blockTreeMock.Object, - _blockConfigMock.Object, + _blockConfig, _logManager); _specHelper.SetupGet(x => x.GenesisBlockNum).Returns(GenesisBlockNum); @@ -80,7 +81,8 @@ public void Setup() _logManager, cachedL1PriceData, _blockProcessingQueue.Object, - _arbitrumConfig); + _arbitrumConfig, + _blockConfig); } [Test] @@ -241,7 +243,8 @@ public async Task HeadMessageIndex_Always_ReturnsHeadMessageIndex() _logManager, cachedL1PriceData, _blockProcessingQueue.Object, - _arbitrumConfig); + _arbitrumConfig, + _blockConfig); _specHelper.Setup(c => c.GenesisBlockNum).Returns((ulong)genesis.Number); @@ -271,7 +274,8 @@ public async Task HeadMessageIndex_HasNoBlocks_NoLatestHeaderFound() _logManager, cachedL1PriceData, _blockProcessingQueue.Object, - _arbitrumConfig); + _arbitrumConfig, + _blockConfig); var result = await _rpcModule.HeadMessageIndex(); @@ -307,7 +311,8 @@ public async Task HeadMessageIndex_BlockNumberIsLowerThanGenesis_Fails() _logManager, cachedL1PriceData, _blockProcessingQueue.Object, - _arbitrumConfig); + _arbitrumConfig, + _blockConfig); _specHelper.Setup(c => c.GenesisBlockNum).Returns(genesisBlockNum); diff --git a/src/Nethermind.Arbitrum.slnx b/src/Nethermind.Arbitrum.slnx index 6750198ff..3e3351a52 100644 --- a/src/Nethermind.Arbitrum.slnx +++ b/src/Nethermind.Arbitrum.slnx @@ -41,7 +41,6 @@ - diff --git a/src/Nethermind.Arbitrum/ArbitrumPlugin.cs b/src/Nethermind.Arbitrum/ArbitrumPlugin.cs index ae51476f8..1c9be09b5 100644 --- a/src/Nethermind.Arbitrum/ArbitrumPlugin.cs +++ b/src/Nethermind.Arbitrum/ArbitrumPlugin.cs @@ -37,7 +37,7 @@ namespace Nethermind.Arbitrum; -public class ArbitrumPlugin(ChainSpec chainSpec) : IConsensusPlugin +public class ArbitrumPlugin(ChainSpec chainSpec, IBlocksConfig blocksConfig) : IConsensusPlugin { private ArbitrumNethermindApi _api = null!; private IJsonRpcConfig _jsonRpcConfig = null!; @@ -47,7 +47,7 @@ public class ArbitrumPlugin(ChainSpec chainSpec) : IConsensusPlugin public string Description => "Nethermind Arbitrum client"; public string Author => "Nethermind"; public bool Enabled => chainSpec.SealEngineType == ArbitrumChainSpecEngineParameters.ArbitrumEngineName; - public IModule Module => new ArbitrumModule(chainSpec); + public IModule Module => new ArbitrumModule(chainSpec, blocksConfig); public Type ApiType => typeof(ArbitrumNethermindApi); public Task Init(INethermindApi api) @@ -91,6 +91,7 @@ public Task InitRpcModules() _api.Config(), _api.Config(), _api.EthereumJsonSerializer, + _api.Config(), _api.ProcessExit ); @@ -156,7 +157,7 @@ public class ArbitrumGasLimitCalculator : IGasLimitCalculator public long GetGasLimit(BlockHeader parentHeader) => long.MaxValue; } -public class ArbitrumModule(ChainSpec chainSpec) : Module +public class ArbitrumModule(ChainSpec chainSpec, IBlocksConfig blocksConfig) : Module { protected override void Load(ContainerBuilder builder) { @@ -194,7 +195,6 @@ protected override void Load(ContainerBuilder builder) .AddScoped((specProvider, blocksConfig) => new ArbitrumBlockProductionTransactionPicker(specProvider)) - .AddSingleton() .AddSingleton() .AddDecorator() .AddScoped() @@ -205,6 +205,11 @@ protected override void Load(ContainerBuilder builder) // Rpcs .AddSingleton() .Bind, ArbitrumEthModuleFactory>(); + + if (blocksConfig.BuildBlocksOnMainState) + builder.AddSingleton(); + else + builder.AddSingleton(); } private class ArbitrumBlockValidationModule : Module, IBlockValidationModule diff --git a/src/Nethermind.Arbitrum/ArbitrumRpcModuleFactory.cs b/src/Nethermind.Arbitrum/ArbitrumRpcModuleFactory.cs index cc2f5061c..734182bf1 100644 --- a/src/Nethermind.Arbitrum/ArbitrumRpcModuleFactory.cs +++ b/src/Nethermind.Arbitrum/ArbitrumRpcModuleFactory.cs @@ -30,6 +30,7 @@ public sealed class ArbitrumRpcModuleFactory( IArbitrumConfig arbitrumConfig, IVerifyBlockHashConfig verifyBlockHashConfig, IJsonSerializer jsonSerializer, + IBlocksConfig blocksConfig, IProcessExitSource? processExitSource = null) : ModuleFactoryBase { public override IArbitrumRpcModule Create() @@ -37,7 +38,7 @@ public override IArbitrumRpcModule Create() if (!verifyBlockHashConfig.Enabled || string.IsNullOrWhiteSpace(verifyBlockHashConfig.ArbNodeRpcUrl)) return new ArbitrumRpcModule( initializer, blockTree, trigger, txSource, chainSpec, specHelper, - logManager, cachedL1PriceData, processingQueue, arbitrumConfig); + logManager, cachedL1PriceData, processingQueue, arbitrumConfig, blocksConfig); ILogger logger = logManager.GetClassLogger(); if (logger.IsInfo) @@ -45,6 +46,6 @@ public override IArbitrumRpcModule Create() return new ArbitrumRpcModuleWithComparison( initializer, blockTree, trigger, txSource, chainSpec, specHelper, - logManager, cachedL1PriceData, processingQueue, arbitrumConfig, verifyBlockHashConfig, jsonSerializer, processExitSource); + logManager, cachedL1PriceData, processingQueue, arbitrumConfig, verifyBlockHashConfig, jsonSerializer, blocksConfig, processExitSource); } } diff --git a/src/Nethermind.Arbitrum/Config/ArbitrumBlockProducerEnvFactory.cs b/src/Nethermind.Arbitrum/Config/ArbitrumBlockProducerEnvFactory.cs index 112b8e8de..757acaa56 100644 --- a/src/Nethermind.Arbitrum/Config/ArbitrumBlockProducerEnvFactory.cs +++ b/src/Nethermind.Arbitrum/Config/ArbitrumBlockProducerEnvFactory.cs @@ -1,5 +1,4 @@ using Autofac; -using Nethermind.Arbitrum.Execution; using Nethermind.Consensus.Processing; using Nethermind.Consensus.Producers; using Nethermind.Core; @@ -23,3 +22,19 @@ protected override ContainerBuilder ConfigureBuilder(ContainerBuilder builder) .AddScoped(); } } + +public class ArbitrumGlobalWorldStateBlockProducerEnvFactory : GlobalWorldStateBlockProducerEnvFactory +{ + public ArbitrumGlobalWorldStateBlockProducerEnvFactory( + ILifetimeScope rootLifetime, + IWorldStateManager worldStateManager, + IBlockProducerTxSourceFactory txSourceFactory) : base(rootLifetime, worldStateManager, txSourceFactory) + { + } + + protected override ContainerBuilder ConfigureBuilder(ContainerBuilder builder) + { + return base.ConfigureBuilder(builder) + .AddScoped(); + } +} diff --git a/src/Nethermind.Arbitrum/Execution/ArbitrumBlockProcessor.cs b/src/Nethermind.Arbitrum/Execution/ArbitrumBlockProcessor.cs index 0bb3c7071..52921deae 100644 --- a/src/Nethermind.Arbitrum/Execution/ArbitrumBlockProcessor.cs +++ b/src/Nethermind.Arbitrum/Execution/ArbitrumBlockProcessor.cs @@ -196,7 +196,7 @@ public virtual TxReceipt[] ProcessTransactions(Block block, ProcessingOptions pr //only pickup scheduled transactions when producing block - otherwise already included in block IEnumerable scheduledTransactions = []; - if (processingOptions.ContainsFlag(ProcessingOptions.ProducingBlock)) + if (blockToProduce is not null) { scheduledTransactions = receiptsTracer.TxReceipts.Count > 0 ? GetScheduledTransactions(arbosState, receiptsTracer.LastReceipt, block.Header, specProvider.ChainId) @@ -333,7 +333,7 @@ private TxAction ProcessTransaction( } else { - if (processingOptions.ContainsFlag(ProcessingOptions.DoNotVerifyNonce) && currentTx.SenderAddress != Address.SystemUser) + if (processingOptions.ContainsFlag(ProcessingOptions.LoadNonceFromState) && currentTx.SenderAddress != Address.SystemUser) { currentTx.Nonce = stateProvider.GetNonce(currentTx.SenderAddress!); } diff --git a/src/Nethermind.Arbitrum/Execution/ArbitrumBlockProducer.cs b/src/Nethermind.Arbitrum/Execution/ArbitrumBlockProducer.cs index ea0814a6d..658f96c39 100644 --- a/src/Nethermind.Arbitrum/Execution/ArbitrumBlockProducer.cs +++ b/src/Nethermind.Arbitrum/Execution/ArbitrumBlockProducer.cs @@ -6,6 +6,7 @@ using Nethermind.Arbitrum.Execution.Transactions; using Nethermind.Arbitrum.Precompiles.Abi; using Nethermind.Blockchain; +using Nethermind.Blockchain.Tracing; using Nethermind.Config; using Nethermind.Consensus; using Nethermind.Consensus.Processing; @@ -16,6 +17,7 @@ using Nethermind.Core.Specs; using Nethermind.Crypto; using Nethermind.Evm.State; +using Nethermind.Evm.Tracing; using Nethermind.Logging; using Nethermind.Merge.Plugin.BlockProduction; diff --git a/src/Nethermind.Arbitrum/Modules/ArbitrumRpcModule.cs b/src/Nethermind.Arbitrum/Modules/ArbitrumRpcModule.cs index b5704d0a6..f721d2fdf 100644 --- a/src/Nethermind.Arbitrum/Modules/ArbitrumRpcModule.cs +++ b/src/Nethermind.Arbitrum/Modules/ArbitrumRpcModule.cs @@ -11,6 +11,7 @@ using Nethermind.Arbitrum.Genesis; using Nethermind.Arbitrum.Math; using Nethermind.Blockchain; +using Nethermind.Config; using Nethermind.Consensus.Processing; using Nethermind.Consensus.Producers; using Nethermind.Core; @@ -31,7 +32,8 @@ public class ArbitrumRpcModule( ILogManager logManager, CachedL1PriceData cachedL1PriceData, IBlockProcessingQueue processingQueue, - IArbitrumConfig arbitrumConfig) : IArbitrumRpcModule + IArbitrumConfig arbitrumConfig, + IBlocksConfig blocksConfig) : IArbitrumRpcModule { protected readonly SemaphoreSlim CreateBlocksSemaphore = new(1, 1); @@ -83,6 +85,9 @@ public virtual async Task> DigestMessage(DigestMess return ResultWrapper.Fail( $"Wrong block number in digest got {blockNumber} expected {headBlockHeader.Number}"); + if (blocksConfig.BuildBlocksOnMainState) + return await ProduceBlockWithoutWaitingOnProcessingQueueAsync(parameters.Message, blockNumber, headBlockHeader); + return await ProduceBlockWhileLockedAsync(parameters.Message, blockNumber, headBlockHeader); } finally @@ -288,6 +293,32 @@ await Task.WhenAll(newBestBlockTcs.Task, blockRemovedTcs.Task) } } + protected async Task> ProduceBlockWithoutWaitingOnProcessingQueueAsync(MessageWithMetadata messageWithMetadata, long blockNumber, BlockHeader? headBlockHeader) + { + ArbitrumPayloadAttributes payload = new() + { + MessageWithMetadata = messageWithMetadata, + Number = blockNumber + }; + + try + { + Block? block = await trigger.BuildBlock(parentHeader: headBlockHeader, payloadAttributes: payload); + if (block?.Hash is null) + return ResultWrapper.Fail("Failed to build block or block has no hash.", ErrorCodes.InternalError); + + return ResultWrapper.Success(new MessageResult + { + BlockHash = block.Hash!, + SendRoot = GetSendRootFromBlock(block) + }); + } + catch (TimeoutException) + { + return ResultWrapper.Fail("Timeout waiting for block processing result.", ErrorCodes.Timeout); + } + } + private Hash256 GetSendRootFromBlock(Block block) { ArbitrumBlockHeaderInfo headerInfo = ArbitrumBlockHeaderInfo.Deserialize(block.Header, Logger); diff --git a/src/Nethermind.Arbitrum/Modules/ArbitrumRpcModuleWithComparison.cs b/src/Nethermind.Arbitrum/Modules/ArbitrumRpcModuleWithComparison.cs index b470220d2..e7ddc5261 100644 --- a/src/Nethermind.Arbitrum/Modules/ArbitrumRpcModuleWithComparison.cs +++ b/src/Nethermind.Arbitrum/Modules/ArbitrumRpcModuleWithComparison.cs @@ -31,8 +31,9 @@ public sealed class ArbitrumRpcModuleWithComparison( IArbitrumConfig arbitrumConfig, IVerifyBlockHashConfig verifyBlockHashConfig, IJsonSerializer jsonSerializer, + IBlocksConfig blocksConfig, IProcessExitSource? processExitSource = null) - : ArbitrumRpcModule(initializer, blockTree, trigger, txSource, chainSpec, specHelper, logManager, cachedL1PriceData, processingQueue, arbitrumConfig) + : ArbitrumRpcModule(initializer, blockTree, trigger, txSource, chainSpec, specHelper, logManager, cachedL1PriceData, processingQueue, arbitrumConfig, blocksConfig) { private readonly ArbitrumComparisonRpcClient _comparisonRpcClient = new(verifyBlockHashConfig.ArbNodeRpcUrl!, jsonSerializer, logManager); private readonly long _verificationInterval = (long)verifyBlockHashConfig.VerifyEveryNBlocks; @@ -60,7 +61,7 @@ public override async Task> DigestMessage(DigestMes if (blockNumber % _verificationInterval == 0) return await DigestMessageWithComparisonAsync(parameters.Message, blockNumber, headBlockHeader); - return await ProduceBlockWhileLockedAsync(parameters.Message, blockNumber, headBlockHeader); + return await ProduceBlock(parameters.Message, blockNumber, headBlockHeader); } finally { @@ -76,7 +77,7 @@ private async Task> DigestMessageWithComparisonAsyn if (Logger.IsInfo) Logger.Info($"Comparison mode: Processing block {blockNumber} with external RPC validation"); - Task> digestTask = ProduceBlockWhileLockedAsync(messageWithMetadata, blockNumber, headBlockHeader); + Task> digestTask = ProduceBlock(messageWithMetadata, blockNumber, headBlockHeader); Task> externalRpcTask = _comparisonRpcClient.GetBlockDataAsync(blockNumber); try @@ -247,4 +248,12 @@ private void TriggerGracefulShutdown(string reason) }); } } + + private Task> ProduceBlock(MessageWithMetadata messageWithMetadata, long blockNumber, + BlockHeader? headBlockHeader) + { + return blocksConfig.BuildBlocksOnMainState + ? ProduceBlockWithoutWaitingOnProcessingQueueAsync(messageWithMetadata, blockNumber, headBlockHeader) + : ProduceBlockWhileLockedAsync(messageWithMetadata, blockNumber, headBlockHeader); + } } diff --git a/src/Nethermind.Arbitrum/Properties/configs/arbitrum-local.json b/src/Nethermind.Arbitrum/Properties/configs/arbitrum-local.json index 188898d48..9037657c0 100644 --- a/src/Nethermind.Arbitrum/Properties/configs/arbitrum-local.json +++ b/src/Nethermind.Arbitrum/Properties/configs/arbitrum-local.json @@ -54,7 +54,8 @@ "PruningBoundary": 192 }, "Blocks": { - "SecondsPerSlot": 2 + "SecondsPerSlot": 2, + "BuildBlocksOnMainState": true }, "Merge": { "Enabled": true diff --git a/src/Nethermind.Arbitrum/Properties/configs/arbitrum-sepolia-archive.json b/src/Nethermind.Arbitrum/Properties/configs/arbitrum-sepolia-archive.json index f74214651..27d36d97f 100644 --- a/src/Nethermind.Arbitrum/Properties/configs/arbitrum-sepolia-archive.json +++ b/src/Nethermind.Arbitrum/Properties/configs/arbitrum-sepolia-archive.json @@ -49,7 +49,8 @@ "MaxBufferedCommitCount": 2500 }, "Blocks": { - "PreWarmStateOnBlockProcessing": false + "PreWarmStateOnBlockProcessing": false, + "BuildBlocksOnMainState": true }, "Metrics": { "NodeName": "Nethermind Arbitrum Sepolia Archive" diff --git a/src/Nethermind.Arbitrum/Properties/configs/arbitrum-sepolia.json b/src/Nethermind.Arbitrum/Properties/configs/arbitrum-sepolia.json index 7c4075abe..a0aac6a4f 100644 --- a/src/Nethermind.Arbitrum/Properties/configs/arbitrum-sepolia.json +++ b/src/Nethermind.Arbitrum/Properties/configs/arbitrum-sepolia.json @@ -55,7 +55,8 @@ }, "Blocks": { "SecondsPerSlot": 2, - "PreWarmStateOnBlockProcessing": false + "PreWarmStateOnBlockProcessing": false, + "BuildBlocksOnMainState": true }, "Metrics": { "NodeName": "Nethermind Arbitrum Sepolia"