Skip to content

Commit

Permalink
Merge pull request #1015 from ethereum/JustinDrake-patch-11
Browse files Browse the repository at this point in the history
Remove get_state_root from state transition doc
  • Loading branch information
djrtwo committed May 1, 2019
2 parents 1bb9397 + 6242e54 commit 715dc32
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
13 changes: 0 additions & 13 deletions specs/core/0_beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
- [`get_attestation_slot`](#get_attestation_slot)
- [`get_block_root_at_slot`](#get_block_root_at_slot)
- [`get_block_root`](#get_block_root)
- [`get_state_root`](#get_state_root)
- [`get_randao_mix`](#get_randao_mix)
- [`get_active_index_root`](#get_active_index_root)
- [`generate_seed`](#generate_seed)
Expand Down Expand Up @@ -793,18 +792,6 @@ def get_block_root(state: BeaconState,
return get_block_root_at_slot(state, get_epoch_start_slot(epoch))
```

### `get_state_root`

```python
def get_state_root(state: BeaconState,
slot: Slot) -> Bytes32:
"""
Return the state root at a recent ``slot``.
"""
assert slot < state.slot <= slot + SLOTS_PER_HISTORICAL_ROOT
return state.latest_state_roots[slot % SLOTS_PER_HISTORICAL_ROOT]
```

### `get_randao_mix`

```python
Expand Down
8 changes: 8 additions & 0 deletions test_libs/pyspec/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,3 +412,11 @@ def next_epoch(state):
block.slot += spec.SLOTS_PER_EPOCH - (state.slot % spec.SLOTS_PER_EPOCH)
state_transition(state, block)
return block


def get_state_root(state, slot) -> bytes:
"""
Return the state root at a recent ``slot``.
"""
assert slot < state.slot <= slot + spec.SLOTS_PER_HISTORICAL_ROOT
return state.latest_state_roots[slot % spec.SLOTS_PER_HISTORICAL_ROOT]
3 changes: 2 additions & 1 deletion test_libs/pyspec/tests/test_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from eth2spec.phase0.spec import (
# constants
ZERO_HASH,
SLOTS_PER_HISTORICAL_ROOT,
# SSZ
Deposit,
Transfer,
Expand All @@ -17,7 +18,6 @@
get_active_validator_indices,
get_beacon_proposer_index,
get_block_root_at_slot,
get_state_root,
get_current_epoch,
get_domain,
advance_slot,
Expand All @@ -38,6 +38,7 @@
build_deposit_data,
build_empty_block_for_next_slot,
fill_aggregate_attestation,
get_state_root,
get_valid_attestation,
get_valid_attester_slashing,
get_valid_proposer_slashing,
Expand Down

0 comments on commit 715dc32

Please sign in to comment.