-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
relax BlockRef
database assumptions
#3472
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -205,19 +205,24 @@ template validateBeaconBlockBellatrix( | |
# mostly relevant around merge transition epochs. It's possible that | ||
# the previous block is phase 0 or Altair, if this is the transition | ||
# block itself. | ||
let blockData = dag.getForkedBlock(parent) | ||
case blockData.kind: | ||
of BeaconBlockFork.Phase0: | ||
let blockData = dag.getForkedBlock(parent.bid) | ||
if blockData.isOk(): | ||
case blockData.get().kind: | ||
of BeaconBlockFork.Phase0: | ||
false | ||
of BeaconBlockFork.Altair: | ||
false | ||
of BeaconBlockFork.Bellatrix: | ||
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/bellatrix/beacon-chain.md#process_execution_payload | ||
# shows how this gets folded into the state each block; checking this | ||
# is equivalent, without ever requiring state replay or any similarly | ||
# expensive computation. | ||
blockData.get().bellatrixData.message.body.execution_payload != | ||
default(ExecutionPayload) | ||
else: | ||
warn "Cannot load block parent, assuming execution is disabled", | ||
parent = shortLog(parent) | ||
false | ||
of BeaconBlockFork.Altair: | ||
false | ||
of BeaconBlockFork.Bellatrix: | ||
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/bellatrix/beacon-chain.md#process_execution_payload | ||
# shows how this gets folded into the state each block; checking this | ||
# is equivalent, without ever requiring state replay or any similarly | ||
# expensive computation. | ||
blockData.bellatrixData.message.body.execution_payload != | ||
default(ExecutionPayload) | ||
|
||
if executionEnabled: | ||
# [REJECT] The block's execution payload timestamp is correct with respect | ||
|
@@ -294,11 +299,13 @@ proc validateBeaconBlock*( | |
|
||
if slotBlock.isProposed() and | ||
slotBlock.blck.slot == signed_beacon_block.message.slot: | ||
let data = dag.getForkedBlock(slotBlock.blck) | ||
if getForkedBlockField(data, proposer_index) == | ||
signed_beacon_block.message.proposer_index and | ||
data.signature.toRaw() != signed_beacon_block.signature.toRaw(): | ||
return errIgnore("BeaconBlock: already proposed in the same slot") | ||
let curBlock = dag.getForkedBlock(slotBlock.blck.bid) | ||
if curBlock.isOk(): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nothing happens if the curBlock is an error? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nothing - we don't have the block so there's nothing to compare with (should typically not happen, except in weird timing scenarios) |
||
let data = curBlock.get() | ||
if getForkedBlockField(data, proposer_index) == | ||
signed_beacon_block.message.proposer_index and | ||
data.signature.toRaw() != signed_beacon_block.signature.toRaw(): | ||
return errIgnore("BeaconBlock: already proposed in the same slot") | ||
|
||
# [IGNORE] The block's parent (defined by block.parent_root) has been seen | ||
# (via both gossip and non-gossip sources) (a client MAY queue blocks for | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a test for that? Or in which situation do we get a 0 block id (backfill?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zero is returned if the block is not found (should probably change that to Option at some point but .. ) - there were tests but they didn't cover zero