mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-20 18:28:12 +00:00
use v1.3.0 stability subnet behavior when appropriate (#5156)
This commit is contained in:
parent
862897124a
commit
49056c3e39
@ -2554,7 +2554,7 @@ proc updateStabilitySubnetMetadata*(node: Eth2Node, attnets: AttnetBits) =
|
|||||||
node.metadata.seq_number += 1
|
node.metadata.seq_number += 1
|
||||||
node.metadata.attnets = attnets
|
node.metadata.attnets = attnets
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/validator.md#phase-0-attestation-subnet-stability
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/specs/phase0/p2p-interface.md#attestation-subnet-subscription
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/p2p-interface.md#attestation-subnet-bitfield
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/p2p-interface.md#attestation-subnet-bitfield
|
||||||
let res = node.discovery.updateRecord({
|
let res = node.discovery.updateRecord({
|
||||||
enrAttestationSubnetsField: SSZ.encode(node.metadata.attnets)
|
enrAttestationSubnetsField: SSZ.encode(node.metadata.attnets)
|
||||||
|
@ -771,7 +771,7 @@ func forkDigests(node: BeaconNode): auto =
|
|||||||
node.dag.forkDigests.deneb]
|
node.dag.forkDigests.deneb]
|
||||||
forkDigestsArray
|
forkDigestsArray
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/validator.md#phase-0-attestation-subnet-stability
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/specs/phase0/p2p-interface.md#attestation-subnet-subscription
|
||||||
proc updateAttestationSubnetHandlers(node: BeaconNode, slot: Slot) =
|
proc updateAttestationSubnetHandlers(node: BeaconNode, slot: Slot) =
|
||||||
if node.gossipState.card == 0:
|
if node.gossipState.card == 0:
|
||||||
# When disconnected, updateGossipState is responsible for all things
|
# When disconnected, updateGossipState is responsible for all things
|
||||||
|
@ -81,7 +81,6 @@ type
|
|||||||
func hash*(x: AggregatorDuty): Hash =
|
func hash*(x: AggregatorDuty): Hash =
|
||||||
hashAllFields(x)
|
hashAllFields(x)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/validator.md#phase-0-attestation-subnet-stability
|
|
||||||
func randomStabilitySubnet(
|
func randomStabilitySubnet(
|
||||||
self: ActionTracker, epoch: Epoch): tuple[subnet_id: SubnetId, expiration: Epoch] =
|
self: ActionTracker, epoch: Epoch): tuple[subnet_id: SubnetId, expiration: Epoch] =
|
||||||
(
|
(
|
||||||
@ -130,11 +129,6 @@ proc hasSyncDuty*(
|
|||||||
tracker: ActionTracker, pubkey: ValidatorPubKey, epoch: Epoch): bool =
|
tracker: ActionTracker, pubkey: ValidatorPubKey, epoch: Epoch): bool =
|
||||||
epoch < tracker.syncDuties.getOrDefault(pubkey, GENESIS_EPOCH)
|
epoch < tracker.syncDuties.getOrDefault(pubkey, GENESIS_EPOCH)
|
||||||
|
|
||||||
const allSubnetBits = block:
|
|
||||||
var res: AttnetBits
|
|
||||||
for i in 0..<res.len: res[i] = true
|
|
||||||
res
|
|
||||||
|
|
||||||
func aggregateSubnets*(tracker: ActionTracker, wallSlot: Slot): AttnetBits =
|
func aggregateSubnets*(tracker: ActionTracker, wallSlot: Slot): AttnetBits =
|
||||||
var res: AttnetBits
|
var res: AttnetBits
|
||||||
# Subscribe to subnets for upcoming duties
|
# Subscribe to subnets for upcoming duties
|
||||||
@ -145,12 +139,20 @@ func aggregateSubnets*(tracker: ActionTracker, wallSlot: Slot): AttnetBits =
|
|||||||
res[duty.subnet_id.int] = true
|
res[duty.subnet_id.int] = true
|
||||||
res
|
res
|
||||||
|
|
||||||
|
# TODO https://github.com/nim-lang/Nim/issues/22215 keeps from stabilitySubnets
|
||||||
|
const allSubnetBits = block:
|
||||||
|
var res: AttnetBits
|
||||||
|
for i in 0..<res.len: res[i] = true
|
||||||
|
res
|
||||||
|
|
||||||
func stabilitySubnets*(tracker: ActionTracker, slot: Slot): AttnetBits =
|
func stabilitySubnets*(tracker: ActionTracker, slot: Slot): AttnetBits =
|
||||||
if tracker.subscribeAllAttnets:
|
if tracker.subscribeAllAttnets:
|
||||||
allSubnetBits
|
allSubnetBits
|
||||||
else:
|
else:
|
||||||
var res: AttnetBits
|
var res: AttnetBits
|
||||||
if tracker.useOldStabilitySubnets:
|
|
||||||
|
if tracker.useOldStabilitySubnets or
|
||||||
|
tracker.stabilitySubnets.len < SUBNETS_PER_NODE.int:
|
||||||
for v in tracker.stabilitySubnets:
|
for v in tracker.stabilitySubnets:
|
||||||
res[v.subnet_id.int] = true
|
res[v.subnet_id.int] = true
|
||||||
else:
|
else:
|
||||||
@ -180,7 +182,6 @@ proc updateSlot*(tracker: var ActionTracker, wallSlot: Slot) =
|
|||||||
debug "Validator no longer active", index = k
|
debug "Validator no longer active", index = k
|
||||||
tracker.knownValidators.del k
|
tracker.knownValidators.del k
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/validator.md#phase-0-attestation-subnet-stability
|
|
||||||
let expectedSubnets =
|
let expectedSubnets =
|
||||||
min(ATTESTATION_SUBNET_COUNT.int, tracker.knownValidators.len)
|
min(ATTESTATION_SUBNET_COUNT.int, tracker.knownValidators.len)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user