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

Use justified blocks execution payload hash as safeBlockHash in engine fcU #4080

Merged
merged 4 commits into from
Jun 3, 2022

Conversation

g11tech
Copy link
Contributor

@g11tech g11tech commented May 28, 2022

The specs (v1.2.0 rc) have been updated on what to pass as safeBlockHash in engine fcU call (https://github.com/ethereum/consensus-specs/pull/2876/files, https://github.com/ethereum/consensus-specs/pull/2851/files, https://github.com/ethereum/consensus-specs/pull/2858/files)
Motivation
This PR implements the same in lodestar and does some comment cleanup.

@g11tech g11tech requested a review from a team as a code owner May 28, 2022 09:58
@@ -284,8 +285,9 @@ async function maybeIssueNextProposerEngineFcU(
const proposerIndex = prepareState.epochCtx.getBeaconProposer(prepareSlot);
const feeRecipient = chain.beaconProposerCache.get(proposerIndex);
if (feeRecipient) {
const safeBlockHash = chain.forkChoice.getJustifiedBlock().executionPayloadBlockHash ?? ZERO_HASH_HEX;
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer to have a separate method like this in forkchoice

def get_safe_execution_payload_hash(store: Store) -> Hash32:
    safe_block_root = get_safe_beacon_block_root(store)
    safe_block = store.blocks[safe_block_root]

    # Return Hash32() if no payload is yet justified
    if compute_epoch_at_slot(safe_block.slot) >= BELLATRIX_FORK_EPOCH:
        return safe_block.body.execution_payload.block_hash
    else:
        return Hash32()

and use it everywhere to make it clear

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ummm justified iproto block in forkchoice will only have executionPayloadBlockHash if its post merge i.e. >= BELLATRIX_FORK_EPOCH.
It is similar to the way we extract finalizedBlockHash, I could add comments for better clarity if you think that would help understanding whats going on? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

if you think safeBlockHash() will not changed in the future then we're good 👍

Copy link
Contributor Author

@g11tech g11tech Jun 3, 2022

Choose a reason for hiding this comment

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

yes its more or less fixed, its the EL counterpart of the justified block, which they can use to tag, prune, throw reorg errors etc may be, earlier it headBlockHash was used as a stub for it, which the ELs were totally ignoring

@wemeetagain wemeetagain merged commit b5e24f7 into unstable Jun 3, 2022
@wemeetagain wemeetagain deleted the g11tech/safe-block-hash branch June 3, 2022 15:07
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