opt-out support for v1.4.0 attestation stability subnets (#5128)
* opt-out support for v1.4.0 attestation stability subnets * document debug-prefix-flag-policy and remove temporary from flag name
This commit is contained in:
parent
e8f3bfdb08
commit
ba94dc849f
|
@ -238,6 +238,11 @@ type
|
|||
desc: "Number of worker threads (\"0\" = use as many threads as there are CPU cores available)"
|
||||
name: "num-threads" .}: int
|
||||
|
||||
useOldStabilitySubnets* {.
|
||||
hidden
|
||||
defaultValue: true
|
||||
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"
|
||||
|
|
|
@ -324,7 +324,8 @@ proc initFullNode(
|
|||
blobQuarantine = newClone(BlobQuarantine())
|
||||
consensusManager = ConsensusManager.new(
|
||||
dag, attestationPool, quarantine, node.elManager,
|
||||
ActionTracker.init(rng, config.subscribeAllSubnets),
|
||||
ActionTracker.init(rng, node.network.nodeId, config.subscribeAllSubnets,
|
||||
config.useOldStabilitySubnets),
|
||||
node.dynamicFeeRecipientsStore, config.validatorsDir,
|
||||
config.defaultFeeRecipient, config.suggestedGasLimit)
|
||||
blockProcessor = BlockProcessor.new(
|
||||
|
|
|
@ -23,7 +23,6 @@ const
|
|||
|
||||
# Constants from `validator.md` not covered by config/presets in the spec
|
||||
TARGET_AGGREGATORS_PER_COMMITTEE*: uint64 = 16
|
||||
RANDOM_SUBNETS_PER_VALIDATOR*: uint64 = 1
|
||||
EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION*: uint64 = 256
|
||||
|
||||
type
|
||||
|
@ -91,6 +90,7 @@ const
|
|||
ignoredValues = [
|
||||
"TRANSITION_TOTAL_DIFFICULTY", # Name that appears in some altair alphas, obsolete, remove when no more testnets
|
||||
"MIN_ANCHOR_POW_BLOCK_DIFFICULTY", # Name that appears in some altair alphas, obsolete, remove when no more testnets
|
||||
"RANDOM_SUBNETS_PER_VALIDATOR", # Removed in consensus-specs v1.4.0
|
||||
]
|
||||
|
||||
when const_preset == "mainnet":
|
||||
|
@ -562,7 +562,6 @@ proc readRuntimeConfig(
|
|||
checkCompatibility MAX_VOLUNTARY_EXITS
|
||||
|
||||
checkCompatibility TARGET_AGGREGATORS_PER_COMMITTEE
|
||||
checkCompatibility RANDOM_SUBNETS_PER_VALIDATOR
|
||||
checkCompatibility EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION
|
||||
checkCompatibility ATTESTATION_SUBNET_COUNT
|
||||
|
||||
|
|
|
@ -6,11 +6,13 @@
|
|||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
std/[sequtils, tables],
|
||||
stew/shims/[sets, hashes], chronicles,
|
||||
eth/p2p/discoveryv5/random2,
|
||||
../spec/forks,
|
||||
../consensus_object_pools/spec_cache
|
||||
../spec/forks
|
||||
|
||||
from ../spec/validator import compute_subscribed_subnets
|
||||
from ../consensus_object_pools/spec_cache import
|
||||
EpochRef, epoch, get_committee_assignments
|
||||
|
||||
export forks, tables, sets
|
||||
|
||||
|
@ -36,7 +38,9 @@ type
|
|||
slot*: Slot
|
||||
|
||||
ActionTracker* = object
|
||||
useOldStabilitySubnets: bool
|
||||
rng: ref HmacDrbgContext
|
||||
nodeId: UInt256
|
||||
|
||||
subscribeAllAttnets: bool
|
||||
|
||||
|
@ -146,8 +150,12 @@ func stabilitySubnets*(tracker: ActionTracker, slot: Slot): AttnetBits =
|
|||
allSubnetBits
|
||||
else:
|
||||
var res: AttnetBits
|
||||
for v in tracker.stabilitySubnets:
|
||||
res[v.subnet_id.int] = true
|
||||
if tracker.useOldStabilitySubnets:
|
||||
for v in tracker.stabilitySubnets:
|
||||
res[v.subnet_id.int] = true
|
||||
else:
|
||||
for subnetId in compute_subscribed_subnets(tracker.nodeId, slot.epoch):
|
||||
res[subnetId.int] = true
|
||||
res
|
||||
|
||||
proc updateSlot*(tracker: var ActionTracker, wallSlot: Slot) =
|
||||
|
@ -172,9 +180,6 @@ proc updateSlot*(tracker: var ActionTracker, wallSlot: Slot) =
|
|||
debug "Validator no longer active", index = k
|
||||
tracker.knownValidators.del k
|
||||
|
||||
# One stability subnet per known validator
|
||||
static: doAssert RANDOM_SUBNETS_PER_VALIDATOR == 1
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/validator.md#phase-0-attestation-subnet-stability
|
||||
let expectedSubnets =
|
||||
min(ATTESTATION_SUBNET_COUNT.int, tracker.knownValidators.len)
|
||||
|
@ -247,6 +252,8 @@ func needsUpdate*(
|
|||
tracker.attesterDepRoot !=
|
||||
state.dependent_root(if epoch > Epoch(0): epoch - 1 else: epoch)
|
||||
|
||||
from std/sequtils import toSeq
|
||||
|
||||
func updateActions*(
|
||||
tracker: var ActionTracker, epochRef: EpochRef) =
|
||||
# Updates the schedule for upcoming attestation and proposal work
|
||||
|
@ -293,9 +300,11 @@ func updateActions*(
|
|||
(1'u32 shl (slot mod SLOTS_PER_EPOCH))
|
||||
|
||||
func init*(
|
||||
T: type ActionTracker, rng: ref HmacDrbgContext,
|
||||
subscribeAllAttnets: bool): T =
|
||||
T: type ActionTracker, rng: ref HmacDrbgContext, nodeId: UInt256,
|
||||
subscribeAllAttnets: bool, useOldStabilitySubnets: bool): T =
|
||||
T(
|
||||
rng: rng,
|
||||
subscribeAllAttnets: subscribeAllAttnets
|
||||
nodeId: nodeId,
|
||||
subscribeAllAttnets: subscribeAllAttnets,
|
||||
useOldStabilitySubnets: useOldStabilitySubnets
|
||||
)
|
||||
|
|
|
@ -127,6 +127,8 @@ The following options are available:
|
|||
...
|
||||
```
|
||||
|
||||
Any `debug`-prefixed flags are considered ephemeral and subject to removal without notice.
|
||||
|
||||
## Configuration files
|
||||
|
||||
All command line options can also be provided in a [TOML](https://toml.io/en/)
|
||||
|
|
|
@ -16,7 +16,7 @@ suite "subnet tracker":
|
|||
let rng = HmacDrbgContext.new()
|
||||
|
||||
test "should register stability subnets on attester duties":
|
||||
var tracker = ActionTracker.init(rng, false)
|
||||
var tracker = ActionTracker.init(rng, default(UInt256), false, true)
|
||||
|
||||
check:
|
||||
tracker.stabilitySubnets(Slot(0)).countOnes() == 0
|
||||
|
@ -62,7 +62,7 @@ suite "subnet tracker":
|
|||
|
||||
test "should register sync committee duties":
|
||||
var
|
||||
tracker = ActionTracker.init(rng, false)
|
||||
tracker = ActionTracker.init(rng, default(UInt256), false, true)
|
||||
pk0 = ValidatorPubKey.fromHex("0xb4102a1f6c80e5c596a974ebd930c9f809c3587dc4d1d3634b77ff66db71e376dbc86c3252c6d140ce031f4ec6167798").get()
|
||||
pk1 = ValidatorPubKey.fromHex("0xa00d2954717425ce047e0928e5f4ec7c0e3bbe1058db511303fd659770ddace686ee2e22ac180422e516f4c503eb2228").get()
|
||||
|
||||
|
|
Loading…
Reference in New Issue