ethereum / execution-specs

Specification for the Execution Layer. Tracking network upgrades.
Creative Commons Zero v1.0 Universal
806 stars 222 forks source link

enhancement: factor out a type from access lists #960

Open richardgreg opened 3 weeks ago

richardgreg commented 3 weeks ago

What was wrong?

Because it's repeated in several different transaction types, the Tuple[Address, Tuple[Bytes32, ...]] portion should be promoted to its own type.

Related to Issue # Fixes #947

How was it fixed?

This PR refactors the access list type used in various transaction classes to reduce redundancy and improve maintainability. Specifically, it introduces a new Access class to represent the access_list structure, which is used in multiple transaction types.

  1. Created a new Access class to encapsulate the account and slots structure.

    @slotted_freezable
    @dataclass
    class Access:
    account: Address
    slots: Tuple[Bytes32, ...]
  2. Updated Transaction Classes

  3. RLP Encoding and Decoding Adjustments:

    • Introduced helper functions encode_access_list and decode_access_list to handle the conversion between the new Access type and the previous tuple structure for RLP encoding and decoding.
    • Updated encode_transaction and decode_transaction functions to use these helpers.

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

SamWilsn commented 1 week ago

This looks like pretty much exactly what I had in mind!

richardgreg commented 3 days ago

If this is good, I can do it for Prague if need be