From d90d56c610e8b58dc697c2dc92f9c1608c974520 Mon Sep 17 00:00:00 2001 From: protolambda Date: Tue, 25 Jun 2019 18:42:34 +0200 Subject: [PATCH 1/3] Change uint aliases to just be subclasses, do not override init with no-op --- scripts/build_spec.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/scripts/build_spec.py b/scripts/build_spec.py index d67c0e5c6..99c5cd69d 100644 --- a/scripts/build_spec.py +++ b/scripts/build_spec.py @@ -130,11 +130,7 @@ def objects_to_spec(functions: Dict[str, str], new_type_definitions = ( '\n\n'.join( [ - f"class {key}({value}):\n" - f" def __init__(self, _x: {value}) -> None:\n" - f" ...\n" - if value.startswith("uint") - else f"class {key}({value}):\n pass\n" + f"class {key}({value}):\n pass\n" for key, value in custom_types.items() ] ) From 3b5c7f243a4ec6555ea9f762411c8541f7c20e3a Mon Sep 17 00:00:00 2001 From: protolambda Date: Tue, 25 Jun 2019 19:32:49 +0200 Subject: [PATCH 2/3] type hint uint input --- test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py b/test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py index 6079f2866..58e66ca68 100644 --- a/test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py +++ b/test_libs/pyspec/eth2spec/utils/ssz/ssz_typing.py @@ -34,7 +34,7 @@ class BasicValue(int, SSZValue, metaclass=BasicType): class Bool(BasicValue): # can't subclass bool. byte_len = 1 - def __new__(cls, value, *args, **kwargs): + def __new__(cls, value: int): # int value, but can be any subclass of int (bool, Bit, Bool, etc...) if value < 0 or value > 1: raise ValueError(f"value {value} out of bounds for bit") return super().__new__(cls, value) @@ -54,7 +54,7 @@ class Bit(Bool): class uint(BasicValue, metaclass=BasicType): - def __new__(cls, value, *args, **kwargs): + def __new__(cls, value: int): if value < 0: raise ValueError("unsigned types must not be negative") if cls.byte_len and value.bit_length() > (cls.byte_len << 3): From 2c6f4f2597b3a6e821b03007de329058871f1d3f Mon Sep 17 00:00:00 2001 From: protolambda Date: Tue, 25 Jun 2019 19:33:24 +0200 Subject: [PATCH 3/3] update validator_registry -> validators missed case --- specs/core/0_beacon-chain.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/core/0_beacon-chain.md b/specs/core/0_beacon-chain.md index 99425c6c2..56a6fd06a 100644 --- a/specs/core/0_beacon-chain.md +++ b/specs/core/0_beacon-chain.md @@ -1142,7 +1142,7 @@ def is_genesis_trigger(deposits: Sequence[Deposit], timestamp: uint64) -> bool: # Count active validators at genesis active_validator_count = 0 - for validator in state.validator_registry: + for validator in state.validators: if validator.effective_balance == MAX_EFFECTIVE_BALANCE: active_validator_count += 1