From 79b6bc616d1ac6c6e2aa6864b2354190fc47534a Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Thu, 25 Jun 2020 10:58:04 +0800 Subject: [PATCH] PR feedback from danny --- specs/phase1/shard-transition.md | 2 +- .../pyspec/eth2spec/test/phase1/sanity/test_blocks.py | 8 ++++---- .../eth2spec/test/phase1/sanity/test_shard_blocks.py | 4 +--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/specs/phase1/shard-transition.md b/specs/phase1/shard-transition.md index 1ca5a9ab8..7deaf9f09 100644 --- a/specs/phase1/shard-transition.md +++ b/specs/phase1/shard-transition.md @@ -66,7 +66,7 @@ def verify_shard_block_signature(beacon_parent_state: BeaconState, ## Shard state transition function -The post-state corresponding to a pre-state `shard_state` and a signed block `signed_block` is defined as `shard_state_transition(state, signed_block)`. State transitions that trigger an unhandled exception (e.g. a failed `assert` or an out-of-range list access) are considered invalid. State transitions that cause a `uint64` overflow or underflow are also considered invalid. +The post-state corresponding to a pre-state `shard_state` and a signed block `signed_block` is defined as `shard_state_transition(shard_state, signed_block)`. State transitions that trigger an unhandled exception (e.g. a failed `assert` or an out-of-range list access) are considered invalid. State transitions that cause a `uint64` overflow or underflow are also considered invalid. ```python def shard_state_transition(shard_state: ShardState, diff --git a/tests/core/pyspec/eth2spec/test/phase1/sanity/test_blocks.py b/tests/core/pyspec/eth2spec/test/phase1/sanity/test_blocks.py index 3cb2fe6c0..2c391a660 100644 --- a/tests/core/pyspec/eth2spec/test/phase1/sanity/test_blocks.py +++ b/tests/core/pyspec/eth2spec/test/phase1/sanity/test_blocks.py @@ -48,10 +48,10 @@ def run_beacon_block_with_shard_blocks(spec, state, target_len_offset_slot, comm yield 'block', beacon_block yield 'post', None return - else: - state_transition_and_sign_block(spec, state, beacon_block) - yield 'block', beacon_block - yield 'post', None + + state_transition_and_sign_block(spec, state, beacon_block) + yield 'block', beacon_block + yield 'post', state for shard in range(spec.get_active_shard_count(state)): post_shard_state = state.shard_states[shard] diff --git a/tests/core/pyspec/eth2spec/test/phase1/sanity/test_shard_blocks.py b/tests/core/pyspec/eth2spec/test/phase1/sanity/test_shard_blocks.py index 4d07f340a..e8c5f91da 100644 --- a/tests/core/pyspec/eth2spec/test/phase1/sanity/test_shard_blocks.py +++ b/tests/core/pyspec/eth2spec/test/phase1/sanity/test_shard_blocks.py @@ -17,14 +17,12 @@ def run_shard_blocks(spec, shard_state, signed_shard_block, beacon_parent_state, validate=True, valid=True): pre_shard_state = shard_state.copy() + yield 'pre', pre_shard_state yield 'signed_shard_block', signed_shard_block yield 'validate', validate yield 'beacon_parent_state', beacon_parent_state - if validate is False: - beacon_parent_state = None - if not valid: expect_assertion_error(lambda: spec.shard_state_transition( shard_state, signed_shard_block, validate=validate, beacon_parent_state=beacon_parent_state)