summary
src/ethereum/forks/amsterdam/transactions.py is a merge hotspot for amsterdam EIPs: calculate_intrinsic_cost() and validate_transaction() currently do too many things at once. because 8037 rewrites the structure of intrinsic-gas accounting, and other EIPs also need to touch parts of the same block (e.g. 7981), we end up with merge-conflicts (or many eip-branch specific refactors that are caused by the same thing).
therefore i propose a neutral base-fork refactor in forks/amsterdam's transactions.py that splits the intrinsic-gas pipeline into small helper functions so each EIP can change only the contributor it owns.
in one function we currently mix together:
- calldata token counting
- base transaction cost
- contract creation cost
- access-list cost
- access-list floor-token accounting
- authorization cost
- final floor-gas aggregation
- final intrinsic-gas aggregation
which makes it a structural conflict hotspot. spliting it into neutral helpers (not eip-specific, so it is fine to do in forks/amsterdam) would help a lot.
suggested helper functions
split the current intrinsic-cost logic into helpers such as:
calculate_intrinsic_data_cost(tx)
calculate_intrinsic_create_regular_cost(tx)
calculate_intrinsic_access_list_cost(tx)
calculate_intrinsic_authorization_regular_cost(tx)
calculate_intrinsic_state_cost(tx, gas_limit)
calculate_floor_tokens_in_calldata(tx)
calculate_floor_tokens_in_access_list(tx)
calculate_calldata_floor_cost(tx)
wdyt
summary
src/ethereum/forks/amsterdam/transactions.pyis a merge hotspot for amsterdam EIPs:calculate_intrinsic_cost()andvalidate_transaction()currently do too many things at once. because 8037 rewrites the structure of intrinsic-gas accounting, and other EIPs also need to touch parts of the same block (e.g. 7981), we end up with merge-conflicts (or many eip-branch specific refactors that are caused by the same thing).therefore i propose a neutral base-fork refactor in
forks/amsterdam'stransactions.pythat splits the intrinsic-gas pipeline into small helper functions so each EIP can change only the contributor it owns.in one function we currently mix together:
which makes it a structural conflict hotspot. spliting it into neutral helpers (not eip-specific, so it is fine to do in
forks/amsterdam) would help a lot.suggested helper functions
split the current intrinsic-cost logic into helpers such as:
calculate_intrinsic_data_cost(tx)calculate_intrinsic_create_regular_cost(tx)calculate_intrinsic_access_list_cost(tx)calculate_intrinsic_authorization_regular_cost(tx)calculate_intrinsic_state_cost(tx, gas_limit)calculate_floor_tokens_in_calldata(tx)calculate_floor_tokens_in_access_list(tx)calculate_calldata_floor_cost(tx)wdyt