mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-01-12 03:34:20 +00:00
Make compute_new_state_root
a pure function
This commit is contained in:
parent
d311248d35
commit
2dbc333270
@ -340,9 +340,10 @@ It is useful to be able to run a state transition function (working on a copy of
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
def compute_new_state_root(state: BeaconState, block: BeaconBlock) -> Root:
|
def compute_new_state_root(state: BeaconState, block: BeaconBlock) -> Root:
|
||||||
process_slots(state, block.slot)
|
temp_state: BeaconState = state.copy()
|
||||||
process_block(state, block)
|
signed_block = SignedBeaconBlock(message=block)
|
||||||
return hash_tree_root(state)
|
temp_state = state_transition(temp_state, signed_block, validate_result=False)
|
||||||
|
return hash_tree_root(temp_state)
|
||||||
```
|
```
|
||||||
|
|
||||||
##### Signature
|
##### Signature
|
||||||
|
@ -246,6 +246,7 @@ def test_compute_new_state_root(spec, state):
|
|||||||
state_root = spec.compute_new_state_root(state, block)
|
state_root = spec.compute_new_state_root(state, block)
|
||||||
|
|
||||||
assert state_root != pre_state.hash_tree_root()
|
assert state_root != pre_state.hash_tree_root()
|
||||||
|
assert state == pre_state
|
||||||
|
|
||||||
# dumb verification
|
# dumb verification
|
||||||
spec.process_slots(post_state, block.slot)
|
spec.process_slots(post_state, block.slot)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user