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

fix: add excess_blob_gas for first cancun block #4700

Merged
merged 2 commits into from
Sep 21, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion crates/payload/builder/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,24 @@ impl PayloadBuilderAttributes {
// configure evm env based on parent block
let mut cfg = CfgEnv::default();
cfg.chain_id = chain_spec.chain().id();

// ensure we're not missing any timestamp based hardforks
cfg.spec_id = revm_spec_by_timestamp_after_merge(chain_spec, self.timestamp);

// if the parent block did not have excess blob gas (i.e. it was pre-cancun), but it is
// cancun now, we need to set the excess blob gas to the default value
let excess_blob_gas = parent.next_block_blob_fee().map_or_else(
|| {
if chain_spec.is_cancun_activated_at_timestamp(self.timestamp) {
// default excess blob gas is zero
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this can be simplified by checking the spec_id instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

oh right, I didn't think of that

Some(0)
} else {
None
}
},
Some,
);

let block_env = BlockEnv {
number: U256::from(parent.number + 1),
coinbase: self.suggested_fee_recipient,
Expand All @@ -192,7 +207,7 @@ impl PayloadBuilderAttributes {
parent.next_block_base_fee(chain_spec.base_fee_params).unwrap_or_default(),
),
// calculate excess gas based on parent block's blob gas usage
excess_blob_gas: parent.next_block_blob_fee(),
excess_blob_gas,
};

(cfg, block_env)
Expand Down
Loading