Skip to content

Commit 88af7ca

Browse files
committed
fix formatting
1 parent f081073 commit 88af7ca

8 files changed

Lines changed: 120 additions & 54 deletions

File tree

tests/generators/compliance_runners/state_transition/aspects/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class SignatureType(Enum):
3535
VALID = auto()
3636
INVALID = auto()
3737

38+
3839
class Record:
3940
"""
4041
Record is a Record in Minizinc.

tests/generators/compliance_runners/state_transition/aspects/bid_processing/bid_processing.py

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -44,37 +44,50 @@ def bid_processing_constraints(p: ExecutionPayloadBidProcessing) -> None:
4444
if p.cmp_bid_value_zero == Cmp.EQ:
4545
assert p.cmp_builder_balance_to_bid_value_plus_min_balance in {Cmp.EQ, Cmp.GT}
4646
if p.cmp_builder_balance_to_bid_value_plus_min_balance == Cmp.EQ:
47-
assert has_pending_withdrawals(p.builder) or p.builder.cmp_balance_min_deposit == OpCmp.EQ
47+
assert (
48+
has_pending_withdrawals(p.builder)
49+
or p.builder.cmp_balance_min_deposit == OpCmp.EQ
50+
)
4851
if p.cmp_builder_balance_to_bid_value_plus_min_balance == Cmp.GT:
4952
assert p.builder.cmp_balance_min_deposit == OpCmp.GT
5053

5154
if p.cmp_bid_value_zero == Cmp.GT:
5255
if p.cmp_builder_balance_to_bid_value_plus_min_balance in {Cmp.EQ, Cmp.GT}:
5356
assert p.builder.cmp_balance_min_deposit == OpCmp.GT
5457

55-
assert no_more_than_several_of([
56-
not is_active_builder(p.builder),
57-
p.builder.payload_builder_version == OpBool.F,
58-
p.cmp_builder_balance_to_bid_value_plus_min_balance == Cmp.LT,
59-
p.bid_signature == SignatureType.INVALID,
60-
p.cmp_len_kzg_commitments_max_blobs == Cmp.GT,
61-
p.cmp_state_slot_bid_slot in {Cmp.GT, Cmp.LT},
62-
p.parent_block_hash_match == Bool.F,
63-
p.parent_block_root_match == Bool.F,
64-
p.prev_randao_match == Bool.F,
65-
], 1)
58+
assert no_more_than_several_of(
59+
[
60+
not is_active_builder(p.builder),
61+
p.builder.payload_builder_version == OpBool.F,
62+
p.cmp_builder_balance_to_bid_value_plus_min_balance == Cmp.LT,
63+
p.bid_signature == SignatureType.INVALID,
64+
p.cmp_len_kzg_commitments_max_blobs == Cmp.GT,
65+
p.cmp_state_slot_bid_slot in {Cmp.GT, Cmp.LT},
66+
p.parent_block_hash_match == Bool.F,
67+
p.parent_block_root_match == Bool.F,
68+
p.prev_randao_match == Bool.F,
69+
],
70+
1,
71+
)
6672

6773
if p.builder_type == BuilderType.SELF:
6874
assert p.bid_signature in {SignatureType.INF, SignatureType.INVALID}
6975
assert p.cmp_builder_balance_to_bid_value_plus_min_balance in {Cmp.EQ, Cmp.LT}
70-
assert (p.cmp_bid_value_zero == Cmp.EQ) == (p.cmp_builder_balance_to_bid_value_plus_min_balance == Cmp.EQ)
71-
assert (p.cmp_bid_value_zero == Cmp.GT) == (p.cmp_builder_balance_to_bid_value_plus_min_balance == Cmp.LT)
72-
assert no_more_than_several_of([
73-
p.cmp_builder_balance_to_bid_value_plus_min_balance == Cmp.LT,
74-
p.bid_signature == SignatureType.INVALID,
75-
p.cmp_len_kzg_commitments_max_blobs == Cmp.GT,
76-
p.cmp_state_slot_bid_slot in {Cmp.GT, Cmp.LT},
77-
p.parent_block_hash_match == Bool.F,
78-
p.parent_block_root_match == Bool.F,
79-
p.prev_randao_match == Bool.F,
80-
], 1)
76+
assert (p.cmp_bid_value_zero == Cmp.EQ) == (
77+
p.cmp_builder_balance_to_bid_value_plus_min_balance == Cmp.EQ
78+
)
79+
assert (p.cmp_bid_value_zero == Cmp.GT) == (
80+
p.cmp_builder_balance_to_bid_value_plus_min_balance == Cmp.LT
81+
)
82+
assert no_more_than_several_of(
83+
[
84+
p.cmp_builder_balance_to_bid_value_plus_min_balance == Cmp.LT,
85+
p.bid_signature == SignatureType.INVALID,
86+
p.cmp_len_kzg_commitments_max_blobs == Cmp.GT,
87+
p.cmp_state_slot_bid_slot in {Cmp.GT, Cmp.LT},
88+
p.parent_block_hash_match == Bool.F,
89+
p.parent_block_root_match == Bool.F,
90+
p.prev_randao_match == Bool.F,
91+
],
92+
1,
93+
)

tests/generators/compliance_runners/state_transition/aspects/bid_processing/bid_processing_validator.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ def bid_processing_validator(
5151
if payment.withdrawal.builder_index == builder_index
5252
)
5353
min_balance = spec.MIN_DEPOSIT_AMOUNT + pending_withdrawals_amount
54-
cmp_builder_balance_to_bid_value_plus_min_balance = _to_cmp(int(builder_balance), int(bid.value + min_balance))
54+
cmp_builder_balance_to_bid_value_plus_min_balance = _to_cmp(
55+
int(builder_balance), int(bid.value + min_balance)
56+
)
5557

5658
cmp_len_kzg_commitments_max_blobs = _to_cmp(
5759
len(bid.blob_kzg_commitments),
@@ -60,7 +62,8 @@ def bid_processing_validator(
6062
cmp_state_slot_bid_slot = _to_cmp(int(beacon_state.slot), int(bid.slot))
6163
parent_block_hash_match = _to_bool(bid.parent_block_hash == beacon_state.latest_block_hash)
6264
parent_block_root_match = _to_bool(
63-
bid.parent_block_root == spec.get_block_root_at_slot(beacon_state, spec.Slot(int(beacon_state.slot) - 1))
65+
bid.parent_block_root
66+
== spec.get_block_root_at_slot(beacon_state, spec.Slot(int(beacon_state.slot) - 1))
6467
)
6568
prev_randao_match = _to_bool(
6669
bid.prev_randao == spec.get_randao_mix(beacon_state, spec.get_current_epoch(beacon_state))

tests/generators/compliance_runners/state_transition/aspects/builder/builder_validator.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,26 @@ def builder_validator(spec, beacon_state, solution: BuilderSolution, builder_ind
2222
payload_builder_version = _to_op_bool(builder.version == spec.PAYLOAD_BUILDER_VERSION)
2323
cmp_state_epoch_deposit_epoch = _to_op_cmp(state_epoch, builder.deposit_epoch)
2424
cmp_state_epoch_withdrawal_epoch = _to_op_cmp(state_epoch, builder.withdrawable_epoch)
25-
cmp_finalized_epoch_deposit_epoch = _to_op_cmp(beacon_state.finalized_checkpoint.epoch, builder.deposit_epoch)
25+
cmp_finalized_epoch_deposit_epoch = _to_op_cmp(
26+
beacon_state.finalized_checkpoint.epoch, builder.deposit_epoch
27+
)
2628
withdrawable_epoch_set = _to_op_bool(builder.withdrawable_epoch != spec.FAR_FUTURE_EPOCH)
2729
cmp_balance_zero = _to_op_cmp(builder.balance, 0)
2830
cmp_balance_min_deposit = _to_op_cmp(builder.balance, spec.MIN_DEPOSIT_AMOUNT)
29-
has_pending_payments = _to_op_bool(any(
30-
p for p in beacon_state.builder_pending_payments
31-
if p.withdrawal.builder_index == builder_index and int(p.withdrawal.amount) > 0
32-
))
33-
has_pending_withdrawals = _to_op_bool(any(
34-
w for w in beacon_state.builder_pending_withdrawals
35-
if w.builder_index == builder_index and int(w.amount) > 0
36-
))
31+
has_pending_payments = _to_op_bool(
32+
any(
33+
p
34+
for p in beacon_state.builder_pending_payments
35+
if p.withdrawal.builder_index == builder_index and int(p.withdrawal.amount) > 0
36+
)
37+
)
38+
has_pending_withdrawals = _to_op_bool(
39+
any(
40+
w
41+
for w in beacon_state.builder_pending_withdrawals
42+
if w.builder_index == builder_index and int(w.amount) > 0
43+
)
44+
)
3745

3846
materialized_solution = BuilderSolution(
3947
payload_builder_version=payload_builder_version,

tests/generators/compliance_runners/state_transition/bid_processing/coverage.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
uv run python -m ...bid_processing.coverage # profile summary
99
uv run python -m ...bid_processing.coverage standard --materialize
1010
"""
11+
1112
from __future__ import annotations
1213

1314
from pathlib import Path
@@ -26,12 +27,15 @@
2627
"builder_funds": ["cmp_builder_balance_to_bid_value_plus_min_balance"],
2728
"blob_kzg_capacity": ["cmp_len_kzg_commitments_max_blobs"],
2829
"slot_epoch": ["cmp_state_slot_bid_slot"],
29-
"block_context": ["parent_block_hash_match", "parent_block_root_match",
30-
"prev_randao_match"],
30+
"block_context": ["parent_block_hash_match", "parent_block_root_match", "prev_randao_match"],
3131
# builder sub-aspect (from the aggregate record's builder field)
3232
"builder_version": ["payload_builder_version"],
33-
"builder_lifecycle": ["cmp_state_epoch_deposit_epoch", "cmp_state_epoch_withdrawal_epoch",
34-
"cmp_finalized_epoch_deposit_epoch", "withdrawable_epoch_set"],
33+
"builder_lifecycle": [
34+
"cmp_state_epoch_deposit_epoch",
35+
"cmp_state_epoch_withdrawal_epoch",
36+
"cmp_finalized_epoch_deposit_epoch",
37+
"withdrawable_epoch_set",
38+
],
3539
"builder_balance": ["cmp_balance_zero", "cmp_balance_min_deposit"],
3640
"builder_pending_balance": ["has_pending_payments", "has_pending_withdrawals"],
3741
}

tests/generators/compliance_runners/state_transition/bid_processing/materializer.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
Usage:
1010
uv run python -m tests.generators.compliance_runners.state_transition.bid_processing.materializer
1111
"""
12+
1213
from __future__ import annotations
1314

1415
from typing import Any, TYPE_CHECKING
@@ -44,7 +45,7 @@
4445
BUILDER_PUBKEY = builder_pubkeys[0]
4546
WRONG_PUBKEY = builder_pubkeys[1]
4647
BUILDER_ADDRESS = b"\x22" * 20
47-
BIG = 10 ** 10
48+
BIG = 10**10
4849

4950
DIMS = [
5051
"builder_type",
@@ -119,7 +120,9 @@ def _to_solution(rec: dict[str, Any]) -> ExecutionPayloadBidProcessing:
119120
builder=builder,
120121
cmp_bid_value_zero=_cmp[rec["cmp_bid_value_zero"]],
121122
bid_signature=_st[rec["bid_signature"]],
122-
cmp_builder_balance_to_bid_value_plus_min_balance=_cmp[rec["cmp_builder_balance_to_bid_value_plus_min_balance"]],
123+
cmp_builder_balance_to_bid_value_plus_min_balance=_cmp[
124+
rec["cmp_builder_balance_to_bid_value_plus_min_balance"]
125+
],
123126
cmp_len_kzg_commitments_max_blobs=_cmp[rec["cmp_len_kzg_commitments_max_blobs"]],
124127
cmp_state_slot_bid_slot=_cmp[rec["cmp_state_slot_bid_slot"]],
125128
parent_block_hash_match=_bool[rec["parent_block_hash_match"]],
@@ -165,8 +168,12 @@ def _pick_withdrawable_epoch(w_cmp: str, state_epoch: int):
165168

166169

167170
def _pick_balance_and_bid_value(
168-
b_zero: str, b_min: str, v_zero: str, v_funds: str,
169-
min_deposit: int, pending_total: int,
171+
b_zero: str,
172+
b_min: str,
173+
v_zero: str,
174+
v_funds: str,
175+
min_deposit: int,
176+
pending_total: int,
170177
) -> tuple[int, int]:
171178
"""Pick (balance, bid_value) satisfying all four comparisons:
172179
- cmp(balance, 0) = b_zero
@@ -368,7 +375,9 @@ def materialize_solution(self, sol: Any) -> tuple[dict, list[TestCasePart]]:
368375
pr = rec["parent_block_root_match"] == "T"
369376
parent_block_hash = pre.latest_block_hash if ph else spec.Hash32(b"\x02" * 32)
370377
prev_randao = (
371-
spec.get_randao_mix(pre, spec.get_current_epoch(pre)) if rr else spec.Bytes32(b"\x06" * 32)
378+
spec.get_randao_mix(pre, spec.get_current_epoch(pre))
379+
if rr
380+
else spec.Bytes32(b"\x06" * 32)
372381
)
373382
if past_genesis and pr:
374383
parent_block_root = spec.get_block_root_at_slot(pre, spec.Slot(int(pre.slot) - 1))

