Skip to content

Commit

Permalink
chore: no need to commit() before sliceTo()
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Sep 11, 2024
1 parent f723594 commit d5ffae4
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export class DepositDataRootRepository extends Repository<number, Root> {

async getDepositRootTreeAtIndex(depositIndex: number): Promise<DepositTree> {
const depositRootTree = await this.getDepositRootTree();
depositRootTree.commit();
return depositRootTree.sliceTo(depositIndex);
}

Expand Down
1 change: 0 additions & 1 deletion packages/beacon-node/src/eth1/utils/deposits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export function getDepositsWithProofs(
eth1Data: phase0.Eth1Data
): phase0.Deposit[] {
// Get tree at this particular depositCount to compute correct proofs
depositRootTree.commit();
const viewAtDepositCount = depositRootTree.sliceTo(eth1Data.depositCount - 1);

const depositRoot = viewAtDepositCount.hashTreeRoot();
Expand Down
1 change: 0 additions & 1 deletion packages/beacon-node/src/eth1/utils/eth1Data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export function getDepositRootByDepositCount(depositCounts: number[], depositRoo

const depositRootByDepositCount = new Map<number, Root>();
for (const depositCount of depositCounts) {
depositRootTree.commit();
depositRootTree = depositRootTree.sliceTo(depositCount - 1);
depositRootByDepositCount.set(depositCount, depositRootTree.hashTreeRoot());
}
Expand Down
2 changes: 0 additions & 2 deletions packages/state-transition/src/epoch/getRewardsAndPenalties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ export function getRewardsAndPenaltiesAltair(
// TODO: Is there a cheaper way to measure length that going to `state.validators`?
const validatorCount = state.validators.length;
const activeIncrements = cache.totalActiveStakeByIncrement;
// const rewards = newZeroedArray(validatorCount);
// const penalties = newZeroedArray(validatorCount);
rewards.length = validatorCount;
rewards.fill(0);
penalties.length = validatorCount;
Expand Down
2 changes: 0 additions & 2 deletions packages/state-transition/src/util/loadState/loadState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ function loadInactivityScores(
if (newValidator - 1 < 0) {
migratedState.inactivityScores = ssz.altair.InactivityScores.defaultViewDU();
} else {
migratedState.inactivityScores.commit();
migratedState.inactivityScores = migratedState.inactivityScores.sliceTo(newValidator - 1);
}
}
Expand Down Expand Up @@ -220,7 +219,6 @@ function loadValidators(
modifiedValidators.push(validatorIndex);
}
} else {
migratedState.validators.commit();
migratedState.validators = migratedState.validators.sliceTo(newValidatorCount - 1);
}
return modifiedValidators;
Expand Down

0 comments on commit d5ffae4

Please sign in to comment.