Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix ssz_static spec tests for all forks #6771

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
12 changes: 12 additions & 0 deletions packages/types/src/allForks/sszTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ export const allForks = {
SignedBeaconBlock: phase0.SignedBeaconBlock,
BeaconState: phase0.BeaconState,
Metadata: phase0.Metadata,
AggregateAndProof: phase0.AggregateAndProof,
SignedAggregateAndProof: phase0.SignedAggregateAndProof,
Attestation: phase0.Attestation,
IndexedAttestation: phase0.IndexedAttestation,
AttesterSlashing: phase0.AttesterSlashing,
},
altair: {
Expand All @@ -26,8 +28,10 @@ export const allForks = {
SignedBeaconBlock: altair.SignedBeaconBlock,
BeaconState: altair.BeaconState,
Metadata: altair.Metadata,
AggregateAndProof: phase0.AggregateAndProof,
SignedAggregateAndProof: phase0.SignedAggregateAndProof,
Attestation: phase0.Attestation,
IndexedAttestation: phase0.IndexedAttestation,
AttesterSlashing: phase0.AttesterSlashing,
},
bellatrix: {
Expand All @@ -36,8 +40,10 @@ export const allForks = {
SignedBeaconBlock: bellatrix.SignedBeaconBlock,
BeaconState: bellatrix.BeaconState,
Metadata: altair.Metadata,
AggregateAndProof: phase0.AggregateAndProof,
SignedAggregateAndProof: phase0.SignedAggregateAndProof,
Attestation: phase0.Attestation,
IndexedAttestation: phase0.IndexedAttestation,
AttesterSlashing: phase0.AttesterSlashing,
},
capella: {
Expand All @@ -46,8 +52,10 @@ export const allForks = {
SignedBeaconBlock: capella.SignedBeaconBlock,
BeaconState: capella.BeaconState,
Metadata: altair.Metadata,
AggregateAndProof: phase0.AggregateAndProof,
SignedAggregateAndProof: phase0.SignedAggregateAndProof,
Attestation: phase0.Attestation,
IndexedAttestation: phase0.IndexedAttestation,
AttesterSlashing: phase0.AttesterSlashing,
},
deneb: {
Expand All @@ -56,8 +64,10 @@ export const allForks = {
SignedBeaconBlock: deneb.SignedBeaconBlock,
BeaconState: deneb.BeaconState,
Metadata: altair.Metadata,
AggregateAndProof: phase0.AggregateAndProof,
SignedAggregateAndProof: phase0.SignedAggregateAndProof,
Attestation: phase0.Attestation,
IndexedAttestation: phase0.IndexedAttestation,
AttesterSlashing: phase0.AttesterSlashing,
},
electra: {
Expand All @@ -66,8 +76,10 @@ export const allForks = {
SignedBeaconBlock: electra.SignedBeaconBlock,
BeaconState: electra.BeaconState,
Metadata: altair.Metadata,
AggregateAndProof: electra.AggregateAndProof,
SignedAggregateAndProof: electra.SignedAggregateAndProof,
Attestation: electra.Attestation,
IndexedAttestation: electra.IndexedAttestation,
AttesterSlashing: electra.AttesterSlashing,
},
};
Expand Down
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
Loading