log errors in more detail when block production fails (#2135)
* log errors in more detail when block production fails * pass through block header error * make everything cstring
This commit is contained in:
parent
94c66f15a9
commit
d5e3712609
|
@ -177,7 +177,8 @@ proc state_transition*(
|
||||||
trace "state_transition: processing block, signature passed",
|
trace "state_transition: processing block, signature passed",
|
||||||
signature = shortLog(signedBlock.signature),
|
signature = shortLog(signedBlock.signature),
|
||||||
blockRoot = shortLog(signedBlock.root)
|
blockRoot = shortLog(signedBlock.root)
|
||||||
if process_block(preset, state.data, signedBlock.message, flags, stateCache):
|
let res = process_block(preset, state.data, signedBlock.message, flags, stateCache)
|
||||||
|
if res.isOk:
|
||||||
if skipStateRootValidation in flags or verifyStateRoot(state.data, signedBlock.message):
|
if skipStateRootValidation in flags or verifyStateRoot(state.data, signedBlock.message):
|
||||||
# State root is what it should be - we're done!
|
# State root is what it should be - we're done!
|
||||||
|
|
||||||
|
@ -190,6 +191,13 @@ proc state_transition*(
|
||||||
else: signedBlock.message.state_root
|
else: signedBlock.message.state_root
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
else:
|
||||||
|
debug "state_transition: process_block failed",
|
||||||
|
blck = shortLog(signedBlock.message),
|
||||||
|
slot = state.data.slot,
|
||||||
|
eth1_deposit_index = state.data.eth1_deposit_index,
|
||||||
|
deposit_root = shortLog(state.data.eth1_data.deposit_root),
|
||||||
|
error = res.error
|
||||||
|
|
||||||
# Block processing failed, roll back changes
|
# Block processing failed, roll back changes
|
||||||
rollback(state)
|
rollback(state)
|
||||||
|
@ -236,10 +244,15 @@ proc makeBeaconBlock*(
|
||||||
voluntary_exits:
|
voluntary_exits:
|
||||||
List[SignedVoluntaryExit, Limit MAX_VOLUNTARY_EXITS](voluntaryExits)))
|
List[SignedVoluntaryExit, Limit MAX_VOLUNTARY_EXITS](voluntaryExits)))
|
||||||
|
|
||||||
let ok = process_block(preset, state.data, blck, {skipBlsValidation}, cache)
|
let res = process_block(preset, state.data, blck, {skipBlsValidation}, cache)
|
||||||
|
|
||||||
if not ok:
|
if res.isErr:
|
||||||
warn "Unable to apply new block to state", blck = shortLog(blck)
|
warn "Unable to apply new block to state",
|
||||||
|
blck = shortLog(blck),
|
||||||
|
slot = state.data.slot,
|
||||||
|
eth1_deposit_index = state.data.eth1_deposit_index,
|
||||||
|
deposit_root = shortLog(state.data.eth1_data.deposit_root),
|
||||||
|
error = res.error
|
||||||
rollback(state)
|
rollback(state)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -342,33 +342,20 @@ proc process_operations(preset: RuntimePreset,
|
||||||
proc process_block*(
|
proc process_block*(
|
||||||
preset: RuntimePreset,
|
preset: RuntimePreset,
|
||||||
state: var BeaconState, blck: SomeBeaconBlock, flags: UpdateFlags,
|
state: var BeaconState, blck: SomeBeaconBlock, flags: UpdateFlags,
|
||||||
stateCache: var StateCache): bool {.nbench.}=
|
stateCache: var StateCache): Result[void, cstring] {.nbench.}=
|
||||||
## When there's a new block, we need to verify that the block is sane and
|
## When there's a new block, we need to verify that the block is sane and
|
||||||
## update the state accordingly - the state is left in an unknown state when
|
## update the state accordingly - the state is left in an unknown state when
|
||||||
## block application fails (!)
|
## block application fails (!)
|
||||||
|
|
||||||
logScope:
|
? process_block_header(state, blck, flags, stateCache)
|
||||||
blck = shortLog(blck)
|
|
||||||
let res_block = process_block_header(state, blck, flags, stateCache)
|
|
||||||
if res_block.isErr:
|
|
||||||
debug "Block header not valid",
|
|
||||||
block_header_error = $(res_block.error),
|
|
||||||
slot = state.slot
|
|
||||||
return false
|
|
||||||
|
|
||||||
if not process_randao(state, blck.body, flags, stateCache):
|
if not process_randao(state, blck.body, flags, stateCache):
|
||||||
debug "Randao failure", slot = shortLog(state.slot)
|
return err("Randao failure".cstring)
|
||||||
return false
|
|
||||||
|
|
||||||
process_eth1_data(state, blck.body)
|
process_eth1_data(state, blck.body)
|
||||||
|
|
||||||
let res_ops = process_operations(preset, state, blck.body, flags, stateCache)
|
let res_ops = process_operations(preset, state, blck.body, flags, stateCache)
|
||||||
if res_ops.isErr:
|
if res_ops.isErr:
|
||||||
debug "process_operations encountered error",
|
return err("process_operations encountered error".cstring)
|
||||||
operation_error = $(res_ops.error),
|
|
||||||
slot = state.slot,
|
|
||||||
eth1_deposit_index = state.eth1_deposit_index,
|
|
||||||
deposit_root = shortLog(state.eth1_data.deposit_root)
|
|
||||||
return false
|
|
||||||
|
|
||||||
true
|
ok()
|
||||||
|
|
Loading…
Reference in New Issue