Moves copy into SSZ container

This commit is contained in:
Carl Beekhuizen 2019-06-20 20:55:28 +02:00
parent 5f8edd6b55
commit c26fffc154
No known key found for this signature in database
GPG Key ID: D05CA176D0020646
3 changed files with 7 additions and 6 deletions

View File

@ -25,8 +25,6 @@ from dataclasses import (
field,
)
from copy import deepcopy
from eth2spec.utils.ssz.ssz_impl import (
hash_tree_root,
signing_root,
@ -60,8 +58,6 @@ from dataclasses import (
field,
)
from copy import deepcopy
from eth2spec.utils.ssz.ssz_impl import (
hash_tree_root,
signing_root,

View File

@ -86,7 +86,8 @@ def get_genesis_store(genesis_state: BeaconState) -> Store:
blocks={root: genesis_block},
states={root: genesis_state},
time=genesis_state.genesis_time,
justified_root=root, finalized_root=root,
justified_root=root,
finalized_root=root,
)
```
@ -143,7 +144,7 @@ def on_block(store: Store, block: BeaconBlock) -> None:
# Check block is a descendant of the finalized block
assert get_ancestor(store, signing_root(block), store.blocks[store.finalized_root].slot) == store.finalized_root
# Check block slot against Unix time
pre_state = deepcopy(store.states[block.parent_root])
pre_state = store.states[block.parent_root].copy()
assert store.time >= pre_state.genesis_time + block.slot * SECONDS_PER_SLOT
# Check the block is valid and compute the post-state
state = state_transition(pre_state, block)

View File

@ -1,3 +1,4 @@
import copy
from types import GeneratorType
from typing import (
List,
@ -151,6 +152,9 @@ class Container(object):
def __hash__(self):
return hash(self.hash_tree_root())
def copy(self):
return copy.deepcopy(self)
@classmethod
def get_fields_dict(cls):
return dict(cls.__annotations__)