Skip to content

Commit be3af65

Browse files
ensi321nflaig
authored andcommitted
chore: fix and add workaround on params e2e tests
1 parent 843a2a8 commit be3af65

File tree

5 files changed

+24
-13
lines changed

5 files changed

+24
-13
lines changed

packages/beacon-node/test/spec/presets/operations.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ const operationFns: Record<string, BlockProcessFn<CachedBeaconStateAllForks>> =
9292
},
9393

9494
deposit_request: (state, testCase: {deposit_request: electra.DepositRequest}) => {
95-
const fork = state.config.getForkSeq(state.slot);
96-
blockFns.processDepositRequest(fork, state as CachedBeaconStateElectra, testCase.deposit_request);
95+
blockFns.processDepositRequest(state as CachedBeaconStateElectra, testCase.deposit_request);
9796
},
9897

9998
consolidation_request: (state, testCase: {consolidation_request: electra.ConsolidationRequest}) => {

packages/params/test/e2e/ensure-config-is-synced.test.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ import {loadConfigYaml} from "../yaml.js";
88
// Not e2e, but slow. Run with e2e tests
99

1010
/** https://github.com/ethereum/consensus-specs/releases */
11-
const specConfigCommit = "v1.5.0-alpha.3";
11+
const specConfigCommit = "v1.5.0-alpha.8";
12+
/**
13+
* Fields that we filter from local config when doing comparison.
14+
* Ideally this should be empty as it is not spec compliant
15+
* For `MAX_BLOBS_PER_BLOCK`, see https://github.com/ChainSafe/lodestar/issues/7172
16+
*/
17+
const ignoredLocalPresetFields: (keyof BeaconPreset)[] = ["MAX_BLOBS_PER_BLOCK"];
1218

1319
describe("Ensure config is synced", () => {
1420
vi.setConfig({testTimeout: 60 * 1000});
@@ -25,12 +31,22 @@ describe("Ensure config is synced", () => {
2531
});
2632

2733
function assertCorrectPreset(localPreset: BeaconPreset, remotePreset: BeaconPreset): void {
34+
const filteredLocalPreset: Partial<BeaconPreset> = Object.keys(localPreset)
35+
.filter((key) => !ignoredLocalPresetFields.includes(key as keyof BeaconPreset))
36+
.reduce(
37+
(acc, key) => {
38+
acc[key as keyof BeaconPreset] = localPreset[key as keyof BeaconPreset];
39+
return acc;
40+
},
41+
{} as Partial<BeaconPreset>
42+
);
43+
2844
// Check each key for better debuggability
2945
for (const key of Object.keys(remotePreset) as (keyof BeaconPreset)[]) {
30-
expect(localPreset[key]).toBe(remotePreset[key]);
46+
expect(filteredLocalPreset[key]).toBe(remotePreset[key]);
3147
}
3248

33-
expect(localPreset).toEqual(remotePreset);
49+
expect(filteredLocalPreset).toEqual(remotePreset);
3450
}
3551

3652
async function downloadRemoteConfig(preset: "mainnet" | "minimal", commit: string): Promise<BeaconPreset> {

packages/state-transition/src/block/processDeposit.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ export function applyDeposit(
5555
state: CachedBeaconStateAllForks,
5656
deposit: DepositData | DepositRequest
5757
): void {
58-
const {config, epochCtx} = state;
58+
const {config, epochCtx, validators} = state;
5959
const {pubkey, withdrawalCredentials, amount, signature} = deposit;
6060

6161
const cachedIndex = epochCtx.getValidatorIndex(pubkey);
62-
const isNewValidator = cachedIndex === null || !Number.isSafeInteger(cachedIndex);
62+
const isNewValidator = cachedIndex === null || !Number.isSafeInteger(cachedIndex) || cachedIndex >= validators.length;
6363

6464
if (fork < ForkSeq.electra) {
6565
if (isNewValidator) {

packages/state-transition/src/block/processDepositRequest.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import {ForkSeq, UNSET_DEPOSIT_REQUESTS_START_INDEX} from "@lodestar/params";
33

44
import {CachedBeaconStateElectra} from "../types.js";
55

6-
export function processDepositRequest(
7-
fork: ForkSeq,
8-
state: CachedBeaconStateElectra,
9-
depositRequest: electra.DepositRequest
10-
): void {
6+
export function processDepositRequest(state: CachedBeaconStateElectra, depositRequest: electra.DepositRequest): void {
117
if (state.depositRequestsStartIndex === UNSET_DEPOSIT_REQUESTS_START_INDEX) {
128
state.depositRequestsStartIndex = BigInt(depositRequest.index);
139
}

packages/state-transition/src/block/processOperations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export function processOperations(
6868
const bodyElectra = body as electra.BeaconBlockBody;
6969

7070
for (const depositRequest of bodyElectra.executionRequests.deposits) {
71-
processDepositRequest(fork, stateElectra, depositRequest);
71+
processDepositRequest(stateElectra, depositRequest);
7272
}
7373

7474
for (const elWithdrawalRequest of bodyElectra.executionRequests.withdrawals) {

0 commit comments

Comments
 (0)