Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions beacon_chain/beacon_chain_db.nim
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,11 @@ proc putDataColumnSidecar*(
let block_root = hash_tree_root(value.signed_block_header.message)
db.columns.putSZSSZ(columnkey(block_root, value.index), value)

proc putDataColumnSidecar*(
db: BeaconChainDB,
value: gloas.DataColumnSidecar) =
db.columns.putSZSSZ(columnkey(value.beacon_block_root, value.index), value)

proc delDataColumnSidecar*(
db: BeaconChainDB,
root: Eth2Digest, index: ColumnIndex): bool =
Expand Down
19 changes: 14 additions & 5 deletions beacon_chain/gossip_processing/block_processor.nim
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ type
## time

NoSidecars* = typeof(())
SomeOptSidecars = NoSidecars | Opt[BlobSidecars] | Opt[DataColumnSidecars]
SomeOptSidecars =
NoSidecars | Opt[BlobSidecars] | Opt[fulu.DataColumnSidecars] |
Opt[gloas.DataColumnSidecars]

const noSidecars* = default(NoSidecars)

Expand Down Expand Up @@ -226,7 +228,10 @@ proc storeSidecars(self: BlockProcessor, sidecarsOpt: Opt[BlobSidecars]) =
for b in sidecarsOpt[]:
self.consensusManager.dag.db.putBlobSidecar(b[])

proc storeSidecars(self: BlockProcessor, sidecarsOpt: Opt[DataColumnSidecars]) =
proc storeSidecars(
self: BlockProcessor,
sidecarsOpt: Opt[fulu.DataColumnSidecars] | Opt[gloas.DataColumnSidecars]
) =
if sidecarsOpt.isSome():
debug "Inserting columns into database", columns = sidecarsOpt[].len
for c in sidecarsOpt[]:
Expand Down Expand Up @@ -396,11 +401,12 @@ proc enqueueQuarantine(self: ref BlockProcessor, root: Eth2Digest) =
withBlck(quarantined):
when consensusFork == ConsensusFork.Gloas:
debugGloasComment ""
self.enqueueBlock(MsgSource.gossip, forkyBlck, Opt.none(DataColumnSidecars))
self.enqueueBlock(
MsgSource.gossip, forkyBlck, Opt.none(gloas.DataColumnSidecars))
elif consensusFork == ConsensusFork.Fulu:
if len(forkyBlck.message.body.blob_kzg_commitments) == 0:
self.enqueueBlock(
MsgSource.gossip, forkyBlck, Opt.some(DataColumnSidecars @[])
MsgSource.gossip, forkyBlck, Opt.some(fulu.DataColumnSidecars @[])
)
else:
if (let res = checkBlobOrColumnlessSignature(self[], forkyBlck); res.isErr):
Expand Down Expand Up @@ -814,9 +820,12 @@ proc addBlock*(
when sidecarsOpt is Opt[BlobSidecars]:
if sidecarsOpt.isSome:
self.blobQuarantine[].put(blockRoot, sidecarsOpt.get)
elif sidecarsOpt is Opt[DataColumnSidecars]:
elif sidecarsOpt is Opt[fulu.DataColumnSidecars]:
if sidecarsOpt.isSome:
self.dataColumnQuarantine[].put(blockRoot, sidecarsOpt.get)
elif sidecarsOpt is Opt[gloas.DataColumnSidecars]:
if sidecarsOpt.isSome:
debugGloasComment ""
elif sidecarsOpt is NoSidecars:
discard
else:
Expand Down
5 changes: 4 additions & 1 deletion beacon_chain/gossip_processing/eth2_processor.nim
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ proc processSignedBeaconBlock*(
if not (isNil(self.dag.onBlockGossipAdded)):
self.dag.onBlockGossipAdded(ForkedSignedBeaconBlock.init(signedBlock))

when consensusFork in ConsensusFork.Fulu .. ConsensusFork.Gloas:
debugGloasComment " "
when consensusFork == ConsensusFork.Gloas:
let sidecarsOpt = Opt.none(gloas.DataColumnSidecars)
elif consensusFork == ConsensusFork.Fulu:
let sidecarsOpt =
self.dataColumnQuarantine[].popSidecars(signedBlock.root, signedBlock)
if sidecarsOpt.isNone():
Expand Down
2 changes: 2 additions & 0 deletions beacon_chain/gossip_processing/gossip_validation.nim
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ func getMaxBlobsPerBlock(cfg: RuntimeConfig, slot: Slot): uint64 =
cfg.MAX_BLOBS_PER_BLOCK

debugGloasComment ""
# https://github.com/ethereum/consensus-specs/blob/v1.6.0-beta.0/specs/gloas/p2p-interface.md#beacon_block
template validateBeaconBlockBellatrix(
_: phase0.SignedBeaconBlock | altair.SignedBeaconBlock | gloas.SignedBeaconBlock,
_: BlockRef): untyped =
Expand Down Expand Up @@ -363,6 +364,7 @@ template validateBeaconBlockBellatrix(
# `ACCEPTED` or `SYNCING` from the EL to get this far.

debugGloasComment ""
# https://github.com/ethereum/consensus-specs/blob/v1.6.0-beta.0/specs/gloas/p2p-interface.md#beacon_block
template validateBeaconBlockDeneb(
_: ChainDAGRef,
_:
Expand Down
2 changes: 1 addition & 1 deletion beacon_chain/networking/eth2_network.nim
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ template gossipMaxSize(T: untyped): uint32 =
elif T is bellatrix.SignedBeaconBlock or T is capella.SignedBeaconBlock or
T is deneb.SignedBeaconBlock or T is electra.SignedBeaconBlock or
T is fulu.SignedBeaconBlock or T is fulu.DataColumnSidecar or
T is gloas.DataColumnSidecar:
T is gloas.SignedBeaconBlock or T is gloas.DataColumnSidecar:
MAX_PAYLOAD_SIZE
# TODO https://github.com/status-im/nim-ssz-serialization/issues/20 for
# Attestation, AttesterSlashing, and SignedAggregateAndProof, which all
Expand Down
36 changes: 18 additions & 18 deletions beacon_chain/nimbus_beacon_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,10 @@ proc initFullNode(
withBlck(signedBlock):
when consensusFork in ConsensusFork.Fulu .. ConsensusFork.Gloas:
# TODO document why there are no columns here
let sidecarsOpt = Opt.none(DataColumnSidecars)
when consensusFork == ConsensusFork.Gloas:
let sidecarsOpt = Opt.none(gloas.DataColumnSidecars)
else:
let sidecarsOpt = Opt.none(fulu.DataColumnSidecars)
elif consensusFork in ConsensusFork.Deneb .. ConsensusFork.Electra:
template sidecarsOpt: untyped = blobs
elif consensusFork in ConsensusFork.Phase0 .. ConsensusFork.Capella:
Expand All @@ -474,7 +477,7 @@ proc initFullNode(
withBlck(signedBlock):
when consensusFork == ConsensusFork.Gloas:
debugGloasComment "no blob_kzg_commitments field for gloas"
let sidecarsOpt = Opt.none(DataColumnSidecars)
let sidecarsOpt = Opt.none(gloas.DataColumnSidecars)
elif consensusFork == ConsensusFork.Fulu:
let sidecarsOpt =
dataColumnQuarantine[].popSidecars(forkyBlck.root, forkyBlck)
Expand Down Expand Up @@ -2269,22 +2272,19 @@ proc installMessageValidators(node: BeaconNode) =
# beacon_block
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.8/specs/phase0/p2p-interface.md#beacon_block
# https://github.com/ethereum/consensus-specs/blob/v1.6.0-beta.0/specs/gloas/p2p-interface.md#beacon_block
when consensusFork >= ConsensusFork.Gloas:
debugGloasComment " "
else:
node.network.addValidator(
getBeaconBlocksTopic(digest), proc (
signedBlock: consensusFork.SignedBeaconBlock,
src: PeerId,
): ValidationResult =
if node.shouldSyncOptimistically(node.currentSlot):
toValidationResult(
node.optimisticProcessor.processSignedBeaconBlock(
signedBlock))
else:
toValidationResult(
node.processor[].processSignedBeaconBlock(
MsgSource.gossip, signedBlock)))
node.network.addValidator(
getBeaconBlocksTopic(digest), proc (
signedBlock: consensusFork.SignedBeaconBlock,
src: PeerId,
): ValidationResult =
if node.shouldSyncOptimistically(node.currentSlot):
toValidationResult(
node.optimisticProcessor.processSignedBeaconBlock(
signedBlock))
else:
toValidationResult(
node.processor[].processSignedBeaconBlock(
MsgSource.gossip, signedBlock)))

# beacon_attestation_{subnet_id}
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id
Expand Down
2 changes: 2 additions & 0 deletions beacon_chain/spec/datatypes/gloas.nim
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ type
kzg_proofs*: deneb.KzgProofs
beacon_block_root*: Eth2Digest

DataColumnSidecars* = seq[ref DataColumnSidecar]

ExecutionPayloadForSigning* = object
executionPayload*: deneb.ExecutionPayload
blockValue*: Wei
Expand Down
Loading