Make ExecutionBlock::total_difficulty Optional #7050
+21
−10
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.
Issue Addressed
This change makes the
total_difficulty
field inExecutionBlock
anOption<Uint256>
since newer clients are no longer including thetotalDifficulty
field.I think this will fix #6937 but I was actually more focused on the builder registration case described below.
In our builder-playground we setup a local devnet using lighthouse, reth, and mev-boost-relay. After upgrading to reth 1.2.0 and lighthouse v7.0.0.beta.0 for Pectra, we noticed that the validator registration process was sometimes failing with:
What was even more confusing, was that it was sometimes working, which actually led to a wild goose chase thinking it was a networking issue. However, when tracing through the LH code, I came across this comment:
lighthouse/beacon_node/beacon_chain/src/beacon_chain.rs
Lines 6048 to 6049 in 70194df
This explained why it sometimes worked, in our playground we run lighthouse with
--prepare-payload-lookahead 8000
thus there was always a 4-second window where the call wasn't made.But, if the call was made, then this code would 100% fail with updated reth:
https://github.com/sigp/lighthouse/blob/unstable/beacon_node/execution_layer/src/lib.rs#L1688-L1692
Which would then mapped to a
Error::ForkchoiceUpdate
inupdate_execution_engine_forkchoice
.Proposed Changes
Anyways, the fix was to make
total_difficulty
Optional, and then to update any code paths where it was used. In doing so, I assume that if the EL doesn't include total difficulty then the chain is already post-merge.Additional Info
I left
execution_layer::test_utils::PoWBlock::total_difficulty
non-optional since its used for testing the PoW transition, and total difficulty was an expected field at that time.