Make phase0 pass
This commit is contained in:
parent
f2c33529df
commit
7a366828ba
|
@ -13,6 +13,7 @@ from typing import (
|
||||||
|
|
||||||
PHASE0_IMPORTS = '''from typing import (
|
PHASE0_IMPORTS = '''from typing import (
|
||||||
Any,
|
Any,
|
||||||
|
Callable,
|
||||||
Dict,
|
Dict,
|
||||||
List,
|
List,
|
||||||
Set,
|
Set,
|
||||||
|
@ -39,6 +40,7 @@ from eth2spec.utils.hash_function import hash
|
||||||
'''
|
'''
|
||||||
PHASE1_IMPORTS = '''from typing import (
|
PHASE1_IMPORTS = '''from typing import (
|
||||||
Any,
|
Any,
|
||||||
|
Callable,
|
||||||
Dict,
|
Dict,
|
||||||
List,
|
List,
|
||||||
Set,
|
Set,
|
||||||
|
|
|
@ -1634,15 +1634,15 @@ def process_operations(state: BeaconState, body: BeaconBlockBody) -> None:
|
||||||
assert len(body.deposits) == min(MAX_DEPOSITS, state.latest_eth1_data.deposit_count - state.deposit_index)
|
assert len(body.deposits) == min(MAX_DEPOSITS, state.latest_eth1_data.deposit_count - state.deposit_index)
|
||||||
# Verify that there are no duplicate transfers
|
# Verify that there are no duplicate transfers
|
||||||
assert len(body.transfers) == len(set(body.transfers))
|
assert len(body.transfers) == len(set(body.transfers))
|
||||||
|
all_operations = [
|
||||||
for operations, max_operations, function in (
|
|
||||||
(body.proposer_slashings, MAX_PROPOSER_SLASHINGS, process_proposer_slashing),
|
(body.proposer_slashings, MAX_PROPOSER_SLASHINGS, process_proposer_slashing),
|
||||||
(body.attester_slashings, MAX_ATTESTER_SLASHINGS, process_attester_slashing),
|
(body.attester_slashings, MAX_ATTESTER_SLASHINGS, process_attester_slashing),
|
||||||
(body.attestations, MAX_ATTESTATIONS, process_attestation),
|
(body.attestations, MAX_ATTESTATIONS, process_attestation),
|
||||||
(body.deposits, MAX_DEPOSITS, process_deposit),
|
(body.deposits, MAX_DEPOSITS, process_deposit),
|
||||||
(body.voluntary_exits, MAX_VOLUNTARY_EXITS, process_voluntary_exit),
|
(body.voluntary_exits, MAX_VOLUNTARY_EXITS, process_voluntary_exit),
|
||||||
(body.transfers, MAX_TRANSFERS, process_transfer),
|
(body.transfers, MAX_TRANSFERS, process_transfer),
|
||||||
):
|
] # type: List[Tuple[List[Container], int, Callable]]
|
||||||
|
for operations, max_operations, function in all_operations:
|
||||||
assert len(operations) <= max_operations
|
assert len(operations) <= max_operations
|
||||||
for operation in operations:
|
for operation in operations:
|
||||||
function(state, operation)
|
function(state, operation)
|
||||||
|
|
|
@ -414,12 +414,12 @@ class Bytes96(BytesN):
|
||||||
# SSZ Defaults
|
# SSZ Defaults
|
||||||
# -----------------------------
|
# -----------------------------
|
||||||
def get_zero_value(typ):
|
def get_zero_value(typ):
|
||||||
if is_list_type(typ):
|
if is_uint_type(typ):
|
||||||
|
return uint64(0)
|
||||||
|
elif is_list_type(typ):
|
||||||
return []
|
return []
|
||||||
elif is_bool_type(typ):
|
elif is_bool_type(typ):
|
||||||
return False
|
return False
|
||||||
elif is_uint_type(typ):
|
|
||||||
return uint64(0)
|
|
||||||
elif is_vector_type(typ):
|
elif is_vector_type(typ):
|
||||||
return typ()
|
return typ()
|
||||||
elif is_bytesn_type(typ):
|
elif is_bytesn_type(typ):
|
||||||
|
@ -437,12 +437,12 @@ def get_zero_value(typ):
|
||||||
|
|
||||||
|
|
||||||
def infer_type(obj):
|
def infer_type(obj):
|
||||||
if isinstance(obj, int):
|
if is_uint_type(obj.__class__):
|
||||||
|
return obj.__class__
|
||||||
|
elif isinstance(obj, int):
|
||||||
return uint64
|
return uint64
|
||||||
elif isinstance(obj, list):
|
elif isinstance(obj, list):
|
||||||
return List[infer_type(obj[0])]
|
return List[infer_type(obj[0])]
|
||||||
elif is_uint_type(obj.__class__):
|
|
||||||
return obj.__class__
|
|
||||||
elif isinstance(obj, (Vector, Container, bool, BytesN, bytes)):
|
elif isinstance(obj, (Vector, Container, bool, BytesN, bytes)):
|
||||||
return obj.__class__
|
return obj.__class__
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue