Skip to content
This repository was archived by the owner on Oct 19, 2024. It is now read-only.
This repository was archived by the owner on Oct 19, 2024. It is now read-only.

Transaction::access_list set to None is incorrectly RLP encoded #1134

@michaelsproul

Description

@michaelsproul

Version

ethers-core @ 1d14f9d

Platform

Linux xxx 5.13.0-39-generic #44-Ubuntu SMP Thu Mar 24 15:35:05 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Description

I believe None access lists in Transactions are being encoded incorrectly, by encoding them as empty strings rather than empty lists here:

rlp_opt(&mut rlp, &self.access_list);

I think the fix might look something like:

rlp.append(&self.access_list.unwrap_or(&[]));

The relevant part of the RLP spec reads:

If the total payload of a list (i.e. the combined length of all its items being RLP encoded) is 0-55 bytes long, the RLP encoding consists of a single byte with value 0xc0 plus the length of the list followed by the concatenation of the RLP encodings of the items. The range of the first byte is thus [0xc0, 0xf7].

https://eth.wiki/fundamentals/rlp

i.e. an empty access list should be 0xc0 not 0x80.

Example

I found this while attempting to re-serialize transactions in Lighthouse on the Kiln merge testnet.

One prototypical transaction is this one, serialized by ethers-rs and Nethermind:

{
        "hash": "0x70e6d41854fe4f50731184371c32d4a2c8bb83c47579ef200dc64c702136fac0",
        "nonce": "0x91",
        "blockHash": "0x892e8efabaae838a689c711789c6b18883ef6fc4c31ec0651f6a13012680dc6c",
        "blockNumber": "0x33828",
        "transactionIndex": "0x0",
        "from": "0x818306150064f0f091c46d4cccaa288b0976ad37",
        "to": "0xd1003b592859d5c0241d7c1f744d64d9d043cef4",
        "value": "0x0",
        "gasPrice": "0x77359407",
        "maxPriorityFeePerGas": "0x77359400",
        "maxFeePerGas": "0x16d6f91027",
        "gas": "0x3b9f2",
        "data": "0x32db54700000000000000000000000000000000000000000000000000000000000033810000000000000000000000000000000000000000000000007370d998df33659000000000000000000000000000000000000000000000000029b4d68f4ef41590000000000000000000000000000000000000000000000000735e2724866b50000",
        "input": "0x32db54700000000000000000000000000000000000000000000000000000000000033810000000000000000000000000000000000000000000000007370d998df33659000000000000000000000000000000000000000000000000029b4d68f4ef41590000000000000000000000000000000000000000000000000735e2724866b50000",
        "chainId": "0x1469ca",
        "type": "0x2",
        "v": "0x0",
        "s": "0x336ec99f0438391d55d9d4e2a52e06e2c9080db987c073966b481415eb0e6846",
        "r": "0x53df3e98bf698f1ce192c7d7452080d793ec4a4b6bbce7b4edf7718e77d7696d",
        "yParity": "0x0"
}

Ethers:

0x02f8f5831469ca819184773594008516d6f910278303b9f294d1003b592859d5c0241d7c1f744d64d9d043cef480b88432db54700000000000000000000000000000000000000000000000000000000000033810000000000000000000000000000000000000000000000007370d998df33659000000000000000000000000000000000000000000000000029b4d68f4ef41590000000000000000000000000000000000000000000000000735e2724866b500008080a053df3e98bf698f1ce192c7d7452080d793ec4a4b6bbce7b4edf7718e77d7696da0336ec99f0438391d55d9d4e2a52e06e2c9080db987c073966b481415eb0e6846

Nethermind:

0x02f8f5831469ca819184773594008516d6f910278303b9f294d1003b592859d5c0241d7c1f744d64d9d043cef480b88432db54700000000000000000000000000000000000000000000000000000000000033810000000000000000000000000000000000000000000000007370d998df33659000000000000000000000000000000000000000000000000029b4d68f4ef41590000000000000000000000000000000000000000000000000735e2724866b50000c080a053df3e98bf698f1ce192c7d7452080d793ec4a4b6bbce7b4edf7718e77d7696da0336ec99f0438391d55d9d4e2a52e06e2c9080db987c073966b481415eb0e6846

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions