From 2c0595da010edee5d9dae8ca170fa6817f524554 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Tue, 30 Jun 2020 00:11:43 +0800 Subject: [PATCH] PR feedback from Danny --- setup.py | 2 +- specs/phase1/custody-game.md | 7 ++++++- specs/phase1/validator.md | 2 -- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 948844fff..ddf178594 100644 --- a/setup.py +++ b/setup.py @@ -226,7 +226,7 @@ get_attesting_indices = cache_this( PHASE1_SUNDRY_FUNCTIONS = ''' def get_block_data_merkle_root(data: ByteList) -> Root: - # To get the Merkle root of the block data, we need the Merkle root without the length Mixing + # To get the Merkle root of the block data, we need the Merkle root without the length mix-in # The below implements this in the Remerkleable framework return data.get_backing().get_left().merkle_root() diff --git a/specs/phase1/custody-game.md b/specs/phase1/custody-game.md index 6b767193a..a6030008d 100644 --- a/specs/phase1/custody-game.md +++ b/specs/phase1/custody-game.md @@ -25,6 +25,7 @@ - [`CustodyKeyReveal`](#custodykeyreveal) - [`EarlyDerivedSecretReveal`](#earlyderivedsecretreveal) - [Helpers](#helpers) + - [`get_block_data_merkle_root`](#get_block_data_merkle_root) - [`replace_empty_or_append`](#replace_empty_or_append) - [`legendre_bit`](#legendre_bit) - [`get_custody_atoms`](#get_custody_atoms) @@ -182,6 +183,10 @@ class EarlyDerivedSecretReveal(Container): ## Helpers +### `get_block_data_merkle_root` + +`get_block_data_merkle_root(data: ByteList) -> Root` is the function that returns the Merkle root of the block data without the length mix-in. + ### `replace_empty_or_append` ```python @@ -515,7 +520,7 @@ def process_custody_slashing(state: BeaconState, signed_custody_slashing: Signed assert hash_tree_root(shard_transition) == attestation.data.shard_transition_root # Verify that the provided data matches the shard-transition assert ( - custody_slashing.data.get_backing().get_left().merkle_root() + get_block_data_merkle_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] diff --git a/specs/phase1/validator.md b/specs/phase1/validator.md index aa5e07f1a..c91dcd09f 100644 --- a/specs/phase1/validator.md +++ b/specs/phase1/validator.md @@ -275,8 +275,6 @@ Set `attestation_data.shard_head_root = hash_tree_root(shard_head_block)`. Set `shard_transition` to the value returned by `get_shard_transition(head_state, shard, shard_blocks)`. -`get_block_data_merkle_root(data: ByteList) -> Root` is the function that returns the Merkle root of the block data without the length mixing. - ```python def get_shard_transition_fields( beacon_state: BeaconState,