From a0c2f5c6b5578d3ee09b155fb487ab739e22195a Mon Sep 17 00:00:00 2001 From: protolambda Date: Thu, 27 Jun 2019 01:57:30 +0200 Subject: [PATCH] fix genesis testing code, add missing constant temporarily, fix py Generator/map/list problems --- specs/core/0_beacon-chain.md | 6 ++++-- .../pyspec/eth2spec/test/genesis/test_genesis_trigger.py | 3 ++- test_libs/pyspec/eth2spec/test/helpers/deposits.py | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index b0490cba5..1ff1d58b3 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -1137,14 +1137,16 @@ When `is_genesis_trigger(deposits, time) is True` for the first time let: ```python def is_genesis_trigger(deposits: List[Deposit, 2**DEPOSIT_CONTRACT_TREE_DEPTH], time: uint64) -> bool: + SECONDS_PER_DAY = 86400 # Do not deploy too early if time - time % SECONDS_PER_DAY + 2 * SECONDS_PER_DAY < MIN_GENESIS_TIME: return False # Initialize deposit root state = BeaconState() - state.eth1_data.deposit_root = hash_tree_root(map(deposits, lambda deposit: deposit.data)) - + state.eth1_data.deposit_root = hash_tree_root( + Vector[DepositData, len(deposits)](list(map(lambda deposit: deposit.data, deposits))) + ) # Process deposits for deposit in deposits: process_deposit(state, deposit) diff --git a/test_libs/pyspec/eth2spec/test/genesis/test_genesis_trigger.py b/test_libs/pyspec/eth2spec/test/genesis/test_genesis_trigger.py index 873638dc9..9425a1750 100644 --- a/test_libs/pyspec/eth2spec/test/genesis/test_genesis_trigger.py +++ b/test_libs/pyspec/eth2spec/test/genesis/test_genesis_trigger.py @@ -26,7 +26,8 @@ def test_is_genesis_trigger_false(spec): def test_is_genesis_trigger_true(spec): deposit_count = spec.GENESIS_ACTIVE_VALIDATOR_COUNT genesis_deposits, deposit_root = prepare_genesis_deposits(spec, deposit_count, spec.MAX_EFFECTIVE_BALANCE) - genesis_time = 1546300800 + SECONDS_PER_DAY = 86400 + genesis_time = 1578009600 - 2 * SECONDS_PER_DAY yield "deposits", genesis_deposits yield "time", genesis_time diff --git a/test_libs/pyspec/eth2spec/test/helpers/deposits.py b/test_libs/pyspec/eth2spec/test/helpers/deposits.py index eea019e8b..bda4f1699 100644 --- a/test_libs/pyspec/eth2spec/test/helpers/deposits.py +++ b/test_libs/pyspec/eth2spec/test/helpers/deposits.py @@ -82,7 +82,7 @@ def prepare_genesis_deposits(spec, genesis_validator_count, amount, signed=False tree = calc_merkle_tree_from_leaves(tuple(deposit_data_leaves)) root = get_merkle_root((tuple(deposit_data_leaves))) - genesis_deposits = ( + genesis_deposits = list( spec.Deposit(proof=list(get_merkle_proof(tree, item_index=index)), data=deposit_data) for index, deposit_data in enumerate(genesis_deposit_data_list) )