tests/generators/compliance_runners/state_transition/bid_processing/validation.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
Usage:
1010
uv run python -m tests.generators.compliance_runners.state_transition.bid_processing.validation [REFTESTS_DIR]
1111
"""
12+
1213
from __future__ import annotations
1314

1415
from typing import Any, TYPE_CHECKING
@@ -94,21 +95,31 @@ def recover(pre: Any, signed: Any) -> dict[str, Any]:
9495
r["cmp_balance_zero"] = _cmp(int(b.balance), 0)
9596
r["cmp_balance_min_deposit"] = _cmp(int(b.balance), int(spec.MIN_DEPOSIT_AMOUNT))
9697
r["has_pending_payments"] = _tri(
97-
any(p.withdrawal.builder_index == idx and int(p.withdrawal.amount) > 0
98-
for p in pre.builder_pending_payments)
98+
any(
99+
p.withdrawal.builder_index == idx and int(p.withdrawal.amount) > 0
100+
for p in pre.builder_pending_payments
101+
)
99102
)
100103
r["has_pending_withdrawals"] = _tri(
101-
any(w.builder_index == idx and int(w.amount) > 0 for w in pre.builder_pending_withdrawals)
104+
any(
105+
w.builder_index == idx and int(w.amount) > 0
106+
for w in pre.builder_pending_withdrawals
107+
)
102108
)
103109
r["cmp_builder_balance_to_bid_value_plus_min_balance"] = _cmp(
104110
int(b.balance), int(bid.value) + min_balance
105111
)
106112
else:
107113
for name in (
108-
"cmp_state_epoch_deposit_epoch", "cmp_state_epoch_withdrawal_epoch",
109-
"cmp_finalized_epoch_deposit_epoch", "withdrawable_epoch_set",
110-
"payload_builder_version", "cmp_balance_zero", "cmp_balance_min_deposit",
111-
"has_pending_payments", "has_pending_withdrawals",
114+
"cmp_state_epoch_deposit_epoch",
115+
"cmp_state_epoch_withdrawal_epoch",
116+
"cmp_finalized_epoch_deposit_epoch",
117+
"withdrawable_epoch_set",
118+
"payload_builder_version",
119+
"cmp_balance_zero",
120+
"cmp_balance_min_deposit",
121+
"has_pending_payments",
122+
"has_pending_withdrawals",
112123
):
113124
r[name] = "NA"
114125
# For SELF/NON_EXISTING: min_balance = 0, so cmp(0, bid.value)

tests/generators/compliance_runners/state_transition/catalog.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,35 @@ class Provider:
3838
HANDLERS = tuple(handler for handlers in RUNNERS.values() for handler in handlers)
3939
PROVIDERS = (
4040
Provider("attestation", "attestation", "operations", "attestation"),
41-
Provider("builder_deposit_request", "builder_deposit_request", "operations", "builder_deposit_request"),
41+
Provider(
42+
"builder_deposit_request",
43+
"builder_deposit_request",
44+
"operations",
45+
"builder_deposit_request",
46+
),
4247
Provider("builder_exit_request", "builder_exit_request", "operations", "builder_exit_request"),
43-
Provider("consolidation_request", "consolidation_request", "operations", "consolidation_request"),
48+
Provider(
49+
"consolidation_request", "consolidation_request", "operations", "consolidation_request"
50+
),
4451
Provider("deposit_request", "deposit_request", "operations", "deposit_request"),
4552
# Provider("execution_payload_bid", "execution_payload_bid", "operations", "execution_payload_bid"),
4653
Provider("bid_processing", "bid_processing", "operations", "execution_payload_bid"),
47-
Provider("parent_execution_payload", "parent_execution_payload", "operations", "parent_execution_payload"),
54+
Provider(
55+
"parent_execution_payload",
56+
"parent_execution_payload",
57+
"operations",
58+
"parent_execution_payload",
59+
),
4860
Provider("payload_attestation", "payload_attestation", "operations", "payload_attestation"),
4961
Provider("proposer_slashing", "proposer_slashing", "operations", "proposer_slashing"),
5062
Provider("withdrawal_request", "withdrawal_request", "operations", "withdrawal_request"),
5163
Provider("withdrawals", "withdrawals", "operations", "withdrawals"),
52-
Provider("builder_pending_payments", "builder_pending_payments", "epoch_processing", "builder_pending_payments"),
64+
Provider(
65+
"builder_pending_payments",
66+
"builder_pending_payments",
67+
"epoch_processing",
68+
"builder_pending_payments",
69+
),
5370
Provider("pending_deposits", "pending_deposits", "epoch_processing", "pending_deposits"),
5471
Provider("ptc_window", "ptc_window", "epoch_processing", "ptc_window"),
5572
)

0 commit comments

Comments
 (0)