ethereum / ethereum/execution-specs

Split `transactions.py:calculate_intrinsic_cost()` into many smaller functions to avoid merge-conflicts due to 8037

Open
#2,708 3 comments 0 reactions 0 assignees View on GitHub
stale
Dominant language
Python
Stars
1.2k
Forks
505
Avg merge
2d 14h
Merged PRs (30d)
116

Description

## 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.