Skip to content

Commit

Permalink
Undo unrelated renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
ensi321 committed Apr 13, 2024
1 parent 5ac6350 commit 6568ac9
Show file tree
Hide file tree
Showing 34 changed files with 96 additions and 102 deletions.
4 changes: 2 additions & 2 deletions packages/beacon-node/src/chain/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
CachedBeaconStateAllForks,
computeEpochAtSlot,
computeStartSlotAtEpoch,
createFinalizedCachedBeaconState,
createCachedBeaconState,
EffectiveBalanceIncrements,
getEffectiveBalanceIncrementsZeroInactive,
isCachedBeaconState,
Expand Down Expand Up @@ -233,7 +233,7 @@ export class BeaconChain implements IBeaconChain {
const cachedState =
isCachedBeaconState(anchorState) && opts.skipCreateStateCacheIfAvailable
? anchorState
: createFinalizedCachedBeaconState(anchorState, {
: createCachedBeaconState(anchorState, {
config,
finalizedPubkey2index: new PubkeyIndexMap(),
finalizedIndex2pubkey: [],
Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/src/chain/genesis/genesis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
applyTimestamp,
applyEth1BlockHash,
CachedBeaconStateAllForks,
createFinalizedCachedBeaconState,
createCachedBeaconState,
BeaconStateAllForks,
createEmptyEpochCacheImmutableData,
getActiveValidatorIndices,
Expand Down Expand Up @@ -86,7 +86,7 @@ export class GenesisBuilder implements IGenesisBuilder {
}

// TODO - PENDING: Ensure EpochCacheImmutableData is created only once
this.state = createFinalizedCachedBeaconState(stateView, createEmptyEpochCacheImmutableData(config, stateView));
this.state = createCachedBeaconState(stateView, createEmptyEpochCacheImmutableData(config, stateView));
this.config = this.state.config;
this.activatedValidatorCount = getActiveValidatorIndices(stateView, GENESIS_EPOCH).length;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {phase0, Epoch, RootHex} from "@lodestar/types";
import {CachedBeaconStateAllForks, computeStartSlotAtEpoch, getBlockRootAtSlot} from "@lodestar/state-transition";
import {Logger, MapDef, sleep} from "@lodestar/utils";
import {routes} from "@lodestar/api";
import {loadUnfinalizedCachedBeaconState} from "@lodestar/state-transition";
import {loadCachedBeaconState} from "@lodestar/state-transition";
import {INTERVALS_PER_SLOT} from "@lodestar/params";
import {Metrics} from "../../metrics/index.js";
import {IClock} from "../../util/clock.js";
Expand Down Expand Up @@ -217,7 +217,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
}
sszTimer?.();
const timer = this.metrics?.stateReloadDuration.startTimer();
const newCachedState = loadUnfinalizedCachedBeaconState(
const newCachedState = loadCachedBeaconState(
seedState,
stateBytes,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {BeaconDb} from "../../../src/db/index.js";
import {generateState} from "../../utils/state.js";
import {Eth1Provider} from "../../../src/eth1/provider/eth1Provider.js";
import {getGoerliRpcUrl} from "../../testParams.js";
import {createFinalizedCachedBeaconStateTest} from "../../utils/cachedBeaconState.js";
import {createCachedBeaconStateTest} from "../../utils/cachedBeaconState.js";

const dbLocation = "./.__testdb";

Expand Down Expand Up @@ -112,7 +112,7 @@ describe.skip("eth1 / Eth1Provider", function () {
config
);

const state = createFinalizedCachedBeaconStateTest(tbState, config);
const state = createCachedBeaconStateTest(tbState, config);

const result = await eth1ForBlockProduction.getEth1DataAndDeposits(state);
expect(result.eth1Data).toEqual(latestEth1Data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
import * as epochFns from "@lodestar/state-transition/epoch";
import {ssz} from "@lodestar/types";
import {ACTIVE_PRESET} from "@lodestar/params";
import {createFinalizedCachedBeaconStateTest} from "../../utils/cachedBeaconState.js";
import {createCachedBeaconStateTest} from "../../utils/cachedBeaconState.js";
import {expectEqualBeaconState, inputTypeSszTreeViewDU} from "../utils/expectEqualBeaconState.js";
import {getConfig} from "../../utils/config.js";
import {RunnerType, TestRunnerFn} from "../utils/types.js";
Expand Down Expand Up @@ -64,7 +64,7 @@ const epochProcessing =
return {
testFunction: (testcase) => {
const stateTB = testcase.pre.clone();
const state = createFinalizedCachedBeaconStateTest(stateTB, config);
const state = createCachedBeaconStateTest(stateTB, config);

const epochTransitionCache = beforeProcessEpoch(state, {assertCorrectProgressiveBalances});

Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/test/spec/presets/finality.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "@lodestar/state-transition";
import {altair, bellatrix, ssz} from "@lodestar/types";
import {ACTIVE_PRESET, ForkName} from "@lodestar/params";
import {createFinalizedCachedBeaconStateTest} from "../../utils/cachedBeaconState.js";
import {createCachedBeaconStateTest} from "../../utils/cachedBeaconState.js";
import {expectEqualBeaconState, inputTypeSszTreeViewDU} from "../utils/expectEqualBeaconState.js";
import {RunnerType, shouldVerify, TestRunnerFn} from "../utils/types.js";
import {getConfig} from "../../utils/config.js";
Expand All @@ -20,7 +20,7 @@ import {specTestIterator} from "../utils/specTestIterator.js";
const finality: TestRunnerFn<FinalityTestCase, BeaconStateAllForks> = (fork) => {
return {
testFunction: (testcase) => {
let state = createFinalizedCachedBeaconStateTest(testcase.pre, getConfig(fork));
let state = createCachedBeaconStateTest(testcase.pre, getConfig(fork));
const verify = shouldVerify(testcase);
for (let i = 0; i < testcase.meta.blocks_count; i++) {
const signedBlock = testcase[`blocks_${i}`] as bellatrix.SignedBeaconBlock;
Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/test/spec/presets/fork.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {phase0, ssz} from "@lodestar/types";
import {ACTIVE_PRESET, ForkName} from "@lodestar/params";
import {createChainForkConfig, ChainForkConfig} from "@lodestar/config";
import {expectEqualBeaconState, inputTypeSszTreeViewDU} from "../utils/expectEqualBeaconState.js";
import {createFinalizedCachedBeaconStateTest} from "../../utils/cachedBeaconState.js";
import {createCachedBeaconStateTest} from "../../utils/cachedBeaconState.js";
import {RunnerType, TestRunnerFn} from "../utils/types.js";
import {ethereumConsensusSpecsTests} from "../specTestVersioning.js";
import {specTestIterator} from "../utils/specTestIterator.js";
Expand All @@ -23,7 +23,7 @@ const fork: TestRunnerFn<ForkStateCase, BeaconStateAllForks> = (forkNext) => {

return {
testFunction: (testcase) => {
const preState = createFinalizedCachedBeaconStateTest(testcase.pre, config);
const preState = createCachedBeaconStateTest(testcase.pre, config);

switch (forkNext) {
case ForkName.phase0:
Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/test/spec/presets/fork_choice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ACTIVE_PRESET, ForkSeq, isForkBlobs} from "@lodestar/params";
import {BeaconChain, ChainEvent} from "../../../src/chain/index.js";
import {ClockEvent} from "../../../src/util/clock.js";
import {computeInclusionProof} from "../../../src/util/blobs.js";
import {createFinalizedCachedBeaconStateTest} from "../../utils/cachedBeaconState.js";
import {createCachedBeaconStateTest} from "../../utils/cachedBeaconState.js";
import {testLogger} from "../../utils/logger.js";
import {getConfig} from "../../utils/config.js";
import {RunnerType, TestRunnerFn} from "../utils/types.js";
Expand Down Expand Up @@ -60,7 +60,7 @@ const forkChoiceTest =
const {steps, anchorState} = testcase;
const currentSlot = anchorState.slot;
const config = getConfig(fork);
const state = createFinalizedCachedBeaconStateTest(anchorState, config);
const state = createCachedBeaconStateTest(anchorState, config);

/** This is to track test's tickTime to be used in proposer boost */
let tickTime = 0;
Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/test/spec/presets/operations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {ssz, phase0, altair, bellatrix, capella, electra} from "@lodestar/types"
import {InputType} from "@lodestar/spec-test-util";
import {ACTIVE_PRESET, ForkName} from "@lodestar/params";

import {createFinalizedCachedBeaconStateTest} from "../../utils/cachedBeaconState.js";
import {createCachedBeaconStateTest} from "../../utils/cachedBeaconState.js";
import {expectEqualBeaconState, inputTypeSszTreeViewDU} from "../utils/expectEqualBeaconState.js";
import {getConfig} from "../../utils/config.js";
import {BaseSpecTest, RunnerType, shouldVerify, TestRunnerFn} from "../utils/types.js";
Expand Down Expand Up @@ -111,7 +111,7 @@ const operations: TestRunnerFn<OperationsTestCase, BeaconStateAllForks> = (fork,
testFunction: (testcase) => {
const state = testcase.pre.clone();
const epoch = (state.fork as phase0.Fork).epoch;
const cachedState = createFinalizedCachedBeaconStateTest(state, getConfig(fork, epoch));
const cachedState = createCachedBeaconStateTest(state, getConfig(fork, epoch));

operationFn(cachedState, testcase);
state.commit();
Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/test/spec/presets/rewards.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {BeaconStateAllForks, beforeProcessEpoch} from "@lodestar/state-transitio
import {getRewardsAndPenalties} from "@lodestar/state-transition/epoch";
import {ssz} from "@lodestar/types";
import {ACTIVE_PRESET} from "@lodestar/params";
import {createFinalizedCachedBeaconStateTest} from "../../utils/cachedBeaconState.js";
import {createCachedBeaconStateTest} from "../../utils/cachedBeaconState.js";
import {inputTypeSszTreeViewDU} from "../utils/expectEqualBeaconState.js";
import {getConfig} from "../../utils/config.js";
import {RunnerType, TestRunnerFn} from "../utils/types.js";
Expand All @@ -21,7 +21,7 @@ const rewards: TestRunnerFn<RewardTestCase, Deltas> = (fork) => {
return {
testFunction: (testcase) => {
const config = getConfig(fork);
const wrappedState = createFinalizedCachedBeaconStateTest(testcase.pre, config);
const wrappedState = createCachedBeaconStateTest(testcase.pre, config);
const epochTransitionCache = beforeProcessEpoch(wrappedState, {assertCorrectProgressiveBalances});

// To debug this test and get granular results you can tweak inputs to get more granular results
Expand Down
6 changes: 3 additions & 3 deletions packages/beacon-node/test/spec/presets/sanity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import {allForks, deneb, ssz} from "@lodestar/types";
import {ACTIVE_PRESET, ForkName} from "@lodestar/params";
import {bnToNum} from "@lodestar/utils";
import {createFinalizedCachedBeaconStateTest} from "../../utils/cachedBeaconState.js";
import {createCachedBeaconStateTest} from "../../utils/cachedBeaconState.js";
import {expectEqualBeaconState, inputTypeSszTreeViewDU} from "../utils/expectEqualBeaconState.js";
import {RunnerType, shouldVerify, TestRunnerFn} from "../utils/types.js";
import {getConfig} from "../../utils/config.js";
Expand All @@ -35,7 +35,7 @@ const sanitySlots: TestRunnerFn<SanitySlotsTestCase, BeaconStateAllForks> = (for
return {
testFunction: (testcase) => {
const stateTB = testcase.pre.clone();
const state = createFinalizedCachedBeaconStateTest(stateTB, getConfig(fork));
const state = createCachedBeaconStateTest(stateTB, getConfig(fork));
const postState = processSlots(state, state.slot + bnToNum(testcase.slots), {assertCorrectProgressiveBalances});
// TODO: May be part of runStateTranstion, necessary to commit again?
postState.commit();
Expand All @@ -62,7 +62,7 @@ const sanityBlocks: TestRunnerFn<SanityBlocksTestCase, BeaconStateAllForks> = (f
return {
testFunction: (testcase) => {
const stateTB = testcase.pre;
let wrappedState = createFinalizedCachedBeaconStateTest(stateTB, getConfig(fork));
let wrappedState = createCachedBeaconStateTest(stateTB, getConfig(fork));
const verify = shouldVerify(testcase);
for (let i = 0; i < testcase.meta.blocks_count; i++) {
const signedBlock = testcase[`blocks_${i}`] as deneb.SignedBeaconBlock;
Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/test/spec/presets/transition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ACTIVE_PRESET, ForkName} from "@lodestar/params";
import {bnToNum} from "@lodestar/utils";
import {config} from "@lodestar/config/default";
import {expectEqualBeaconState, inputTypeSszTreeViewDU} from "../utils/expectEqualBeaconState.js";
import {createFinalizedCachedBeaconStateTest} from "../../utils/cachedBeaconState.js";
import {createCachedBeaconStateTest} from "../../utils/cachedBeaconState.js";
import {RunnerType, TestRunnerFn} from "../utils/types.js";
import {assertCorrectProgressiveBalances} from "../config.js";
import {ethereumConsensusSpecsTests} from "../specTestVersioning.js";
Expand Down Expand Up @@ -51,7 +51,7 @@ const transition =
const forkEpoch = bnToNum(meta.fork_epoch);
const testConfig = createChainForkConfig(getTransitionConfig(forkNext, forkEpoch));

let state = createFinalizedCachedBeaconStateTest(testcase.pre, testConfig);
let state = createCachedBeaconStateTest(testcase.pre, testConfig);
for (let i = 0; i < meta.blocks_count; i++) {
const signedBlock = testcase[`blocks_${i}`] as allForks.SignedBeaconBlock;
state = stateTransition(state, signedBlock, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import {FAR_FUTURE_EPOCH} from "../../../../../../src/constants/index.js";
import {SYNC_TOLERANCE_EPOCHS, getValidatorApi} from "../../../../../../src/api/impl/validator/index.js";
import {generateState, zeroProtoBlock} from "../../../../../utils/state.js";
import {generateValidators} from "../../../../../utils/validator.js";
import {createFinalizedCachedBeaconStateTest} from "../../../../../utils/cachedBeaconState.js";
import {createCachedBeaconStateTest} from "../../../../../utils/cachedBeaconState.js";
import {SyncState} from "../../../../../../src/sync/interface.js";

describe("get proposers api impl", function () {
let api: ReturnType<typeof getValidatorApi>;
let modules: ApiTestModules;
let state: BeaconStateAllForks;
let cachedState: ReturnType<typeof createFinalizedCachedBeaconStateTest>;
let cachedState: ReturnType<typeof createCachedBeaconStateTest>;

beforeEach(function () {
vi.useFakeTimers({now: 0});
Expand All @@ -33,7 +33,7 @@ describe("get proposers api impl", function () {
},
config
);
cachedState = createFinalizedCachedBeaconStateTest(state, config);
cachedState = createCachedBeaconStateTest(state, config);

modules.chain.getHeadStateAtCurrentEpoch.mockResolvedValue(cachedState);
modules.forkChoice.getHead.mockReturnValue(zeroProtoBlock);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {phase0, Slot, ssz, ValidatorIndex} from "@lodestar/types";
import {getTemporaryBlockHeader, processSlots} from "@lodestar/state-transition";
import {ChainEventEmitter, computeAnchorCheckpoint, initializeForkChoice} from "../../../../src/chain/index.js";
import {generateSignedBlockAtSlot} from "../../../utils/typeGenerator.js";
import {createFinalizedCachedBeaconStateTest} from "../../../utils/cachedBeaconState.js";
import {createCachedBeaconStateTest} from "../../../utils/cachedBeaconState.js";
import {generateState} from "../../../utils/state.js";
import {generateValidators} from "../../../utils/validator.js";

Expand All @@ -21,7 +21,7 @@ vi.unmock("@lodestar/fork-choice");

describe("LodestarForkChoice", function () {
let forkChoice: ForkChoice;
const anchorState = createFinalizedCachedBeaconStateTest(
const anchorState = createCachedBeaconStateTest(
generateState(
{
slot: 0,
Expand Down Expand Up @@ -53,7 +53,7 @@ describe("LodestarForkChoice", function () {
let state: CachedBeaconStateAllForks;

beforeAll(() => {
state = createFinalizedCachedBeaconStateTest(anchorState, config);
state = createCachedBeaconStateTest(anchorState, config);
});

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {generateState} from "../../../utils/state.js";
import {validateGossipBlsToExecutionChange} from "../../../../src/chain/validation/blsToExecutionChange.js";
import {BlsToExecutionChangeErrorCode} from "../../../../src/chain/errors/blsToExecutionChangeError.js";
import {expectRejectedWithLodestarError} from "../../../utils/errors.js";
import {createFinalizedCachedBeaconStateTest} from "../../../utils/cachedBeaconState.js";
import {createCachedBeaconStateTest} from "../../../utils/cachedBeaconState.js";

describe("validate bls to execution change", () => {
let chainStub: MockedBeaconChain;
Expand Down Expand Up @@ -70,7 +70,7 @@ describe("validate bls to execution change", () => {
// Generate the state
const _state = generateState(stateEmpty, defaultConfig);
const config = createBeaconConfig(defaultConfig, _state.genesisValidatorsRoot);
const state = createFinalizedCachedBeaconStateTest(_state, config);
const state = createCachedBeaconStateTest(_state, config);

// Gen a valid blsToExecutionChange for first val
const blsToExecutionChange = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {generateState} from "../../../utils/state.js";
import {validateGossipVoluntaryExit} from "../../../../src/chain/validation/voluntaryExit.js";
import {VoluntaryExitErrorCode} from "../../../../src/chain/errors/voluntaryExitError.js";
import {expectRejectedWithLodestarError} from "../../../utils/errors.js";
import {createFinalizedCachedBeaconStateTest} from "../../../utils/cachedBeaconState.js";
import {createCachedBeaconStateTest} from "../../../utils/cachedBeaconState.js";

describe("validate voluntary exit", () => {
let chainStub: MockedBeaconChain;
Expand Down Expand Up @@ -58,7 +58,7 @@ describe("validate voluntary exit", () => {
signedVoluntaryExit = {message: voluntaryExit, signature: sk.sign(signingRoot).toBytes()};
const _state = generateState(stateEmpty, config);

state = createFinalizedCachedBeaconStateTest(_state, createBeaconConfig(config, _state.genesisValidatorsRoot));
state = createCachedBeaconStateTest(_state, createBeaconConfig(config, _state.genesisValidatorsRoot));
});

beforeEach(() => {
Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/test/unit/eth1/utils/deposits.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {generateState} from "../../../utils/state.js";
import {expectRejectedWithLodestarError} from "../../../utils/errors.js";
import {getDeposits, getDepositsWithProofs, DepositGetter} from "../../../../src/eth1/utils/deposits.js";
import {DepositTree} from "../../../../src/db/repositories/depositDataRoot.js";
import {createFinalizedCachedBeaconStateTest} from "../../../utils/cachedBeaconState.js";
import {createCachedBeaconStateTest} from "../../../utils/cachedBeaconState.js";

describe("eth1 / util / deposits", function () {
describe("getDeposits", () => {
Expand Down Expand Up @@ -116,7 +116,7 @@ describe("eth1 / util / deposits", function () {
const state = postElectra
? generateState({slot: postElectraSlot, eth1DepositIndex}, postElectraConfig)
: generateState({eth1DepositIndex});
const cachedState = createFinalizedCachedBeaconStateTest(
const cachedState = createCachedBeaconStateTest(
state,
postElectra ? postElectraConfig : createChainForkConfig({})
);
Expand Down
6 changes: 3 additions & 3 deletions packages/beacon-node/test/utils/cachedBeaconState.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {
BeaconStateAllForks,
BeaconStateCache,
createFinalizedCachedBeaconState,
createCachedBeaconState,
createEmptyEpochCacheImmutableData,
} from "@lodestar/state-transition";
import {ChainForkConfig} from "@lodestar/config";

export function createFinalizedCachedBeaconStateTest<T extends BeaconStateAllForks>(
export function createCachedBeaconStateTest<T extends BeaconStateAllForks>(
state: T,
chainConfig: ChainForkConfig
): T & BeaconStateCache {
return createFinalizedCachedBeaconState<T>(state, createEmptyEpochCacheImmutableData(chainConfig, state));
return createCachedBeaconState<T>(state, createEmptyEpochCacheImmutableData(chainConfig, state));
}
4 changes: 2 additions & 2 deletions packages/beacon-node/test/utils/networkWithMockDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {GossipHandlers, Network, NetworkInitModules, getReqRespHandlers} from ".
import {NetworkOptions, defaultNetworkOptions} from "../../src/network/options.js";
import {GetReqRespHandlerFn} from "../../src/network/reqresp/types.js";
import {getMockedBeaconDb} from "../mocks/mockedBeaconDb.js";
import {createFinalizedCachedBeaconStateTest} from "./cachedBeaconState.js";
import {createCachedBeaconStateTest} from "./cachedBeaconState.js";
import {ClockStatic} from "./clock.js";
import {testLogger} from "./logger.js";
import {generateState} from "./state.js";
Expand Down Expand Up @@ -64,7 +64,7 @@ export async function getNetworkForTest(
// mock timer does not work on worker thread
clock: new ClockStatic(startSlot, Math.floor(Date.now() / 1000) - startSlot * beaconConfig.SECONDS_PER_SLOT),
metrics: null,
anchorState: createFinalizedCachedBeaconStateTest(state, beaconConfig),
anchorState: createCachedBeaconStateTest(state, beaconConfig),
eth1: new Eth1ForBlockProductionDisabled(),
executionEngine: new ExecutionEngineDisabled(),
}
Expand Down
Loading

0 comments on commit 6568ac9

Please sign in to comment.