diff --git a/packages/beacon-node/test/spec/presets/fork.test.ts b/packages/beacon-node/test/spec/presets/fork.test.ts index c121e651fcea..efcf75166207 100644 --- a/packages/beacon-node/test/spec/presets/fork.test.ts +++ b/packages/beacon-node/test/spec/presets/fork.test.ts @@ -38,6 +38,8 @@ const fork: TestRunnerFn = (forkNext) => { return slotFns.upgradeStateToDeneb(preState as CachedBeaconStateCapella); case ForkName.electra: return slotFns.upgradeStateToElectra(preState as CachedBeaconStateDeneb); + case ForkName.ebps: + throw Error("not Implemented"); } }, options: { diff --git a/packages/beacon-node/test/spec/presets/transition.test.ts b/packages/beacon-node/test/spec/presets/transition.test.ts index cae7c667b590..41619b5bed48 100644 --- a/packages/beacon-node/test/spec/presets/transition.test.ts +++ b/packages/beacon-node/test/spec/presets/transition.test.ts @@ -110,6 +110,15 @@ function getTransitionConfig(fork: ForkName, forkEpoch: number): Partial${toFork}`, function () { + lcHeaderByFork[fromFork].beacon.slot = testSlots[fromFork]; + lcHeaderByFork[toFork].beacon.slot = testSlots[fromFork]; + + expect(() => { + upgradeLightClientHeader(config, toFork, lcHeaderByFork[fromFork]); + }).toThrow("Not Implemented"); + }); + } + + // Since ebps is not implemented for loop is till deneb (Object.values(ForkName).length-1) + // Once ebps is implemnted run for loop till Object.values(ForkName).length + + // for (let i = ForkSeq.altair; i < Object.values(ForkName).length; i++) { + + for (let i = ForkSeq.altair; i < Object.values(ForkName).length - 1; i++) { for (let j = i; j > 0; j--) { const fromFork = ForkName[ForkSeq[i] as ForkName]; const toFork = ForkName[ForkSeq[j] as ForkName]; diff --git a/packages/beacon-node/test/unit/network/fork.test.ts b/packages/beacon-node/test/unit/network/fork.test.ts index bbe1c0870d30..101d4eed0a23 100644 --- a/packages/beacon-node/test/unit/network/fork.test.ts +++ b/packages/beacon-node/test/unit/network/fork.test.ts @@ -10,6 +10,7 @@ function getForkConfig({ capella, deneb, electra, + ebps, }: { phase0: number; altair: number; @@ -17,6 +18,7 @@ function getForkConfig({ capella: number; deneb: number; electra: number; + ebps: number; }): BeaconConfig { const forks: Record = { phase0: { @@ -67,6 +69,14 @@ function getForkConfig({ prevVersion: Buffer.from([0, 0, 0, 4]), prevForkName: ForkName.deneb, }, + ebps: { + name: ForkName.ebps, + seq: ForkSeq.ebps, + epoch: ebps, + version: Buffer.from([0, 0, 0, 9]), + prevVersion: Buffer.from([0, 0, 0, 5]), + prevForkName: ForkName.electra, + }, }; const forksAscendingEpochOrder = Object.values(forks); const forksDescendingEpochOrder = Object.values(forks).reverse(); @@ -144,9 +154,10 @@ for (const testScenario of testScenarios) { const {phase0, altair, bellatrix, capella, testCases} = testScenario; const deneb = Infinity; const electra = Infinity; + const ebps = Infinity; describe(`network / fork: phase0: ${phase0}, altair: ${altair}, bellatrix: ${bellatrix} capella: ${capella}`, () => { - const forkConfig = getForkConfig({phase0, altair, bellatrix, capella, deneb, electra}); + const forkConfig = getForkConfig({phase0, altair, bellatrix, capella, deneb, electra, ebps}); const forks = forkConfig.forks; for (const testCase of testCases) { const {epoch, currentFork, nextFork, activeForks} = testCase; diff --git a/packages/beacon-node/test/utils/config.ts b/packages/beacon-node/test/utils/config.ts index 2aad1c14c03e..930ec3dfcf28 100644 --- a/packages/beacon-node/test/utils/config.ts +++ b/packages/beacon-node/test/utils/config.ts @@ -39,5 +39,14 @@ export function getConfig(fork: ForkName, forkEpoch = 0): ChainForkConfig { DENEB_FORK_EPOCH: 0, ELECTRA_FORK_EPOCH: forkEpoch, }); + case ForkName.ebps: + return createChainForkConfig({ + ALTAIR_FORK_EPOCH: 0, + BELLATRIX_FORK_EPOCH: 0, + CAPELLA_FORK_EPOCH: 0, + DENEB_FORK_EPOCH: 0, + ELECTRA_FORK_EPOCH: 0, + EBPS_FORK_EPOCH: forkEpoch, + }); } } diff --git a/packages/config/src/chainConfig/configs/mainnet.ts b/packages/config/src/chainConfig/configs/mainnet.ts index 741ddc99f8cd..705d65c492c4 100644 --- a/packages/config/src/chainConfig/configs/mainnet.ts +++ b/packages/config/src/chainConfig/configs/mainnet.ts @@ -53,6 +53,10 @@ export const chainConfig: ChainConfig = { ELECTRA_FORK_VERSION: b("0x05000000"), ELECTRA_FORK_EPOCH: Infinity, + // Ebps + EBPS_FORK_VERSION: b("0x09000000"), + EBPS_FORK_EPOCH: Infinity, + // Time parameters // --------------------------------------------------------------- // 12 seconds diff --git a/packages/config/src/chainConfig/configs/minimal.ts b/packages/config/src/chainConfig/configs/minimal.ts index 26f49cc3e47d..5f8b28c178d5 100644 --- a/packages/config/src/chainConfig/configs/minimal.ts +++ b/packages/config/src/chainConfig/configs/minimal.ts @@ -49,6 +49,10 @@ export const chainConfig: ChainConfig = { ELECTRA_FORK_VERSION: b("0x05000001"), ELECTRA_FORK_EPOCH: Infinity, + // Ebps + EBPS_FORK_VERSION: b("0x05000001"), + EBPS_FORK_EPOCH: Infinity, + // Time parameters // --------------------------------------------------------------- // [customized] Faster for testing purposes diff --git a/packages/config/src/chainConfig/types.ts b/packages/config/src/chainConfig/types.ts index 05fff02f2eaf..781d26cde2bd 100644 --- a/packages/config/src/chainConfig/types.ts +++ b/packages/config/src/chainConfig/types.ts @@ -43,6 +43,9 @@ export type ChainConfig = { // ELECTRA ELECTRA_FORK_VERSION: Uint8Array; ELECTRA_FORK_EPOCH: number; + // EBPS + EBPS_FORK_VERSION: Uint8Array; + EBPS_FORK_EPOCH: number; // Time parameters SECONDS_PER_SLOT: number; @@ -107,6 +110,9 @@ export const chainConfigTypes: SpecTypes = { // ELECTRA ELECTRA_FORK_VERSION: "bytes", ELECTRA_FORK_EPOCH: "number", + // EBPS + EBPS_FORK_VERSION: "bytes", + EBPS_FORK_EPOCH: "number", // Time parameters SECONDS_PER_SLOT: "number", diff --git a/packages/config/src/forkConfig/index.ts b/packages/config/src/forkConfig/index.ts index 513cd7559ee3..3349ab536a73 100644 --- a/packages/config/src/forkConfig/index.ts +++ b/packages/config/src/forkConfig/index.ts @@ -67,10 +67,18 @@ export function createForkConfig(config: ChainConfig): ForkConfig { prevVersion: config.DENEB_FORK_VERSION, prevForkName: ForkName.deneb, }; + const ebps: ForkInfo = { + name: ForkName.ebps, + seq: ForkSeq.ebps, + epoch: config.EBPS_FORK_EPOCH, + version: config.EBPS_FORK_VERSION, + prevVersion: config.ELECTRA_FORK_VERSION, + prevForkName: ForkName.electra, + }; /** Forks in order order of occurence, `phase0` first */ // Note: Downstream code relies on proper ordering. - const forks = {phase0, altair, bellatrix, capella, deneb, electra}; + const forks = {phase0, altair, bellatrix, capella, deneb, electra, ebps}; // Prevents allocating an array on every getForkInfo() call const forksAscendingEpochOrder = Object.values(forks); diff --git a/packages/light-client/src/spec/utils.ts b/packages/light-client/src/spec/utils.ts index 3e59cb14cfa0..b2a2803aa2ca 100644 --- a/packages/light-client/src/spec/utils.ts +++ b/packages/light-client/src/spec/utils.ts @@ -124,6 +124,10 @@ export function upgradeLightClientHeader( // Break if no further upgrades is required else fall through if (ForkSeq[targetFork] <= ForkSeq.electra) break; + + // eslint-disable-next-line no-fallthrough + case ForkName.ebps: + throw Error("Not Implemented"); } return upgradedHeader; } diff --git a/packages/params/src/forkName.ts b/packages/params/src/forkName.ts index 42e8917942d2..11648a9cb462 100644 --- a/packages/params/src/forkName.ts +++ b/packages/params/src/forkName.ts @@ -8,6 +8,7 @@ export enum ForkName { capella = "capella", deneb = "deneb", electra = "electra", + ebps = "ebps", } /** @@ -20,6 +21,7 @@ export enum ForkSeq { capella = 3, deneb = 4, electra = 5, + ebps = 6, } function exclude(coll: T[], val: U[]): Exclude[] { @@ -93,3 +95,20 @@ export const forkPostElectra = exclude(forkAll, [ export function isForkPostElectra(fork: ForkName): fork is ForkPostElectra { return isForkBlobs(fork) && fork !== ForkName.deneb; } + +// TODO add electra type in ForkPreEpbs +export type ForkPreEpbs = ForkPreBlobs | ForkName.deneb | ForkName.electra; +export type ForkExecutionPreEpbs = Exclude; +export const forkExecutionPreEpbs = [ForkName.bellatrix, ForkName.capella, ForkName.deneb, ForkName.electra]; +export type ForkEpbs = Exclude; +export const forkEpbs = exclude(forkAll, [ + ForkName.phase0, + ForkName.altair, + ForkName.bellatrix, + ForkName.capella, + ForkName.deneb, + ForkName.electra, +]); +export function isForkEpbs(fork: ForkName): fork is ForkEpbs { + return isForkBlobs(fork) && fork !== ForkName.deneb && fork !== ForkName.electra; +} diff --git a/packages/params/src/index.ts b/packages/params/src/index.ts index e7fd5b976336..129cc6b23055 100644 --- a/packages/params/src/index.ts +++ b/packages/params/src/index.ts @@ -108,6 +108,9 @@ export const { MAX_ATTESTATIONS_ELECTRA, MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP, WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA, + + PTC_SIZE, + MAX_PAYLOAD_ATTESTATIONS, } = activePreset; //////////// @@ -145,6 +148,8 @@ export const DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF = Uint8Array.from([8, 0, 0, 0 export const DOMAIN_CONTRIBUTION_AND_PROOF = Uint8Array.from([9, 0, 0, 0]); export const DOMAIN_BLS_TO_EXECUTION_CHANGE = Uint8Array.from([10, 0, 0, 0]); export const DOMAIN_CONSOLIDATION = Uint8Array.from([11, 0, 0, 0]); +export const DOMAIN_PTC_ATTESTER = Uint8Array.from([12, 0, 0, 0]); //DomainType('0x0C000000') # (New in EIP-7732) +export const DOMAIN_BEACON_BUILDER = Uint8Array.from([27, 0, 0, 0]); // DomainType('0x1B000000') # (New in EIP-7732) // Application specific domains @@ -268,3 +273,9 @@ 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; + +// ebps +export const PAYLOAD_ABSENT = 0; +export const PAYLOAD_PRESENT = 1; +export const PAYLOAD_WITHHELD = 2; +export const PAYLOAD_INVALID_STATUS = 3; diff --git a/packages/params/src/presets/mainnet.ts b/packages/params/src/presets/mainnet.ts index a4a88aac1f58..869223c2fedf 100644 --- a/packages/params/src/presets/mainnet.ts +++ b/packages/params/src/presets/mainnet.ts @@ -135,4 +135,10 @@ export const mainnetPreset: BeaconPreset = { PENDING_CONSOLIDATIONS_LIMIT: 262144, MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 1, WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA: 4096, + + // ebps - EIP-7732 + // uint64(2**9) = 512 + PTC_SIZE: 512, + // 2**2 = 4 + MAX_PAYLOAD_ATTESTATIONS: 4, }; diff --git a/packages/params/src/presets/minimal.ts b/packages/params/src/presets/minimal.ts index 97eff53cf013..e19278431799 100644 --- a/packages/params/src/presets/minimal.ts +++ b/packages/params/src/presets/minimal.ts @@ -136,4 +136,10 @@ export const minimalPreset: BeaconPreset = { PENDING_CONSOLIDATIONS_LIMIT: 64, MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 1, WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA: 4096, + + // ebps - EIP-7732 + // uint64(2**9) = 512 + PTC_SIZE: 512, + // 2**2 = 4 + MAX_PAYLOAD_ATTESTATIONS: 4, }; diff --git a/packages/params/src/types.ts b/packages/params/src/types.ts index e867b4a3cf71..82222b1ac32f 100644 --- a/packages/params/src/types.ts +++ b/packages/params/src/types.ts @@ -97,6 +97,10 @@ export type BeaconPreset = { PENDING_CONSOLIDATIONS_LIMIT: number; MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: number; WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA: number; + + // EBPS + PTC_SIZE: number; + MAX_PAYLOAD_ATTESTATIONS: number; }; /** @@ -197,6 +201,10 @@ export const beaconPresetTypes: BeaconPresetTypes = { PENDING_CONSOLIDATIONS_LIMIT: "number", MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: "number", WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA: "number", + + // EBPS + PTC_SIZE: "number", + MAX_PAYLOAD_ATTESTATIONS: "number", }; type BeaconPresetTypes = { diff --git a/packages/state-transition/test/unit/upgradeState.test.ts b/packages/state-transition/test/unit/upgradeState.test.ts index df9b052542f9..f09e843dcf5c 100644 --- a/packages/state-transition/test/unit/upgradeState.test.ts +++ b/packages/state-transition/test/unit/upgradeState.test.ts @@ -79,5 +79,14 @@ function getConfig(fork: ForkName, forkEpoch = 0): ChainForkConfig { DENEB_FORK_EPOCH: 0, ELECTRA_FORK_EPOCH: forkEpoch, }); + case ForkName.ebps: + return createChainForkConfig({ + ALTAIR_FORK_EPOCH: 0, + BELLATRIX_FORK_EPOCH: 0, + CAPELLA_FORK_EPOCH: 0, + DENEB_FORK_EPOCH: 0, + ELECTRA_FORK_EPOCH: 0, + EBPS_FORK_EPOCH: forkEpoch, + }); } } diff --git a/packages/types/src/ebps/index.ts b/packages/types/src/ebps/index.ts new file mode 100644 index 000000000000..7856cd729620 --- /dev/null +++ b/packages/types/src/ebps/index.ts @@ -0,0 +1,3 @@ +export * from "./types.js"; +export * as ts from "./types.js"; +export * as ssz from "./sszTypes.js"; diff --git a/packages/types/src/ebps/sszTypes.ts b/packages/types/src/ebps/sszTypes.ts new file mode 100644 index 000000000000..5a7cf9c1b8c9 --- /dev/null +++ b/packages/types/src/ebps/sszTypes.ts @@ -0,0 +1,236 @@ +import {ContainerType, ListCompositeType, BitVectorType, ListBasicType} from "@chainsafe/ssz"; +import {PTC_SIZE, MAX_PAYLOAD_ATTESTATIONS, EPOCHS_PER_SYNC_COMMITTEE_PERIOD, SLOTS_PER_EPOCH} from "@lodestar/params"; +import {ssz as primitiveSsz} from "../primitive/index.js"; +import {ssz as phase0Ssz} from "../phase0/index.js"; +import {ssz as altairSsz} from "../altair/index.js"; +import {ssz as capellaSsz} from "../capella/index.js"; +import {ssz as denebSsz} from "../deneb/index.js"; + +const {BLSSignature, Root, Slot, Uint8, ValidatorIndex, Gwei, Boolean, UintNum64} = primitiveSsz; + +export const PayloadAttestationData = new ContainerType( + { + beaconBlockRoot: Root, + slot: Slot, + payload_status: Uint8, + }, + {typeName: "PayloadAttestationData", jsonCase: "eth2"} +); + +export const PayloadAttestation = new ContainerType( + { + aggregationBits: new BitVectorType(PTC_SIZE), + data: PayloadAttestationData, + signature: BLSSignature, + }, + {typeName: "PayloadAttestation", jsonCase: "eth2"} +); +export const PayloadAttestations = new ListCompositeType(PayloadAttestation, MAX_PAYLOAD_ATTESTATIONS); + +export const PayloadAttestationMessage = new ContainerType( + { + validator_index: ValidatorIndex, + data: PayloadAttestationData, + signature: BLSSignature, + }, + {typeName: "PayloadAttestationMessage", jsonCase: "eth2"} +); + +export const AttestingIndices = new ListBasicType(ValidatorIndex, PTC_SIZE); +export const IndexedPayloadAttestation = new ContainerType( + { + attestingIndices: AttestingIndices, + data: PayloadAttestationData, + signature: BLSSignature, + }, + {typeName: "IndexedPayloadAttestation", jsonCase: "eth2"} +); + +export const ExecutionPayload = new ContainerType( + { + ...denebSsz.ExecutionPayload.fields, + }, + {typeName: "ExecutionPayload", jsonCase: "eth2"} +); + +export const ExecutionPayloadHeader = new ContainerType( + { + parentBlockHash: Root, + parentBlockRoot: Root, + blockHash: Root, + gasLimit: UintNum64, + builderIndex: ValidatorIndex, + slot: Slot, + value: Gwei, + blobKzgCommitmentsRoot: Root, + }, + {typeName: "ExecutionPayloadHeader", jsonCase: "eth2"} +); + +export const SignedExecutionPayloadHeader = new ContainerType( + { + message: ExecutionPayloadHeader, + signature: BLSSignature, + }, + {typeName: "SignedExecutionPayloadHeader", jsonCase: "eth2"} +); + +export const ExecutionPayloadEnvelope = new ContainerType( + { + payload: ExecutionPayload, + builderIndex: ValidatorIndex, + beaconBlockRoot: Root, + blobKzgCommitments: denebSsz.BlobKzgCommitments, + payloadWithheld: Boolean, + stateRoot: Root, + }, + {typeName: "ExecutionPayloadEnvelope", jsonCase: "eth2"} +); + +export const SignedExecutionPayloadEnvelope = new ContainerType( + { + message: ExecutionPayloadEnvelope, + signature: BLSSignature, + }, + {typeName: "SignedExecutionPayloadEnvelope", jsonCase: "eth2"} +); + +export const BeaconBlockBody = new ContainerType( + { + // execution related fields pre epbs are removed and instead + ...altairSsz.BeaconBlockBody.fields, + blsToExecutionChanges: capellaSsz.BLSToExecutionChanges, + signedExecutionPayloadHeader: SignedExecutionPayloadHeader, // [New in EIP-7732] + payloadAttestations: new ListCompositeType(PayloadAttestation, MAX_PAYLOAD_ATTESTATIONS), // [New in EIP-7732] + }, + {typeName: "BeaconBlockBody", jsonCase: "eth2", cachePermanentRootStruct: true} +); + +export const BeaconBlock = new ContainerType( + { + ...denebSsz.BeaconBlock.fields, + body: BeaconBlockBody, // Modified in EPBS + }, + {typeName: "BeaconBlock", jsonCase: "eth2", cachePermanentRootStruct: true} +); + +export const SignedBeaconBlock = new ContainerType( + { + message: BeaconBlock, + signature: BLSSignature, + }, + {typeName: "SignedBeaconBlock", jsonCase: "eth2"} +); + +export const BlindedBeaconBlockBody = BeaconBlockBody; + +export const BlindedBeaconBlock = BeaconBlock; + +export const SignedBlindedBeaconBlock = SignedBeaconBlock; + +export const BuilderBid = ExecutionPayloadHeader; +export const SignedBuilderBid = SignedExecutionPayloadHeader; + +export const ExecutionPayloadAndBlobsBundle = new ContainerType( + { + executionPayload: ExecutionPayload, + blobsBundle: denebSsz.BlobsBundle, + }, + {typeName: "ExecutionPayloadAndBlobsBundle", jsonCase: "eth2"} +); + +export const BeaconState = new ContainerType( + { + ...capellaSsz.BeaconState.fields, + latestExecutionPayloadHeader: ExecutionPayloadHeader, + // TODO electra fields once rebased on electra + latestBlockHash: Root, // [New in EIP-7732] + latestFullSlot: Slot, // [New in EIP-7732] + latestWithdrawalsRoot: Root, // [New in EIP-7732] + }, + {typeName: "BeaconState", jsonCase: "eth2"} +); + +export const LightClientHeader = new ContainerType( + { + beacon: phase0Ssz.BeaconBlockHeader, + execution: ExecutionPayloadHeader, + executionBranch: capellaSsz.LightClientHeader.fields.executionBranch, + }, + {typeName: "LightClientHeader", jsonCase: "eth2"} +); + +export const LightClientBootstrap = new ContainerType( + { + header: LightClientHeader, + currentSyncCommittee: altairSsz.SyncCommittee, + currentSyncCommitteeBranch: altairSsz.LightClientBootstrap.fields.currentSyncCommitteeBranch, + }, + {typeName: "LightClientBootstrap", jsonCase: "eth2"} +); + +export const LightClientUpdate = new ContainerType( + { + attestedHeader: LightClientHeader, + nextSyncCommittee: altairSsz.SyncCommittee, + nextSyncCommitteeBranch: altairSsz.LightClientUpdate.fields.nextSyncCommitteeBranch, + finalizedHeader: LightClientHeader, + finalityBranch: altairSsz.LightClientUpdate.fields.finalityBranch, + syncAggregate: altairSsz.SyncAggregate, + signatureSlot: Slot, + }, + {typeName: "LightClientUpdate", jsonCase: "eth2"} +); + +export const LightClientFinalityUpdate = new ContainerType( + { + attestedHeader: LightClientHeader, + finalizedHeader: LightClientHeader, + finalityBranch: altairSsz.LightClientFinalityUpdate.fields.finalityBranch, + syncAggregate: altairSsz.SyncAggregate, + signatureSlot: Slot, + }, + {typeName: "LightClientFinalityUpdate", jsonCase: "eth2"} +); + +export const LightClientOptimisticUpdate = new ContainerType( + { + attestedHeader: LightClientHeader, + syncAggregate: altairSsz.SyncAggregate, + signatureSlot: Slot, + }, + {typeName: "LightClientOptimisticUpdate", jsonCase: "eth2"} +); + +export const LightClientStore = new ContainerType( + { + snapshot: LightClientBootstrap, + validUpdates: new ListCompositeType(LightClientUpdate, EPOCHS_PER_SYNC_COMMITTEE_PERIOD * SLOTS_PER_EPOCH), + }, + {typeName: "LightClientStore", jsonCase: "eth2"} +); + +export const SSEPayloadAttributes = new ContainerType( + { + ...denebSsz.SSEPayloadAttributes.fields, + }, + {typeName: "SSEPayloadAttributes", jsonCase: "eth2"} +); + +export const BlockContents = new ContainerType( + { + block: BeaconBlock, + kzgProofs: denebSsz.KZGProofs, + blobs: denebSsz.Blobs, + }, + {typeName: "BlockContents", jsonCase: "eth2"} +); + +export const SignedBlockContents = new ContainerType( + { + signedBlock: SignedBeaconBlock, + kzgProofs: denebSsz.KZGProofs, + blobs: denebSsz.Blobs, + }, + {typeName: "SignedBlockContents", jsonCase: "eth2"} +); diff --git a/packages/types/src/ebps/types.ts b/packages/types/src/ebps/types.ts new file mode 100644 index 000000000000..caaa63ad8cbb --- /dev/null +++ b/packages/types/src/ebps/types.ts @@ -0,0 +1,32 @@ +import {ValueOf} from "@chainsafe/ssz"; +import * as ssz from "./sszTypes.js"; + +export type ExecutionPayloadAndBlobsBundle = ValueOf; + +export type ExecutionPayload = ValueOf; +export type ExecutionPayloadHeader = ValueOf; + +export type BeaconBlockBody = ValueOf; +export type BeaconBlock = ValueOf; +export type SignedBeaconBlock = ValueOf; + +export type BeaconState = ValueOf; + +export type BlindedBeaconBlockBody = ValueOf; +export type BlindedBeaconBlock = ValueOf; +export type SignedBlindedBeaconBlock = ValueOf; + +export type BuilderBid = ValueOf; +export type SignedBuilderBid = ValueOf; +export type SSEPayloadAttributes = ValueOf; + +export type LightClientHeader = ValueOf; +export type LightClientBootstrap = ValueOf; +export type LightClientUpdate = ValueOf; +export type LightClientFinalityUpdate = ValueOf; +export type LightClientOptimisticUpdate = ValueOf; +export type LightClientStore = ValueOf; + +export type BlockContents = ValueOf; +export type SignedBlockContents = ValueOf; +export type Contents = Omit; diff --git a/packages/types/src/sszTypes.ts b/packages/types/src/sszTypes.ts index 4399904a94bc..e17d5e80a4ce 100644 --- a/packages/types/src/sszTypes.ts +++ b/packages/types/src/sszTypes.ts @@ -6,9 +6,10 @@ import {ssz as bellatrix} from "./bellatrix/index.js"; import {ssz as capella} from "./capella/index.js"; import {ssz as deneb} from "./deneb/index.js"; import {ssz as electra} from "./electra/index.js"; +import {ssz as ebps} from "./ebps/index.js"; export * from "./primitive/sszTypes.js"; -export {phase0, altair, bellatrix, capella, deneb, electra}; +export {phase0, altair, bellatrix, capella, deneb, electra, ebps}; /** * Index the ssz types that differ by fork @@ -21,6 +22,7 @@ const typesByFork = { [ForkName.capella]: {...phase0, ...altair, ...bellatrix, ...capella}, [ForkName.deneb]: {...phase0, ...altair, ...bellatrix, ...capella, ...deneb}, [ForkName.electra]: {...phase0, ...altair, ...bellatrix, ...capella, ...deneb, ...electra}, + [ForkName.ebps]: {...phase0, ...altair, ...bellatrix, ...capella, ...deneb, ...electra, ...ebps}, }; /** diff --git a/packages/types/src/types.ts b/packages/types/src/types.ts index 1071eed79a10..13ed10ed2f42 100644 --- a/packages/types/src/types.ts +++ b/packages/types/src/types.ts @@ -5,6 +5,7 @@ import {ts as bellatrix} from "./bellatrix/index.js"; import {ts as capella} from "./capella/index.js"; import {ts as deneb} from "./deneb/index.js"; import {ts as electra} from "./electra/index.js"; +import {ts as ebps} from "./ebps/index.js"; import {Slot} from "./primitive/types.js"; export * from "./primitive/types.js"; @@ -14,6 +15,7 @@ export {ts as bellatrix} from "./bellatrix/index.js"; export {ts as capella} from "./capella/index.js"; export {ts as deneb} from "./deneb/index.js"; export {ts as electra} from "./electra/index.js"; +export {ts as ebps} from "./ebps/index.js"; /** Common non-spec type to represent roots as strings */ export type RootHex = string; @@ -200,6 +202,43 @@ type TypesByFork = { AggregateAndProof: electra.AggregateAndProof; SignedAggregateAndProof: electra.SignedAggregateAndProof; }; + [ForkName.ebps]: { + BeaconBlockHeader: phase0.BeaconBlockHeader; + SignedBeaconBlockHeader: phase0.SignedBeaconBlockHeader; + BeaconBlock: ebps.BeaconBlock; + BeaconBlockBody: ebps.BeaconBlockBody; + BeaconState: ebps.BeaconState; + SignedBeaconBlock: ebps.SignedBeaconBlock; + Metadata: altair.Metadata; + LightClientHeader: ebps.LightClientHeader; + LightClientBootstrap: ebps.LightClientBootstrap; + LightClientUpdate: ebps.LightClientUpdate; + LightClientFinalityUpdate: ebps.LightClientFinalityUpdate; + LightClientOptimisticUpdate: ebps.LightClientOptimisticUpdate; + LightClientStore: ebps.LightClientStore; + BlindedBeaconBlock: ebps.BlindedBeaconBlock; + BlindedBeaconBlockBody: ebps.BlindedBeaconBlockBody; + SignedBlindedBeaconBlock: ebps.SignedBlindedBeaconBlock; + ExecutionPayload: ebps.ExecutionPayload; + ExecutionPayloadHeader: ebps.ExecutionPayloadHeader; + BuilderBid: ebps.BuilderBid; + SignedBuilderBid: ebps.SignedBuilderBid; + SSEPayloadAttributes: ebps.SSEPayloadAttributes; + BlockContents: ebps.BlockContents; + SignedBlockContents: ebps.SignedBlockContents; + + ExecutionPayloadAndBlobsBundle: deneb.ExecutionPayloadAndBlobsBundle; + BlobsBundle: deneb.BlobsBundle; + Contents: deneb.Contents; + SyncCommittee: altair.SyncCommittee; + SyncAggregate: altair.SyncAggregate; + Attestation: phase0.Attestation; + IndexedAttestation: phase0.IndexedAttestation; + IndexedAttestationBigint: phase0.IndexedAttestationBigint; + AttesterSlashing: phase0.AttesterSlashing; + AggregateAndProof: phase0.AggregateAndProof; + SignedAggregateAndProof: phase0.SignedAggregateAndProof; + }; }; export type TypesFor = K extends void diff --git a/packages/types/src/utils/typeguards.ts b/packages/types/src/utils/typeguards.ts index 72910645f6e1..1047a5ddf470 100644 --- a/packages/types/src/utils/typeguards.ts +++ b/packages/types/src/utils/typeguards.ts @@ -1,4 +1,4 @@ -import {ForkBlobs, ForkExecution, ForkPostElectra} from "@lodestar/params"; +import {ForkBlobs, ForkExecution, ForkPostElectra, ForkExecutionPreEpbs} from "@lodestar/params"; import { BlockContents, SignedBeaconBlock, @@ -24,7 +24,7 @@ export function isExecutionPayload( return (payload as ExecutionPayload).transactions !== undefined; } -export function isExecutionPayloadHeader( +export function isExecutionPayloadHeader( payload: ExecutionPayload | ExecutionPayloadHeader ): payload is ExecutionPayloadHeader { // we just check transactionsRoot for determining as it the base field @@ -44,16 +44,16 @@ export function isBlindedBeaconBlock( return (block as BeaconBlock).body !== null && isBlindedBeaconBlockBody((block as BeaconBlock).body); } -export function isBlindedSignedBeaconBlock( +export function isBlindedSignedBeaconBlock( signedBlock: SignedBeaconBlock | SignedBeaconBlockOrContents ): signedBlock is SignedBlindedBeaconBlock { return (signedBlock as SignedBlindedBeaconBlock).message.body.executionPayloadHeader !== undefined; } -export function isBlindedBeaconBlockBody( +export function isBlindedBeaconBlockBody( body: BeaconBlockBody | BlindedBeaconBlockBody ): body is BlindedBeaconBlockBody { - return (body as BlindedBeaconBlockBody).executionPayloadHeader !== undefined; + return (body as BlindedBeaconBlockBody).executionPayloadHeader !== undefined; } export function isBlockContents( diff --git a/packages/validator/src/util/params.ts b/packages/validator/src/util/params.ts index 6d6705f512df..d8419a31ece4 100644 --- a/packages/validator/src/util/params.ts +++ b/packages/validator/src/util/params.ts @@ -74,6 +74,7 @@ function getSpecCriticalParams(localConfig: ChainConfig): Record