Skip to content

Commit

Permalink
test: fix ssz_static spec tests for all forks (#6771)
Browse files Browse the repository at this point in the history
  • Loading branch information
nflaig authored and g11tech committed Jun 25, 2024
1 parent d84c754 commit 6371ae3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
7 changes: 4 additions & 3 deletions packages/beacon-node/test/spec/presets/operations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,12 @@ const operations: TestRunnerFn<OperationsTestCase, BeaconStateAllForks> = (fork,
sszTypes: {
pre: ssz[fork].BeaconState,
post: ssz[fork].BeaconState,
attestation: fork === ForkName.electra ? ssz.electra.Attestation : ssz.phase0.Attestation,
attester_slashing: fork === ForkName.electra ? ssz.electra.AttesterSlashing : ssz.phase0.AttesterSlashing,
attestation: ssz.allForks[fork].Attestation,
attester_slashing: ssz.allForks[fork].AttesterSlashing,
block: ssz[fork].BeaconBlock,
body: ssz[fork].BeaconBlockBody,
deposit: ssz.phase0.Deposit,
deposit_receipt: ssz.electra.DepositRequest,
deposit_receipt: ssz.electra.DepositReceipt,
proposer_slashing: ssz.phase0.ProposerSlashing,
voluntary_exit: ssz.phase0.SignedVoluntaryExit,
// Altair
Expand All @@ -155,6 +155,7 @@ const operations: TestRunnerFn<OperationsTestCase, BeaconStateAllForks> = (fork,
: ssz.bellatrix.ExecutionPayload,
// Capella
address_change: ssz.capella.SignedBLSToExecutionChange,
// Electra
consolidation: ssz.electra.SignedConsolidation,
execution_layer_withdrawal_request: ssz.electra.ExecutionLayerWithdrawalRequest,
},
Expand Down
4 changes: 3 additions & 1 deletion packages/beacon-node/test/spec/presets/ssz_static.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from "node:path";
import {it, vi} from "vitest";
import {Type} from "@chainsafe/ssz";
import {ssz} from "@lodestar/types";
import {ACTIVE_PRESET, ForkName, ForkLightClient} from "@lodestar/params";
import {ACTIVE_PRESET, ForkName, ForkLightClient, ForkExecution} from "@lodestar/params";
import {replaceUintTypeWithUintBigintType} from "../utils/replaceUintTypeWithUintBigintType.js";
import {parseSszStaticTestcase} from "../utils/sszTestCaseParser.js";
import {runValidSszTest} from "../utils/runValidSszTest.js";
Expand Down Expand Up @@ -47,6 +47,8 @@ const sszStatic =
// Since lightclient types are not updated/declared at all forks, this allForksLightClient
// will help us get the right type for lightclient objects
((ssz.allForksLightClient[fork as ForkLightClient] || {}) as Types)[typeName] ||
((ssz.allForksExecution[fork as ForkExecution] || {}) as Types)[typeName] ||
(ssz.allForks[fork] as Types)[typeName] ||
(ssz[fork] as Types)[typeName] ||
(ssz.electra as Types)[typeName] ||
(ssz.deneb as Types)[typeName] ||
Expand Down
2 changes: 1 addition & 1 deletion packages/params/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,4 @@ export const FULL_EXIT_REQUEST_AMOUNT = 0;
export const NEXT_SYNC_COMMITTEE_GINDEX_ELECTRA = 87;
export const NEXT_SYNC_COMMITTEE_DEPTH_ELECTRA = 6;
export const FINALIZED_ROOT_DEPTH_ELECTRA = 7;
export const FINALIZED_ROOT_INDEX_ELECTRA = 169;
export const FINALIZED_ROOT_INDEX_ELECTRA = 169;
11 changes: 4 additions & 7 deletions packages/types/src/electra/sszTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,7 @@ export const PendingBalanceDeposit = new ContainerType(
{typeName: "PendingBalanceDeposit", jsonCase: "eth2"}
);

export const PendingBalanceDeposits = new ListCompositeType(
PendingBalanceDeposit,
Number(PENDING_BALANCE_DEPOSITS_LIMIT)
);
export const PendingBalanceDeposits = new ListCompositeType(PendingBalanceDeposit, PENDING_BALANCE_DEPOSITS_LIMIT);

export const PendingPartialWithdrawal = new ContainerType(
{
Expand Down Expand Up @@ -348,9 +345,9 @@ export const BeaconState = new ContainerType(
earliestExitEpoch: Epoch, // New in Electra:EIP7251
consolidationBalanceToConsume: Gwei, // New in Electra:EIP7251
earliestConsolidationEpoch: Epoch, // New in Electra:EIP7251
pendingBalanceDeposits: PendingBalanceDeposits, // new in electra:eip7251
pendingPartialWithdrawals: new ListCompositeType(PendingPartialWithdrawal, Number(PENDING_PARTIAL_WITHDRAWALS_LIMIT)), // New in Electra:EIP7251
pendingConsolidations: new ListCompositeType(PendingConsolidation, Number(PENDING_CONSOLIDATIONS_LIMIT)), // new in electra:eip7251
pendingBalanceDeposits: PendingBalanceDeposits, // New in Electra:EIP7251
pendingPartialWithdrawals: new ListCompositeType(PendingPartialWithdrawal, PENDING_PARTIAL_WITHDRAWALS_LIMIT), // New in Electra:EIP7251
pendingConsolidations: new ListCompositeType(PendingConsolidation, PENDING_CONSOLIDATIONS_LIMIT), // New in Electra:EIP7251
},
{typeName: "BeaconState", jsonCase: "eth2"}
);
Expand Down

0 comments on commit 6371ae3

Please sign in to comment.