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

Implement eth/68 (EIP-5793) #4730

Merged

Conversation

Gabriel-Trintinalia
Copy link
Contributor

@Gabriel-Trintinalia Gabriel-Trintinalia commented Nov 24, 2022

PR description

Implement eth/68

The NewPooledTransactionHashes message announces transaction hashes, allowing the peer to selectively fetch transactions it does not yet have.

EIP-4844 introduces a new transaction type for blob transactions. Since these blob transactions are large, naively broadcasting them to sqrt(peers) could significantly increase bandwidth requirements. Adding the transaction type and the size to the announcement message will allow nodes to select which transactions they want to fetch and also allow them to load balance or throttle peers based on past behavior.

The added metadata fields will also enable future - upgradeless - protocol tweaks to prevent certain transaction type (e.g. blob transactions) or certain transaction sizes (e.g. 128KB+) from being blindly broadcast to many peers. Enforcing announcements only and retrieval on demand would ensure a much more predictable networking behavior, limiting the amplification effect of transaction propagation DoS attack.

Modify the NewPooledTransactionHashes (0x08) message:

(eth/67): [hash_0: B_32, hash_1: B_32, ...]
(eth/68): [[type_0: B_1, type_1: B_1, ...], [size_0: B_4, size_1: B_4, ...], [hash_0: B_32, hash_1: B_32, ...]]

Fixed Issue(s)

fixes #4715

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if
    updates are required.

Changelog

Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
…nsactionHashesMessage

Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
…actionHashesMessage

Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
…ncoding

Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
…ctionAnnouncement

Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
…ooledTransactionHashesMessage accept capability instead of boolean

Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
@gezero gezero mentioned this pull request Nov 29, 2022
22 tasks
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
@Gabriel-Trintinalia Gabriel-Trintinalia marked this pull request as ready for review November 29, 2022 21:50
Copy link
Contributor

@fab-10 fab-10 left a comment

Choose a reason for hiding this comment

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

overall the implementation is good, please read the inline comments for questions, optimizations and suggestions to improve the handling of malformed messages.

Then there is another part of this implementation that should cover our new strategy on how we broadcast transactions taking in account the new type and size parameters, it is fine to do it in another PR to keep them small, have you already planned to do it?

Comment on lines 43 to 44
this.type = Optional.ofNullable(type);
this.size = Optional.ofNullable(size);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why allowing nulls here?
type and size should never be null at this point, otherwise it means there message was malformed, and its processing should have stopped before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hum, if the transaction is announced by a protocol version older than Eth/68, only the hash is announced

Copy link
Contributor

Choose a reason for hiding this comment

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

if the transaction is announced by a protocol < Eth/68 then the constructor public TransactionAnnouncement(final Hash hash) is used if I am not wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I understood your point now. I changed the constructors to not accept null and throw instead. Also added a unit test for that. Thanks again!

Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
@Gabriel-Trintinalia
Copy link
Contributor Author

@fab-10 Thanks for the review.

Then there is another part of this implementation that should cover our new strategy on how we broadcast transactions taking in account the new type and size parameters, it is fine to do it in another PR to keep them small, have you already planned to do it?

Yeah, that makes sense. This PR only implements the protocol specs, implementing the ability to send and receive NewPooledTransactionHashes with their sizes and types when using eth68 ensuring that we are compatible with older protocol versions.

What the client should do with the type and size and how it impacts broadcast transaction strategy are not part of the scope. I believe it would be better to handle it in a separate PR.

Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Copy link
Contributor

@fab-10 fab-10 left a comment

Choose a reason for hiding this comment

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

LGTM, just a comment on the nullable arguments

Comment on lines 43 to 44
this.type = Optional.ofNullable(type);
this.size = Optional.ofNullable(size);
Copy link
Contributor

Choose a reason for hiding this comment

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

if the transaction is announced by a protocol < Eth/68 then the constructor public TransactionAnnouncement(final Hash hash) is used if I am not wrong

Copy link
Contributor

@macfarla macfarla left a comment

Choose a reason for hiding this comment

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

LGTM just need to move the changelog entry

CHANGELOG.md Outdated Show resolved Hide resolved
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
Signed-off-by: Gabriel Trintinalia <gabriel.trintinalia@gmail.com>
@Gabriel-Trintinalia Gabriel-Trintinalia merged commit c9fba12 into hyperledger:main Dec 6, 2022
Gabriel-Trintinalia added a commit to Gabriel-Trintinalia/besu that referenced this pull request Dec 8, 2022
Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
@Gabriel-Trintinalia Gabriel-Trintinalia deleted the 4715-implement-eth68 branch December 12, 2022 02:23
ahamlat pushed a commit to ahamlat/besu that referenced this pull request Dec 18, 2022
Signed-off-by: Ameziane H <ameziane.hamlat@consensys.net>
macfarla pushed a commit to jflo/besu that referenced this pull request Jan 10, 2023
Signed-off-by: Sally MacFarlane <macfarla.github@gmail.com>
eum602 pushed a commit to lacchain/besu that referenced this pull request Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement eth/68 (EIP-5793) - Add tx type and size to tx announcement
3 participants