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

feat: integrate blobs into the payload builder #4305

Merged
merged 14 commits into from
Aug 29, 2023
Merged

Conversation

Rjected
Copy link
Member

@Rjected Rjected commented Aug 22, 2023

This prompts the payload builder to include EIP-4844 transactions if the fork is active, and fill in the required header fields if necessary.

ref #4205

@Rjected Rjected added A-block-building Related to block building M-eip This change relates to the implementation of an EIP E-cancun Related to the Cancun network upgrade labels Aug 22, 2023
@codecov
Copy link

codecov bot commented Aug 22, 2023

Codecov Report

Attention: Patch coverage is 1.17647% with 84 lines in your changes missing coverage. Please review.

Project coverage is 68.32%. Comparing base (0c7a937) to head (9f4daa4).
Report is 4517 commits behind head on main.

Files with missing lines Patch % Lines
crates/payload/basic/src/lib.rs 0.00% 39 Missing ⚠️
crates/payload/builder/src/payload.rs 0.00% 21 Missing ⚠️
crates/rpc/rpc-engine-api/src/engine_api.rs 7.69% 12 Missing ⚠️
crates/rpc/rpc-types/src/eth/engine/payload.rs 0.00% 12 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

Files with missing lines Coverage Δ
crates/payload/builder/src/error.rs 0.00% <ø> (ø)
crates/transaction-pool/src/lib.rs 40.21% <ø> (ø)
crates/rpc/rpc-engine-api/src/engine_api.rs 81.37% <7.69%> (-1.97%) ⬇️
crates/rpc/rpc-types/src/eth/engine/payload.rs 81.75% <0.00%> (-3.60%) ⬇️
crates/payload/builder/src/payload.rs 0.00% <0.00%> (ø)
crates/payload/basic/src/lib.rs 0.00% <0.00%> (ø)

... and 11 files with indirect coverage changes

Flag Coverage Δ
integration-tests 16.71% <1.17%> (-0.03%) ⬇️
unit-tests 63.57% <0.00%> (-0.05%) ⬇️

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

Components Coverage Δ
reth binary 26.01% <ø> (ø)
blockchain tree 82.56% <ø> (ø)
pipeline 90.07% <ø> (ø)
storage (db) 74.72% <ø> (ø)
trie 94.84% <ø> (-0.04%) ⬇️
txpool 47.97% <ø> (+0.49%) ⬆️
networking 77.49% <ø> (-0.05%) ⬇️
rpc 57.83% <4.00%> (-0.13%) ⬇️
consensus 63.54% <ø> (ø)
revm 31.74% <ø> (ø)
payload builder 6.39% <0.00%> (-0.38%) ⬇️
primitives 86.18% <ø> (-0.02%) ⬇️

@Rjected Rjected force-pushed the dan/payload-builder-v3 branch 2 times, most recently from 6f8acb2 to 98754b7 Compare August 22, 2023 20:57
Comment on lines 687 to 692
if chain_spec.is_cancun_activated_at_timestamp(attributes.timestamp) {
// mark tx and all dependent txs as invalid because we can't process blob txs
// until cancun is active
best_txs.mark_invalid(&pool_tx);
continue
}
Copy link
Member Author

Choose a reason for hiding this comment

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

@mattsse do fork checks in the txpool make this redundant?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, they're only accepted when the timestamp has been reached, this also does not affect reorgs, so we can omit the check here.

Copy link
Member Author

Choose a reason for hiding this comment

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

cool, removed

@Rjected Rjected marked this pull request as ready for review August 22, 2023 21:01
Comment on lines 687 to 692
if chain_spec.is_cancun_activated_at_timestamp(attributes.timestamp) {
// mark tx and all dependent txs as invalid because we can't process blob txs
// until cancun is active
best_txs.mark_invalid(&pool_tx);
continue
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, they're only accepted when the timestamp has been reached, this also does not affect reorgs, so we can omit the check here.

crates/payload/basic/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines +86 to +89
// TODO(rjected): we could improve this by wrapping envelope / payload types by version, so we can
// have explicitly versioned return types for getPayload. Then BuiltPayload could essentially be a
// builder for those types, and it would not be possible to e.g. return cancun fields for a
// pre-cancun endpoint.
Copy link
Collaborator

Choose a reason for hiding this comment

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

yes I like this

Comment on lines 226 to 231
// TODO: either upstream a conversion or upstream QUANTITY serde impls
let (commitments, proofs, blobs) = sidecars.into_iter().fold(
(Vec::new(), Vec::new(), Vec::new()),
|(mut commitments, mut proofs, mut blobs), sidecar| {
commitments
.extend(sidecar.commitments.iter().map(|sidecar| Bytes::from(sidecar.deref())));
proofs.extend(sidecar.proofs.iter().map(|proof| Bytes::from(proof.deref())));
blobs.extend(sidecar.blobs.iter().map(|blob| Bytes::from(blob.deref())));
(commitments, proofs, blobs)
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah this is a bit bad because this effectively clones everything, right?

ideally there's a into_bytes or to_vec impl

Copy link
Member Author

Choose a reason for hiding this comment

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

Ended up using the kzg types now that the serde traits are upstreamed

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.

last two nits

@@ -679,6 +682,20 @@ where
// convert tx to a signed transaction
let tx = pool_tx.to_recovered_transaction();

if let Transaction::Eip4844(blob_tx) = &tx.transaction {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit, we now have as_eip4844

Copy link
Member Author

Choose a reason for hiding this comment

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

right, that makes this cleaner

// only determine cancun fields when active
if chain_spec.is_cancun_activated_at_timestamp(attributes.timestamp) {
// grab the blob sidecars from the executed txs
let blobs = pool.get_all_blobs(executed_txs.iter().map(|tx| tx.hash).collect())?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this also includes non eip4844 transactions?

should filter before (is_eip4844), otherwise we wast blobstore lookups

Copy link
Member Author

Choose a reason for hiding this comment

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

makes sense, added

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, pending conflict

@Rjected Rjected enabled auto-merge August 29, 2023 18:32
@Rjected Rjected added this pull request to the merge queue Aug 29, 2023
Merged via the queue into main with commit 82fb0ee Aug 29, 2023
25 checks passed
@Rjected Rjected deleted the dan/payload-builder-v3 branch August 29, 2023 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-block-building Related to block building E-cancun Related to the Cancun network upgrade M-eip This change relates to the implementation of an EIP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants