fix: use canonical transaction encoding for transactions in payloads and root calculations#240
Merged
Merged
Conversation
This was referenced Aug 12, 2024
mpaulucci
reviewed
Aug 12, 2024
| // Value: tx_type || RLP(tx) if tx_type != 0 | ||
| // RLP(tx) else | ||
| trie.insert(idx.encode_to_vec(), tx.encode_to_vec()); | ||
| trie.insert(idx.encode_to_vec(), tx.encode_canonical_to_vec()); |
Collaborator
There was a problem hiding this comment.
the previous change added a regression to the transaction root calculation. Maybe we can add some unit test for this method to avoid this from happening again in the future?
Collaborator
There was a problem hiding this comment.
Are we not validating this in EF tests?
Contributor
Author
There was a problem hiding this comment.
The ef tests provide the blocks with the transaction root already set so it is always valid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
In a previous PR, transaction encoding and decoding for non legacy transactions was changed from
tx_type || rlp(tx_fieldss)torlp(bytes(tx_type || rlp(tx_fields))). While this is the correct encoding used when encoding and decoding a block with transactions, it removed the implementation of the "canonical" encoding that is used when decoding an execution payload and computing transaction roots. This PR aims to fix this issue by implementing the previous canonical encoding separately from the rlp encoding and updating the doc to avoid future confusions and problemsDescription
Implement
encode_canonical&decode_canonicalfor Transaction and use it to decode transactions in execution payloads and encode transactions when computing the transactions root.Update documentation for rlp implementation of transactions to clearly state that it is encoding the transaction into a bytes object.
Other:
Closes None, but is needed for #51 to work
With this fix we can now successfully validate and execute all payloads with kurtosis local network 🚀
kurtosis-clip-cut.mov