remove pre-v1.4.0 attestation stability subnets (#5402)
* remove pre-v1.4.0 attestation stability subnets * re-add most of should register stability subnets on attester duties test
This commit is contained in:
parent
ff176a1569
commit
2b4f987c80
|
@ -248,11 +248,6 @@ type
|
|||
desc: "Number of worker threads (\"0\" = use as many threads as there are CPU cores available)"
|
||||
name: "num-threads" .}: int
|
||||
|
||||
useOldStabilitySubnets* {.
|
||||
hidden
|
||||
defaultValue: false
|
||||
name: "debug-use-old-attestation-stability-subnets" .}: bool
|
||||
|
||||
# https://github.com/ethereum/execution-apis/blob/v1.0.0-beta.3/src/engine/authentication.md#key-distribution
|
||||
jwtSecret* {.
|
||||
desc: "A file containing the hex-encoded 256 bit secret key to be used for verifying/generating JWT tokens"
|
||||
|
|
|
@ -597,7 +597,7 @@ func init*(
|
|||
# checkpoint - we pre-load the balances here to avoid rewinding the justified
|
||||
# state later and compress them because not all checkpoints end up being used
|
||||
# for fork choice - specially during long periods of non-finalization
|
||||
proc snappyEncode(inp: openArray[byte]): seq[byte] =
|
||||
func snappyEncode(inp: openArray[byte]): seq[byte] =
|
||||
try:
|
||||
snappy.encode(inp)
|
||||
except CatchableError as err:
|
||||
|
|
|
@ -324,8 +324,7 @@ proc initFullNode(
|
|||
blobQuarantine = newClone(BlobQuarantine())
|
||||
consensusManager = ConsensusManager.new(
|
||||
dag, attestationPool, quarantine, node.elManager,
|
||||
ActionTracker.init(rng, node.network.nodeId, config.subscribeAllSubnets,
|
||||
config.useOldStabilitySubnets),
|
||||
ActionTracker.init(node.network.nodeId, config.subscribeAllSubnets),
|
||||
node.dynamicFeeRecipientsStore, config.validatorsDir,
|
||||
config.defaultFeeRecipient, config.suggestedGasLimit)
|
||||
blockProcessor = BlockProcessor.new(
|
||||
|
|
|
@ -253,9 +253,6 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
|||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/validator.md#constants
|
||||
TARGET_AGGREGATORS_PER_COMMITTEE:
|
||||
Base10.toString(TARGET_AGGREGATORS_PER_COMMITTEE),
|
||||
RANDOM_SUBNETS_PER_VALIDATOR: "1",
|
||||
EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION:
|
||||
Base10.toString(EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION),
|
||||
ATTESTATION_SUBNET_COUNT:
|
||||
Base10.toString(ATTESTATION_SUBNET_COUNT),
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ const
|
|||
|
||||
# Constants from `validator.md` not covered by config/presets in the spec
|
||||
TARGET_AGGREGATORS_PER_COMMITTEE*: uint64 = 16
|
||||
EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION*: uint64 = 256
|
||||
EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION: uint64 = 256
|
||||
|
||||
type
|
||||
Version* = distinct array[4, byte]
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
import
|
||||
stew/shims/[sets, hashes], chronicles,
|
||||
eth/p2p/discoveryv5/random2,
|
||||
../spec/forks
|
||||
|
||||
from ../spec/validator import compute_subscribed_subnets
|
||||
|
@ -38,8 +37,6 @@ type
|
|||
slot*: Slot
|
||||
|
||||
ActionTracker* = object
|
||||
useOldStabilitySubnets: bool
|
||||
rng: ref HmacDrbgContext
|
||||
nodeId: UInt256
|
||||
|
||||
subscribeAllAttnets: bool
|
||||
|
@ -50,9 +47,6 @@ type
|
|||
subscribedSubnets*: AttnetBits
|
||||
## All subnets we're currently subscribed to
|
||||
|
||||
stabilitySubnets: seq[tuple[subnet_id: SubnetId, expiration: Epoch]]
|
||||
## The subnets on which we listen and broadcast gossip traffic to maintain
|
||||
## the health of the network - these are advertised in the ENR
|
||||
nextCycleEpoch: Epoch
|
||||
|
||||
# Used to track the next attestation and proposal slots using an
|
||||
|
@ -81,14 +75,6 @@ type
|
|||
func hash*(x: AggregatorDuty): Hash =
|
||||
hashAllFields(x)
|
||||
|
||||
func randomStabilitySubnet(
|
||||
self: ActionTracker, epoch: Epoch): tuple[subnet_id: SubnetId, expiration: Epoch] =
|
||||
(
|
||||
self.rng[].rand(ATTESTATION_SUBNET_COUNT - 1).SubnetId,
|
||||
epoch + EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION +
|
||||
self.rng[].rand(EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION.int).uint64,
|
||||
)
|
||||
|
||||
proc registerDuty*(
|
||||
tracker: var ActionTracker, slot: Slot, subnet_id: SubnetId,
|
||||
vidx: ValidatorIndex, isAggregator: bool) =
|
||||
|
@ -150,11 +136,7 @@ func stabilitySubnets*(tracker: ActionTracker, slot: Slot): AttnetBits =
|
|||
allSubnetBits
|
||||
else:
|
||||
var res: AttnetBits
|
||||
|
||||
if tracker.useOldStabilitySubnets or tracker.stabilitySubnets.len == 0:
|
||||
for v in tracker.stabilitySubnets:
|
||||
res[v.subnet_id.int] = true
|
||||
else:
|
||||
if tracker.knownValidators.len > 0:
|
||||
for subnetId in compute_subscribed_subnets(tracker.nodeId, slot.epoch):
|
||||
res[subnetId.int] = true
|
||||
res
|
||||
|
@ -173,7 +155,6 @@ proc updateSlot*(tracker: var ActionTracker, wallSlot: Slot) =
|
|||
for k in dels:
|
||||
tracker.syncDuties.del(k)
|
||||
|
||||
# Keep stability subnets for as long as validators are validating
|
||||
var toPrune: seq[ValidatorIndex]
|
||||
for k, v in tracker.knownValidators:
|
||||
if v + KNOWN_VALIDATOR_DECAY < wallSlot: toPrune.add k
|
||||
|
@ -181,28 +162,6 @@ proc updateSlot*(tracker: var ActionTracker, wallSlot: Slot) =
|
|||
debug "Validator no longer active", index = k
|
||||
tracker.knownValidators.del k
|
||||
|
||||
let expectedSubnets =
|
||||
min(ATTESTATION_SUBNET_COUNT.int, tracker.knownValidators.len)
|
||||
|
||||
let epoch = wallSlot.epoch
|
||||
block:
|
||||
# If we have too many stability subnets, remove some expired ones
|
||||
var i = 0
|
||||
while tracker.stabilitySubnets.len > expectedSubnets and
|
||||
i < tracker.stabilitySubnets.len:
|
||||
if epoch >= tracker.stabilitySubnets[i].expiration:
|
||||
tracker.stabilitySubnets.delete(i)
|
||||
else:
|
||||
inc i
|
||||
|
||||
for ss in tracker.stabilitySubnets.mitems():
|
||||
if epoch >= ss.expiration:
|
||||
ss = tracker.randomStabilitySubnet(epoch)
|
||||
|
||||
# and if we have too few, add a few more
|
||||
for i in tracker.stabilitySubnets.len..<expectedSubnets:
|
||||
tracker.stabilitySubnets.add(tracker.randomStabilitySubnet(epoch))
|
||||
|
||||
tracker.currentSlot = wallSlot
|
||||
|
||||
func getNextValidatorAction(
|
||||
|
@ -300,11 +259,8 @@ func updateActions*(
|
|||
(1'u32 shl (slot mod SLOTS_PER_EPOCH))
|
||||
|
||||
func init*(
|
||||
T: type ActionTracker, rng: ref HmacDrbgContext, nodeId: UInt256,
|
||||
subscribeAllAttnets: bool, useOldStabilitySubnets: bool): T =
|
||||
T: type ActionTracker, nodeId: UInt256, subscribeAllAttnets: bool): T =
|
||||
T(
|
||||
rng: rng,
|
||||
nodeId: nodeId,
|
||||
subscribeAllAttnets: subscribeAllAttnets,
|
||||
useOldStabilitySubnets: useOldStabilitySubnets
|
||||
)
|
||||
|
|
|
@ -2802,7 +2802,7 @@
|
|||
"response": {
|
||||
"status": {"operator": "equals", "value": "200"},
|
||||
"headers": [{"key": "Content-Type", "value": "application/json", "operator": "equals"}],
|
||||
"body": [{"operator": "jstructcmps", "start": ["data"], "value": {"MAX_COMMITTEES_PER_SLOT":"","TARGET_COMMITTEE_SIZE":"","MAX_VALIDATORS_PER_COMMITTEE":"","SHUFFLE_ROUND_COUNT":"","HYSTERESIS_QUOTIENT":"","HYSTERESIS_DOWNWARD_MULTIPLIER":"","HYSTERESIS_UPWARD_MULTIPLIER":"","MIN_DEPOSIT_AMOUNT":"","MAX_EFFECTIVE_BALANCE":"","EFFECTIVE_BALANCE_INCREMENT":"","MIN_ATTESTATION_INCLUSION_DELAY":"","SLOTS_PER_EPOCH":"","MIN_SEED_LOOKAHEAD":"","MAX_SEED_LOOKAHEAD":"","EPOCHS_PER_ETH1_VOTING_PERIOD":"","SLOTS_PER_HISTORICAL_ROOT":"","MIN_EPOCHS_TO_INACTIVITY_PENALTY":"","EPOCHS_PER_HISTORICAL_VECTOR":"","EPOCHS_PER_SLASHINGS_VECTOR":"","HISTORICAL_ROOTS_LIMIT":"","VALIDATOR_REGISTRY_LIMIT":"","BASE_REWARD_FACTOR":"","WHISTLEBLOWER_REWARD_QUOTIENT":"","PROPOSER_REWARD_QUOTIENT":"","INACTIVITY_PENALTY_QUOTIENT":"","MIN_SLASHING_PENALTY_QUOTIENT":"","PROPORTIONAL_SLASHING_MULTIPLIER":"","MAX_PROPOSER_SLASHINGS":"","MAX_ATTESTER_SLASHINGS":"","MAX_ATTESTATIONS":"","MAX_DEPOSITS":"","MAX_VOLUNTARY_EXITS":"","INACTIVITY_PENALTY_QUOTIENT_ALTAIR":"","MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR":"","PROPORTIONAL_SLASHING_MULTIPLIER_ALTAIR":"","SYNC_COMMITTEE_SIZE":"","EPOCHS_PER_SYNC_COMMITTEE_PERIOD":"","MIN_SYNC_COMMITTEE_PARTICIPANTS":"","UPDATE_TIMEOUT":"","INACTIVITY_PENALTY_QUOTIENT_BELLATRIX":"","MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX":"","PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX":"","MAX_BYTES_PER_TRANSACTION":"","MAX_TRANSACTIONS_PER_PAYLOAD":"","BYTES_PER_LOGS_BLOOM":"","MAX_EXTRA_DATA_BYTES":"","MAX_BLS_TO_EXECUTION_CHANGES":"","MAX_WITHDRAWALS_PER_PAYLOAD":"","MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP":"","PRESET_BASE":"","CONFIG_NAME":"","TERMINAL_TOTAL_DIFFICULTY":"","TERMINAL_BLOCK_HASH":"","TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH":"","MIN_GENESIS_ACTIVE_VALIDATOR_COUNT":"","MIN_GENESIS_TIME":"","GENESIS_FORK_VERSION":"","GENESIS_DELAY":"","ALTAIR_FORK_VERSION":"","ALTAIR_FORK_EPOCH":"","BELLATRIX_FORK_VERSION":"","BELLATRIX_FORK_EPOCH":"","CAPELLA_FORK_VERSION":"","CAPELLA_FORK_EPOCH":"","DENEB_FORK_VERSION":"","DENEB_FORK_EPOCH":"","SECONDS_PER_SLOT":"","SECONDS_PER_ETH1_BLOCK":"","MIN_VALIDATOR_WITHDRAWABILITY_DELAY":"","SHARD_COMMITTEE_PERIOD":"","ETH1_FOLLOW_DISTANCE":"","INACTIVITY_SCORE_BIAS":"","INACTIVITY_SCORE_RECOVERY_RATE":"","EJECTION_BALANCE":"","MIN_PER_EPOCH_CHURN_LIMIT":"","CHURN_LIMIT_QUOTIENT":"","PROPOSER_SCORE_BOOST":"","DEPOSIT_CHAIN_ID":"","DEPOSIT_NETWORK_ID":"","DEPOSIT_CONTRACT_ADDRESS":"","BLS_WITHDRAWAL_PREFIX":"","ETH1_ADDRESS_WITHDRAWAL_PREFIX":"","DOMAIN_BEACON_PROPOSER":"","DOMAIN_BEACON_ATTESTER":"","DOMAIN_RANDAO":"","DOMAIN_DEPOSIT":"","DOMAIN_VOLUNTARY_EXIT":"","DOMAIN_SELECTION_PROOF":"","DOMAIN_AGGREGATE_AND_PROOF":"","TIMELY_SOURCE_FLAG_INDEX":"","TIMELY_TARGET_FLAG_INDEX":"","TIMELY_HEAD_FLAG_INDEX":"","TIMELY_SOURCE_WEIGHT":"","TIMELY_TARGET_WEIGHT":"","TIMELY_HEAD_WEIGHT":"","SYNC_REWARD_WEIGHT":"","PROPOSER_WEIGHT":"","WEIGHT_DENOMINATOR":"","DOMAIN_SYNC_COMMITTEE":"","DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF":"","DOMAIN_CONTRIBUTION_AND_PROOF":"","DOMAIN_BLS_TO_EXECUTION_CHANGE":"","TARGET_AGGREGATORS_PER_COMMITTEE":"","RANDOM_SUBNETS_PER_VALIDATOR":"","EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION":"","ATTESTATION_SUBNET_COUNT":"","TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE":"","SYNC_COMMITTEE_SUBNET_COUNT":""}}]
|
||||
"body": [{"operator": "jstructcmps", "start": ["data"], "value": {"MAX_COMMITTEES_PER_SLOT":"","TARGET_COMMITTEE_SIZE":"","MAX_VALIDATORS_PER_COMMITTEE":"","SHUFFLE_ROUND_COUNT":"","HYSTERESIS_QUOTIENT":"","HYSTERESIS_DOWNWARD_MULTIPLIER":"","HYSTERESIS_UPWARD_MULTIPLIER":"","MIN_DEPOSIT_AMOUNT":"","MAX_EFFECTIVE_BALANCE":"","EFFECTIVE_BALANCE_INCREMENT":"","MIN_ATTESTATION_INCLUSION_DELAY":"","SLOTS_PER_EPOCH":"","MIN_SEED_LOOKAHEAD":"","MAX_SEED_LOOKAHEAD":"","EPOCHS_PER_ETH1_VOTING_PERIOD":"","SLOTS_PER_HISTORICAL_ROOT":"","MIN_EPOCHS_TO_INACTIVITY_PENALTY":"","EPOCHS_PER_HISTORICAL_VECTOR":"","EPOCHS_PER_SLASHINGS_VECTOR":"","HISTORICAL_ROOTS_LIMIT":"","VALIDATOR_REGISTRY_LIMIT":"","BASE_REWARD_FACTOR":"","WHISTLEBLOWER_REWARD_QUOTIENT":"","PROPOSER_REWARD_QUOTIENT":"","INACTIVITY_PENALTY_QUOTIENT":"","MIN_SLASHING_PENALTY_QUOTIENT":"","PROPORTIONAL_SLASHING_MULTIPLIER":"","MAX_PROPOSER_SLASHINGS":"","MAX_ATTESTER_SLASHINGS":"","MAX_ATTESTATIONS":"","MAX_DEPOSITS":"","MAX_VOLUNTARY_EXITS":"","INACTIVITY_PENALTY_QUOTIENT_ALTAIR":"","MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR":"","PROPORTIONAL_SLASHING_MULTIPLIER_ALTAIR":"","SYNC_COMMITTEE_SIZE":"","EPOCHS_PER_SYNC_COMMITTEE_PERIOD":"","MIN_SYNC_COMMITTEE_PARTICIPANTS":"","UPDATE_TIMEOUT":"","INACTIVITY_PENALTY_QUOTIENT_BELLATRIX":"","MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX":"","PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX":"","MAX_BYTES_PER_TRANSACTION":"","MAX_TRANSACTIONS_PER_PAYLOAD":"","BYTES_PER_LOGS_BLOOM":"","MAX_EXTRA_DATA_BYTES":"","MAX_BLS_TO_EXECUTION_CHANGES":"","MAX_WITHDRAWALS_PER_PAYLOAD":"","MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP":"","PRESET_BASE":"","CONFIG_NAME":"","TERMINAL_TOTAL_DIFFICULTY":"","TERMINAL_BLOCK_HASH":"","TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH":"","MIN_GENESIS_ACTIVE_VALIDATOR_COUNT":"","MIN_GENESIS_TIME":"","GENESIS_FORK_VERSION":"","GENESIS_DELAY":"","ALTAIR_FORK_VERSION":"","ALTAIR_FORK_EPOCH":"","BELLATRIX_FORK_VERSION":"","BELLATRIX_FORK_EPOCH":"","CAPELLA_FORK_VERSION":"","CAPELLA_FORK_EPOCH":"","DENEB_FORK_VERSION":"","DENEB_FORK_EPOCH":"","SECONDS_PER_SLOT":"","SECONDS_PER_ETH1_BLOCK":"","MIN_VALIDATOR_WITHDRAWABILITY_DELAY":"","SHARD_COMMITTEE_PERIOD":"","ETH1_FOLLOW_DISTANCE":"","INACTIVITY_SCORE_BIAS":"","INACTIVITY_SCORE_RECOVERY_RATE":"","EJECTION_BALANCE":"","MIN_PER_EPOCH_CHURN_LIMIT":"","CHURN_LIMIT_QUOTIENT":"","PROPOSER_SCORE_BOOST":"","DEPOSIT_CHAIN_ID":"","DEPOSIT_NETWORK_ID":"","DEPOSIT_CONTRACT_ADDRESS":"","BLS_WITHDRAWAL_PREFIX":"","ETH1_ADDRESS_WITHDRAWAL_PREFIX":"","DOMAIN_BEACON_PROPOSER":"","DOMAIN_BEACON_ATTESTER":"","DOMAIN_RANDAO":"","DOMAIN_DEPOSIT":"","DOMAIN_VOLUNTARY_EXIT":"","DOMAIN_SELECTION_PROOF":"","DOMAIN_AGGREGATE_AND_PROOF":"","TIMELY_SOURCE_FLAG_INDEX":"","TIMELY_TARGET_FLAG_INDEX":"","TIMELY_HEAD_FLAG_INDEX":"","TIMELY_SOURCE_WEIGHT":"","TIMELY_TARGET_WEIGHT":"","TIMELY_HEAD_WEIGHT":"","SYNC_REWARD_WEIGHT":"","PROPOSER_WEIGHT":"","WEIGHT_DENOMINATOR":"","DOMAIN_SYNC_COMMITTEE":"","DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF":"","DOMAIN_CONTRIBUTION_AND_PROOF":"","DOMAIN_BLS_TO_EXECUTION_CHANGE":"","TARGET_AGGREGATORS_PER_COMMITTEE":"","ATTESTATION_SUBNET_COUNT":"","TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE":"","SYNC_COMMITTEE_SUBNET_COUNT":""}}]
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -12,11 +12,8 @@ import
|
|||
../beacon_chain/validators/action_tracker
|
||||
|
||||
suite "subnet tracker":
|
||||
setup:
|
||||
let rng = HmacDrbgContext.new()
|
||||
|
||||
test "should register stability subnets on attester duties":
|
||||
var tracker = ActionTracker.init(rng, default(UInt256), false, true)
|
||||
var tracker = ActionTracker.init(default(UInt256), false)
|
||||
|
||||
check:
|
||||
tracker.stabilitySubnets(Slot(0)).countOnes() == 0
|
||||
|
@ -27,7 +24,6 @@ suite "subnet tracker":
|
|||
tracker.updateSlot(Slot(0))
|
||||
|
||||
check:
|
||||
tracker.stabilitySubnets(Slot(0)).countOnes() == 1
|
||||
tracker.aggregateSubnets(Slot(0)).countOnes() == 1
|
||||
tracker.aggregateSubnets(Slot(1)).countOnes() == 0
|
||||
|
||||
|
@ -52,9 +48,8 @@ suite "subnet tracker":
|
|||
|
||||
# Guaranteed to expire
|
||||
tracker.updateSlot(
|
||||
(Epoch(EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION * 2) + 1).start_slot() +
|
||||
SUBNET_SUBSCRIPTION_LEAD_TIME_SLOTS + KNOWN_VALIDATOR_DECAY + 1)
|
||||
|
||||
(Epoch(1025).start_slot() +
|
||||
SUBNET_SUBSCRIPTION_LEAD_TIME_SLOTS + KNOWN_VALIDATOR_DECAY + 1))
|
||||
|
||||
check:
|
||||
tracker.stabilitySubnets(Slot(0)).countOnes() == 0
|
||||
|
@ -62,7 +57,7 @@ suite "subnet tracker":
|
|||
|
||||
test "should register sync committee duties":
|
||||
var
|
||||
tracker = ActionTracker.init(rng, default(UInt256), false, true)
|
||||
tracker = ActionTracker.init(default(UInt256), false)
|
||||
pk0 = ValidatorPubKey.fromHex("0xb4102a1f6c80e5c596a974ebd930c9f809c3587dc4d1d3634b77ff66db71e376dbc86c3252c6d140ce031f4ec6167798").get()
|
||||
pk1 = ValidatorPubKey.fromHex("0xa00d2954717425ce047e0928e5f4ec7c0e3bbe1058db511303fd659770ddace686ee2e22ac180422e516f4c503eb2228").get()
|
||||
|
||||
|
|
Loading…
Reference in New Issue