Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Oct 17, 2024
1 parent ea1dc3c commit 519bfa3
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 22 deletions.
21 changes: 12 additions & 9 deletions packages/beacon-node/src/chain/blocks/importBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,19 @@ export async function importBlock(

// This adds the state necessary to process the next block
// Some block event handlers require state being in state cache so need to do this before emitting EventType.block
this.regen.processState(blockRootHex, postState).then((prunedStates) => {
if (prunedStates) {
for (const states of prunedStates.values()) {
// cp states on the same epoch shares the same balances seed tree so only need one of them
this.balancesTreeCache.processUnusedState(states[0]);
this.regen
.processState(blockRootHex, postState)
.then((prunedStates) => {
if (prunedStates) {
for (const states of prunedStates.values()) {
// cp states on the same epoch shares the same balances seed tree so only need one of them
this.balancesTreeCache.processUnusedState(states[0]);
}
}
}
}).catch((e) => {
this.logger.error("Regen error to process state for block", {slot: blockSlot, root: blockRootHex}, e as Error);
});
})
.catch((e) => {
this.logger.error("Regen error to process state for block", {slot: blockSlot, root: blockRootHex}, e as Error);
});

this.metrics?.importBlock.bySource.inc({source});
this.logger.verbose("Added block to forkchoice and state cache", {slot: blockSlot, root: blockRootHex});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
try {
const prunedStates = await this.deleteAllEpochItems(epoch);
result.set(epoch, prunedStates);
} catch(e) {
} catch (e) {
this.logger.debug("Error prune finalized epoch", {epoch, finalizedEpoch}, e as Error);
}
}
Expand Down Expand Up @@ -484,7 +484,6 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
blockRootHex: RootHex,
state: CachedBeaconStateAllForks
): Promise<Map<Epoch, CachedBeaconStateAllForks[]> | null> {
let persistCount = 0;
// it's important to sort the epochs in ascending order, in case of big reorg we always want to keep the most recent checkpoint states
const sortedEpochs = Array.from(this.epochIndex.keys()).sort((a, b) => a - b);
if (sortedEpochs.length <= this.maxEpochsInMemory) {
Expand Down Expand Up @@ -516,14 +515,6 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
result.set(lowestEpoch, prunedStates);
}

if (persistCount > 0) {
this.logger.verbose("Persisted checkpoint states", {
slot: blockSlot,
root: blockRootHex,
persistCount,
persistEpochs: persistEpochs.length,
});
}
return result;
}

Expand Down
1 change: 1 addition & 0 deletions packages/state-transition/src/block/processEth1Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function becomesNewEth1Data(
// Then isEqualEth1DataView compares cached roots (HashObject as of Jan 2022) which is much cheaper
// than doing structural equality, which requires tree -> value conversions
let sameVotesCount = 0;
// biome-ignore lint/complexity/noForEach: ssz api
state.eth1DataVotes.forEach((eth1DataVote) => {
if (isEqualEth1DataView(eth1DataVote, newEth1Data)) {
sameVotesCount++;
Expand Down
2 changes: 1 addition & 1 deletion packages/state-transition/src/util/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {EFFECTIVE_BALANCE_INCREMENT} from "@lodestar/params";
import {Gwei, ValidatorIndex} from "@lodestar/types";
import {bigIntMax} from "@lodestar/utils";
import {EffectiveBalanceIncrements} from "../cache/effectiveBalanceIncrements.js";
import {BeaconStateAllForks} from "..";
import {BeaconStateAllForks} from "../index.js";
import {CachedBeaconStateAllForks} from "../types.js";

/**
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/phase0/listValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export class ListValidatorType extends ListCompositeType<ValidatorNodeStructType
}

getViewDU(node: Node, cache?: unknown): ListCompositeTreeViewDU<ValidatorNodeStructType> {
// biome-ignore lint/suspicious/noExplicitAny: ssz api
return new ListValidatorTreeViewDU(this, node, cache as any);
}
}
1 change: 1 addition & 0 deletions packages/types/src/phase0/validator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {ByteViews, ContainerNodeStructType, ValueOfFields} from "@chainsafe/ssz";
import * as primitiveSsz from "../primitive/sszTypes.js";

// biome-ignore lint/suspicious/noShadowRestrictedNames: We explicitly want `Boolean` name to be imported
const {Boolean, Bytes32, UintNum64, BLSPubkey, EpochInf} = primitiveSsz;

// this is to work with uint32, see https://github.com/ChainSafe/ssz/blob/ssz-v0.15.1/packages/ssz/src/type/uint.ts
Expand Down
8 changes: 6 additions & 2 deletions packages/types/src/phase0/viewDU/listValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export class ListValidatorTreeViewDU extends ListCompositeTreeViewDU<ValidatorNo
commit(hcOffset = 0, hcByLevel: HashComputationLevel[] | null = null): void {
if (hcByLevel === null) {
// this is not from batchHashTreeRoot() call, go with regular flow
return super.commit();
super.commit();
return;
}

const isOldRootHashed = this._rootNode.h0 !== null;
Expand Down Expand Up @@ -125,7 +126,10 @@ export class ListValidatorTreeViewDU extends ListCompositeTreeViewDU<ValidatorNo
}
}

function doBatchHashTreeRootValidators(indices: ValidatorIndex[], validators: Map<ValidatorIndex, ContainerNodeStructTreeViewDU<typeof ValidatorType>>): void {
function doBatchHashTreeRootValidators(
indices: ValidatorIndex[],
validators: Map<ValidatorIndex, ContainerNodeStructTreeViewDU<typeof ValidatorType>>
): void {
const endBatch = indices.length - (indices.length % PARALLEL_FACTOR);

// commit every 16 validators in batch
Expand Down

0 comments on commit 519bfa3

Please sign in to comment.