From cf18b040b4fbac21b469a1000deb44f237287c57 Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Wed, 22 Jan 2020 07:24:15 -0700 Subject: [PATCH 1/2] fix default value in compute_domain --- specs/phase0/beacon-chain.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/specs/phase0/beacon-chain.md b/specs/phase0/beacon-chain.md index 503286e48..478a2daa1 100644 --- a/specs/phase0/beacon-chain.md +++ b/specs/phase0/beacon-chain.md @@ -788,10 +788,12 @@ def compute_activation_exit_epoch(epoch: Epoch) -> Epoch: #### `compute_domain` ```python -def compute_domain(domain_type: DomainType, fork_version: Version=GENESIS_FORK_VERSION) -> Domain: +def compute_domain(domain_type: DomainType, fork_version: Version=None) -> Domain: """ Return the domain for the ``domain_type`` and ``fork_version``. """ + if fork_version is None: + fork_version = GENESIS_FORK_VERSION return Domain(domain_type + fork_version) ``` From e821476c07560c8810acc768bb30a7abd2d00e2b Mon Sep 17 00:00:00 2001 From: Danny Ryan Date: Wed, 22 Jan 2020 11:27:45 -0700 Subject: [PATCH 2/2] explicitly use Optiona type for fork_version in compute_domain Co-Authored-By: Carl Beekhuizen --- scripts/build_spec.py | 2 +- specs/phase0/beacon-chain.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build_spec.py b/scripts/build_spec.py index 114832bc2..16dd0d21d 100644 --- a/scripts/build_spec.py +++ b/scripts/build_spec.py @@ -31,7 +31,7 @@ from eth2spec.utils.hash_function import hash SSZObject = TypeVar('SSZObject', bound=SSZType) ''' PHASE1_IMPORTS = '''from typing import ( - Any, Dict, Set, Sequence, MutableSequence, NewType, Tuple, Union, TypeVar + Any, Dict, Set, Sequence, MutableSequence, NewType, Optional, Tuple, Union, TypeVar ) from math import ( log2, diff --git a/specs/phase0/beacon-chain.md b/specs/phase0/beacon-chain.md index 478a2daa1..7f2e873bf 100644 --- a/specs/phase0/beacon-chain.md +++ b/specs/phase0/beacon-chain.md @@ -788,7 +788,7 @@ def compute_activation_exit_epoch(epoch: Epoch) -> Epoch: #### `compute_domain` ```python -def compute_domain(domain_type: DomainType, fork_version: Version=None) -> Domain: +def compute_domain(domain_type: DomainType, fork_version: Optional[Version]=None) -> Domain: """ Return the domain for the ``domain_type`` and ``fork_version``. """