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

Old receipts sync fix + beacon main chain marking fix #4370

Merged
merged 21 commits into from
Aug 9, 2022
Merged

Conversation

MarekM25
Copy link
Contributor

@MarekM25 MarekM25 commented Aug 5, 2022

Two fixes:

  1. We didn't stop on beacon chain reorg when the block is from main chain. Critical fix if we got timeout on NewPayload processing
  2. It seems that on ropsten some validators are producing invalid blocks constantly, because of that we're calling BlockAcceptingNewBlocks() when we're deleting invalid blocks https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Nethermind.Blockchain/BlockTree.cs#L1098
    and later in old bodies sync: https://github.com/NethermindEth/nethermind/blob/master/src/Nethermind/Nethermind.Blockchain/BlockTree.cs#L542

so we won't insert the block and later we will fail with old receipts. In theory, it could happen in pre-merge client too

deffrian and others added 17 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
@MarekM25 MarekM25 marked this pull request as ready for review August 5, 2022 14:12
@MarekM25 MarekM25 changed the base branch from master to engine-url-parameters August 5, 2022 14:12
@MarekM25 MarekM25 changed the base branch from engine-url-parameters to master August 5, 2022 14:12
# 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
@@ -352,8 +352,8 @@ private BlockInfo[] GetBeaconChainBranch(Block newHeadBlock, BlockInfo newHeadBl
}
BlockInfo predecessorInfo = _blockTree.GetInfo(predecessor.Number, predecessor.GetOrCalculateHash()).Info;
predecessorInfo.BlockNumber = predecessor.Number;
if (predecessorInfo.IsBeaconMainChain) break;
if (_logger.IsInfo) _logger.Info($"Reorged to beacon block ({predecessorInfo.BlockNumber}) {predecessorInfo.BlockHash} or cache rebuilt after restart");
if (predecessorInfo.IsBeaconMainChain || !predecessorInfo.IsBeaconInfo) break;
Copy link
Member

Choose a reason for hiding this comment

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

Should we also have some depth limit?
Should we also check if something is just MainChain?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in theory depth limit might be useful only in case of our bug, but I'm wondering what we can set here. Do you think we should break after, let's say 2000 blocks?

If something is on main chain we should break here: !predecessorInfo.IsBeaconInfo

@@ -33,7 +33,7 @@ public enum BlockTreeLookupOptions
}

[Flags]
public enum BlockTreeInsertOptions
public enum BlockTreeInsertHeaderOptions
Copy link
Member

Choose a reason for hiding this comment

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

All those options should be documented. It's getting extremely confusing what does what.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

100% agreed

@@ -46,6 +46,14 @@ public enum BlockTreeInsertOptions
BeaconHeaderInsert = BeaconHeaderMetadata | MoveToBeaconMainChain | NotOnMainChain
}

[Flags]
Copy link
Member

Choose a reason for hiding this comment

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

All those options should be documented.

@LukaszRozmej
Copy link
Member

Another, potentially better idea is doing something similar to what is done in SuggestBlockAsync, but it might be problematic with changing the code to async

@MarekM25
Copy link
Contributor Author

MarekM25 commented Aug 9, 2022

Another, potentially better idea is doing something similar to what is done in SuggestBlockAsync, but it might be problematic with changing the code to async

That is good idea. Maybe not for old receipts, but we can use it when we're inserting newPayloads

@MarekM25 MarekM25 merged commit 03c058f into master Aug 9, 2022
@MarekM25 MarekM25 deleted the beacon_reorg branch August 9, 2022 12:19
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.

5 participants