Skip to content

Commit 1f93a8c

Browse files
committed
restructure: nest payload_status into head check
1 parent 55519bb commit 1f93a8c

3 files changed

Lines changed: 13 additions & 25 deletions

File tree

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -536,12 +536,16 @@ def add_payload_vote_checks(store, block_root, test_steps):
536536
def get_formatted_head_output(spec, store, head=None):
537537
if head is None:
538538
head = spec.get_head(store)
539-
slot = store.blocks[head.root].slot
540-
return {
541-
"slot": int(slot),
539+
formatted_head = {
540+
"slot": int(store.blocks[head.root].slot),
542541
"root": encode_hex(head.root),
543542
}
544543

544+
if is_post_gloas(spec):
545+
formatted_head["payload_status"] = int(head.payload_status)
546+
547+
return formatted_head
548+
545549

546550
def output_head_check(spec, store, test_steps):
547551
head = spec.get_head(store)
@@ -555,10 +559,9 @@ def output_head_check(spec, store, test_steps):
555559

556560

557561
def get_basic_store_checks(spec, store):
558-
head = spec.get_head(store)
559-
checks = {
562+
return {
560563
"time": int(store.time),
561-
"head": get_formatted_head_output(spec, store, head),
564+
"head": get_formatted_head_output(spec, store),
562565
"justified_checkpoint": {
563566
"epoch": int(store.justified_checkpoint.epoch),
564567
"root": encode_hex(store.justified_checkpoint.root),
@@ -570,11 +573,6 @@ def get_basic_store_checks(spec, store):
570573
"proposer_boost_root": encode_hex(store.proposer_boost_root),
571574
}
572575

573-
if is_post_gloas(spec):
574-
checks["head_payload_status"] = int(head.payload_status)
575-
576-
return checks
577-
578576

579577
def get_weighed_node_checks(spec, store, node):
580578
if is_post_gloas(spec):

tests/formats/fork_choice/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ client implementation. The fields include:
238238
head: {
239239
slot: int,
240240
root: string, -- Encoded 32-byte value from get_head(store).root
241+
payload_status: int, -- Gloas and later, the head's payload_status
241242
}
242243
time: int -- store.time
243244
genesis_time: int -- store.genesis_time
@@ -266,7 +267,6 @@ should_override_forkchoice_update: { -- [New in Bellatrix]
266267
validator_is_connected: bool, -- The mocking result of `validator_is_connected(proposer_index)` in this call
267268
result: bool, -- The result of `should_override_forkchoice_update(store, head_root)`, where head_root is the result value from get_head(store).root
268269
}
269-
head_payload_status: int -- The payload_status field from the ForkChoiceNode returned by get_head(store)
270270
payload_timeliness_vote: { -- [New in Gloas]
271271
block_root: string, -- Encoded 32-byte beacon block root
272272
votes: [bool | null, ...] -- Votes ordered by PTC positions. Length is `PTC_SIZE`.

tests/generators/compliance_runners/fork_choice/runner/test_run.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,23 +143,16 @@ def run_test(test_info):
143143
)
144144
elif "checks" in step:
145145
checks = step["checks"]
146-
147-
cached_head = None
148-
149-
def get_head():
150-
nonlocal cached_head
151-
if cached_head is None:
152-
cached_head = spec.get_head(store)
153-
return cached_head
154-
155146
for check, value in checks.items():
156147
if check == "time":
157148
expected_time = value
158149
assert store.time == expected_time
159150
elif check == "head":
160-
head = get_head()
151+
head = spec.get_head(store)
161152
assert store.blocks[head.root].slot == value["slot"]
162153
assert str(head.root) == value["root"]
154+
if is_post_gloas(spec):
155+
assert head.payload_status == value["payload_status"]
163156
elif check == "proposer_boost_root":
164157
assert str(store.proposer_boost_root) == str(value)
165158
elif check == "justified_checkpoint":
@@ -174,9 +167,6 @@ def get_head():
174167
actual = value
175168
expected = get_viable_for_head_checks(spec, store)
176169
assert {frozenset(e) for e in actual} == {frozenset(e) for e in expected}
177-
elif check == "head_payload_status":
178-
head = get_head()
179-
assert head.payload_status == value
180170
elif check in ("payload_timeliness_vote", "payload_data_availability_vote"):
181171
target_root = spec.Root(decode_hex(value["block_root"]))
182172
assert list(getattr(store, check)[target_root]) == value["votes"]

0 commit comments

Comments
 (0)