Skip to content

Commit 1c47403

Browse files
committed
Merge branch 'projects/zkevm' into projects/zkevm-bal-devnet-3
2 parents d2845e8 + fe7e68f commit 1c47403

18 files changed

Lines changed: 507 additions & 42 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
@@ -463,6 +463,7 @@ class FixtureEngineNewPayload(CamelModel):
463463
params: EngineNewPayloadParameters
464464
new_payload_version: Number
465465
forkchoice_updated_version: Number
466+
execution_witness: ExecutionWitness | None = None
466467
validation_error: ExceptionInstanceOrList | None = None
467468
error_code: (
468469
Annotated[
@@ -488,6 +489,7 @@ def from_fixture_header(
488489
withdrawals: List[Withdrawal] | None,
489490
requests: List[Bytes] | None,
490491
block_access_list: Bytes | None = None,
492+
execution_witness: ExecutionWitness | None = None,
491493
**kwargs: Any,
492494
) -> Self:
493495
"""Create `FixtureEngineNewPayload` from a `FixtureHeader`."""
@@ -540,6 +542,7 @@ def from_fixture_header(
540542
params=payload_params,
541543
new_payload_version=new_payload_version,
542544
forkchoice_updated_version=forkchoice_updated_version,
545+
execution_witness=execution_witness,
543546
**kwargs,
544547
)
545548

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
@@ -664,6 +664,7 @@ def get_fixture_engine_new_payload(self) -> FixtureEngineNewPayload:
664664
block_access_list=self.block_access_list.rlp
665665
if self.block_access_list
666666
else None,
667+
execution_witness=self.execution_witness,
667668
validation_error=self.expected_exception,
668669
error_code=self.engine_api_error_code,
669670
)

src/ethereum/forks/amsterdam/execution_engine/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
BlobsBundle,
2929
ExecutionEngine,
3030
ExecutionPayload,
31+
ExecutionRequests,
3132
GetPayloadResponse,
3233
NewPayloadRequest,
3334
PayloadAttributes,
@@ -38,6 +39,7 @@
3839
"BlobsBundle",
3940
"ExecutionEngine",
4041
"ExecutionPayload",
42+
"ExecutionRequests",
4143
"GetPayloadResponse",
4244
"NewPayloadRequest",
4345
"PayloadAttributes",

src/ethereum/forks/amsterdam/execution_engine/new_payload.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Payload verification.
33
"""
44

5-
from typing import Sequence, Tuple
5+
from typing import Tuple
66

77
from ethereum_rlp import rlp
88

@@ -15,14 +15,15 @@
1515
from ..fork_types import VersionedHash
1616
from ..state import apply_changes_to_state
1717
from ..transactions import BlobTransaction, decode_transaction
18+
from .requests import ExecutionRequests
1819
from .types import ExecutionEngine, ExecutionPayload, NewPayloadRequest
1920
from .validation_helpers import _payload_block, _payload_header
2021

2122

2223
def is_valid_block_hash(
2324
execution_payload: ExecutionPayload,
2425
parent_beacon_block_root: Root,
25-
execution_requests_list: Sequence[bytes],
26+
execution_requests: ExecutionRequests,
2627
) -> bool:
2728
"""
2829
Return ``True`` if and only if ``execution_payload.block_hash`` is
@@ -32,7 +33,7 @@ def is_valid_block_hash(
3233
header = _payload_header(
3334
execution_payload,
3435
parent_beacon_block_root,
35-
tuple(execution_requests_list),
36+
execution_requests,
3637
)
3738
except Exception:
3839
# Any decoding or conversion failure means the payload
@@ -98,15 +99,15 @@ def execute_new_payload_request(
9899
"""
99100
payload = new_payload_request.execution_payload
100101
parent_beacon_block_root = new_payload_request.parent_beacon_block_root
101-
execution_requests_list = new_payload_request.execution_requests
102+
execution_requests = new_payload_request.execution_requests
102103

103104
if b"" in payload.transactions:
104105
raise InvalidBlock("Empty transaction in payload")
105106

106107
if not is_valid_block_hash(
107108
payload,
108109
parent_beacon_block_root,
109-
execution_requests_list,
110+
execution_requests,
110111
):
111112
raise InvalidBlock("Invalid block hash")
112113

@@ -116,7 +117,7 @@ def execute_new_payload_request(
116117
block = _payload_block(
117118
payload,
118119
parent_beacon_block_root,
119-
tuple(execution_requests_list),
120+
execution_requests,
120121
)
121122
block_diff = execute_block(block, pre_state, chain_context)
122123
return block_diff, block

0 commit comments

Comments
 (0)