Skip to content

Commit e60dd8e

Browse files
committed
Stronger validation for third-party Eth1Data votes
1 parent 9d031a8 commit e60dd8e

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

beacon_chain/eth1/eth1_monitor.nim

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -672,21 +672,17 @@ proc getBlockProposalData*(chain: var Eth1Chain,
672672
var otherVotesCountTable = initCountTable[Eth1Data]()
673673
for vote in state.eth1_data_votes:
674674
let eth1Block = chain.findBlock(vote)
675-
if eth1Block == nil:
676-
continue
677-
let
678-
isSuccessor = vote.deposit_count >= state.eth1_data.deposit_count
679-
# TODO(zah)
680-
# There is a slight deviation from the spec here to deal with the following
681-
# problem: the in-memory database of eth1 blocks for a restarted node will
682-
# be empty which will lead a "no change" vote. To fix this, we'll need to
683-
# add rolling persistance for all potentially voted on blocks.
684-
isCandidate = (is_candidate_block(chain.preset, eth1Block, periodStart))
685-
686-
if isSuccessor and isCandidate:
675+
if eth1Block != nil and
676+
eth1Block.voteData.deposit_root == vote.deposit_root and
677+
vote.deposit_count >= state.eth1_data.deposit_count and
678+
is_candidate_block(chain.preset, eth1Block, periodStart):
687679
otherVotesCountTable.inc vote
688680
else:
689-
debug "Ignoring eth1 vote", root = vote.block_hash, isSuccessor, isCandidate
681+
debug "Ignoring eth1 vote",
682+
root = vote.block_hash,
683+
deposits = vote.deposit_count,
684+
depositsRoot = vote.deposit_root,
685+
localDeposits = state.eth1_data.deposit_count
690686

691687
var pendingDepositsCount = state.eth1_data.deposit_count - state.eth1_deposit_index
692688
if otherVotesCountTable.len > 0:

0 commit comments

Comments
 (0)