Skip to content

Commit 7167eba

Browse files
committed
feat(test): calculate gas and header verify for create collision test
1 parent 78977c2 commit 7167eba

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

tests/ported_static/stCreateTest/test_transaction_collision_to_empty_but_nonce.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
Address,
1313
Alloc,
1414
Environment,
15+
Header,
1516
StateTestFiller,
1617
Transaction,
1718
)
@@ -104,4 +105,28 @@ def test_transaction_collision_to_empty_but_nonce(
104105
contract_0: Account(storage={1: 0}, nonce=1),
105106
}
106107

107-
state_test(env=env, pre=pre, post=post, tx=tx)
108+
# On collision, all execution gas is reclassified to regular and the
109+
# tx-time state reservoir is restored. Under EIP-8037 2D gas this
110+
# gives header.gas_used = max(intrinsic_regular + execution_gas,
111+
# intrinsic_state); pre-EIP-8037 the state component is zero, so the
112+
# same expression collapses to tx.gas.
113+
intrinsic_total = fork.transaction_intrinsic_cost_calculator()(
114+
calldata=bytes(tx_data[d]),
115+
contract_creation=True,
116+
)
117+
intrinsic_state = fork.create_state_gas()
118+
intrinsic_regular = intrinsic_total - intrinsic_state
119+
execution_gas = tx_gas[g] - intrinsic_total
120+
expected_header_gas_used = max(
121+
intrinsic_regular + execution_gas, intrinsic_state
122+
)
123+
124+
state_test(
125+
env=env,
126+
pre=pre,
127+
post=post,
128+
tx=tx,
129+
blockchain_test_header_verify=Header(
130+
gas_used=expected_header_gas_used,
131+
),
132+
)

0 commit comments

Comments
 (0)