don't crash on block production error; build lookahead proposal from current head (#4842)
This commit is contained in:
parent
d3400ca11b
commit
c0b90833db
|
@ -322,6 +322,13 @@ proc runProposalForkchoiceUpdated*(
|
||||||
debug "runProposalForkchoiceUpdated: expected to be proposing next slot",
|
debug "runProposalForkchoiceUpdated: expected to be proposing next slot",
|
||||||
nextWallSlot, validatorIndex, nextProposer
|
nextWallSlot, validatorIndex, nextProposer
|
||||||
|
|
||||||
|
# In Capella and later, computing correct withdrawals would mean creating a
|
||||||
|
# proposal state. Instead, only do that at proposal time.
|
||||||
|
if nextWallSlot.is_epoch:
|
||||||
|
debug "runProposalForkchoiceUpdated: not running early fcU for epoch-aligned proposal slot",
|
||||||
|
nextWallSlot, validatorIndex, nextProposer
|
||||||
|
return
|
||||||
|
|
||||||
# Approximately lines up with validator_duties version. Used optimistically/
|
# Approximately lines up with validator_duties version. Used optimistically/
|
||||||
# opportunistically, so mismatches are fine if not too frequent.
|
# opportunistically, so mismatches are fine if not too frequent.
|
||||||
let
|
let
|
||||||
|
@ -334,28 +341,15 @@ proc runProposalForkchoiceUpdated*(
|
||||||
get_randao_mix(forkyState.data, get_current_epoch(forkyState.data)).data
|
get_randao_mix(forkyState.data, get_current_epoch(forkyState.data)).data
|
||||||
feeRecipient = self[].getFeeRecipient(
|
feeRecipient = self[].getFeeRecipient(
|
||||||
nextProposer, Opt.some(validatorIndex), nextWallSlot.epoch)
|
nextProposer, Opt.some(validatorIndex), nextWallSlot.epoch)
|
||||||
withdrawals = withState(self.dag.headState):
|
withdrawals =
|
||||||
when consensusFork >= ConsensusFork.Capella:
|
if self.dag.headState.kind >= ConsensusFork.Capella:
|
||||||
# Within an epoch, so long as there's no block, the withdrawals also
|
# Head state is not eventual proposal state, but withdrawals will be
|
||||||
# remain unchanged. Balances change at epoch boundaries, however, so
|
# identical within an epoch.
|
||||||
# if and only if the proposal slot is the first slot of an epoch the
|
withState(self.dag.headState):
|
||||||
# beacon node must transition epochs to compute correct balances.
|
when consensusFork >= ConsensusFork.Capella:
|
||||||
if nextWallSlot.is_epoch:
|
Opt.some get_expected_withdrawals(forkyState.data)
|
||||||
var cache: StateCache
|
else:
|
||||||
let proposalState = self.dag.getProposalState(
|
Opt.none(seq[Withdrawal])
|
||||||
self.dag.head, nextWallSlot, cache).valueOr:
|
|
||||||
warn "Failed to create proposal state for withdrawals",
|
|
||||||
err = error, nextWallSlot, validatorIndex, nextProposer
|
|
||||||
return
|
|
||||||
withState(proposalState[]):
|
|
||||||
when consensusFork >= ConsensusFork.Capella:
|
|
||||||
Opt.some get_expected_withdrawals(forkyState.data)
|
|
||||||
else:
|
|
||||||
Opt.none(seq[Withdrawal])
|
|
||||||
else:
|
|
||||||
# Head state is not eventual proposal state, but withdrawals will be
|
|
||||||
# identical.
|
|
||||||
Opt.some get_expected_withdrawals(forkyState.data)
|
|
||||||
else:
|
else:
|
||||||
Opt.none(seq[Withdrawal])
|
Opt.none(seq[Withdrawal])
|
||||||
beaconHead = self.attestationPool[].getBeaconHead(self.dag.head)
|
beaconHead = self.attestationPool[].getBeaconHead(self.dag.head)
|
||||||
|
|
|
@ -443,7 +443,10 @@ proc makeBeaconBlockForHeadAndSlot*(
|
||||||
slot, head = shortLog(head), error
|
slot, head = shortLog(head), error
|
||||||
$error
|
$error
|
||||||
|
|
||||||
return ok((blck.get, payload.blockValue))
|
return if blck.isOk:
|
||||||
|
ok((blck.get, payload.blockValue))
|
||||||
|
else:
|
||||||
|
err(blck.error)
|
||||||
|
|
||||||
# workaround for https://github.com/nim-lang/Nim/issues/20900 to avoid default
|
# workaround for https://github.com/nim-lang/Nim/issues/20900 to avoid default
|
||||||
# parameters
|
# parameters
|
||||||
|
|
Loading…
Reference in New Issue