Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix usage of dependant where should be dependent #6056

Merged
merged 2 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions packages/beacon-node/src/chain/lightClient/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export type LightClientServerOpts = {
disableLightClientServerOnImportBlockHead?: boolean;
};

type DependantRootHex = RootHex;
type DependentRootHex = RootHex;
type BlockRooHex = RootHex;

export type SyncAttestedData = {
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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<SyncPeriod, Set<DependantRootHex>>(() => new Set());
private readonly knownSyncCommittee = new MapDef<SyncPeriod, Set<DependentRootHex>>(() => new Set());
private storedCurrentSyncCommittee = false;

/**
Expand Down Expand Up @@ -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});
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/src/util/clock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/fork-choice/src/forkChoice/forkChoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions packages/state-transition/src/cache/epochCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//

Expand Down
8 changes: 4 additions & 4 deletions packages/validator/src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down
4 changes: 2 additions & 2 deletions packages/validator/src/services/attestation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
*
Expand Down