Skip to content

Commit a9127d2

Browse files
committed
Sync constants
1 parent b9fa7bf commit a9127d2

File tree

8 files changed

+175
-173
lines changed

8 files changed

+175
-173
lines changed

eth/beacon/helpers.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,20 @@ def get_block_hash(
7777
recent_block_hashes: Sequence[Hash32],
7878
current_block_slot_number: int,
7979
slot: int,
80-
cycle_length: int) -> Hash32:
80+
epoch_length: int) -> Hash32:
8181
"""
8282
Return the blockhash from ``ActiveState.recent_block_hashes`` by
8383
``current_block_slot_number``.
8484
"""
85-
if len(recent_block_hashes) != cycle_length * 2:
85+
if len(recent_block_hashes) != epoch_length * 2:
8686
raise ValueError(
87-
"Length of recent_block_hashes != cycle_length * 2"
87+
"Length of recent_block_hashes != epoch_length * 2"
8888
"\texpected: %s, found: %s" % (
89-
cycle_length * 2, len(recent_block_hashes)
89+
epoch_length * 2, len(recent_block_hashes)
9090
)
9191
)
9292

93-
slot_relative_position = current_block_slot_number - cycle_length * 2
93+
slot_relative_position = current_block_slot_number - epoch_length * 2
9494
return _get_element_from_recent_list(
9595
recent_block_hashes,
9696
slot,
@@ -104,7 +104,7 @@ def get_hashes_from_recent_block_hashes(
104104
current_block_slot_number: int,
105105
from_slot: int,
106106
to_slot: int,
107-
cycle_length: int) -> Iterable[Hash32]:
107+
epoch_length: int) -> Iterable[Hash32]:
108108
"""
109109
Returns the block hashes between ``from_slot`` and ``to_slot``.
110110
"""
@@ -113,24 +113,24 @@ def get_hashes_from_recent_block_hashes(
113113
recent_block_hashes,
114114
current_block_slot_number,
115115
slot,
116-
cycle_length,
116+
epoch_length,
117117
)
118118

119119

120120
@to_tuple
121121
def get_hashes_to_sign(recent_block_hashes: Sequence[Hash32],
122122
block: 'BaseBeaconBlock',
123-
cycle_length: int) -> Iterable[Hash32]:
123+
epoch_length: int) -> Iterable[Hash32]:
124124
"""
125125
Given the head block to attest to, collect the list of hashes to be
126126
signed in the attestation.
127127
"""
128128
yield from get_hashes_from_recent_block_hashes(
129129
recent_block_hashes,
130130
block.slot_number,
131-
from_slot=block.slot_number - cycle_length + 1,
131+
from_slot=block.slot_number - epoch_length + 1,
132132
to_slot=block.slot_number - 1,
133-
cycle_length=cycle_length,
133+
epoch_length=epoch_length,
134134
)
135135
yield block.hash
136136

@@ -139,17 +139,17 @@ def get_hashes_to_sign(recent_block_hashes: Sequence[Hash32],
139139
def get_signed_parent_hashes(recent_block_hashes: Sequence[Hash32],
140140
block: 'BaseBeaconBlock',
141141
attestation: 'AttestationRecord',
142-
cycle_length: int) -> Iterable[Hash32]:
142+
epoch_length: int) -> Iterable[Hash32]:
143143
"""
144144
Given an attestation and the block they were included in,
145145
the list of hashes that were included in the signature.
146146
"""
147147
yield from get_hashes_from_recent_block_hashes(
148148
recent_block_hashes,
149149
block.slot_number,
150-
from_slot=attestation.slot - cycle_length + 1,
150+
from_slot=attestation.slot - epoch_length + 1,
151151
to_slot=attestation.slot - len(attestation.oblique_parent_hashes),
152-
cycle_length=cycle_length,
152+
epoch_length=epoch_length,
153153
)
154154
yield from attestation.oblique_parent_hashes
155155

