From b7e6012628f299b64b4a4dba4f30dfa3435a73d4 Mon Sep 17 00:00:00 2001 From: Preston Van Loon Date: Sat, 1 Feb 2020 17:03:21 -0800 Subject: [PATCH] Better eth1data equals (#4712) * Better eth1data equals * Merge branch 'master' into better-eth1-data-equal --- beacon-chain/core/blocks/block_operations.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/beacon-chain/core/blocks/block_operations.go b/beacon-chain/core/blocks/block_operations.go index 8b4a6bbd2..b020ae384 100644 --- a/beacon-chain/core/blocks/block_operations.go +++ b/beacon-chain/core/blocks/block_operations.go @@ -117,6 +117,12 @@ func ProcessEth1DataInBlock(beaconState *stateTrie.BeaconState, block *ethpb.Bea return beaconState, nil } +func areEth1DataEqual(a, b *ethpb.Eth1Data) bool { + return a.DepositCount == b.DepositCount && + bytes.Equal(a.BlockHash, b.BlockHash) && + bytes.Equal(a.DepositRoot, b.DepositRoot) +} + // Eth1DataHasEnoughSupport returns true when the given eth1data has more than 50% votes in the // eth1 voting period. A vote is cast by including eth1data in a block and part of state processing // appends eth1data to the state in the Eth1DataVotes list. Iterating through this list checks the @@ -139,7 +145,7 @@ func Eth1DataHasEnoughSupport(beaconState *stateTrie.BeaconState, data *ethpb.Et } if voteCount == 0 { for _, vote := range beaconState.Eth1DataVotes() { - if proto.Equal(vote, data) { + if areEth1DataEqual(vote, data) { voteCount++ } }