Skip to content

Commit 29ffb26

Browse files
authored
Merge branch 'master' into feat/eip8025-optional-engines-v3
2 parents a13b3dc + a7ab94b commit 29ffb26

7 files changed

Lines changed: 52 additions & 7 deletions

File tree

specs/gloas/beacon-chain.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ class ExecutionPayloadEnvelope(Container):
289289
execution_requests: ExecutionRequests
290290
builder_index: BuilderIndex
291291
beacon_block_root: Root
292+
parent_beacon_block_root: Root
292293
```
293294

294295
#### `SignedExecutionPayloadEnvelope`

specs/gloas/builder.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ alias `bid` to be the committed `ExecutionPayloadBid` in
244244
3. Set `envelope.builder_index` to be the index of the builder performing these
245245
steps. This field **MUST** be `bid.builder_index`.
246246
4. Set `envelope.beacon_block_root` to be `hash_tree_root(block)`.
247+
5. Set `envelope.parent_beacon_block_root` to be `block.parent_root`.
247248

248249
After preparing the `envelope` the builder signs it using:
249250

specs/gloas/fork-choice.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,7 @@ def verify_execution_payload_envelope(
788788
header = copy(state.latest_block_header)
789789
header.state_root = hash_tree_root(state)
790790
assert envelope.beacon_block_root == hash_tree_root(header)
791+
assert envelope.parent_beacon_block_root == state.latest_block_header.parent_root
791792

792793
# Verify consistency with the committed bid
793794
bid = state.latest_execution_payload_bid
@@ -809,7 +810,7 @@ def verify_execution_payload_envelope(
809810
kzg_commitment_to_versioned_hash(commitment)
810811
for commitment in bid.blob_kzg_commitments
811812
],
812-
parent_beacon_block_root=state.latest_block_header.parent_root,
813+
parent_beacon_block_root=envelope.parent_beacon_block_root,
813814
execution_requests=envelope.execution_requests,
814815
)
815816
)

tests/core/pyspec/eth_consensus_specs/test/gloas/fork_choice/test_on_execution_payload_envelope.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,13 @@ def _build_invalid_envelope(spec, state, block_root, signed_block, **overrides):
5656
setattr(payload, key, overrides.pop(key))
5757

5858
envelope = spec.ExecutionPayloadEnvelope(
59-
beacon_block_root=overrides.pop("beacon_block_root", block_root),
6059
payload=payload,
6160
execution_requests=overrides.pop("execution_requests", spec.ExecutionRequests()),
6261
builder_index=overrides.pop("builder_index", builder_index),
62+
beacon_block_root=overrides.pop("beacon_block_root", block_root),
63+
parent_beacon_block_root=overrides.pop(
64+
"parent_beacon_block_root", state.latest_block_header.parent_root
65+
),
6366
)
6467

6568
if overrides.pop("valid_signature", True):
@@ -191,6 +194,33 @@ def test_on_execution_payload_envelope__wrong_beacon_block_root(spec, state):
191194
yield "steps", test_steps
192195

193196

197+
@with_gloas_and_later
198+
@spec_state_test
199+
def test_on_execution_payload_envelope__wrong_parent_beacon_block_root(spec, state):
200+
test_steps = []
201+
store, anchor_block = get_genesis_forkchoice_store_and_block(spec, state)
202+
yield "anchor_state", state
203+
yield "anchor_block", anchor_block
204+
205+
current_time = state.slot * (spec.config.SLOT_DURATION_MS // 1000) + store.genesis_time
206+
on_tick_and_append_step(spec, store, current_time, test_steps)
207+
208+
signed_block, block_root = yield from _add_block_and_get_root(spec, state, store, test_steps)
209+
210+
envelope = _build_invalid_envelope(
211+
spec,
212+
state,
213+
block_root,
214+
signed_block,
215+
parent_beacon_block_root=spec.Root(b"\x42" * 32),
216+
)
217+
yield from add_execution_payload(spec, store, envelope, test_steps, valid=False)
218+
219+
assert block_root not in store.payloads
220+
221+
yield "steps", test_steps
222+
223+
194224
@with_gloas_and_later
195225
@spec_state_test
196226
def test_on_execution_payload_envelope__wrong_slot(spec, state):

tests/core/pyspec/eth_consensus_specs/test/gloas/sanity/test_blocks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def _attempt_payload_with_withdrawals(spec, state, withdrawals):
101101
execution_requests=spec.ExecutionRequests(),
102102
builder_index=committed_bid.builder_index,
103103
beacon_block_root=header.hash_tree_root(),
104+
parent_beacon_block_root=test_state.latest_block_header.parent_root,
104105
)
105106

106107
if envelope.builder_index == spec.BUILDER_INDEX_SELF_BUILD:

tests/core/pyspec/eth_consensus_specs/test/helpers/execution_payload.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,10 +466,11 @@ def build_signed_execution_payload_envelope(
466466

467467
# Create the execution payload envelope message
468468
envelope_message = spec.ExecutionPayloadEnvelope(
469-
beacon_block_root=block_root,
470469
payload=payload,
471470
execution_requests=execution_requests,
472471
builder_index=builder_index,
472+
beacon_block_root=block_root,
473+
parent_beacon_block_root=signed_block.message.parent_root,
473474
)
474475

475476
# Sign the envelope: self-builds use proposer key, external builds use builder key

tests/generators/compliance_runners/fork_choice/instantiators/block_tree.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,9 @@ def _generate_block_tree(
565565
block_index = 1
566566
block_tree_tips = set([0])
567567
in_block_attester_slashings = []
568-
attester_slashings_count = 0
568+
# Tracks every validator selected for a generated attester slashing in this
569+
# scenario, so later selections cannot target the same validator again.
570+
validators_to_be_slashed = set()
569571
out_of_block_attestation_messages = []
570572
out_of_block_pa_messages = []
571573
out_of_block_attester_slashing_messages = []
@@ -736,10 +738,18 @@ def split_list(lst, n):
736738
)
737739

738740
# Create attester slashing
739-
if with_attester_slashings and attester_slashings_count < MAX_ATTESTER_SLASHINGS:
741+
if with_attester_slashings and len(validators_to_be_slashed) < MAX_ATTESTER_SLASHINGS:
740742
if rnd.randint(0, 99) < ATTESTER_SLASHINGS_RATE:
741743
state = post_states[attesting_tips[0]]
742-
indices = [rnd.randint(0, len(state.validators) - 1)]
744+
745+
assert len(validators_to_be_slashed) < len(state.validators)
746+
while True:
747+
validator_to_slash = rnd.randint(0, len(state.validators) - 1)
748+
# avoid slashing a validator who might be slashed already
749+
if validator_to_slash not in validators_to_be_slashed:
750+
break
751+
752+
indices = [validator_to_slash]
743753
attester_slashing = get_valid_attester_slashing_by_indices(
744754
spec, state, indices, slot=current_slot, signed_1=True, signed_2=True
745755
)
@@ -755,7 +765,7 @@ def split_list(lst, n):
755765
spoil_fn=lambda msg: _spoil_attester_slashing(spec, rnd, msg),
756766
)
757767

758-
attester_slashings_count += 1
768+
validators_to_be_slashed.update(indices)
759769

760770
# Next slot
761771
current_slot += 1

0 commit comments

Comments
 (0)