From d15e5c78a9a296c2ebe641034c3a3998e9a9c87f Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Thu, 7 Mar 2019 17:20:50 -0700 Subject: [PATCH] changes from https://github.com/ethereum/eth2.0-specs/pull/732 --- spec_pythonizer/sanity_check.py | 4 ++-- spec_pythonizer/spec.md | 8 ++++---- spec_pythonizer/state_transition.py | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec_pythonizer/sanity_check.py b/spec_pythonizer/sanity_check.py index 3fc4df42..c3667603 100644 --- a/spec_pythonizer/sanity_check.py +++ b/spec_pythonizer/sanity_check.py @@ -41,7 +41,7 @@ advance_slot, process_block, state_transition, - store_state_root, + cache_state_root, verify_merkle_branch, ) from utils.merkle_normal import ( @@ -169,7 +169,7 @@ def build_attestation_data(state, slot, shard): def test_slot_transition(state): test_state = deepcopy(state) - store_state_root(test_state) + cache_state_root(test_state) advance_slot(test_state) assert test_state.slot == state.slot + 1 assert get_state_root(test_state, state.slot) == state.hash_tree_root() diff --git a/spec_pythonizer/spec.md b/spec_pythonizer/spec.md index d11d4b1f..05c36c67 100644 --- a/spec_pythonizer/spec.md +++ b/spec_pythonizer/spec.md @@ -1680,7 +1680,7 @@ _Note_: If there are skipped slots between a block and its parent block, run the At every `slot > GENESIS_SLOT` run the following function: ```python -def store_state_root(state: BeaconState) -> None: +def cache_state_root(state: BeaconState) -> None: state.latest_state_roots[state.slot % SLOTS_PER_HISTORICAL_ROOT] = hash_tree_root(state) ``` @@ -2146,9 +2146,9 @@ def process_slashings(state: BeaconState) -> None: total_balance = get_total_balance(state, active_validator_indices) # Compute `total_penalties` - epoch_index = current_epoch % LATEST_SLASHED_EXIT_LENGTH - total_at_start = state.latest_slashed_balances[(epoch_index + 1) % LATEST_SLASHED_EXIT_LENGTH] - total_at_end = state.latest_slashed_balances[epoch_index] + total_at_start = state.latest_slashed_balances[(current_epoch + 1) % LATEST_SLASHED_EXIT_LENGTH] + total_at_end = state.latest_slashed_balances[current_epoch % LATEST_SLASHED_EXIT_LENGTH] + total_penalties = total_at_end - total_at_start for index, validator in enumerate(state.validator_registry): diff --git a/spec_pythonizer/state_transition.py b/spec_pythonizer/state_transition.py index 3bd41583..db5758be 100644 --- a/spec_pythonizer/state_transition.py +++ b/spec_pythonizer/state_transition.py @@ -76,7 +76,7 @@ def state_transition(state: BeaconState, block: BeaconBlock, verify_state_root: bool=False) -> BeaconState: while state.slot < block.slot: - store_state_root(state) + cache_state_root(state) if (state.slot + 1) % SLOTS_PER_EPOCH == 0: process_epoch_transition(state) advance_slot(state)