Skip to content

Commit 4c66a97

Browse files
committed
feat: add envelope table
1 parent 44b938a commit 4c66a97

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

beacon_chain/beacon_chain_db.nim

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ type
121121

122122
stateRoots: KvStoreRef # (Slot, BlockRoot) -> StateRoot
123123

124+
envelopes: KvStoreRef # (BlockRoot -> SignedExecutionPayloadEnvelope)
125+
124126
statesNoVal: array[ConsensusFork, KvStoreRef] # StateRoot -> ForkBeaconStateNoImmutableValidators
125127

126128
stateDiffs: KvStoreRef ##\
@@ -604,6 +606,10 @@ proc new*(T: type BeaconChainDB,
604606
if cfg.FULU_FORK_EPOCH != FAR_FUTURE_EPOCH:
605607
columns = kvStore db.openKvStore("fulu_columns").expectDb()
606608

609+
var envelopes: KvStoreRef
610+
if cfg.GLOAS_FORK_EPOCH != FAR_FUTURE_EPOCH:
611+
envelopes = kvStore db.openKvStore("gloas_envelopes").expectDb()
612+
607613
let quarantine = db.initQuarantineDB().expectDb()
608614

609615
# Versions prior to 1.4.0 (altair) stored validators in `immutable_validators`
@@ -642,6 +648,7 @@ proc new*(T: type BeaconChainDB,
642648
blocks: blocks,
643649
blobs: blobs,
644650
columns: columns,
651+
envelopes: envelopes,
645652
stateRoots: stateRoots,
646653
statesNoVal: statesNoVal,
647654
stateDiffs: stateDiffs,
@@ -866,6 +873,14 @@ proc delDataColumnSidecar*(
866873
root: Eth2Digest, index: ColumnIndex): bool =
867874
db.columns.del(columnkey(root, index)).expectDb()
868875

876+
proc putExecutionPayloadEnvelope*(
877+
db: BeaconChainDB, value: SignedExecutionPayloadEnvelope) =
878+
template key: untyped = value.message.beacon_block_root
879+
db.envelopes.putSZSSZ(key.data, value)
880+
881+
proc delExecutionPayloadEnvelope*(db: BeaconChainDB, root: Eth2Digest): bool =
882+
db.envelopes.del(root.data).expectDb()
883+
869884
proc updateImmutableValidators*(
870885
db: BeaconChainDB, validators: openArray[Validator]) =
871886
# Must be called before storing a state that references the new validators
@@ -1078,6 +1093,13 @@ proc getDataColumnSidecar*(db: BeaconChainDB, root: Eth2Digest, index: ColumnInd
10781093
return false
10791094
db.columns.getSZSSZ(columnkey(root, index), value) == GetResult.found
10801095

1096+
proc getExecutionPayloadEnvelope*(
1097+
db: BeaconChainDB, root: Eth2Digest,
1098+
value: var TrustedSignedExecutionPayloadEnvelope): bool =
1099+
if db.envelopes == nil:
1100+
return false
1101+
db.envelopes.getSZSSZ(root.data, value) == GetResult.found
1102+
10811103
proc getBlockSZ*[X: ForkyTrustedSignedBeaconBlock](
10821104
db: BeaconChainDB, key: Eth2Digest,
10831105
data: var seq[byte], T: typedesc[X]): bool =

0 commit comments

Comments
 (0)