Skip to content

Commit 346e8a3

Browse files
committed
Add constants
1 parent 01e9af2 commit 346e8a3

File tree

6 files changed

+194
-0
lines changed

6 files changed

+194
-0
lines changed

eth/beacon/state_machines/__init__.py

Whitespace-only changes.

eth/beacon/state_machines/configs.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from typing import (
2+
NamedTuple,
3+
)
4+
5+
from eth.typing import (
6+
Address,
7+
)
8+
9+
10+
BeaconConfig = NamedTuple(
11+
'BeaconConfig',
12+
(
13+
('SHARD_COUNT', int), # shards
14+
('DEPOSIT_SIZE', int), # ETH
15+
('MIN_ONLINE_DEPOSIT_SIZE', int), # ETH
16+
('DEPOSIT_CONTRACT_ADDRESS', Address),
17+
('TARGET_COMMITTEE_SIZE', int), # validators
18+
('GENESIS_TIME', int), # seconds
19+
('SLOT_DURATION', int), # seconds
20+
('CYCLE_LENGTH', int), # slots
21+
('MIN_VALIDATOR_SET_CHANGE_INTERVAL', int), # slots
22+
('SHARD_PERSISTENT_COMMITTEE_CHANGE_PERIOD', int), # slots
23+
('MIN_ATTESTATION_INCLUSION_DELAY', int), # slots
24+
('RANDAO_SLOTS_PER_LAYER', 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+
('MAX_VALIDATOR_CHURN_QUOTIENT', int),
34+
('POW_CONTRACT_MERKLE_TREE_DEPTH', int),
35+
('LOGOUT_MESSAGE', str),
36+
('INITIAL_FORK_VERSION', int),
37+
)
38+
)

eth/beacon/state_machines/forks/__init__.py

Whitespace-only changes.

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

Whitespace-only changes.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from eth.constants import (
2+
ZERO_ADDRESS,
3+
)
4+
from eth.beacon.state_machines.configs import BeaconConfig
5+
6+
7+
SERENITY_CONFIG = BeaconConfig(
8+
SHARD_COUNT=2**10, # = 1,024 shards
9+
DEPOSIT_SIZE=2**5, # = 32 ETH
10+
MIN_ONLINE_DEPOSIT_SIZE=2**4, # = 16 ETH
11+
DEPOSIT_CONTRACT_ADDRESS=ZERO_ADDRESS, # TODO: TBD
12+
TARGET_COMMITTEE_SIZE=2**8, # = 256 validators
13+
GENESIS_TIME=0, # TBD seconds
14+
SLOT_DURATION=6, # seconds
15+
CYCLE_LENGTH=2**6, # = 64 slots
16+
MIN_VALIDATOR_SET_CHANGE_INTERVAL=2**8, # = 256 slots
17+
SHARD_PERSISTENT_COMMITTEE_CHANGE_PERIOD=2**17, # = 131,072 slots
18+
MIN_ATTESTATION_INCLUSION_DELAY=2**2, # = 4 slots
19+
RANDAO_SLOTS_PER_LAYER=2**12, # = 4,096 slots
20+
SQRT_E_DROP_TIME=2**18, # = 262,144 slots
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**15, # = 32,768
28+
MAX_VALIDATOR_CHURN_QUOTIENT=2**5, # = 32
29+
POW_CONTRACT_MERKLE_TREE_DEPTH=2**5, # =32
30+
LOGOUT_MESSAGE="LOGOUT",
31+
INITIAL_FORK_VERSION=0,
32+
)

tests/beacon/conftest.py

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import eth.utils.bls as bls
44
from eth.utils.blake import blake
55

6+
from eth.beacon.state_machines.forks.serenity.configs import SERENITY_CONFIG
67

78
DEFAULT_SHUFFLING_SEED = b'\00' * 32
89
DEFAULT_RANDAO = b'\45' * 32
@@ -177,3 +178,126 @@ def num_validators():
177178
@pytest.fixture
178179
def init_validator_keys(pubkeys, num_validators):
179180
return pubkeys[:num_validators]
181+
182+
183+
#
184+
# config
185+
#
186+
@pytest.fixture
187+
def shard_count():
188+
return SERENITY_CONFIG.SHARD_COUNT
189+
190+
191+
@pytest.fixture
192+
def deposit_size():
193+
return SERENITY_CONFIG.DEPOSIT_SIZE
194+
195+
196+
@pytest.fixture
197+
def min_online_deposit_size():
198+
return SERENITY_CONFIG.MIN_ONLINE_DEPOSIT_SIZE
199+
200+
201+
@pytest.fixture
202+
def deposit_contract_address():
203+
return SERENITY_CONFIG.DEPOSIT_CONTRACT_ADDRESS
204+
205+
206+
@pytest.fixture
207+
def target_committee_size():
208+
return SERENITY_CONFIG.TARGET_COMMITTEE_SIZE
209+
210+
211+
@pytest.fixture
212+
def genesis_time():
213+
return SERENITY_CONFIG.GENESIS_TIME
214+
215+
216+
@pytest.fixture
217+
def slot_duration():
218+
return SERENITY_CONFIG.SLOT_DURATION
219+
220+
221+
@pytest.fixture
222+
def cycle_length():
223+
return SERENITY_CONFIG.CYCLE_LENGTH
224+
225+
226+
@pytest.fixture
227+
def min_validator_set_change_interval():
228+
return SERENITY_CONFIG.MIN_VALIDATOR_SET_CHANGE_INTERVAL
229+
230+
231+
@pytest.fixture
232+
def shard_persistent_committee_change_period():
233+
return SERENITY_CONFIG.SHARD_PERSISTENT_COMMITTEE_CHANGE_PERIOD
234+
235+
236+
@pytest.fixture
237+
def min_attestation_inclusion_delay():
238+
return SERENITY_CONFIG.MIN_ATTESTATION_INCLUSION_DELAY
239+
240+
241+
@pytest.fixture
242+
def randao_slots_per_layer():
243+
return SERENITY_CONFIG.RANDAO_SLOTS_PER_LAYER
244+
245+
246+
@pytest.fixture
247+
def sqrt_e_drop_time():
248+
return SERENITY_CONFIG.SQRT_E_DROP_TIME
249+
250+
251+
@pytest.fixture
252+
def withdrawals_per_cycle():
253+
return SERENITY_CONFIG.WITHDRAWALS_PER_CYCLE
254+
255+
256+
@pytest.fixture
257+
def min_withdrawal_period():
258+
return SERENITY_CONFIG.MIN_WITHDRAWAL_PERIOD
259+
260+
261+
@pytest.fixture
262+
def deletion_period():
263+
return SERENITY_CONFIG.DELETION_PERIOD
264+
265+
266+
@pytest.fixture
267+
def collective_penalty_calculation_period():
268+
return SERENITY_CONFIG.COLLECTIVE_PENALTY_CALCULATION_PERIOD
269+
270+
271+
@pytest.fixture
272+
def pow_receipt_root_voting_period():
273+
return SERENITY_CONFIG.POW_RECEIPT_ROOT_VOTING_PERIOD
274+
275+
276+
@pytest.fixture
277+
def slashing_whistleblower_reward_denominator():
278+
return SERENITY_CONFIG.SLASHING_WHISTLEBLOWER_REWARD_DENOMINATOR
279+
280+
281+
@pytest.fixture
282+
def base_reward_quotient():
283+
return SERENITY_CONFIG.BASE_REWARD_QUOTIENT
284+
285+
286+
@pytest.fixture
287+
def max_validator_churn_quotient():
288+
return SERENITY_CONFIG.MAX_VALIDATOR_CHURN_QUOTIENT
289+
290+
291+
@pytest.fixture
292+
def pow_contract_merkle_tree_depth():
293+
return SERENITY_CONFIG.POW_CONTRACT_MERKLE_TREE_DEPTH
294+
295+
296+
@pytest.fixture
297+
def logout_message():
298+
return SERENITY_CONFIG.LOGOUT_MESSAGE
299+
300+
301+
@pytest.fixture
302+
def initial_fork_version():
303+
return SERENITY_CONFIG.INITIAL_FORK_VERSION

0 commit comments

Comments
 (0)