mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-21 02:38:23 +00:00
make all csc uint64
This commit is contained in:
parent
fd1ae50830
commit
6127bd6ed2
@ -127,7 +127,7 @@ proc queryRandom*(
|
||||
forkId: ENRForkID,
|
||||
wantedAttnets: AttnetBits,
|
||||
wantedSyncnets: SyncnetBits,
|
||||
wantedCscnets: CscBits,
|
||||
wantedCscnets: CscCount,
|
||||
minScore: int): Future[seq[Node]] {.async.} =
|
||||
## Perform a discovery query for a random target
|
||||
## (forkId) and matching at least one of the attestation subnets.
|
||||
@ -156,16 +156,12 @@ proc queryRandom*(
|
||||
if cscnetsBytes.isOk():
|
||||
let cscnetsNode =
|
||||
try:
|
||||
SSZ.decode(cscnetsBytes.get(), CscBits)
|
||||
SSZ.decode(cscnetsBytes.get(), CscCount)
|
||||
except SszError as e:
|
||||
debug "Could not decode the csc count ENR bitfield of peer",
|
||||
peer = n.record.toURI(), exception = e.name, msg = e.msg
|
||||
continue
|
||||
|
||||
for i in 0..<DATA_COLUMN_SIDECAR_SUBNET_COUNT:
|
||||
if wantedCscnets[i] and cscnetsNode[i]:
|
||||
score += 1
|
||||
|
||||
let attnetsBytes = n.record.get(enrAttestationSubnetsField, seq[byte])
|
||||
if attnetsBytes.isOk():
|
||||
let attnetsNode =
|
||||
|
@ -1484,7 +1484,7 @@ proc trimConnections(node: Eth2Node, count: int) =
|
||||
if toKick <= 0: return
|
||||
|
||||
proc getLowSubnets(node: Eth2Node, epoch: Epoch):
|
||||
(AttnetBits, SyncnetBits, CscBits) =
|
||||
(AttnetBits, SyncnetBits, CscCount) =
|
||||
# Returns the subnets required to have a healthy mesh
|
||||
# The subnets are computed, to, in order:
|
||||
# - Have 0 subnet with < `dLow` peers from topic subscription
|
||||
@ -1550,7 +1550,7 @@ proc getLowSubnets(node: Eth2Node, epoch: Epoch):
|
||||
findLowSubnets(getSyncCommitteeTopic, SyncSubcommitteeIndex, SYNC_COMMITTEE_SUBNET_COUNT)
|
||||
else:
|
||||
default(SyncnetBits),
|
||||
findLowSubnets(getDataColumnSidecarTopic, uint64, DATA_COLUMN_SIDECAR_SUBNET_COUNT.int)
|
||||
findLowSubnets(getDataColumnSidecarTopic, uint64, DATA_COLUMN_SIDECAR_SUBNET_COUNT.int).countOnes.uint64
|
||||
)
|
||||
|
||||
proc runDiscoveryLoop(node: Eth2Node) {.async.} =
|
||||
@ -1562,7 +1562,7 @@ proc runDiscoveryLoop(node: Eth2Node) {.async.} =
|
||||
(wantedAttnets, wantedSyncnets, wantedCscnets) = node.getLowSubnets(currentEpoch)
|
||||
wantedAttnetsCount = wantedAttnets.countOnes()
|
||||
wantedSyncnetsCount = wantedSyncnets.countOnes()
|
||||
wantedCscnetsCount = wantedCscnets.countOnes()
|
||||
wantedCscnetsCount = wantedCscnets
|
||||
outgoingPeers = node.peerPool.lenCurrent({PeerType.Outgoing})
|
||||
targetOutgoingPeers = max(node.wantedPeers div 10, 3)
|
||||
|
||||
|
@ -77,14 +77,14 @@ type
|
||||
column_index*: ColumnIndex
|
||||
row_index*: RowIndex
|
||||
|
||||
CscBits* = BitArray[DATA_COLUMN_SIDECAR_SUBNET_COUNT]
|
||||
CscCount* = uint64
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/_features/eip7594/p2p-interface.md#metadata
|
||||
MetaData* = object
|
||||
seq_number*: uint64
|
||||
attnets*: AttnetBits
|
||||
syncnets*: SyncnetBits
|
||||
custody_subnet_count*: uint64
|
||||
custody_subnet_count*: CscCount
|
||||
|
||||
# func serializeDataColumn(data_column: DataColumn): auto =
|
||||
# var counter = 0
|
||||
|
@ -33,7 +33,7 @@ const
|
||||
PARALLEL_REQUESTS* = 2
|
||||
## Number of peers we using to resolve our request.
|
||||
|
||||
PARALLEL_REQUESTS_DATA_COLUMNS* = 8
|
||||
PARALLEL_REQUESTS_DATA_COLUMNS* = 32
|
||||
|
||||
BLOB_GOSSIP_WAIT_TIME_NS* = 2 * 1_000_000_000
|
||||
## How long to wait for blobs to arrive over gossip before fetching.
|
||||
@ -289,8 +289,8 @@ proc lookupCscFromPeer(peer: Peer): uint64 =
|
||||
|
||||
if enrFieldOpt.isOk:
|
||||
try:
|
||||
let csc = SSZ.decode(enrFieldOpt.get(), CscBits)
|
||||
return csc.countOnes.uint64
|
||||
let csc = SSZ.decode(enrFieldOpt.get(), CscCount)
|
||||
return csc
|
||||
except SszError as e:
|
||||
debug "Could not decide the csc field in the ENR"
|
||||
return 0
|
||||
|
@ -36,7 +36,7 @@ proc generateNode(rng: ref HmacDrbgContext, port: Port,
|
||||
|
||||
# TODO: Add tests with a syncnets preference
|
||||
const noSyncnetsPreference = SyncnetBits()
|
||||
const noCscnetsPreference = CscBits()
|
||||
const noCscnetsPreference = CscCount()
|
||||
|
||||
procSuite "Eth2 specific discovery tests":
|
||||
let
|
||||
|
Loading…
x
Reference in New Issue
Block a user