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 rlp encoding of access_lists #1263

Closed
wants to merge 3 commits into from

Conversation

Nashtare
Copy link
Collaborator

@Nashtare Nashtare commented Oct 1, 2023

Also derive Clone to be reused on the test-runner side.

@@ -89,13 +120,13 @@ pub struct AccessListTransactionRlp {
pub to: AddressOption,
pub value: U256,
pub data: Bytes,
pub access_list: Vec<AccessListItemRlp>,
pub access_list: Vec<AccessListInner>,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit confused by this. EIP-2930 says that the format for access_list is [[{20 bytes}, [{32 bytes}...]]...], i.e., Vec<AccessListItemRlp>. But this change seems to indicate that it could also be something like Vec<Vec<AccessListItemRlp>>.
Are there txns with this access list format?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, this doesn't look right: like it stands this would be accepted: vec![AccessListInner::List(vec![AccessListItemRlp{address: …, storage_keys: …}, AccessListItemRlp{address: …, storage_keys: …}])], which seems odd.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree that this isn't the regular encoding, but the EVM test suite has some weird block RLP encodings on some of its tests, which either need to be ignored when parsing or require this specific handling.
The other weird encoding is at the transactions section of the block, I've seen so far three versions:

  • a list of txns
  • a single txn
  • a list of strings (ie doubly encoded)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What I could do then, if just port these changes directly to evm-tests instead. I need some logic there anyway to handle the non-RLP prefix for those transactions, so it wouldn't add too much, and at least here we'd respect the specs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I think that's probably a better idea. These are public structs so I feel like we should have them follow the specs and handle the test suite's oddities in the evm-tests repo.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also they are public only for integration tests I believe, right? If so we may want to place them into a testing module to emphasize they aren't really aimed at being used.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea 👍

Copy link
Contributor

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

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

A unit test or two would be good.


impl Decodable for AccessListInner {
fn decode(rlp: &Rlp) -> Result<Self, DecoderError> {
if rlp.is_list() {
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is in the hot loop it can probably be optimized a bit by checking is_empty() once and then switch based on byte 0 instead, like:

if rlp.is_empty() { return DecoderError:RlpExpectedToBeData }
// Can only be list or data now and byte 0 is != 0xc0
if rlp.as_raw[0] > 0xc0 { 
  // do list stuff 
} else {
  // do data stuff
}

@Nashtare
Copy link
Collaborator Author

Nashtare commented Oct 2, 2023

Porting the changes to evm-tests instead.

@Nashtare Nashtare closed this Oct 2, 2023
@Nashtare Nashtare deleted the fix_rlp branch December 2, 2023 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants