Skip to content

Commit 42d91d5

Browse files
committed
fix tests for mainnet preset
1 parent f14900f commit 42d91d5

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

tests/core/pyspec/eth2spec/test/helpers/block.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def build_empty_block(spec, state, slot=None, proposer_index=None):
126126

127127
# Create valid whisk opening proof
128128
# TODO: Use k_initial or k_final to handle first and subsequent proposals
129-
k_initial = whisk_ks_initial[proposer_index]
129+
k_initial = whisk_ks_initial(proposer_index)
130130

131131
# Sanity check proposer is correct
132132
proposer_k_commitment = state.whisk_k_commitments[proposer_index]
@@ -156,7 +156,7 @@ def build_empty_block(spec, state, slot=None, proposer_index=None):
156156
# Branching logic depending if first proposal or not
157157
if is_first_proposal(spec, state, proposer_index):
158158
# Register new tracker
159-
k_final = whisk_ks_final[proposer_index]
159+
k_final = whisk_ks_final(proposer_index)
160160
# TODO: Actual logic should pick a random r, but may need to do something fancy to locate trackers quickly
161161
r = 2
162162
tracker, k_commitment = compute_whisk_tracker_and_commitment(k_final, r)

tests/core/pyspec/eth2spec/test/helpers/keys.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@
55
pubkeys = [bls.SkToPk(privkey) for privkey in privkeys]
66
pubkey_to_privkey = {pubkey: privkey for privkey, pubkey in zip(privkeys, pubkeys)}
77

8-
MAX_KEYS = 32 * 256
9-
whisk_ks_initial = [i for i in range(MAX_KEYS)]
10-
# Must be unique among the set `whisk_ks_initial + whisk_ks_final`
11-
whisk_ks_final = [MAX_KEYS + i for i in range(MAX_KEYS)]
12-
138
known_whisk_trackers = {}
149

1510

1611
def register_known_whisk_tracker(k_r_G: bytes, index: int):
1712
known_whisk_trackers[k_r_G] = index
13+
14+
15+
def whisk_ks_initial(i: int):
16+
return i
17+
18+
19+
# Must be unique among the set `whisk_ks_initial + whisk_ks_final`
20+
def whisk_ks_final(i: int):
21+
return i + 10000000

tests/core/pyspec/eth2spec/test/helpers/whisk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def compute_whisk_initial_tracker_cached(i: int) -> WhiskTracker:
2121
if i in whisk_initial_tracker_cache_by_index:
2222
return whisk_initial_tracker_cache_by_index[i]
2323

24-
tracker = compute_whisk_tracker(whisk_ks_initial[i], INITIAL_R)
24+
tracker = compute_whisk_tracker(whisk_ks_initial(i), INITIAL_R)
2525
whisk_initial_tracker_cache_by_index[i] = tracker
2626
whisk_initial_tracker_cache_by_k_r_G[tracker.k_r_G] = i
2727
return tracker
@@ -31,7 +31,7 @@ def compute_whisk_initial_k_commitment_cached(i: int) -> BLSPubkey:
3131
if i in whisk_initial_k_commitment_cache_by_index:
3232
return whisk_initial_k_commitment_cache_by_index[i]
3333

34-
commitment = compute_whisk_k_commitment(whisk_ks_initial[i])
34+
commitment = compute_whisk_k_commitment(whisk_ks_initial(i))
3535
whisk_initial_k_commitment_cache_by_index[i] = commitment
3636
return commitment
3737

tests/core/pyspec/eth2spec/test/whisk/block_processing/test_process_shuffled_trackers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def get_and_populate_pre_shuffle_trackers(spec, state, body):
1717
pre_shuffle_trackers = []
1818
for i in shuffle_indices:
1919
# Set r to some value > 1 ( = 2+i)
20-
tracker = compute_whisk_tracker(whisk_ks_initial[i], 2 + i)
20+
tracker = compute_whisk_tracker(whisk_ks_initial(i), 2 + i)
2121
state.whisk_candidate_trackers[i] = tracker
2222
pre_shuffle_trackers.append(tracker)
2323
return pre_shuffle_trackers

tests/core/pyspec/eth2spec/test/whisk/sanity/blocks/test_whisk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def assign_proposer_at_slot(state, slot: int):
1515
def initialize_whisk_full(spec, state):
1616
# TODO: De-duplicate code from whisk/fork.md
1717
for index in range(len(state.validators)):
18-
whisk_k_commitment, whisk_tracker = spec.get_initial_commitments(whisk_ks_initial[index])
18+
whisk_k_commitment, whisk_tracker = spec.get_initial_commitments(whisk_ks_initial(index))
1919
state.whisk_k_commitments[index] = whisk_k_commitment
2020
state.whisk_trackers[index] = whisk_tracker
2121

@@ -36,7 +36,7 @@ def fill_candidate_trackers(spec, state, tracker: WhiskTracker):
3636
def test_whisk__process_block_single_initial(spec, state):
3737
assert state.slot == 0
3838
proposer_slot_1 = 0
39-
tracker_slot_1, k_commitment = compute_whisk_tracker_and_commitment(whisk_ks_initial[proposer_slot_1], 1)
39+
tracker_slot_1, k_commitment = compute_whisk_tracker_and_commitment(whisk_ks_initial(proposer_slot_1), 1)
4040
state.whisk_k_commitments[proposer_slot_1] = k_commitment
4141
state.whisk_proposer_trackers[1] = tracker_slot_1
4242
fill_candidate_trackers(spec, state, tracker_slot_1)

0 commit comments

Comments
 (0)