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

Fix MergeBlockDownloader keep repeating last block #4390

Merged
merged 53 commits into from
Aug 11, 2022

Conversation

asdacap
Copy link
Contributor

@asdacap asdacap commented Aug 9, 2022

Changes:

  • Fix MergeBlockDownloader keep repeating last block.
  • Returns null on ChainLevelHelper if only one header is returned.
  • Move ProcessDestination forward if MergeBlockDownloader suggest higher block.
  • Move ProcessDestination to BeaconPivot.

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Other (please describe):

Testing

Requires testing

  • Yes
  • No

In case you checked yes, did you write tests??

  • Yes
  • No

Comments about testing , should you have some (optional)

Incremental Sync hive test passes on previous test version if test is modified to not check synched via head.
Sync Client Post Merge hive test passed.
Only 4 test from engine-transition hive test failed, which is a known regression on master.

Still state-syncing ropsten.

Further comments (optional)

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

deffrian and others added 30 commits August 3, 2022 21:26
# Conflicts:
#	src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.Setup.cs
#	src/Nethermind/Nethermind.Merge.Plugin.Test/Synchronization/BeaconHeadersSyncTests.cs
#	src/Nethermind/Nethermind.Merge.Plugin/Handlers/V1/NewPayloadV1Handler.cs
#	src/Nethermind/Nethermind.Merge.Plugin/Synchronization/BeaconHeadersSyncFeed.cs
# Conflicts:
#	src/Nethermind/Nethermind.Merge.Plugin/Synchronization/ChainLevelHelper.cs
# Conflicts:
#	src/Nethermind/Nethermind.JsonRpc/JsonRpcUrl.cs
#	src/Nethermind/Nethermind.JsonRpc/JsonRpcUrlCollection.cs
#	src/Nethermind/Nethermind.Merge.Plugin/Synchronization/ChainLevelHelper.cs
#	src/Nethermind/Nethermind.Runner/configs/catalyst.cfg
#	src/Nethermind/Nethermind.Runner/configs/goerli_shadowfork.cfg
#	src/Nethermind/Nethermind.Runner/configs/mainnet_shadowfork.cfg
@asdacap asdacap requested a review from MarekM25 August 9, 2022 10:53
if (_logger.IsDebug)
_logger.Debug($"Parent of block not available. Starting new beacon header. sync.");

StartNewBeaconHeaderSync(forkchoiceState, newHeadBlock!, requestStr);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible scenario?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

BlockHeader? blockParent = _blockTree.FindHeader(newHeadBlock.ParentHash!);
if (blockParent == null)
{
if (_logger.IsDebug)
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe Logger.IsInfo to be able to distinguish situations for now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok

@@ -169,10 +169,10 @@ public async Task<ResultWrapper<PayloadStatusV1>> HandleAsync(ExecutionPayloadV1

BlockTreeInsertOptions insertOptions = BlockTreeInsertOptions.BeaconBlockInsert;

if (_blockCacheService.ProcessDestination != null && _blockCacheService.ProcessDestination.Hash == block.ParentHash)
if (_beaconPivot.ProcessDestination != null && _beaconPivot.ProcessDestination.Hash == block.ParentHash)
Copy link
Contributor

Choose a reason for hiding this comment

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

What if we don't have BeaconPivot here? It could be in two cases:

  1. We're doing sync from PoW chain and we have parent (no need to start beacon header sync), but we haven't processed blocks yet.
  2. We have a timeout in newPayload(x) and we have next newPayload(x+1) in this case we don't have beacon pivot at all.

So I think if we shouldn't EnsurePivot in this if. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah great... well I'm gonna put that as out of scope.

Copy link
Contributor

Choose a reason for hiding this comment

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

but it could introduce regression in such cases

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why? This is a rename.

@@ -91,6 +93,10 @@ public void EnsurePivot(BlockHeader? blockHeader)
return;
}

// BeaconHeaderSync actually starts from the parent of the pivot. So we need to to manually insert
// the pivot itself here.
_blockTree.Insert(blockHeader,
Copy link
Contributor

@MarekM25 MarekM25 Aug 9, 2022

Choose a reason for hiding this comment

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

I thought that we're adding it in TryInsertDanglingBlock. Aren't we?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not if beacon header sync is not started yet.

Copy link
Contributor

@MarekM25 MarekM25 left a comment

Choose a reason for hiding this comment

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

Added a few comments

return ForkchoiceUpdatedV1Result.Syncing;
}

BlockInfo blockInfo = _blockTree.GetInfo(newHeadBlock.Number, newHeadBlock.GetOrCalculateHash()).Info;
if (!blockInfo.WasProcessed)
{
BlockHeader? blockParent = _blockTree.FindHeader(newHeadBlock.ParentHash!);
Copy link
Contributor

Choose a reason for hiding this comment

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

do we have any unit tests for this if?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure.

asdacap and others added 5 commits August 9, 2022 21:15
# Conflicts:
#	src/Nethermind/Nethermind.Merge.Plugin.Test/EngineModuleTests.Synchronization.cs
#	src/Nethermind/Nethermind.Merge.Plugin/Handlers/V1/NewPayloadV1Handler.cs
@asdacap asdacap requested a review from MarekM25 August 10, 2022 02:15
@MarekM25 MarekM25 merged commit 9848934 into master Aug 11, 2022
@MarekM25 MarekM25 deleted the fix-mergeblockdownloader-keep-suggesting-block branch August 11, 2022 01:39
@MarekM25 MarekM25 mentioned this pull request Aug 12, 2022
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.

3 participants