Skip to content

Commit

Permalink
better logging on invalid database (#3097)
Browse files Browse the repository at this point in the history
* remove redundant test report
  • Loading branch information
arnetheduck authored Nov 13, 2021
1 parent f3881cb commit 222674b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 290 deletions.
284 changes: 0 additions & 284 deletions FixtureSSZGeneric-mainnet.md

This file was deleted.

20 changes: 16 additions & 4 deletions beacon_chain/consensus_object_pools/blockchain_dag.nim
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,12 @@ proc init*(T: type ChainDAGRef, cfg: RuntimeConfig, db: BeaconChainDB,
blocks.incl(KeyedBlockRef.init(curRef))
trace "Populating block dag", key = curRef.root, val = curRef

doAssert curRef == tailRef,
"head block does not lead to tail, database corrupt?"
if curRef != tailRef:
fatal "Head block does not lead to tail - database corrupt?",
genesisRef, tailRef, headRef, curRef, tailRoot, headRoot,
blocks = blocks.len()

quit 1
else:
headRef = tailRef

Expand All @@ -459,27 +463,35 @@ proc init*(T: type ChainDAGRef, cfg: RuntimeConfig, db: BeaconChainDB,
cur = cur.parentOrSlot()

if tmpState.blck == nil:
warn "No state found in head history, database corrupt?"
warn "No state found in head history, database corrupt?",
genesisRef, tailRef, headRef, tailRoot, headRoot,
blocks = blocks.len()
# TODO Potentially we could recover from here instead of crashing - what
# would be a good recovery model?
raiseAssert "No state found in head history, database corrupt?"
quit 1

case tmpState.data.kind
of BeaconStateFork.Phase0:
if tmpState.data.phase0Data.data.fork != genesisFork(cfg):
error "State from database does not match network, check --network parameter",
genesisRef, tailRef, headRef, tailRoot, headRoot,
blocks = blocks.len(),
stateFork = tmpState.data.phase0Data.data.fork,
configFork = genesisFork(cfg)
quit 1
of BeaconStateFork.Altair:
if tmpState.data.altairData.data.fork != altairFork(cfg):
error "State from database does not match network, check --network parameter",
genesisRef, tailRef, headRef, tailRoot, headRoot,
blocks = blocks.len(),
stateFork = tmpState.data.altairData.data.fork,
configFork = altairFork(cfg)
quit 1
of BeaconStateFork.Merge:
if tmpState.data.mergeData.data.fork != mergeFork(cfg):
error "State from database does not match network, check --network parameter",
genesisRef, tailRef, headRef, tailRoot, headRoot,
blocks = blocks.len(),
stateFork = tmpState.data.mergeData.data.fork,
configFork = mergeFork(cfg)
quit 1
Expand Down
2 changes: 0 additions & 2 deletions tests/consensus_spec/test_fixture_ssz_generic_types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -278,5 +278,3 @@ suite "Ethereum Foundation - SSZ generic types":
checkpoint getStackTrace(getCurrentException())
checkpoint getCurrentExceptionMsg()
check false

summarizeLongTests("FixtureSSZGeneric")

0 comments on commit 222674b

Please sign in to comment.