Skip to content

Commit 713d1ee

Browse files
authored
Merge pull request #2667 from jsign/jsign-support-blockchain-test-engine
feat(zkevm): add execution witness support to other fixture formats
2 parents e2ff4cc + 3ffbe59 commit 713d1ee

7 files changed

Lines changed: 59 additions & 3 deletions

File tree

docs/running_tests/test_formats/blockchain_test_engine.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ They can mismatch the hashes of the versioned blobs in the execution payload, fo
104104

105105
Hash of the parent beacon block root.
106106

107+
#### - `executionWitness`: Optional execution witness object
108+
109+
Optional fixture metadata for stateless validation. When present, contains
110+
`state`, `codes`, and `headers` byte lists associated with this payload.
111+
107112
#### - `validationError`: [`TransactionException`](../../library/execution_testing_exceptions.md#execution_testing.exceptions.TransactionException)` | `[`BlockException`](../../library/execution_testing_exceptions.md#execution_testing.exceptions.BlockException)
108113

109114
Validation error expected when executing the payload.

docs/running_tests/test_formats/blockchain_test_engine_x.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ Optional; present from Cancun on. Maps forks to their blob schedule configuratio
134134

135135
### `FixtureEngineNewPayload`
136136

137-
Engine API payload structure identical to the one defined in [Blockchain Engine Tests](./blockchain_test_engine.md#fixtureenginenewpayload). Includes execution payload, versioned hashes, parent beacon block root, validation errors, version, and error codes.
137+
Engine API payload structure identical to the one defined in [Blockchain Engine
138+
Tests](./blockchain_test_engine.md#fixtureenginenewpayload). Includes
139+
execution payload, optional execution witness metadata, versioned hashes,
140+
parent beacon block root, validation errors, version, and error codes.
138141

139142
## Usage Notes
140143

docs/running_tests/test_formats/blockchain_test_sync.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ List of hashes of the versioned blobs that are part of the execution payload.
127127

128128
Hash of the parent beacon block root.
129129

130+
#### - `executionWitness`: Optional execution witness object
131+
132+
Optional fixture metadata for stateless validation. When present, contains
133+
`state`, `codes`, and `headers` byte lists associated with this payload.
134+
130135
#### - `validationError`: [`Optional`](./common_types.md#optional)`[`[`TransactionException`](../../library/execution_testing_exceptions.md#execution_testing.exceptions.TransactionException)` | `[`BlockException`](../../library/execution_testing_exceptions.md#execution_testing.exceptions.BlockException)`]`
131136

132137
For sync tests, this field should not be present as sync tests only work with valid chains. Invalid blocks cannot be synced.

packages/testing/src/execution_testing/cli/pytest_commands/plugins/filler/tests/test_filler.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,8 @@ def test_execution_witness_in_blockchain_fixture(
993993
) -> None:
994994
"""
995995
Fill a minimal Amsterdam state_test that calls a pre-deployed contract,
996-
then verify the resulting blockchain fixture contains execution witness
997-
and stateless validation fields.
996+
then verify the resulting blockchain and engine fixtures contain
997+
execution witness data.
998998
"""
999999
tests_dir = testdir.mkdir("tests")
10001000
amsterdam_tests_dir = tests_dir.mkdir("amsterdam")
@@ -1055,6 +1055,34 @@ def test_execution_witness_in_blockchain_fixture(
10551055
)
10561056
assert stateless_output.successful_validation is True
10571057

1058+
engine_fixture_path = Path(
1059+
"fixtures/blockchain_tests_engine/for_amsterdam/amsterdam/"
1060+
"module_execution_witness/execution_witness.json"
1061+
)
1062+
assert engine_fixture_path.exists(), (
1063+
f"{engine_fixture_path} does not exist"
1064+
)
1065+
1066+
with open(engine_fixture_path, "r") as f:
1067+
engine_fixture_data = json.load(f)
1068+
1069+
assert len(engine_fixture_data) == 1, "Expected exactly one engine fixture"
1070+
engine_fixture = next(iter(engine_fixture_data.values()))
1071+
engine_payload = engine_fixture["engineNewPayloads"][0]
1072+
1073+
assert "executionWitness" in engine_payload
1074+
engine_witness = engine_payload["executionWitness"]
1075+
assert len(engine_witness["state"]) > 0, (
1076+
"engine executionWitness.state is empty"
1077+
)
1078+
assert len(engine_witness["codes"]) > 0, (
1079+
"engine executionWitness.codes is empty"
1080+
)
1081+
assert len(engine_witness["headers"]) > 0, (
1082+
"engine executionWitness.headers is empty"
1083+
)
1084+
assert engine_witness == witness
1085+
10581086

10591087
def test_execution_witness_expected_true_reuses_canonical_stateless_result(
10601088
testdir: pytest.Testdir,

packages/testing/src/execution_testing/fixtures/blockchain.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ class FixtureEngineNewPayload(CamelModel):
457457
params: EngineNewPayloadParameters
458458
new_payload_version: Number
459459
forkchoice_updated_version: Number
460+
execution_witness: ExecutionWitness | None = None
460461
validation_error: ExceptionInstanceOrList | None = None
461462
error_code: (
462463
Annotated[
@@ -482,6 +483,7 @@ def from_fixture_header(
482483
withdrawals: List[Withdrawal] | None,
483484
requests: List[Bytes] | None,
484485
block_access_list: Bytes | None = None,
486+
execution_witness: ExecutionWitness | None = None,
485487
**kwargs: Any,
486488
) -> Self:
487489
"""Create `FixtureEngineNewPayload` from a `FixtureHeader`."""
@@ -534,6 +536,7 @@ def from_fixture_header(
534536
params=payload_params,
535537
new_payload_version=new_payload_version,
536538
forkchoice_updated_version=forkchoice_updated_version,
539+
execution_witness=execution_witness,
537540
**kwargs,
538541
)
539542

packages/testing/src/execution_testing/fixtures/tests/test_blockchain.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
AuthorizationTuple,
3030
ConsolidationRequest,
3131
DepositRequest,
32+
ExecutionWitness,
3233
Requests,
3334
Transaction,
3435
Withdrawal,
@@ -737,6 +738,11 @@
737738
target_pubkey=BLSPublicKey(2),
738739
),
739740
).requests_list,
741+
execution_witness=ExecutionWitness(
742+
state=[Bytes(b"state")],
743+
codes=[Bytes(b"code")],
744+
headers=[Bytes(b"header")],
745+
),
740746
validation_error=[
741747
BlockException.INCORRECT_BLOCK_FORMAT,
742748
TransactionException.INTRINSIC_GAS_TOO_LOW,
@@ -821,6 +827,11 @@
821827
).requests_list
822828
],
823829
],
830+
"executionWitness": {
831+
"state": [Bytes(b"state").hex()],
832+
"codes": [Bytes(b"code").hex()],
833+
"headers": [Bytes(b"header").hex()],
834+
},
824835
"forkchoiceUpdatedVersion": "3",
825836
"newPayloadVersion": "4",
826837
"validationError": "BlockException.INCORRECT_BLOCK_FORMAT"

packages/testing/src/execution_testing/specs/blockchain.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@ def get_fixture_engine_new_payload(self) -> FixtureEngineNewPayload:
658658
block_access_list=self.block_access_list.rlp
659659
if self.block_access_list
660660
else None,
661+
execution_witness=self.execution_witness,
661662
validation_error=self.expected_exception,
662663
error_code=self.engine_api_error_code,
663664
)

0 commit comments

Comments
 (0)