include supernode and nodeid in dc quarantine

This commit is contained in:
Agnish Ghosh 2024-10-11 00:54:59 +05:30
parent 3ec7b522c8
commit 6a300f75af
2 changed files with 30 additions and 13 deletions

View File

@ -9,6 +9,7 @@
import
std/tables,
eth/p2p/discoveryv5/[node],
../spec/[helpers, eip7594_helpers]
from std/sequtils import mapIt
@ -23,6 +24,8 @@ type
DataColumnQuarantine* = object
data_columns*:
OrderedTable[(Eth2Digest, ColumnIndex), ref DataColumnSidecar]
supernode*: bool
nodeid*: NodeId
onDataColumnSidecarCallback*: OnDataColumnSidecarCallback
DataColumnFetchRecord* = object
@ -115,24 +118,35 @@ func checkForInitialDcSidecars*(quarantine: DataColumnQuarantine,
func hasDataColumns*(quarantine: DataColumnQuarantine,
blck: deneb.SignedBeaconBlock | electra.SignedBeaconBlock): bool =
var counter = 0
for i in 0..<NUMBER_OF_COLUMNS:
if len(blck.message.body.blob_kzg_commitments) != 0:
if (blck.root, ColumnIndex i) in quarantine.data_columns:
inc counter
else:
let
localSubnetCount =
if quarantine.supernode:
DATA_COLUMN_SIDECAR_SUBNET_COUNT.uint64
else:
CUSTODY_REQUIREMENT.uint64
localCustodyColumns =
get_custody_columns(quarantine.nodeid,
max(SAMPLES_PER_SLOT.uint64,
localSubnetCount))
for i in localCustodyColumns:
if (blck.root, ColumnIndex i) notin quarantine.data_columns:
return false
if counter == DATA_COLUMN_SIDECAR_SUBNET_COUNT or
(counter == max(SAMPLES_PER_SLOT, CUSTODY_REQUIREMENT) and
counter < max(SAMPLES_PER_SLOT, CUSTODY_REQUIREMENT) + 1):
return true
else:
false
true
func dataColumnFetchRecord*(quarantine: DataColumnQuarantine,
blck: deneb.SignedBeaconBlock | electra.SignedBeaconBlock): DataColumnFetchRecord =
let
localSubnetCount =
if quarantine.supernode:
DATA_COLUMN_SIDECAR_SUBNET_COUNT.uint64
else:
CUSTODY_REQUIREMENT.uint64
localCustodyColumns =
get_custody_columns(quarantine.nodeid,
max(SAMPLES_PER_SLOT.uint64,
localSubnetCount))
var indices: seq[ColumnIndex]
for i in 0..<NUMBER_OF_COLUMNS:
for i in localCustodyColumns:
let idx = ColumnIndex(i)
if not quarantine.data_columns.hasKey(
(blck.root, idx)):

View File

@ -385,6 +385,9 @@ proc initFullNode(
onProposerSlashingAdded, onAttesterSlashingAdded))
blobQuarantine = newClone(BlobQuarantine.init(onBlobSidecarAdded))
dataColumnQuarantine = newClone(DataColumnQuarantine.init())
dataColumnQuarantine[].supernode = supernode
dataColumnQuarantine[].nodeid = node.network.nodeId
let
consensusManager = ConsensusManager.new(
dag, attestationPool, quarantine, node.elManager,
ActionTracker.init(node.network.nodeId, config.subscribeAllSubnets),