Apply refactoring suggestions from Danny

This commit is contained in:
Hsiao-Wei Wang 2020-07-28 21:51:00 +08:00
parent e7f070d525
commit a8370f7448
No known key found for this signature in database
GPG Key ID: 95B070122902DEA4
2 changed files with 2 additions and 6 deletions

View File

@ -516,12 +516,8 @@ def process_custody_slashing(state: BeaconState, signed_custody_slashing: Signed
shard_transition = custody_slashing.shard_transition
assert hash_tree_root(shard_transition) == attestation.data.shard_transition_root
# Verify that the provided data matches the shard-transition
assert (
hash_tree_root(custody_slashing.data)
== shard_transition.shard_data_roots[custody_slashing.data_index]
)
assert len(custody_slashing.data) == shard_transition.shard_block_lengths[custody_slashing.data_index]
assert hash_tree_root(custody_slashing.data) == shard_transition.shard_data_roots[custody_slashing.data_index]
# Verify existence and participation of claimed malefactor
attesters = get_attesting_indices(state, attestation.data, attestation.aggregation_bits)
assert custody_slashing.malefactor_index in attesters

View File

@ -150,7 +150,7 @@ def get_valid_custody_chunk_response(spec, state, chunk_challenge, challenge_ind
chunk_index = chunk_challenge.chunk_index
leaf_index = chunk_index + 2**spec.CUSTODY_RESPONSE_DEPTH
serialized_length = (len(custody_data_block)).to_bytes(32, 'little')
serialized_length = len(custody_data_block).to_bytes(32, 'little')
data_branch = build_proof(custody_data_block.get_backing().get_left(), leaf_index) + [serialized_length]
return spec.CustodyChunkResponse(