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: ensure no blob transactions in payloads pre-cancun #4779

Merged
merged 6 commits into from
Sep 26, 2023

Conversation

Rjected
Copy link
Member

@Rjected Rjected commented Sep 26, 2023

This ensures there are no blob transactions pre-cancun, adding a new error variant that maps to INVALID_PARAMS_CODE.

Makes the /cancun/eip4844_blobs/blob_txs/blob_type_tx_pre_fork/001-fork=ShanghaiToCancunAtTime15k-one_blob_tx test pass.

Not really happy on the new return type of ensure_well_formed_payload - am considering adding a separate error type that makes this easier.

Fixes #4670

@Rjected Rjected added C-bug An unexpected or incorrect behavior A-rpc Related to the RPC implementation A-consensus Related to the consensus engine labels Sep 26, 2023
@codecov
Copy link

codecov bot commented Sep 26, 2023

Codecov Report

Merging #4779 (ad8e4cc) into main (5e01a21) will increase coverage by 0.00%.
The diff coverage is 92.59%.

Impacted file tree graph

Files Coverage Δ
crates/consensus/beacon/src/engine/error.rs 33.33% <ø> (ø)
crates/primitives/src/block.rs 78.26% <100.00%> (+0.11%) ⬆️
crates/rpc/rpc-types-compat/src/engine/payload.rs 47.46% <100.00%> (+3.23%) ⬆️
crates/rpc/rpc-engine-api/src/error.rs 63.15% <0.00%> (-3.51%) ⬇️
crates/consensus/beacon/src/engine/mod.rs 73.11% <88.46%> (+0.15%) ⬆️

... and 8 files with indirect coverage changes

Flag Coverage Δ
integration-tests 16.18% <44.44%> (+0.01%) ⬆️
unit-tests 63.30% <70.37%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
reth binary 32.11% <ø> (ø)
blockchain tree 83.69% <ø> (ø)
pipeline 88.45% <ø> (ø)
storage (db) 73.47% <ø> (ø)
trie 94.52% <ø> (ø)
txpool 49.97% <ø> (-0.02%) ⬇️
networking 76.45% <ø> (-0.02%) ⬇️
rpc 57.71% <96.00%> (+0.04%) ⬆️
consensus 62.59% <88.46%> (+0.11%) ⬆️
revm 28.33% <ø> (ø)
payload builder 8.20% <ø> (ø)
primitives 86.39% <100.00%> (+<0.01%) ⬆️

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm

Ok(block) => block,
Err(error) => {
// TODO: need to fix this to use the correct type
Copy link
Collaborator

Choose a reason for hiding this comment

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

correct type of what?

Copy link
Member Author

Choose a reason for hiding this comment

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

Outdated comment

@rkrasiuk rkrasiuk added the E-cancun Related to the Cancun network upgrade label Sep 26, 2023
Copy link
Member

@rkrasiuk rkrasiuk left a comment

Choose a reason for hiding this comment

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

how is this not a noop given version/fork validation performed in EngineApi::validate_payload_timestamp method? disregard this q

Comment on lines 1141 to 1169
// make sure there are no blob transactions in the payload if it is pre-cancun
// we perform this check before validating the block hash because INVALID_PARAMS
// must be returned over an INVALID response.
if !self.chain_spec().is_cancun_activated_at_timestamp(block.timestamp) &&
block.has_blob_transactions()
{
return Err(BeaconOnNewPayloadError::PreCancunBlockWithBlobTransactions)
}

validate_block_hash(block_hash, block)
Copy link
Member

Choose a reason for hiding this comment

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

imo this should be handled on payload validation step inside EngineApi handlers

Copy link
Member Author

Choose a reason for hiding this comment

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

It's possible, but a bit more hacky to do this because the actual transaction decoding happens later, i.e. it happens in try_into_block. Forgot to link #4670, see:

they are still stored as Bytes in the ExecutionPayload

@Rjected Rjected added this pull request to the merge queue Sep 26, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 26, 2023
@Rjected Rjected force-pushed the dan/ensure-no-blob-transactions-pre-cancun branch from 6129476 to 0e48f72 Compare September 26, 2023 18:10
@Rjected Rjected added this pull request to the merge queue Sep 26, 2023
Merged via the queue into main with commit eb6dc51 Sep 26, 2023
23 checks passed
@Rjected Rjected deleted the dan/ensure-no-blob-transactions-pre-cancun branch September 26, 2023 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-consensus Related to the consensus engine A-rpc Related to the RPC implementation C-bug An unexpected or incorrect behavior E-cancun Related to the Cancun network upgrade
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ensure pre-cancun payload does not have blob transactions
3 participants