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: implement network encoding for blob transactions #4172

Merged
merged 19 commits into from
Aug 16, 2023

Conversation

Rjected
Copy link
Member

@Rjected Rjected commented Aug 12, 2023

This implements network encoding and decoding methods for the BlobTransaction method. The type is refactored to include a BlobSidecar type.

TODO:

@Rjected Rjected added C-enhancement New feature or request A-networking Related to networking in general M-eip This change relates to the implementation of an EIP E-cancun Related to the Cancun network upgrade labels Aug 12, 2023
@codecov
Copy link

codecov bot commented Aug 12, 2023

Codecov Report

Merging #4172 (e1ad9fb) into main (45db5a6) will decrease coverage by 0.14%.
The diff coverage is 39.39%.

Impacted file tree graph

Files Changed Coverage Δ
crates/net/network/src/message.rs 44.66% <ø> (ø)
crates/primitives/src/lib.rs 100.00% <ø> (ø)
crates/primitives/src/transaction/eip4844.rs 18.26% <19.77%> (+8.59%) ⬆️
crates/net/network/src/transactions.rs 59.83% <28.57%> (-0.20%) ⬇️
crates/primitives/src/transaction/pooled.rs 57.14% <57.14%> (ø)
crates/net/eth-wire/src/types/transactions.rs 99.32% <100.00%> (+2.23%) ⬆️
crates/primitives/src/transaction/eip1559.rs 68.11% <100.00%> (+6.71%) ⬆️
crates/primitives/src/transaction/eip2930.rs 85.50% <100.00%> (+2.74%) ⬆️
crates/primitives/src/transaction/mod.rs 83.43% <100.00%> (-0.08%) ⬇️
crates/primitives/src/transaction/signature.rs 94.79% <100.00%> (ø)

... and 8 files with indirect coverage changes

Flag Coverage Δ
integration-tests 16.94% <34.00%> (+0.11%) ⬆️
unit-tests 63.95% <31.31%> (-0.17%) ⬇️

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

Components Coverage Δ
reth binary 26.13% <ø> (ø)
blockchain tree 82.56% <ø> (ø)
pipeline 90.07% <ø> (ø)
storage (db) 74.73% <ø> (ø)
trie 94.71% <ø> (ø)
txpool 51.62% <ø> (+0.56%) ⬆️
networking 77.49% <37.50%> (-0.07%) ⬇️
rpc 58.64% <ø> (-0.02%) ⬇️
consensus 63.53% <ø> (ø)
revm 32.15% <ø> (ø)
payload builder 6.82% <ø> (ø)
primitives 86.63% <39.44%> (-1.30%) ⬇️

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.

nice, only a few nits

/// - `blobs`
/// - `commitments`
/// - `proofs`
pub fn encode_inner(&self, out: &mut dyn bytes::BufMut) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be pub?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah this needs to be pub because eth-wire needs to use it

Copy link
Member Author

Choose a reason for hiding this comment

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

now is not pub any more because the types are in primitives

crates/primitives/src/transaction/eip4844.rs Show resolved Hide resolved
pub proofs: Vec<Bytes48>,
}

impl BlobTransactionSidecar {
Copy link
Collaborator

Choose a reason for hiding this comment

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

we also want a fn size

@0xprames
Copy link
Contributor

some of the changes here seem like they'd be useful for #4170

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.

this is great,

I want to use what's now called PooledTransactionResponse in txpool directly and suggest we move to primitives and rename

crates/net/eth-wire/src/types/transactions.rs Outdated Show resolved Hide resolved
crates/net/eth-wire/src/types/transactions.rs Outdated Show resolved Hide resolved
Comment on lines +196 to +197
// TODO: remove this! this will be different when we introduce the blobpool
let resp = PooledTransactions(transactions.into_iter().map(Into::into).collect());
Copy link
Collaborator

Choose a reason for hiding this comment

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

how it should work is that the pool should have a function that returns a Vec

so it would be useful to have that in primitives

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.

great, some nits and q re regular typed variant

/// non-4844 signed transaction.
// TODO: redo arbitrary for this encoding - the previous encoding was incorrect
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum PooledTransactionsElement {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like this and the docs

Comment on lines 1330 to 1331
/// A non-4844 signed transaction.
Transaction(TransactionSigned),
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, this now also has eip4844 as a variant, does it support decoding them without the sidecar?

This should be an invalid response, right?

should we flatten the variants?

Copy link
Member Author

Choose a reason for hiding this comment

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

opened this
#4238

/// non-4844 signed transaction.
// TODO: redo arbitrary for this encoding - the previous encoding was incorrect
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum PooledTransactionsElement {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd like to move this to pooled.rs

Copy link
Member Author

Choose a reason for hiding this comment

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

moved

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, we likely need a few followups but this should unblock us now

@Rjected Rjected added this pull request to the merge queue Aug 16, 2023
Merged via the queue into main with commit 40f9576 Aug 16, 2023
25 checks passed
@Rjected Rjected deleted the dan/network-blob-tx branch August 16, 2023 23:23
alessandromazza98 pushed a commit to alessandromazza98/reth that referenced this pull request Aug 19, 2023
)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-networking Related to networking in general C-enhancement New feature or request 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.

3 participants