From ed50ec717ab42a611addebf350a324bcc3711384 Mon Sep 17 00:00:00 2001 From: Kevin Heavey Date: Sat, 21 Oct 2023 17:34:05 +0400 Subject: [PATCH 1/2] chore: fix usage of dependant where should be dependent --- packages/beacon-node/src/util/clock.ts | 2 +- packages/state-transition/src/cache/epochCache.ts | 4 ++-- .../test/perf/block/processBlockAltair.test.ts | 2 +- .../test/perf/block/processBlockPhase0.test.ts | 2 +- packages/validator/src/services/attestation.ts | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/beacon-node/src/util/clock.ts b/packages/beacon-node/src/util/clock.ts index 82fc04aac727..0be3b706a5ec 100644 --- a/packages/beacon-node/src/util/clock.ts +++ b/packages/beacon-node/src/util/clock.ts @@ -27,7 +27,7 @@ export type ClockEvents = { /** * Tracks the current chain time, measured in `Slot`s and `Epoch`s * - * The time is dependant on: + * The time is dependent on: * - `state.genesisTime` - the genesis time * - `SECONDS_PER_SLOT` - # of seconds per slot * - `SLOTS_PER_EPOCH` - # of slots per epoch diff --git a/packages/state-transition/src/cache/epochCache.ts b/packages/state-transition/src/cache/epochCache.ts index 9892de37a569..db698b40f053 100644 --- a/packages/state-transition/src/cache/epochCache.ts +++ b/packages/state-transition/src/cache/epochCache.ts @@ -368,7 +368,7 @@ export class EpochCache { // ``` // So the returned value of is_active_validator(epoch) is guaranteed to not change during `MAX_SEED_LOOKAHEAD` epochs. // - // activeIndices size is dependant on the state epoch. The epoch is advanced after running the epoch transition, and + // activeIndices size is dependent on the state epoch. The epoch is advanced after running the epoch transition, and // the first block of the epoch process_block() call. So churnLimit must be computed at the end of the before epoch // transition and the result is valid until the end of the next epoch transition const churnLimit = getChurnLimit(config, currentShuffling.activeIndices.length); @@ -514,7 +514,7 @@ export class EpochCache { // ``` // So the returned value of is_active_validator(epoch) is guaranteed to not change during `MAX_SEED_LOOKAHEAD` epochs. // - // activeIndices size is dependant on the state epoch. The epoch is advanced after running the epoch transition, and + // activeIndices size is dependent on the state epoch. The epoch is advanced after running the epoch transition, and // the first block of the epoch process_block() call. So churnLimit must be computed at the end of the before epoch // transition and the result is valid until the end of the next epoch transition this.churnLimit = getChurnLimit(this.config, this.currentShuffling.activeIndices.length); diff --git a/packages/state-transition/test/perf/block/processBlockAltair.test.ts b/packages/state-transition/test/perf/block/processBlockAltair.test.ts index 3e06dcd0852d..cf0898946ab6 100644 --- a/packages/state-transition/test/perf/block/processBlockAltair.test.ts +++ b/packages/state-transition/test/perf/block/processBlockAltair.test.ts @@ -67,7 +67,7 @@ import {BlockAltairOpts, getBlockAltair} from "./util.js"; // // // ### Hashing the state -// Hashing cost is dependant on how many nodes have been modified in the tree. After mutating the state, just count +// Hashing cost is dependent on how many nodes have been modified in the tree. After mutating the state, just count // how many nodes have no cached _root, then multiply by the cost of hashing. // diff --git a/packages/state-transition/test/perf/block/processBlockPhase0.test.ts b/packages/state-transition/test/perf/block/processBlockPhase0.test.ts index 335ca8d8b4b0..92d8630a58ac 100644 --- a/packages/state-transition/test/perf/block/processBlockPhase0.test.ts +++ b/packages/state-transition/test/perf/block/processBlockPhase0.test.ts @@ -63,7 +63,7 @@ import {BlockOpts, getBlockPhase0} from "./util.js"; // - processVoluntaryExit : - // // ### Hashing the state -// Hashing cost is dependant on how many nodes have been modified in the tree. After mutating the state, just count +// Hashing cost is dependent on how many nodes have been modified in the tree. After mutating the state, just count // how many nodes have no cached _root, then multiply by the cost of hashing. // diff --git a/packages/validator/src/services/attestation.ts b/packages/validator/src/services/attestation.ts index f954a9d2d0d5..73162b67f1af 100644 --- a/packages/validator/src/services/attestation.ts +++ b/packages/validator/src/services/attestation.ts @@ -97,7 +97,7 @@ export class AttestationService { ) ); } else { - // Beacon node's endpoint produceAttestationData return data is not dependant on committeeIndex. + // Beacon node's endpoint produceAttestationData return data is not dependent on committeeIndex. // Produce a single attestation for all committees and submit unaggregated attestations in one go. try { await this.runAttestationTasksGrouped(duties, slot, signal); @@ -159,7 +159,7 @@ export class AttestationService { /** * Performs the first step of the attesting process: downloading one `Attestation` object. - * Beacon node's endpoint produceAttestationData return data is not dependant on committeeIndex. + * Beacon node's endpoint produceAttestationData return data is not dependent on committeeIndex. * For a validator client with many validators this allows to do a single call for all committees * in a slot, saving resources in both the vc and beacon node * From 392853c398f5186a1d00a5de212c1fef1c071e9a Mon Sep 17 00:00:00 2001 From: Kevin Heavey Date: Tue, 24 Oct 2023 16:29:30 +0400 Subject: [PATCH 2/2] fix various instances of "dependant root" spelling --- .../src/chain/lightClient/index.ts | 20 +++++++++---------- .../opPools/aggregatedAttestationPool.ts | 6 +++--- .../fork-choice/src/forkChoice/forkChoice.ts | 2 +- packages/validator/src/metrics.ts | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/beacon-node/src/chain/lightClient/index.ts b/packages/beacon-node/src/chain/lightClient/index.ts index 202d1adc3e3d..1a09652dc233 100644 --- a/packages/beacon-node/src/chain/lightClient/index.ts +++ b/packages/beacon-node/src/chain/lightClient/index.ts @@ -36,7 +36,7 @@ export type LightClientServerOpts = { disableLightClientServerOnImportBlockHead?: boolean; }; -type DependantRootHex = RootHex; +type DependentRootHex = RootHex; type BlockRooHex = RootHex; export type SyncAttestedData = { @@ -122,7 +122,7 @@ const MAX_PREV_HEAD_DATA = 32; * After importing a new block + postState: * - Persist SyncCommitteeWitness, indexed by block root of state's witness, always * - Persist currentSyncCommittee, indexed by hashTreeRoot, once (not necessary after the first run) - * - Persist nextSyncCommittee, indexed by hashTreeRoot, for each period + dependantRoot + * - Persist nextSyncCommittee, indexed by hashTreeRoot, for each period + dependentRoot * - Persist FinalizedCheckpointWitness only if checkpoint period = syncAggregate period * * TODO: Prune strategy: @@ -171,7 +171,7 @@ export class LightClientServer { private readonly metrics: Metrics | null; private readonly emitter: ChainEventEmitter; private readonly logger: Logger; - private readonly knownSyncCommittee = new MapDef>(() => new Set()); + private readonly knownSyncCommittee = new MapDef>(() => new Set()); private storedCurrentSyncCommittee = false; /** @@ -378,17 +378,17 @@ export class LightClientServer { this.logger.debug("Stored currentSyncCommittee", {slot: blockSlot}); } - // Only store next sync committee once per dependant root + // Only store next sync committee once per dependent root const parentBlockPeriod = computeSyncPeriodAtSlot(parentBlockSlot); const period = computeSyncPeriodAtSlot(blockSlot); if (parentBlockPeriod < period) { - // If the parentBlock is in a previous epoch it must be the dependantRoot of this epoch transition - const dependantRoot = toHexString(block.parentRoot); - const periodDependantRoots = this.knownSyncCommittee.getOrDefault(period); - if (!periodDependantRoots.has(dependantRoot)) { - periodDependantRoots.add(dependantRoot); + // If the parentBlock is in a previous epoch it must be the dependentRoot of this epoch transition + const dependentRoot = toHexString(block.parentRoot); + const periodDependentRoots = this.knownSyncCommittee.getOrDefault(period); + if (!periodDependentRoots.has(dependentRoot)) { + periodDependentRoots.add(dependentRoot); await this.storeSyncCommittee(postState.nextSyncCommittee, syncCommitteeWitness.nextSyncCommitteeRoot); - this.logger.debug("Stored nextSyncCommittee", {period, slot: blockSlot, dependantRoot}); + this.logger.debug("Stored nextSyncCommittee", {period, slot: blockSlot, dependentRoot}); } } diff --git a/packages/beacon-node/src/chain/opPools/aggregatedAttestationPool.ts b/packages/beacon-node/src/chain/opPools/aggregatedAttestationPool.ts index e531e2c39cf6..f9911275b6ee 100644 --- a/packages/beacon-node/src/chain/opPools/aggregatedAttestationPool.ts +++ b/packages/beacon-node/src/chain/opPools/aggregatedAttestationPool.ts @@ -450,16 +450,16 @@ export function isValidAttestationData( throw Error(`Attestation data.beaconBlockRoot ${beaconBlockRootHex} not found in forkchoice`); } - let attestationDependantRoot: string; + let attestationDependentRoot: string; try { - attestationDependantRoot = forkChoice.getDependentRoot(beaconBlock, EpochDifference.previous); + attestationDependentRoot = forkChoice.getDependentRoot(beaconBlock, EpochDifference.previous); } catch (_) { // getDependent root may throw error if the dependent root of attestation data is prior to finalized slot // ignore this attestation data in that case since we're not sure it's compatible to the state // see https://github.com/ChainSafe/lodestar/issues/4743 return false; } - return attestationDependantRoot === stateDependentRoot; + return attestationDependentRoot === stateDependentRoot; } function flagIsTimelySource(flag: number): boolean { diff --git a/packages/fork-choice/src/forkChoice/forkChoice.ts b/packages/fork-choice/src/forkChoice/forkChoice.ts index ef859a239dc5..396146b193c7 100644 --- a/packages/fork-choice/src/forkChoice/forkChoice.ts +++ b/packages/fork-choice/src/forkChoice/forkChoice.ts @@ -861,7 +861,7 @@ export class ForkChoice implements IForkChoice { // The navigation at the end of the while loop will always progress backwards, // jumping to a block with a strictly less slot number. So the condition `blockEpoch < atEpoch` // is guaranteed to happen. Given the use of target blocks for faster navigation, it will take - // at most `2 * (blockEpoch - atEpoch + 1)` iterations to find the dependant root. + // at most `2 * (blockEpoch - atEpoch + 1)` iterations to find the dependent root. const beforeSlot = block.slot - (block.slot % SLOTS_PER_EPOCH) - epochDifference * SLOTS_PER_EPOCH; diff --git a/packages/validator/src/metrics.ts b/packages/validator/src/metrics.ts index 4ae4724fb1c1..5bc3895414a2 100644 --- a/packages/validator/src/metrics.ts +++ b/packages/validator/src/metrics.ts @@ -203,7 +203,7 @@ export function getMetrics(register: MetricsRegister, gitData: LodestarGitData) attesterDutiesReorg: register.gauge({ name: "vc_attestation_duties_reorg_total", - help: "Total count of instances the attester duties dependant root changed", + help: "Total count of instances the attester duties dependent root changed", }), attesterDutiesNextSlot: register.gauge({ @@ -241,7 +241,7 @@ export function getMetrics(register: MetricsRegister, gitData: LodestarGitData) proposerDutiesReorg: register.gauge({ name: "vc_proposer_duties_reorg_total", - help: "Total count of instances the proposer duties dependant root changed", + help: "Total count of instances the proposer duties dependent root changed", }), newProposalDutiesDetected: register.gauge({ @@ -287,14 +287,14 @@ export function getMetrics(register: MetricsRegister, gitData: LodestarGitData) syncCommitteeDutiesReorg: register.gauge({ name: "vc_sync_committee_duties_reorg_total", - help: "Total count of instances the sync committee duties dependant root changed", + help: "Total count of instances the sync committee duties dependent root changed", }), // ValidatorStore signers: register.gauge({ name: "vc_signers_count", - help: "Total count of instances the sync committee duties dependant root changed", + help: "Total count of instances the sync committee duties dependent root changed", }), localSignTime: register.histogram({