-
Notifications
You must be signed in to change notification settings - Fork 451
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
Add pivot updator for optimism #7586
Conversation
Wouldn't it be safer to get Head - N blocks? (Whatever that N would be) |
@LukaszRozmej it would be safer, but then we need to refactor and complicate the logic way more Right now we are getting block hash and we are asking peers for a block by hash. Then we have block number and that's it. If we want to have |
Ok after discussion we need to use |
…ethermindEth/nethermind into feature/optimism_pivot_updator
# Conflicts: # src/Nethermind/Nethermind.Runner/configs/base-mainnet.cfg # src/Nethermind/Nethermind.Runner/configs/base-sepolia.cfg # src/Nethermind/Nethermind.Runner/configs/op-mainnet.cfg # src/Nethermind/Nethermind.Runner/configs/op-sepolia.cfg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the class hierarchy is too complicated duplicating a lot of stuff, details in comments.
This resulted of making a lot of stuff protected
which is not great.
Basically subpar code organization and reuse.
blockCacheService, beaconSyncStrategy, metadataDb, logManager) | ||
{ | ||
|
||
private const int NumberOfBlocksBehindHeadForSettingPivot = 64; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reorganization.MaxDepth
?
Hash256? finalizedBlockHash = _beaconSyncStrategy.GetFinalizedHash(); | ||
|
||
if (finalizedBlockHash is null || finalizedBlockHash == Keccak.Zero) | ||
{ | ||
if (_logger.IsInfo && (_maxAttempts - _attemptsLeft) % 10 == 0) _logger.Info($"Waiting for Forkchoice message from Consensus Layer to set fresh pivot block [{_maxAttempts - _attemptsLeft}s]"); | ||
|
||
PrintWaitingForMessageFromCl(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when you invert this if
then the override looks quite similar in structure and probably can be mostly shared.
return null; | ||
} | ||
|
||
private long? TryGetHeadBlockNumberFromBlockCache(Hash256 headBlockHash) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more or less same as TryGetFinalizedBlockNumberFromBlockCache
return null; | ||
} | ||
|
||
private async Task<long> TryGetHeadBlockNumberFromPeers(Hash256 headBlockHash, CancellationToken cancellationToken) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more or less the same as TryGetFinalizedBlockNumberFromPeers
return null; | ||
} | ||
|
||
private async Task<Hash256?> TryGetPotentialPivotBlockHashFromPeers(long potentialPivotBlockNumber, CancellationToken cancellationToken) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very similar to other peer methods TryGetPotentialPivotBlockHashFromPeers
Changes
UnsafePivotUpdator
which is working similar as generalPivotUpdator
except using head block hash (minus 64 blocks) instead of finalized block hash.In
PivotUpdator
we are using finalized block hash, because it can't be reorganized so is a safe starting point. Optimism is not providing finalized block hash until fully synced, so we need to use unsafe head block hash, which potentially can be reorganized and break the node. For more safety we are using head block minus 64. On Optimism reorganizations aren't common, so it can be a justified risk to significantly improve UX in most casesTypes of changes
What types of changes does your code introduce?
Testing
Requires testing
If yes, did you write tests?