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: correct implementations of Encodable and Decodable for sidecars #1528

Merged
merged 2 commits into from
Oct 21, 2024

Conversation

prestwich
Copy link
Member

Closes #1499

Motivation

current Encodable and Decodable implementations do not RLP encode or RLP decode the sidecar. Instead they encode only the fields, without the header, producing incorrect RLP output

Solution

Current behavior has been moved into more-explicitly named functions and is used to construct correct RLP implementations

This is a breaking change as things that previously (incorrectly) deserialized now will not

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Copy link
Member

@onbjerg onbjerg left a comment

Choose a reason for hiding this comment

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

smol nit,

do we not use this in reth right now? @Rjected or @mattsse

if so, any reason for the encoding being the way it is? i assume we use this for network

crates/consensus/src/transaction/eip4844.rs Outdated Show resolved Hide resolved
@onbjerg onbjerg added the bug Something isn't working label Oct 19, 2024
@prestwich
Copy link
Member Author

prestwich commented Oct 19, 2024

nit fixed 🫡

if so, any reason for the encoding being the way it is? i assume we use this for network

It appears to have been a hack to deal with the eip4844 2718 encoding when the sidecar is present. See #1496 for more cleanup around these APIs (this bug was found while working on that). The sketch is that 4844 specifies that the 2718 payload is rlp([tx_payload_body, blobs, commitments, proofs]) in the network. Each field is encoded in that list. This PR makes that behavior an explicit, separate, non-trait function

More interestingly, do we have any use case in which a sidecar itself should be RLP encoded at all? We have to RLP encode it's fields, but when is a standalone sidecar rlp encoded or included as a sublist in another list? We could just delete these impls if there's not a use case

@onbjerg
Copy link
Member

onbjerg commented Oct 19, 2024

More interestingly, do we have any use case in which a sidecar itself should be RLP encoded at all?

not that I can recall, overall this PR looks good to me, but I'm wary of merging it mostly because I don't have a full overview of 4844 in reth, so I'd like to get either @mattsse or @Rjected to take a look since they worked on this and might know if there is such a usecase

@prestwich
Copy link
Member Author

not that I can recall, overall this PR looks good to me, but I'm wary of merging it mostly because I don't have a full overview of 4844 in reth, so I'd like to get either @mattsse or @Rjected to take a look since they worked on this and might know if there is such a usecase

In the interest of fixing the logic bug, can we merge this as is, without deleting the impls? Reth's tests will easily flag reliance on the current faulty coding logic, and it's trivial to fix when reth bumps to a new alloy version

Copy link
Contributor

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

Yeah, we should definitely make the no-header functions not Encodable / Decodable fns. Sidecars are basically never rlp encoded on their own. We can easily switch over the decoding fn to call, and we have blob tx encoding tests that would catch the behavior change

@mattsse
Copy link
Member

mattsse commented Oct 21, 2024

yeah @Rjected the trait impls in the sidecar we should remove

@mattsse mattsse merged commit 2d15e90 into main Oct 21, 2024
26 checks passed
@mattsse mattsse deleted the prestwich/fix-4844-rlp branch October 21, 2024 09:29
@prestwich prestwich mentioned this pull request Oct 23, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] RLP is incorrectly implemented for Sidecars
4 participants