PR feedback from danny

This commit is contained in:
Hsiao-Wei Wang 2020-06-25 10:58:04 +08:00
parent 661959c13e
commit 79b6bc616d
No known key found for this signature in database
GPG Key ID: 95B070122902DEA4
3 changed files with 6 additions and 8 deletions

View File

@ -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,

View File

@ -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]

View File

@ -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)