From 94c3b005fa69fe7f487659952f8eb05f8a452890 Mon Sep 17 00:00:00 2001 From: Dustin Brody Date: Thu, 21 Mar 2019 16:02:50 +0000 Subject: [PATCH] https://github.com/ethereum/eth2.0-specs/pull/816 hotfix (#194) --- beacon_chain/spec/beaconstate.nim | 3 ++- beacon_chain/state_transition.nim | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/beacon_chain/spec/beaconstate.nim b/beacon_chain/spec/beaconstate.nim index 7acba8a8c..b8614e419 100644 --- a/beacon_chain/spec/beaconstate.nim +++ b/beacon_chain/spec/beaconstate.nim @@ -221,7 +221,8 @@ func get_temporary_block_header*(blck: BeaconBlock): BeaconBlockHeader = previous_block_root: blck.previous_block_root, state_root: ZERO_HASH, block_body_root: hash_tree_root_final(blck.body), - signature: blck.signature) + signature: EMPTY_SIGNATURE, + ) # https://github.com/ethereum/eth2.0-specs/blob/0.4.0/specs/core/0_beacon-chain.md#on-genesis func get_empty_block*(): BeaconBlock = diff --git a/beacon_chain/state_transition.nim b/beacon_chain/state_transition.nim index 0b28d56b0..5b35e18b2 100644 --- a/beacon_chain/state_transition.nim +++ b/beacon_chain/state_transition.nim @@ -68,8 +68,10 @@ proc processBlockHeader( state_slot = humaneSlotNum(state.slot) return false - if not (blck.previous_block_root == - hash_tree_root_final(state.latest_block_header)): + ## https://github.com/ethereum/eth2.0-specs/pull/816/files remove when + ## switched to 0.5.1 + if not (blck.previous_block_root.data == + signed_root(state.latest_block_header)): notice "Block header: previous block root mismatch", previous_block_root = blck.previous_block_root, latest_block_header = state.latest_block_header, @@ -466,7 +468,7 @@ func cacheState(state: var BeaconState) = # store latest known block for previous slot state.latest_block_roots[state.slot mod SLOTS_PER_HISTORICAL_ROOT] = - hash_tree_root_final(state.latest_block_header) + Eth2Digest(data: signed_root(state.latest_block_header)) func processSlot(state: var BeaconState, previous_block_root: Eth2Digest) = advanceSlot(state)