Skip to content
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

pass in world state where there in no context which worldState to use #55

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

tanishqjasoria
Copy link
Owner

Fixes Closes Resolves #

Please choose one of the keywords above to refer to the issue this PR solves followed by the issue number (e.g. Fixes #000). If no issue number, remove the line. Also, remove everything marked optional that is not applicable. Remove this note after reading.

Changes

  • List the changes

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a change that causes existing functionality not to work as expected)
  • Optimization
  • Refactoring
  • Documentation update
  • Build-related changes
  • Other: Description

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

Notes on testing

Optional. Remove if not applicable.

Documentation

Requires documentation update

  • Yes
  • No

If yes, link the PR to the docs update or the issue with the details labeled docs. Remove if not applicable.

Requires explanation in Release Notes

  • Yes
  • No

If yes, fill in the details here. Remove if not applicable.

Remarks

Optional. Remove if not applicable.

@@ -71,25 +71,24 @@ protected override ITxSource CreateTxSourceForProducer(ITxSource? additionalTxSo
return new OptimismTxPoolTxSource(baseTxSource);
}

protected override BlockProcessor CreateBlockProcessor(
IReadOnlyTxProcessingScope readOnlyTxProcessingEnv,
protected override BlockProcessor CreateBlockProcessor(IReadOnlyTxProcessingScope readOnlyTxProcessingEnv,
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check if we now need readOnlyTransiton processor or not, or we can just replace WorldState inside the readOnlyTxProcessingEnv itself?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also check on the difference on how produce and processor are intialized to get some more ideas?

@@ -108,7 +91,7 @@ protected virtual Task InitBlockchain()
setApi.TxPoolInfoProvider = new TxPoolInfoProvider(chainHeadInfoProvider.AccountStateProvider, txPool);
setApi.GasPriceOracle = new GasPriceOracle(getApi.BlockTree!, getApi.SpecProvider, _api.LogManager, blocksConfig.MinGasPrice);
BlockCachePreWarmer? preWarmer = blocksConfig.PreWarmStateOnBlockProcessing
? new(new(_api.WorldStateManager!, _api.BlockTree!, _api.SpecProvider, _api.LogManager, _api.WorldState), _api.SpecProvider, _api.LogManager, _api.WorldState)
? new(new(_api.WorldStateManager!, _api.BlockTree!, _api.SpecProvider, _api.LogManager), _api.SpecProvider, _api.WorldStateManager!, _api.LogManager)
: null;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have a look at this as well again - might be a better way to do this?

@@ -165,14 +165,13 @@ public Task Execute(CancellationToken cancellationToken)
worldState,
trieStore,
getApi.DbProvider,
getApi.LogManager);
getApi.LogManager, preBlockCaches);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this as well?

@@ -37,7 +38,8 @@ public BlockhashProvider(IBlockFinder blockTree, ISpecProvider specProvider, IWo

if (spec.IsBlockHashInStateAvailable)
{
return _blockhashStore.GetBlockHashFromState(currentBlock, number);
IWorldState? worldStateToUse = _worldStateManager.GetGlobalWorldState(currentBlock);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we instead use a function here or a sperate interface that gives us the correct interface when given a header

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another issues here, this will only work when we have a global worldState instantiation.

@@ -14,12 +14,12 @@
[assembly: InternalsVisibleTo("Nethermind.Merge.Plugin.Test")]
namespace Nethermind.Blockchain.Blocks;

public class BlockhashStore(ISpecProvider specProvider, IWorldState worldState)
public class BlockhashStore(ISpecProvider specProvider)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add worldStateManager for this as well, both the functions have the required information to query the correct worldState

@@ -58,16 +61,17 @@ public bool ValidateParams(BlockHeader parent, BlockHeader header, bool isUncle
{
long step = header.AuRaStep.Value;

IWorldState? worldState = _worldStateManager.GetGlobalWorldState(header);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is mostly done here to avoid a huge bad refactor to pass with down with every seal validator

@@ -85,17 +82,18 @@ public override object[] Call(CallInfo callInfo)

lock (_readOnlyTxProcessorSource)
{
using var scope = _readOnlyTxProcessorSource.Build(GetState(callInfo.ParentHeader));
using IReadOnlyTxProcessingScope? scope =
_readOnlyTxProcessorSource.Build(GetState(callInfo.ParentHeader), callInfo.ParentHeader);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not feel like correct, why are we using parent header? does this work for aura? because technically this is a constant contract and we are getting data from the parent block only.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we use the parentHeader for the block execution as well, so we can get the state for the parent header as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant