Skip to content

Commit cb2ec20

Browse files
committed
Adjust InitcodeTransaction cost of initcodes spec to align with EIP-7623
1 parent b1903a1 commit cb2ec20

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

spec/eof.md

+18-2
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,25 @@ Under transaction validation rules `initcodes` are not validated for conforming
117117
1) It must be fully transmitted in the transaction.
118118
2) It is accessible to the EVM, but it can't be fully loaded into EVM memory.
119119

120-
For these reasons, define cost of each of the `initcodes` items same as calldata (16 gas for non-zero bytes, 4 for zero bytes -- see EIP-2028). The intrinsic gas of an `InitcodeTransaction` is extended by the sum of all those items' costs.
120+
For these reasons, define cost of `initcodes` bytes same as calldata: formula for transaction gas from EIP-7623 is extened to include tokens in initcodes, priced the same as `tokens_in_calldata`:
121+
122+
```python
123+
STANDARD_TOKEN_COST = 4
124+
TOTAL_COST_FLOOR_PER_TOKEN = 10
125+
126+
tokens_in_initcodes = zero_bytes_in_initcdes + nonzero_bytes_in_initcodes * 4
127+
tx.gasUsed = (
128+
21000
129+
+
130+
max(
131+
STANDARD_TOKEN_COST * (tokens_in_calldata + tokens_in_initcodes)
132+
+ execution_gas_used,
133+
TOTAL_COST_FLOOR_PER_TOKEN * tokens_in_calldata
134+
)
135+
)
136+
```
121137

122-
EIP-3860 and EIP-170 still apply, i.e. `MAX_CODE_SIZE` as 24576, `MAX_INITCODE_SIZE` as `2 * MAX_CODE_SIZE`. Define `MAX_INITCODE_COUNT` as 256.
138+
EIP-3860 and EIP-170 limits still apply, i.e. `MAX_CODE_SIZE` as 24576, `MAX_INITCODE_SIZE` as `2 * MAX_CODE_SIZE`. Define `MAX_INITCODE_COUNT` as 256.
123139

124140
`InitcodeTransaction` is invalid if either:
125141
- there are more than `MAX_INITCODE_COUNT` entries in `initcodes`

0 commit comments

Comments
 (0)