-
Notifications
You must be signed in to change notification settings - Fork 716
Add support for block producer based on global world state instance. #9388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
damian-orzechowski
merged 10 commits into
master
from
feature/build-block-on-global-state
Oct 22, 2025
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
bd53b92
Add support for block producer based on global world state instance.
damian-orzechowski b7d8d98
Register ProducedBlockSuggester
damian-orzechowski a58eb22
Merge branch 'master' into feature/build-block-on-global-state
damian-orzechowski 37aa70b
Merge branch 'master' into feature/build-block-on-global-state
damian-orzechowski fb57d3a
Add config. Suggest produced block and update main chain.
damian-orzechowski 42cd33e
Merge branch 'master' into feature/build-block-on-global-state
damian-orzechowski e70dbcd
Added test
damian-orzechowski ef1ce20
Merge branch 'master' into feature/build-block-on-global-state
damian-orzechowski 3317ee7
Small refactor
damian-orzechowski 2402216
Merge branch 'master' into feature/build-block-on-global-state
damian-orzechowski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/Nethermind/Nethermind.Consensus/Producers/GlobalWorldStateBlockProducerEnvFactory.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| // SPDX-FileCopyrightText: 2022 Demerzel Solutions Limited | ||
| // SPDX-License-Identifier: LGPL-3.0-only | ||
|
|
||
| using Autofac; | ||
| using Nethermind.Consensus.Processing; | ||
| using Nethermind.Consensus.Transactions; | ||
| using Nethermind.Consensus.Withdrawals; | ||
| using Nethermind.Core; | ||
| using Nethermind.Evm.TransactionProcessing; | ||
| using Nethermind.State; | ||
|
|
||
| namespace Nethermind.Consensus.Producers | ||
| { | ||
| /// <summary> | ||
| /// Block producer environment factory that uses the global world state and stores receipts by default. | ||
| /// It will not trigger suggesting produced blocks. | ||
| /// </summary> | ||
| /// <param name="rootLifetime"></param> | ||
| /// <param name="worldStateManager"></param> | ||
| /// <param name="txSourceFactory"></param> | ||
| public class GlobalWorldStateBlockProducerEnvFactory( | ||
| ILifetimeScope rootLifetime, | ||
| IWorldStateManager worldStateManager, | ||
| IBlockProducerTxSourceFactory txSourceFactory) | ||
| : IBlockProducerEnvFactory | ||
| { | ||
| protected virtual ContainerBuilder ConfigureBuilder(ContainerBuilder builder) => builder | ||
| .AddScoped<ITxSource>(txSourceFactory.Create()) | ||
| .AddScoped(BlockchainProcessor.Options.Default) | ||
| .AddScoped<ITransactionProcessorAdapter, BuildUpTransactionProcessorAdapter>() | ||
| .AddScoped<IBlockProcessor.IBlockTransactionsExecutor, BlockProcessor.BlockProductionTransactionsExecutor>() | ||
| .AddDecorator<IWithdrawalProcessor, BlockProductionWithdrawalProcessor>() | ||
| .AddDecorator<IBlockchainProcessor, OneTimeChainProcessor>() | ||
| .AddScoped<IProducedBlockSuggester, NoOpProducedBlockSuggester>() | ||
|
|
||
| .AddScoped<IBlockProducerEnv, BlockProducerEnv>(); | ||
|
|
||
| public virtual IBlockProducerEnv Create() | ||
| { | ||
| ILifetimeScope lifetimeScope = rootLifetime.BeginLifetimeScope(builder => | ||
| ConfigureBuilder(builder) | ||
| .AddScoped(worldStateManager.GlobalWorldState)); | ||
|
|
||
| rootLifetime.Disposer.AddInstanceForAsyncDisposal(lifetimeScope); | ||
| return lifetimeScope.Resolve<IBlockProducerEnv>(); | ||
| } | ||
| } | ||
| } |
11 changes: 11 additions & 0 deletions
11
src/Nethermind/Nethermind.Consensus/Producers/IProducedBlockSuggester.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // SPDX-FileCopyrightText: 2025 Demerzel Solutions Limited | ||
| // SPDX-License-Identifier: LGPL-3.0-only | ||
|
|
||
| using System; | ||
|
|
||
| namespace Nethermind.Consensus.Producers; | ||
|
|
||
| public interface IProducedBlockSuggester : IDisposable | ||
| { | ||
| // Just a marker interface to support DI | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/Nethermind/Nethermind.Consensus/Producers/NoOpProducedBlockSuggester.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // SPDX-FileCopyrightText: 2025 Demerzel Solutions Limited | ||
| // SPDX-License-Identifier: LGPL-3.0-only | ||
|
|
||
| namespace Nethermind.Consensus.Producers; | ||
| public class NoOpProducedBlockSuggester : IProducedBlockSuggester | ||
| { | ||
| public void Dispose() { } | ||
| } |
3 changes: 1 addition & 2 deletions
3
src/Nethermind/Nethermind.Consensus/Producers/ProducedBlockSuggester.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.