Skip to content

Commit e9045fc

Browse files
authored
chore(tests): Update 7951 Checklist Markers (#2088)
* chore(tests): Update pytest markers for checklist docs * chore(tests): Remove unknown markers * bugfix(tests): Use eip kwarg to allow checklist to find tests * chore(tests): Add eip_checklist_external_coverage.txt * chore(tests): Add checklist marks for excessive gas usage and codecov test coverage * chore(tests): Add max values checklist decorator * chore(tests): Move old eip_checklist marker style to new EIPCheckList decorator * bugfix(tests): Check calling precompile when value gets sent * Final fixes
1 parent a7544eb commit e9045fc

File tree

8 files changed

+125
-28
lines changed

8 files changed

+125
-28
lines changed

docs/writing_tests/checklist_templates/eip_testing_checklist_template.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,6 @@ Opcode is used to attempt to recreate a contract that is currently mid-creation
299299

300300
### Framework Changes
301301

302-
| ID | Description | Status | Tests |
303-
| --- | ----------- | ------ | ----- |
304-
305302
- Add opcode to `src/ethereum_test_vm/opcode.py`
306303
- Add opcode to relevant methods in the fork where the EIP is introduced in `src/ethereum_test_forks/forks/forks.py`
307304

@@ -403,6 +400,8 @@ If the precompile requires a minimum value (fee) to execute, either constant or
403400

404401
If the precompile does not require any minimum value (fee) to execute.
405402

403+
| ID | Description | Status | Tests |
404+
| ------------------------------------------------ | ----------------------------- | ------ | ----- |
406405
| `precompile/test/value_transfer/no_fee` | Sending non-zero value does not cause an exception (unless otherwise specified by the EIP). | | |
407406

408407
#### Out-of-bounds checks
@@ -868,6 +867,8 @@ Verify the transaction is correctly rejected if it contains an invalid signature
868867

869868
Verify values or variables that are persistent through the execution of the transaction (e.g. transient storage, warm/cold accounts).
870869

870+
| ID | Description | Status | Tests |
871+
| --------------------------------------------------------------------- | ----------------------------------------------| ------ | ----- |
871872
| `transaction_type/test/tx_scoped_attributes/persistent/throughout` | Persist throughout the entire transaction. | | |
872873
| `transaction_type/test/tx_scoped_attributes/persistent/reset` | Reset on subsequent transactions in the same block. | | |
873874

tests/benchmark/test_worst_compute.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,6 +1688,7 @@ def test_worst_modexp(
16881688
p256verify_spec.Spec.Y0,
16891689
],
16901690
id="p256verify",
1691+
marks=[pytest.mark.eip_checklist("precompile/test/excessive_gas_usage", eip=[7951])],
16911692
),
16921693
],
16931694
)

tests/berlin/eip2929_gas_cost_increases/test_precompile_warming.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import pytest
99

