fix(miner): write fork hash into block header extra_data vanity bytes#425
Open
deszhou wants to merge 1 commit into
Open
fix(miner): write fork hash into block header extra_data vanity bytes#425deszhou wants to merge 1 commit into
deszhou wants to merge 1 commit into
Conversation
Pull Request ReviewThis PR updates the BSC miner/header finalization flow to write the current fork hash into the last 4 bytes of the Sensitive ContentNo sensitive content detected. Security IssuesNo serious security issues detected. Generated by Hashdit Bot. This tool can absolutely NOT replace manual audits. |
Author
|
cc @chee-chyuan |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
finalize_new_headerleftextra_datavanity bytes [28..32] as zeros (a TODO from the original port). These bytes carry the current fork hash, whichsnapshot.apply()reads to populatesnapshot.recent_fork_hashes. This fix writesfork_id(number, timestamp).hashinto those bytes, aligning with the ParliaPreparemethod in go-bsc.Rationale
Without this fix,
parlia_getSnapshotalways returns"00000000"forrecentForkHasheson reth-bsc produced blocks, making it impossible to verifywhich fork a validator was on when producing a block.
Example
parlia_getSnapshoton a locally mined block (block 5, local chain):Before
After
Changes
Notable changes:
src/node/miner/util.rs— replace TODO block with fork hash write intoextra_datavanity bytes; add unit testsrc/node/evm/assembler.rs— propagate+ Hardforksbound toBlockAssemblerimpl (EthereumHardforksdoes not extendHardforks)Potential Impacts
recent_fork_hashesis only consumed byparlia_getSnapshotRPC and snapshot window cleanup, not by block validation