diff --git a/tests/core/pyspec/eth2spec/test/helpers/block.py b/tests/core/pyspec/eth2spec/test/helpers/block.py index 0760749b0..84770623e 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/block.py +++ b/tests/core/pyspec/eth2spec/test/helpers/block.py @@ -126,7 +126,7 @@ def build_empty_block(spec, state, slot=None, proposer_index=None): # Create valid whisk opening proof # TODO: Use k_initial or k_final to handle first and subsequent proposals - k_initial = whisk_ks_initial[proposer_index] + k_initial = whisk_ks_initial(proposer_index) # Sanity check proposer is correct proposer_k_commitment = state.whisk_k_commitments[proposer_index] @@ -156,7 +156,7 @@ def build_empty_block(spec, state, slot=None, proposer_index=None): # Branching logic depending if first proposal or not if is_first_proposal(spec, state, proposer_index): # Register new tracker - k_final = whisk_ks_final[proposer_index] + k_final = whisk_ks_final(proposer_index) # TODO: Actual logic should pick a random r, but may need to do something fancy to locate trackers quickly r = 2 tracker, k_commitment = compute_whisk_tracker_and_commitment(k_final, r) diff --git a/tests/core/pyspec/eth2spec/test/helpers/keys.py b/tests/core/pyspec/eth2spec/test/helpers/keys.py index 36af022a2..a849f1132 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/keys.py +++ b/tests/core/pyspec/eth2spec/test/helpers/keys.py @@ -5,13 +5,17 @@ privkeys = [i + 1 for i in range(32 * 256)] pubkeys = [bls.SkToPk(privkey) for privkey in privkeys] pubkey_to_privkey = {pubkey: privkey for privkey, pubkey in zip(privkeys, pubkeys)} -MAX_KEYS = 32 * 256 -whisk_ks_initial = [i for i in range(MAX_KEYS)] -# Must be unique among the set `whisk_ks_initial + whisk_ks_final` -whisk_ks_final = [MAX_KEYS + i for i in range(MAX_KEYS)] - known_whisk_trackers = {} def register_known_whisk_tracker(k_r_G: bytes, index: int): known_whisk_trackers[k_r_G] = index + + +def whisk_ks_initial(i: int): + return i + + +# Must be unique among the set `whisk_ks_initial + whisk_ks_final` +def whisk_ks_final(i: int): + return i + 10000000 diff --git a/tests/core/pyspec/eth2spec/test/helpers/whisk.py b/tests/core/pyspec/eth2spec/test/helpers/whisk.py index 70b69973c..a92dd267b 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/whisk.py +++ b/tests/core/pyspec/eth2spec/test/helpers/whisk.py @@ -21,7 +21,7 @@ def compute_whisk_initial_tracker_cached(i: int) -> WhiskTracker: if i in whisk_initial_tracker_cache_by_index: return whisk_initial_tracker_cache_by_index[i] - tracker = compute_whisk_tracker(whisk_ks_initial[i], INITIAL_R) + tracker = compute_whisk_tracker(whisk_ks_initial(i), INITIAL_R) whisk_initial_tracker_cache_by_index[i] = tracker whisk_initial_tracker_cache_by_k_r_G[tracker.k_r_G] = i return tracker @@ -31,7 +31,7 @@ def compute_whisk_initial_k_commitment_cached(i: int) -> BLSPubkey: if i in whisk_initial_k_commitment_cache_by_index: return whisk_initial_k_commitment_cache_by_index[i] - commitment = compute_whisk_k_commitment(whisk_ks_initial[i]) + commitment = compute_whisk_k_commitment(whisk_ks_initial(i)) whisk_initial_k_commitment_cache_by_index[i] = commitment return commitment diff --git a/tests/core/pyspec/eth2spec/test/whisk/block_processing/test_process_shuffled_trackers.py b/tests/core/pyspec/eth2spec/test/whisk/block_processing/test_process_shuffled_trackers.py index 7d7d39914..31665dc22 100644 --- a/tests/core/pyspec/eth2spec/test/whisk/block_processing/test_process_shuffled_trackers.py +++ b/tests/core/pyspec/eth2spec/test/whisk/block_processing/test_process_shuffled_trackers.py @@ -17,7 +17,7 @@ def get_and_populate_pre_shuffle_trackers(spec, state, body): pre_shuffle_trackers = [] for i in shuffle_indices: # Set r to some value > 1 ( = 2+i) - tracker = compute_whisk_tracker(whisk_ks_initial[i], 2 + i) + tracker = compute_whisk_tracker(whisk_ks_initial(i), 2 + i) state.whisk_candidate_trackers[i] = tracker pre_shuffle_trackers.append(tracker) return pre_shuffle_trackers diff --git a/tests/core/pyspec/eth2spec/test/whisk/sanity/blocks/test_whisk.py b/tests/core/pyspec/eth2spec/test/whisk/sanity/blocks/test_whisk.py index 9e6eedcd3..152eccbf3 100644 --- a/tests/core/pyspec/eth2spec/test/whisk/sanity/blocks/test_whisk.py +++ b/tests/core/pyspec/eth2spec/test/whisk/sanity/blocks/test_whisk.py @@ -15,7 +15,7 @@ def assign_proposer_at_slot(state, slot: int): def initialize_whisk_full(spec, state): # TODO: De-duplicate code from whisk/fork.md for index in range(len(state.validators)): - whisk_k_commitment, whisk_tracker = spec.get_initial_commitments(whisk_ks_initial[index]) + whisk_k_commitment, whisk_tracker = spec.get_initial_commitments(whisk_ks_initial(index)) state.whisk_k_commitments[index] = whisk_k_commitment state.whisk_trackers[index] = whisk_tracker @@ -36,7 +36,7 @@ def fill_candidate_trackers(spec, state, tracker: WhiskTracker): def test_whisk__process_block_single_initial(spec, state): assert state.slot == 0 proposer_slot_1 = 0 - tracker_slot_1, k_commitment = compute_whisk_tracker_and_commitment(whisk_ks_initial[proposer_slot_1], 1) + tracker_slot_1, k_commitment = compute_whisk_tracker_and_commitment(whisk_ks_initial(proposer_slot_1), 1) state.whisk_k_commitments[proposer_slot_1] = k_commitment state.whisk_proposer_trackers[1] = tracker_slot_1 fill_candidate_trackers(spec, state, tracker_slot_1)