@@ -173,19 +173,19 @@ def get_new_recent_block_hashes(old_block_hashes: Sequence[Hash32],
173173
def get_shards_and_committees_for_slot(
174174
crystallized_state: 'CrystallizedState',
175175
slot: int,
176-
cycle_length: int) -> Iterable[ShardCommittee]:
176+
epoch_length: int) -> Iterable[ShardCommittee]:
177177
"""
178178
FIXME
179179
"""
180-
if len(crystallized_state.shard_committee_for_slots) != cycle_length * 2:
180+
if len(crystallized_state.shard_committee_for_slots) != epoch_length * 2:
181181
raise ValueError(
182-
"Length of shard_committee_for_slots != cycle_length * 2"
182+
"Length of shard_committee_for_slots != epoch_length * 2"
183183
"\texpected: %s, found: %s" % (
184-
cycle_length * 2, len(crystallized_state.shard_committee_for_slots)
184+
epoch_length * 2, len(crystallized_state.shard_committee_for_slots)
185185
)
186186
)
187187

188-
slot_relative_position = crystallized_state.last_state_recalc - cycle_length
188+
slot_relative_position = crystallized_state.last_state_recalc - epoch_length
189189

190190
yield from _get_element_from_recent_list(
191191
crystallized_state.shard_committee_for_slots,
@@ -197,7 +197,7 @@ def get_shards_and_committees_for_slot(
197197
@to_tuple
198198
def get_attestation_indices(crystallized_state: 'CrystallizedState',
199199
attestation: 'AttestationRecord',
200-
cycle_length: int) -> Iterable[int]:
200+
epoch_length: int) -> Iterable[int]:
201201
"""
202202
FIXME
203203
Return committee of the given attestation.
@@ -207,7 +207,7 @@ def get_attestation_indices(crystallized_state: 'CrystallizedState',
207207
shards_and_committees_for_slot = get_shards_and_committees_for_slot(
208208
crystallized_state,
209209
attestation.slot,
210-
cycle_length,
210+
epoch_length,
211211
)
212212

213213
for shard_committee in shards_and_committees_for_slot:
@@ -248,7 +248,7 @@ def get_new_shuffling(*,
248248
seed: Hash32,
249249
validators: Sequence['ValidatorRecord'],
250250
crosslinking_start_shard: int,
251-
cycle_length: int,
251+
epoch_length: int,
252252
target_committee_size: int,
253253
shard_count: int) -> Iterable[Iterable[ShardCommittee]]:
254254
"""
@@ -297,14 +297,14 @@ def get_new_shuffling(*,
297297
active_validators_size = len(active_validators)
298298
committees_per_slot = clamp(
299299
1,
300-
shard_count // cycle_length,
301-
active_validators_size // cycle_length // target_committee_size,
300+
shard_count // epoch_length,
301+
active_validators_size // epoch_length // target_committee_size,
302302
)
303303
# Shuffle with seed
304304
shuffled_active_validator_indices = shuffle(active_validators, seed)
305305

306306
# Split the shuffled list into epoch_length pieces
307-
validators_per_slot = split(shuffled_active_validator_indices, cycle_length)
307+
validators_per_slot = split(shuffled_active_validator_indices, epoch_length)
308308
for index, slot_indices in enumerate(validators_per_slot):
309309
# Split the shuffled list into committees_per_slot pieces
310310
shard_indices = split(slot_indices, committees_per_slot)
@@ -321,11 +321,11 @@ def get_new_shuffling(*,
321321
#
322322
def get_block_committees_info(parent_block: 'BaseBeaconBlock',
323323
crystallized_state: 'CrystallizedState',
324-
cycle_length: int) -> BlockCommitteesInfo:
324+
epoch_length: int) -> BlockCommitteesInfo:
325325
shards_and_committees = get_shards_and_committees_for_slot(
326326
crystallized_state,
327327
parent_block.slot_number,
328-
cycle_length,
328+
epoch_length,
329329
)
330330
"""
331331
FIXME

eth/beacon/state_machines/configs.py

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,36 @@
1010
BeaconConfig = NamedTuple(
1111
'BeaconConfig',
1212
(
13-
('SHARD_COUNT', int), # shards
14-
('DEPOSIT_SIZE', int), # ETH
15-
('MIN_TOPUP_SIZE', int), # ETH
16-
('MIN_ONLINE_DEPOSIT_SIZE', int), # ETH
13+
# Misc
14+
('SHARD_COUNT', int),
15+
('TARGET_COMMITTEE_SIZE', int),
16+
('MAX_ATTESTATIONS_PER_BLOCK', int),
17+
('MIN_BALANCE', int),
18+
('MAX_BALANCE_CHURN_QUOTIENT', int),
19+
('GWEI_PER_ETH', int),
20+
('BEACON_CHAIN_SHARD_NUMBER', int),
21+
('BLS_WITHDRAWAL_CREDENTIALS', bytes),
22+
# Deposit contract
1723
('DEPOSIT_CONTRACT_ADDRESS', Address),
18-
('DEPOSITS_FOR_CHAIN_START', int), # deposits
19-
('TARGET_COMMITTEE_SIZE', int), # validators
20-
('SLOT_DURATION', int), # seconds
21-
('CYCLE_LENGTH', int), # slots
22-
('MIN_VALIDATOR_SET_CHANGE_INTERVAL', int), # slots
23-
('SHARD_PERSISTENT_COMMITTEE_CHANGE_PERIOD', int), # slots
24-
('MIN_ATTESTATION_INCLUSION_DELAY', int), # slots
25-
('SQRT_E_DROP_TIME', int), # slots
26-
('WITHDRAWALS_PER_CYCLE', int), # validators
27-
('MIN_WITHDRAWAL_PERIOD', int), # slots
28-
('DELETION_PERIOD', int), # slots
29-
('COLLECTIVE_PENALTY_CALCULATION_PERIOD', int), # slots
30-
('POW_RECEIPT_ROOT_VOTING_PERIOD', int), # slots
31-
('SLASHING_WHISTLEBLOWER_REWARD_DENOMINATOR', int),
32-
('BASE_REWARD_QUOTIENT', int),
33-
('INCLUDER_REWARD_SHARE_QUOTIENT', int),
34-
('MAX_VALIDATOR_CHURN_QUOTIENT', int),
35-
('POW_CONTRACT_MERKLE_TREE_DEPTH', int),
36-
('MAX_ATTESTATION_COUNT', int),
24+
('DEPOSIT_CONTRACT_TREE_DEPTH', int),
25+
('MIN_DEPOSIT', int),
26+
('MAX_DEPOSIT', int),
27+
# Initial values
3728
('INITIAL_FORK_VERSION', int),
29+
('INITIAL_SLOT_NUMBER', int),
30+
# Time parameters
31+
('SLOT_DURATION', int),
32+
('MIN_ATTESTATION_INCLUSION_DELAY', int),
33+
('EPOCH_LENGTH', int),
34+
('MIN_VALIDATOR_REGISTRY_CHANGE_INTERVAL', int),
35+
('POW_RECEIPT_ROOT_VOTING_PERIOD', int),
36+
('SHARD_PERSISTENT_COMMITTEE_CHANGE_PERIOD', int),
37+
('COLLECTIVE_PENALTY_CALCULATION_PERIOD', int),
38+
('ZERO_BALANCE_VALIDATOR_TTL', int),
39+
# Reward and penalty quotients
40+
('BASE_REWARD_QUOTIENT', int),
41+
('WHISTLEBLOWER_REWARD_QUOTIENT', int),
42+
('INCLUDER_REWARD_QUOTIENT', int),
43+
('INACTIVITY_PENALTY_QUOTIENT', int),
3844
)
3945
)

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

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,35 @@
55

66

77
SERENITY_CONFIG = BeaconConfig(
8-
SHARD_COUNT=2**10, # = 1,024 shards
9-
DEPOSIT_SIZE=2**5, # = 32 ETH
10-
MIN_TOPUP_SIZE=1, # 1 ETH
11-
MIN_ONLINE_DEPOSIT_SIZE=2**4, # = 16 ETH
12-
DEPOSIT_CONTRACT_ADDRESS=ZERO_ADDRESS, # TODO: TBD
13-
DEPOSITS_FOR_CHAIN_START=2**14, # = 16,384 deposits
14-
TARGET_COMMITTEE_SIZE=2**8, # = 256 validators
15-
SLOT_DURATION=6, # seconds
16-
CYCLE_LENGTH=2**6, # = 64 slots
17-
MIN_VALIDATOR_SET_CHANGE_INTERVAL=2**8, # = 256 slots
18-
SHARD_PERSISTENT_COMMITTEE_CHANGE_PERIOD=2**17, # = 131,072 slots
19-
MIN_ATTESTATION_INCLUSION_DELAY=2**2, # = 4 slots
20-
SQRT_E_DROP_TIME=2**11, # = 2,048 cycles
21-
WITHDRAWALS_PER_CYCLE=2**2, # = 4 validators
22-
MIN_WITHDRAWAL_PERIOD=2**13, # = 8,192 slots
23-
DELETION_PERIOD=2**22, # = 4,194,304 slots
24-
COLLECTIVE_PENALTY_CALCULATION_PERIOD=2**20, # = 1,048,576 slots
25-
POW_RECEIPT_ROOT_VOTING_PERIOD=2**10, # = 1024
26-
SLASHING_WHISTLEBLOWER_REWARD_DENOMINATOR=2**9, # = 512
27-
BASE_REWARD_QUOTIENT=2**11, # = 2,048
28-
INCLUDER_REWARD_SHARE_QUOTIENT=2**3, # = 8
29-
MAX_VALIDATOR_CHURN_QUOTIENT=2**5, # = 32
30-
POW_CONTRACT_MERKLE_TREE_DEPTH=2**5, # =32
31-
MAX_ATTESTATION_COUNT=2**7, # 128
8+
# Misc
9+
SHARD_COUNT=2**1, # (= 1,024) shards
10+
TARGET_COMMITTEE_SIZE=2**8, # (= 256) validators
11+
MAX_ATTESTATIONS_PER_BLOCK=2**7, # (= 128) attestations
12+
MIN_BALANCE=2**4, # (= 16) ETH
13+
MAX_BALANCE_CHURN_QUOTIENT=2**5, # (= 32)
14+
GWEI_PER_ETH=10**9, # Gwei/ETH
15+
BEACON_CHAIN_SHARD_NUMBER=2**64 - 1,
16+
BLS_WITHDRAWAL_CREDENTIALS=b'\x00',
17+
# Deposit contract
18+
DEPOSIT_CONTRACT_ADDRESS=ZERO_ADDRESS, # TBD
19+
DEPOSIT_CONTRACT_TREE_DEPTH=2**5, # (= 32)
20+
MIN_DEPOSIT=2**0, # (= 1) ETH
21+
MAX_DEPOSIT=2**5, # (= 32) ETH
22+
# Initial values
3223
INITIAL_FORK_VERSION=0,
24+
INITIAL_SLOT_NUMBER=0,
25+
# Time parameters
26+
SLOT_DURATION=6, # seconds
27+
MIN_ATTESTATION_INCLUSION_DELAY=2**2, # (= 4) slots
28+
EPOCH_LENGTH=2**6, # (= 64) slots
29+
MIN_VALIDATOR_REGISTRY_CHANGE_INTERVAL=2**8, # (= 256) slots
30+
POW_RECEIPT_ROOT_VOTING_PERIOD=2**10, # (= 1,024) slots
31+
SHARD_PERSISTENT_COMMITTEE_CHANGE_PERIOD=2**17, # (= 131,072) slots
32+
COLLECTIVE_PENALTY_CALCULATION_PERIOD=2**20, # (= 1,048,576) slots
33+
ZERO_BALANCE_VALIDATOR_TTL=2**22, # (= 4,194,304) slots
34+
# Reward and penalty quotients
35+
BASE_REWARD_QUOTIENT=2**11, # (= 2,048)
36+
WHISTLEBLOWER_REWARD_QUOTIENT=2**9, # (= 512)
37+
INCLUDER_REWARD_QUOTIENT=2**3, # (= 8)
38+
INACTIVITY_PENALTY_QUOTIENT=2**34, # (= 131,072)
3339
)

eth/beacon/types/deposit_parameters_records.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
)
88
import rlp
99
from rlp.sedes import (
10-
binary,
1110
CountableList,
1211
)
1312

0 commit comments

Comments
 (0)