Skip to content

Commit 8970d0d

Browse files
committed
pr: dag init (#8090)
1 parent c97640e commit 8970d0d

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

beacon_chain/consensus_object_pools/blockchain_dag.nim

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1187,10 +1187,17 @@ proc init*(T: type ChainDAGRef, cfg: RuntimeConfig, db: BeaconChainDB,
11871187
var info: ForkedEpochInfo
11881188

11891189
while headBlocks.len > 0:
1190+
let blck = headBlocks.pop()
11901191
dag.applyBlock(
1191-
dag.headState, headBlocks.pop().bid, cache,
1192+
dag.headState, blck.bid, cache,
11921193
info, dag.updateFlags).expect("head blocks should apply")
11931194

1195+
dag.applyExecutionPayloadEnvelope(dag.headState, blck.bid, cache).isOkOr:
1196+
# Since Gloas, envelopes can only be missing at the head block.
1197+
if blck != headRef:
1198+
error "Envelope is missing for non-head block. Database may be corrupted"
1199+
quit 1
1200+
11941201
dag.head = headRef
11951202
dag.heads = @[headRef]
11961203

beacon_chain/consensus_object_pools/envelope_quarantine.nim

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77

88
{.push raises: [], gcsafe.}
99

10-
import std/tables
11-
import ../spec/[digest, forks]
10+
import
11+
std/tables,
12+
./block_dag,
13+
../beacon_chain_db,
14+
../spec/[digest, forks]
1215
from std/sequtils import addUnique, keepItIf
1316

1417
type
@@ -91,3 +94,8 @@ func cleanupOrphans*(self: var EnvelopeQuarantine, finalizedSlot: Slot) =
9194

9295
for k in toDel:
9396
self.orphans.del(k)
97+
98+
proc checkIfMissingHeadEnvelope*(
99+
self: var EnvelopeQuarantine, db: BeaconChainDB, head: BlockRef) =
100+
if not db.containsExecutionPayloadEnvelope(head.root()):
101+
self.addMissing(head.root())

beacon_chain/nimbus_beacon_node.nim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,11 @@ proc initFullNode(
921921
node.dataColumnQuarantine)
922922
node.router = router
923923

924+
# DAG doesn't have access to quarantine. So checking for missing head
925+
# envelope in beacon node start up process.
926+
if dag.cfg.consensusForkAtEpoch(dag.head.slot().epoch()) >= ConsensusFork.Gloas:
927+
envelopeQuarantine[].checkIfMissingHeadEnvelope(dag.db, dag.head)
928+
924929
await node.addValidators()
925930

926931
block:

0 commit comments

Comments
 (0)