10+
from ethereum_test_checklists import EIPChecklist
1011
from ethereum_test_forks import (
1112
Fork,
1213
get_transition_fork_predecessor,
@@ -70,6 +71,8 @@ def precompile_addresses_in_predecessor_successor(
7071
"address,precompile_in_successor,precompile_in_predecessor",
7172
precompile_addresses_in_predecessor_successor,
7273
)
74+
@EIPChecklist.Precompile.Test.ForkTransition.Before.Cold(eip=[7951])
75+
@EIPChecklist.Precompile.Test.ForkTransition.After.Warm(eip=[7951])
7376
def test_precompile_warming(
7477
blockchain_test: BlockchainTestFiller,
7578
fork: Fork,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
general/code_coverage/eels = Covered in EELS
2+
general/code_coverage/test_coverage = Run locally
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
general/code_coverage/second_client = Optional
2+
system_contract = EIP does not include a new system contract
3+
opcode = EIP does not introduce a new opcode
4+
removed_precompile = EIP does not remove a precompile
5+
precompile/test/gas_usage/dynamic = EIP uses a constant amount of gas
6+
precompile/test/input_lengths/dynamic = EIP input is a constant length
7+
precompile/test/value_transfer/fee = EIP does not require a minimum value to execute
8+
transaction_type = EIP does not introduce a new transaction type
9+
block_header_field = EIP does not add any new block header fields
10+
gas_cost_changes = EIP does not introduce any gas cost changes
11+
gas_refunds_changes = EIP does not introduce any gas refund changes
12+
blob_count_changes = EIP does not introduce any blob count changes
13+
execution_layer_request = EIP does not introduce an execution layer request
14+
new_transaction_validity_constraint = EIP does not introduce a new transaction validity constraint
15+
modified_transaction_validity_constraint = EIP does not introduce a modified transaction validity constraint
16+
block_body_field = EIP does not add any new block body fields

tests/osaka/eip7951_p256verify_precompiles/test_p256verify.py

Lines changed: 77 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55

66
import pytest
77

8+
from ethereum_test_checklists import EIPChecklist
89
from ethereum_test_tools import (
10+
Address,
911
Alloc,
1012
Environment,
1113
StateTestFiller,
@@ -33,8 +35,9 @@
3335
# Source: https://github.com/C2SP/wycheproof/blob/main/testvectors/ecdsa_secp256r1_sha256_test.json
3436
)
3537
@pytest.mark.parametrize("precompile_address", [Spec.P256VERIFY], ids=[""])
36-
@pytest.mark.eip_checklist("precompile/test/call_contexts/normal")
37-
@pytest.mark.eip_checklist("precompile/test/inputs/valid")
38+
@EIPChecklist.Precompile.Test.CallContexts.Normal()
39+
@EIPChecklist.Precompile.Test.Inputs.Valid()
40+
@EIPChecklist.Precompile.Test.Inputs.MaxValues()
3841
def test_valid(state_test: StateTestFiller, pre: Alloc, post: dict, tx: Transaction):
3942
"""Test P256Verify precompile."""
4043
state_test(env=Environment(), pre=pre, post=post, tx=tx)
@@ -189,14 +192,16 @@ def test_valid(state_test: StateTestFiller, pre: Alloc, post: dict, tx: Transact
189192
)
190193
@pytest.mark.parametrize("expected_output", [Spec.INVALID_RETURN_VALUE], ids=[""])
191194
@pytest.mark.parametrize("precompile_address", [Spec.P256VERIFY], ids=[""])
192-
@pytest.mark.eip_checklist("precompile/test/inputs/all_zeros")
193-
@pytest.mark.eip_checklist("precompile/test/inputs/invalid")
194-
@pytest.mark.eip_checklist("precompile/test/inputs/invalid/crypto")
195-
@pytest.mark.eip_checklist("precompile/test/inputs/invalid/corrupted")
196-
@pytest.mark.eip_checklist("precompile/test/input_lengths/zero")
197-
@pytest.mark.eip_checklist("precompile/test/input_lengths/static/correct")
198-
@pytest.mark.eip_checklist("precompile/test/input_lengths/static/too_short")
199-
@pytest.mark.eip_checklist("precompile/test/input_lengths/static/too_long")
195+
@EIPChecklist.Precompile.Test.Inputs.AllZeros()
196+
@EIPChecklist.Precompile.Test.Inputs.Invalid()
197+
@EIPChecklist.Precompile.Test.Inputs.Invalid.Crypto()
198+
@EIPChecklist.Precompile.Test.Inputs.Invalid.Corrupted()
199+
@EIPChecklist.Precompile.Test.InputLengths.Zero()
200+
@EIPChecklist.Precompile.Test.InputLengths.Static.Correct()
201+
@EIPChecklist.Precompile.Test.InputLengths.Static.TooShort()
202+
@EIPChecklist.Precompile.Test.InputLengths.Static.TooLong()
203+
@EIPChecklist.Precompile.Test.OutOfBounds.Max()
204+
@EIPChecklist.Precompile.Test.OutOfBounds.MaxPlusOne()
200205
def test_invalid(state_test: StateTestFiller, pre: Alloc, post: dict, tx: Transaction):
201206
"""Negative tests for the P256VERIFY precompile."""
202207
state_test(env=Environment(), pre=pre, post=post, tx=tx)
@@ -236,8 +241,8 @@ def test_invalid(state_test: StateTestFiller, pre: Alloc, post: dict, tx: Transa
236241
],
237242
)
238243
@pytest.mark.parametrize("precompile_address", [Spec.P256VERIFY], ids=[""])
239-
@pytest.mark.eip_checklist("precompile/test/gas_usage/constant/exact")
240-
@pytest.mark.eip_checklist("precompile/test/gas_usage/constant/oog")
244+
@EIPChecklist.Precompile.Test.GasUsage.Constant.Exact()
245+
@EIPChecklist.Precompile.Test.GasUsage.Constant.Oog()
241246
def test_gas(state_test: StateTestFiller, pre: Alloc, post: dict, tx: Transaction):
242247
"""Test P256Verify precompile gas requirements."""
243248
state_test(env=Environment(), pre=pre, post=post, tx=tx)
@@ -262,9 +267,9 @@ def test_gas(state_test: StateTestFiller, pre: Alloc, post: dict, tx: Transactio
262267
],
263268
)
264269
@pytest.mark.parametrize("precompile_address", [Spec.P256VERIFY], ids=[""])
265-
@pytest.mark.eip_checklist("precompile/test/call_contexts/delegate")
266-
@pytest.mark.eip_checklist("precompile/test/call_contexts/static")
267-
@pytest.mark.eip_checklist("precompile/test/call_contexts/callcode")
270+
@EIPChecklist.Precompile.Test.CallContexts.Delegate()
271+
@EIPChecklist.Precompile.Test.CallContexts.Static()
272+
@EIPChecklist.Precompile.Test.CallContexts.Callcode()
268273
def test_call_types(
269274
state_test: StateTestFiller,
270275
pre: Alloc,
@@ -286,7 +291,7 @@ def test_call_types(
286291
),
287292
],
288293
)
289-
@pytest.mark.eip_checklist("precompile/test/call_contexts/tx_entry")
294+
@EIPChecklist.Precompile.Test.CallContexts.TxEntry()
290295
def test_precompile_as_tx_entry_point(
291296
state_test: StateTestFiller,
292297
pre: Alloc,
@@ -297,6 +302,58 @@ def test_precompile_as_tx_entry_point(
297302
state_test(env=Environment(), pre=pre, post=post, tx=tx)
298303

299304

305+
@pytest.mark.parametrize(
306+
"input_data,precompile_address,expected_output",
307+
[
308+
pytest.param(
309+
Spec.H0 + Spec.R0 + Spec.S0 + Spec.X0 + Spec.Y0,
310+
Spec.P256VERIFY,
311+
Spec.SUCCESS_RETURN_VALUE,
312+
id="valid_input_with_value_transfer",
313+
),
314+
],
315+
)
316+
@EIPChecklist.Precompile.Test.ValueTransfer.NoFee()
317+
def test_precompile_will_return_success_with_tx_value(
318+
state_test: StateTestFiller,
319+
pre: Alloc,
320+
input_data: bytes,
321+
expected_output: bytes,
322+
precompile_address: Address,
323+
):
324+
"""Test P256Verify precompile will not fail if value is sent."""
325+
sender = pre.fund_eoa()
326+
storage = Storage()
327+
328+
call_256verify_bytecode = (
329+
Op.CALLDATACOPY(0, 0, Op.CALLDATASIZE())
330+
+ Op.CALL(
331+
gas=Spec.P256VERIFY_GAS,
332+
address=Spec.P256VERIFY,
333+
value=Op.CALLVALUE(),
334+
args_offset=0,
335+
args_size=Op.CALLDATASIZE(),
336+
ret_offset=0,
337+
ret_size=32,
338+
)
339+
+ Op.SSTORE(storage.store_next(True), Op.DUP1())
340+
+ Op.SSTORE(storage.store_next(expected_output), Op.MLOAD(0))
341+
+ Op.SSTORE(storage.store_next(len(expected_output)), Op.RETURNDATASIZE())
342+
+ Op.STOP
343+
)
344+
345+
contract_address = pre.deploy_contract(call_256verify_bytecode)
346+
tx = Transaction(
347+
sender=sender,
348+
gas_limit=1000000,
349+
to=contract_address,
350+
value=1000,
351+
data=input_data,
352+
)
353+
post = {contract_address: {"storage": storage}}
354+
state_test(env=Environment(), pre=pre, post=post, tx=tx)
355+
356+
300357
@pytest.mark.parametrize(
301358
"input_data,expected_output",
302359
[
@@ -334,8 +391,8 @@ def test_precompile_as_tx_entry_point(
334391
],
335392
)
336393
@pytest.mark.parametrize("precompile_address", [Spec.P256VERIFY], ids=[""])
337-
@pytest.mark.eip_checklist("precompile/test/inputs/valid")
338-
@pytest.mark.eip_checklist("precompile/test/inputs/invalid/crypto")
394+
@EIPChecklist.Precompile.Test.Inputs.Valid()
395+
@EIPChecklist.Precompile.Test.Inputs.Invalid.Crypto()
339396
def test_modular_comparison(state_test: StateTestFiller, pre: Alloc, post: dict, tx: Transaction):
340397
"""
341398
Test the modular comparison condition for secp256r1 precompile.
@@ -363,10 +420,10 @@ def test_modular_comparison(state_test: StateTestFiller, pre: Alloc, post: dict,
363420
],
364421
)
365422
@pytest.mark.parametrize("precompile_address", [Spec.P256VERIFY], ids=[""])
423+
@EIPChecklist.Precompile.Test.CallContexts.Initcode.Tx()
366424
def test_contract_creation_transaction(
367425
state_test: StateTestFiller,
368426
pre: Alloc,
369-
post: dict,
370427
tx: Transaction,
371428
input_data: bytes,
372429
expected_output: bytes,
@@ -426,10 +483,10 @@ def test_contract_creation_transaction(
426483
)
427484
@pytest.mark.parametrize("precompile_address", [Spec.P256VERIFY], ids=[""])
428485
@pytest.mark.parametrize("opcode", [Op.CREATE, Op.CREATE2])
486+
@EIPChecklist.Precompile.Test.CallContexts.Initcode.CREATE()
429487
def test_contract_initcode(
430488
state_test: StateTestFiller,
431489
pre: Alloc,
432-
post: dict,
433490
tx: Transaction,
434491
input_data: bytes,
435492
expected_output: bytes,

tests/osaka/eip7951_p256verify_precompiles/test_p256verify_before_fork.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import pytest
88

9+
from ethereum_test_checklists import EIPChecklist
910
from ethereum_test_tools import Alloc, Block, BlockchainTestFiller, Transaction
1011

1112
from .spec import Spec, ref_spec_7951
@@ -17,19 +18,34 @@
1718

1819

1920
@pytest.mark.parametrize(
20-
"precompile_address,input_data",
21+
"precompile_address,input_data,precompile_gas_modifier",
2122
[
2223
pytest.param(
2324
Spec.P256VERIFY,
2425
Spec.H0 + Spec.R0 + Spec.S0 + Spec.X0 + Spec.Y0,
25-
id="P256VERIFY",
26+
0,
27+
id="P256VERIFY_valid_input_6900_gas",
28+
),
29+
pytest.param(
30+
Spec.P256VERIFY,
31+
Spec.H0 + Spec.R0 + Spec.S0 + Spec.X0 + Spec.X0,
32+
0,
33+
id="P256VERIFY_invalid_input",
34+
),
35+
pytest.param(
36+
Spec.P256VERIFY,
37+
Spec.H0 + Spec.R0 + Spec.S0 + Spec.X0 + Spec.Y0,
38+
-6900,
39+
id="P256VERIFY_valid_input_zero_gas",
2640
),
2741
],
2842
)
2943
@pytest.mark.parametrize(
30-
"expected_output,call_succeeds", [pytest.param(b"", True, id=pytest.HIDDEN_PARAM)]
44+
"expected_output,call_succeeds",
45+
[pytest.param(Spec.INVALID_RETURN_VALUE, True, id=pytest.HIDDEN_PARAM)],
3146
)
32-
@pytest.mark.eip_checklist("precompile/test/fork_transition/before/invalid_input")
47+
@EIPChecklist.Precompile.Test.ForkTransition.Before.InvalidInput()
48+
@EIPChecklist.Precompile.Test.ForkTransition.Before.ZeroGas()
3349
def test_precompile_before_fork(
3450
blockchain_test: BlockchainTestFiller,
3551
pre: Alloc,

tests/prague/eip7702_set_code_tx/test_set_code_txs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import pytest
1212

1313
from ethereum_test_base_types import HexNumber
14+
from ethereum_test_checklists import EIPChecklist
1415
from ethereum_test_forks import Fork
1516
from ethereum_test_tools import (
1617
AccessList,
@@ -2588,7 +2589,7 @@ def test_set_code_to_log(
25882589

25892590
@pytest.mark.with_all_call_opcodes
25902591
@pytest.mark.with_all_precompiles
2591-
@pytest.mark.eip_checklist("precompile/test/call_contexts/set_code", eips=[7951, 7883])
2592+
@EIPChecklist.Precompile.Test.CallContexts.SetCode(eip=[7951, 7883])
25922593
def test_set_code_to_precompile(
25932594
state_test: StateTestFiller,
25942595
pre: Alloc,

0 commit comments

Comments
 (0)