Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
djrtwo committed Mar 8, 2019
1 parent 9ffb19c commit d15e5c7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions spec_pythonizer/sanity_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
advance_slot,
process_block,
state_transition,
store_state_root,
cache_state_root,
verify_merkle_branch,
)
from utils.merkle_normal import (
Expand Down Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions spec_pythonizer/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```

Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion spec_pythonizer/state_transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d15e5c7

Please sign in to comment.