Apply suggestions from code review

Co-Authored-By: Carl Beekhuizen <carl@ethereum.org>
This commit is contained in:
Danny Ryan 2019-08-01 13:39:32 -06:00 committed by Hsiao-Wei Wang
parent 2ae7323183
commit 6560bc42d2
No known key found for this signature in database
GPG Key ID: 95B070122902DEA4
1 changed files with 8 additions and 8 deletions

View File

@ -30,9 +30,9 @@
```python ```python
class ShardReceiptProof(Container): class ShardReceiptProof(Container):
shard: Shard shard: Shard
proof: List[Hash, PLACEHOLDER] proof: List[Hash, PLACEHOLDER]
receipt: List[ShardReceiptDelta, PLACEHOLDER] receipt: List[ShardReceiptDelta, PLACEHOLDER]
``` ```
## Helpers ## Helpers
@ -107,9 +107,9 @@ def compute_historical_state_generalized_index(earlier: ShardSlot, later: ShardS
""" """
o = GeneralizedIndex(1) o = GeneralizedIndex(1)
for i in range(63, -1, -1): for i in range(63, -1, -1):
if (later-1) & 2**i > (earlier-1) & 2**i: if (later - 1) & 2**i > (earlier - 1) & 2**i:
later = later - ((later-1) % 2**i) - 1 later = later - ((later - 1) % 2**i) - 1
o = concat_generalized_indices(o, get_generalized_index(ShardState, 'history_acc', i)) o = concat_generalized_indices(o, get_generalized_index(ShardState, 'history_acc', i))
return o return o
``` ```
@ -136,8 +136,8 @@ def process_shard_receipt(state: BeaconState, receipt_proof: ShardReceiptProof):
first_slot_in_last_crosslink = state.current_crosslinks[receipt_proof.shard].start_epoch * SLOTS_PER_EPOCH first_slot_in_last_crosslink = state.current_crosslinks[receipt_proof.shard].start_epoch * SLOTS_PER_EPOCH
gindex = concat_generalized_indices( gindex = concat_generalized_indices(
get_generalized_index_of_crosslink_header(0), get_generalized_index_of_crosslink_header(0),
get_generalized_index(ShardBlockHeader, 'state_root') get_generalized_index(ShardBlockHeader, 'state_root'),
compute_historical_state_generalized_index(receipt_slot, first_slot_in_last_crosslink) compute_historical_state_generalized_index(receipt_slot, first_slot_in_last_crosslink),
get_generalized_index(ShardState, 'receipt_root') get_generalized_index(ShardState, 'receipt_root')
) )
assert verify_merkle_proof( assert verify_merkle_proof(