Skip to content

Commit 4d3a441

Browse files
committed
Update randomness-related fields
1. Add constants: `LATEST_RANDAO_MIXES_LENGTH` 2. Update `BeaconState` fields. ``` - ('randao_mix', hash32), - ('next_seed', hash32), + ('latest_randao_mixes', CountableList(hash32)), + ('latest_vdf_outputs', CountableList(hash32)), ```
1 parent 1f7172a commit 4d3a441

File tree

6 files changed

+19
-10
lines changed

6 files changed

+19
-10
lines changed

eth/beacon/state_machines/configs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
('BLS_WITHDRAWAL_PREFIX_BYTE', bytes),
2020
('MAX_CASPER_VOTES', int),
2121
('LATEST_BLOCK_ROOTS_LENGTH', int),
22+
('LATEST_RANDAO_MIXES_LENGTH', int),
2223
# EMPTY_SIGNATURE is defined in constants.py
2324
# Deposit contract
2425
('DEPOSIT_CONTRACT_ADDRESS', Address),

eth/beacon/state_machines/forks/serenity/configs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
BLS_WITHDRAWAL_PREFIX_BYTE=b'\x00',
1515
MAX_CASPER_VOTES=2**10, # (= 1,024) votes
1616
LATEST_BLOCK_ROOTS_LENGTH=2**13, # (= 8,192) block roots
17+
LATEST_RANDAO_MIXES_LENGTH=2**13, # (= 8,192) randao mixes
1718
# Deposit contract
1819
DEPOSIT_CONTRACT_ADDRESS=ZERO_ADDRESS, # TBD
1920
DEPOSIT_CONTRACT_TREE_DEPTH=2**5, # (= 32)

eth/beacon/types/states.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class BeaconState(rlp.Serializable):
5050
('validator_registry_delta_chain_tip', hash32), # For light clients to easily track delta
5151

5252
# Randomness and committees
53-
('randao_mix', hash32),
54-
('next_seed', hash32),
53+
('latest_randao_mixes', CountableList(hash32)),
54+
('latest_vdf_outputs', CountableList(hash32)),
5555
('shard_committees_at_slots', CountableList(CountableList((ShardCommittee)))),
5656
('persistent_committees', CountableList(CountableList(uint24))),
5757
('persistent_committee_reassignments', CountableList(ShardReassignmentRecord)),
@@ -82,15 +82,15 @@ def __init__(
8282
validator_registry_latest_change_slot: int,
8383
validator_registry_exit_count: int,
8484
validator_registry_delta_chain_tip: Hash32,
85-
randao_mix: Hash32,
86-
next_seed: Hash32,
8785
previous_justified_slot: int,
8886
justified_slot: int,
8987
justification_bitfield: int,
9088
finalized_slot: int,
9189
processed_pow_receipt_root: Hash32,
9290
validator_registry: Sequence[ValidatorRecord]=(),
9391
validator_balances: Sequence[int]=(),
92+
latest_randao_mixes: Sequence[Hash32]=(),
93+
latest_vdf_outputs: Sequence[Hash32]=(),
9494
shard_committees_at_slots: Sequence[Sequence[ShardCommittee]]=(),
9595
persistent_committees: Sequence[Sequence[int]]=(),
9696
persistent_committee_reassignments: Sequence[ShardReassignmentRecord]=(),
@@ -113,8 +113,8 @@ def __init__(
113113
validator_registry_exit_count=validator_registry_exit_count,
114114
validator_registry_delta_chain_tip=validator_registry_delta_chain_tip,
115115
# Randomness and committees
116-
randao_mix=randao_mix,
117-
next_seed=next_seed,
116+
latest_randao_mixes=latest_randao_mixes,
117+
latest_vdf_outputs=latest_vdf_outputs,
118118
shard_committees_at_slots=shard_committees_at_slots,
119119
persistent_committees=persistent_committees,
120120
persistent_committee_reassignments=persistent_committee_reassignments,

tests/beacon/conftest.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ def sample_beacon_state_params(sample_fork_data_params):
133133
'validator_registry_latest_change_slot': 10,
134134
'validator_registry_exit_count': 10,
135135
'validator_registry_delta_chain_tip': b'\x55' * 32,
136-
'randao_mix': b'\x55' * 32,
137-
'next_seed': b'\x55' * 32,
136+
'latest_randao_mixes': (),
137+
'latest_vdf_outputs': (),
138138
'shard_committees_at_slots': (),
139139
'persistent_committees': (),
140140
'persistent_committee_reassignments': (),
@@ -368,6 +368,11 @@ def latest_block_roots_length():
368368
return SERENITY_CONFIG.LATEST_BLOCK_ROOTS_LENGTH
369369

370370

371+
@pytest.fixture
372+
def latest_randao_mixes_length():
373+
return SERENITY_CONFIG.LATEST_RANDAO_MIXES_LENGTH
374+
375+
371376
@pytest.fixture
372377
def deposit_contract_address():
373378
return SERENITY_CONFIG.DEPOSIT_CONTRACT_ADDRESS

tests/beacon/state_machines/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def config(
1616
bls_withdrawal_prefix_byte,
1717
max_casper_votes,
1818
latest_block_roots_length,
19+
latest_randao_mixes_length,
1920
deposit_contract_address,
2021
deposit_contract_tree_depth,
2122
min_deposit,
@@ -49,6 +50,7 @@ def config(
4950
BLS_WITHDRAWAL_PREFIX_BYTE=bls_withdrawal_prefix_byte,
5051
MAX_CASPER_VOTES=max_casper_votes,
5152
LATEST_BLOCK_ROOTS_LENGTH=latest_block_roots_length,
53+
LATEST_RANDAO_MIXES_LENGTH=latest_randao_mixes_length,
5254
DEPOSIT_CONTRACT_ADDRESS=deposit_contract_address,
5355
DEPOSIT_CONTRACT_TREE_DEPTH=deposit_contract_tree_depth,
5456
MIN_DEPOSIT=min_deposit,

tests/beacon/types/test_states.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ def empty_beacon_state():
3434
validator_registry_latest_change_slot=10,
3535
validator_registry_exit_count=10,
3636
validator_registry_delta_chain_tip=b'\x55' * 32,
37-
randao_mix=b'\x55' * 32,
38-
next_seed=b'\x55' * 32,
37+
latest_randao_mixes=(),
38+
latest_vdf_outputs=(),
3939
shard_committees_at_slots=(),
4040
persistent_committees=(),
4141
persistent_committee_reassignments=(),

0 commit comments

Comments
 (0)