Refactor getting Merkle root of data part of ByteList
This commit is contained in:
parent
113563176a
commit
2dee432536
|
@ -136,6 +136,12 @@ def build_proof(anchor, leaf_index):
|
|||
return list(reversed(proof))
|
||||
|
||||
|
||||
def get_block_data_merkle_root(data_as_bytelist):
|
||||
# To get the Merkle root of the block data, we need the Merkle root without the length Mixing
|
||||
# The below implements this in the Remerkleable framework
|
||||
return data_as_bytelist.get_backing().get_left().merkle_root()
|
||||
|
||||
|
||||
def get_valid_custody_chunk_response(spec, state, chunk_challenge, block_length, challenge_index,
|
||||
invalid_chunk_data=False):
|
||||
custody_data = get_custody_test_vector(block_length)
|
||||
|
@ -160,8 +166,8 @@ def get_custody_test_vector(bytelength, offset=0):
|
|||
|
||||
|
||||
def get_shard_transition(spec, start_slot, block_lengths):
|
||||
b = [ByteList[spec.MAX_SHARD_BLOCK_SIZE](get_custody_test_vector(x))
|
||||
.get_backing().get_left().merkle_root() for x in block_lengths]
|
||||
b = [get_block_data_merkle_root(ByteList[spec.MAX_SHARD_BLOCK_SIZE](get_custody_test_vector(x)))
|
||||
for x in block_lengths]
|
||||
shard_transition = spec.ShardTransition(
|
||||
start_slot=start_slot,
|
||||
shard_block_lengths=block_lengths,
|
||||
|
@ -195,5 +201,5 @@ def get_custody_slashable_shard_transition(spec, start_slot, block_lengths, cust
|
|||
slashable_test_vector = get_custody_slashable_test_vector(spec, custody_secret,
|
||||
block_lengths[0], slashable=slashable)
|
||||
block_data = ByteList[spec.MAX_SHARD_BLOCK_SIZE](slashable_test_vector)
|
||||
shard_transition.shard_data_roots[0] = block_data.get_backing().get_left().merkle_root()
|
||||
shard_transition.shard_data_roots[0] = get_block_data_merkle_root(block_data)
|
||||
return shard_transition, slashable_test_vector
|
||||
|
|
Loading…
Reference in New Issue