From 519bfa3c3ab1726e3482256643e12f49a520ac57 Mon Sep 17 00:00:00 2001 From: Tuyen Nguyen Date: Thu, 17 Oct 2024 08:08:04 +0700 Subject: [PATCH] fix: lint --- .../src/chain/blocks/importBlock.ts | 21 +++++++++++-------- .../stateCache/persistentCheckpointsCache.ts | 11 +--------- .../src/block/processEth1Data.ts | 1 + packages/state-transition/src/util/balance.ts | 2 +- packages/types/src/phase0/listValidator.ts | 1 + packages/types/src/phase0/validator.ts | 1 + .../types/src/phase0/viewDU/listValidator.ts | 8 +++++-- 7 files changed, 23 insertions(+), 22 deletions(-) diff --git a/packages/beacon-node/src/chain/blocks/importBlock.ts b/packages/beacon-node/src/chain/blocks/importBlock.ts index 4fea6b38042e..38c54f63f69a 100644 --- a/packages/beacon-node/src/chain/blocks/importBlock.ts +++ b/packages/beacon-node/src/chain/blocks/importBlock.ts @@ -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}); diff --git a/packages/beacon-node/src/chain/stateCache/persistentCheckpointsCache.ts b/packages/beacon-node/src/chain/stateCache/persistentCheckpointsCache.ts index c69d636b59b1..4d3e50d78d7f 100644 --- a/packages/beacon-node/src/chain/stateCache/persistentCheckpointsCache.ts +++ b/packages/beacon-node/src/chain/stateCache/persistentCheckpointsCache.ts @@ -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); } } @@ -484,7 +484,6 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache { blockRootHex: RootHex, state: CachedBeaconStateAllForks ): Promise | 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) { @@ -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; } diff --git a/packages/state-transition/src/block/processEth1Data.ts b/packages/state-transition/src/block/processEth1Data.ts index 8e6ded467821..3846eaaa5f55 100644 --- a/packages/state-transition/src/block/processEth1Data.ts +++ b/packages/state-transition/src/block/processEth1Data.ts @@ -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++; diff --git a/packages/state-transition/src/util/balance.ts b/packages/state-transition/src/util/balance.ts index a1b086cbd591..ce5c2a46b4da 100644 --- a/packages/state-transition/src/util/balance.ts +++ b/packages/state-transition/src/util/balance.ts @@ -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"; /** diff --git a/packages/types/src/phase0/listValidator.ts b/packages/types/src/phase0/listValidator.ts index a2228d5ec410..3a19931d1f5b 100644 --- a/packages/types/src/phase0/listValidator.ts +++ b/packages/types/src/phase0/listValidator.ts @@ -9,6 +9,7 @@ export class ListValidatorType extends ListCompositeType { + // biome-ignore lint/suspicious/noExplicitAny: ssz api return new ListValidatorTreeViewDU(this, node, cache as any); } } diff --git a/packages/types/src/phase0/validator.ts b/packages/types/src/phase0/validator.ts index 2861f52d2deb..9a64d9569f92 100644 --- a/packages/types/src/phase0/validator.ts +++ b/packages/types/src/phase0/validator.ts @@ -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 diff --git a/packages/types/src/phase0/viewDU/listValidator.ts b/packages/types/src/phase0/viewDU/listValidator.ts index 05aeeebd75a5..adec88a94b10 100644 --- a/packages/types/src/phase0/viewDU/listValidator.ts +++ b/packages/types/src/phase0/viewDU/listValidator.ts @@ -60,7 +60,8 @@ export class ListValidatorTreeViewDU extends ListCompositeTreeViewDU>): void { +function doBatchHashTreeRootValidators( + indices: ValidatorIndex[], + validators: Map> +): void { const endBatch = indices.length - (indices.length % PARALLEL_FACTOR); // commit every 16 validators in batch