Linted :)
This commit is contained in:
parent
229dfe81a6
commit
3e085947b7
|
@ -1,11 +1,5 @@
|
|||
from . import spec
|
||||
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
List
|
||||
)
|
||||
|
||||
from .spec import (
|
||||
BeaconState,
|
||||
BeaconBlock,
|
||||
|
@ -13,18 +7,14 @@ from .spec import (
|
|||
)
|
||||
|
||||
from eth2spec.phase0.state_transition import (
|
||||
expected_deposit_count,
|
||||
process_operation_type,
|
||||
process_operations as process_operations_phase0,
|
||||
process_block as process_block_phase0,
|
||||
process_epoch_transition as process_epoch_transition_phase0,
|
||||
state_transition_to as state_transition_to_phase0,
|
||||
state_transition as state_transition_phase0
|
||||
)
|
||||
|
||||
|
||||
def process_operations(state: BeaconState, block: BeaconBlock) -> None:
|
||||
process_operations_phase0(state, block)
|
||||
|
||||
|
||||
process_operation_type(
|
||||
state,
|
||||
block.body.custody_key_reveals,
|
||||
|
@ -39,6 +29,7 @@ def process_operations(state: BeaconState, block: BeaconBlock) -> None:
|
|||
spec.process_early_derived_secret_reveal,
|
||||
)
|
||||
|
||||
|
||||
def process_block(state: BeaconState,
|
||||
block: BeaconBlock,
|
||||
verify_state_root: bool=False) -> None:
|
||||
|
@ -50,6 +41,7 @@ def process_block(state: BeaconState,
|
|||
if verify_state_root:
|
||||
spec.verify_block_state_root(state, block)
|
||||
|
||||
|
||||
def process_epoch_transition(state: BeaconState) -> None:
|
||||
spec.process_justification_and_finalization(state)
|
||||
spec.process_crosslinks(state)
|
||||
|
@ -62,6 +54,7 @@ def process_epoch_transition(state: BeaconState) -> None:
|
|||
spec.process_final_updates(state)
|
||||
spec.after_process_final_updates(state)
|
||||
|
||||
|
||||
def state_transition_to(state: BeaconState, up_to: Slot) -> BeaconState:
|
||||
while state.slot < up_to:
|
||||
spec.cache_state(state)
|
||||
|
@ -74,4 +67,4 @@ def state_transition(state: BeaconState,
|
|||
block: BeaconBlock,
|
||||
verify_state_root: bool=False) -> BeaconState:
|
||||
state_transition_to(state, block.slot)
|
||||
process_block(state, block, verify_state_root)
|
||||
process_block(state, block, verify_state_root)
|
||||
|
|
|
@ -8,12 +8,13 @@ ZERO_CHUNK = b'\x00' * BYTES_PER_CHUNK
|
|||
|
||||
cached_typedefs = {}
|
||||
|
||||
|
||||
def SSZType(name, fields):
|
||||
class SSZObject():
|
||||
if name != None:
|
||||
if name is not None:
|
||||
__name__ = name
|
||||
__qualname__ = name
|
||||
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
for f, t in fields.items():
|
||||
if f not in kwargs:
|
||||
|
@ -32,7 +33,7 @@ def SSZType(name, fields):
|
|||
for field in self.fields:
|
||||
output.append(f'{field}: {repr(getattr(self, field))},')
|
||||
return "\n".join(output)
|
||||
|
||||
|
||||
def __repr__(self):
|
||||
return name + "(**{\n " + str(self).replace("\n", "\n ") + "\n})"
|
||||
|
||||
|
@ -43,17 +44,19 @@ def SSZType(name, fields):
|
|||
return hash_tree_root(self, self.__class__)
|
||||
|
||||
SSZObject.fields = fields
|
||||
|
||||
if name != None:
|
||||
|
||||
if name is not None:
|
||||
cached_typedefs[name] = SSZObject
|
||||
|
||||
return SSZObject
|
||||
|
||||
|
||||
def SSZTypeExtension(original_type, new_fields):
|
||||
typedef = cached_typedefs[original_type]
|
||||
typedef.fields.update(new_fields)
|
||||
return typedef
|
||||
|
||||
|
||||
class Vector():
|
||||
def __init__(self, items):
|
||||
self.items = items
|
||||
|
|
Loading…
Reference in New Issue