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