diff --git a/packages/beacon-node/test/spec/presets/fork.test.ts b/packages/beacon-node/test/spec/presets/fork.test.ts index c121e651fce..a1d937d7ed7 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.epbs: + 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 cae7c667b59..02aa5324cb4 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 epbs is not implemented for loop is till deneb (Object.values(ForkName).length-1) + // Once epbs 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 bbe1c0870d3..691cb34e272 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, + epbs, }: { phase0: number; altair: number; @@ -17,6 +18,7 @@ function getForkConfig({ capella: number; deneb: number; electra: number; + epbs: number; }): BeaconConfig { const forks: Record = { phase0: { @@ -67,6 +69,14 @@ function getForkConfig({ prevVersion: Buffer.from([0, 0, 0, 4]), prevForkName: ForkName.deneb, }, + epbs: { + name: ForkName.epbs, + seq: ForkSeq.epbs, + epoch: epbs, + 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 epbs = 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, epbs}); 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 2aad1c14c03..e0651b4bab2 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.epbs: + return createChainForkConfig({ + ALTAIR_FORK_EPOCH: 0, + BELLATRIX_FORK_EPOCH: 0, + CAPELLA_FORK_EPOCH: 0, + DENEB_FORK_EPOCH: 0, + ELECTRA_FORK_EPOCH: 0, + EPBS_FORK_EPOCH: forkEpoch, + }); } } diff --git a/packages/config/src/chainConfig/configs/mainnet.ts b/packages/config/src/chainConfig/configs/mainnet.ts index 741ddc99f8c..6eff6a0f8d5 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, + // epbs + EPBS_FORK_VERSION: b("0x09000000"), + EPBS_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 26f49cc3e47..0b8131af4ff 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, + // epbs + EPBS_FORK_VERSION: b("0x05000001"), + EPBS_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 05fff02f2ea..ea949971bdf 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; + // EPBS + EPBS_FORK_VERSION: Uint8Array; + EPBS_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", + // epbs + EPBS_FORK_VERSION: "bytes", + EPBS_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 513cd7559ee..51a12f1daef 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 epbs: ForkInfo = { + name: ForkName.epbs, + seq: ForkSeq.epbs, + epoch: config.EPBS_FORK_EPOCH, + version: config.EPBS_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, epbs}; // 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 3e59cb14cfa..8dfbcde0129 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.epbs: + throw Error("Not Implemented"); } return upgradedHeader; } diff --git a/packages/params/src/forkName.ts b/packages/params/src/forkName.ts index 42e8917942d..3cabf7014e8 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", + epbs = "epbs", } /** @@ -20,6 +21,7 @@ export enum ForkSeq { capella = 3, deneb = 4, electra = 5, + epbs = 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 = ForkPreElectra | 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 isForkPostElectra(fork) && fork !== ForkName.electra; +} diff --git a/packages/params/src/index.ts b/packages/params/src/index.ts index e7fd5b97633..4c07b39fd13 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; + +// epbs +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 a4a88aac1f5..6fc455b592d 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, + + // epbs - 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 97eff53cf01..cbd8c8d00c1 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, + + // epbs - 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 e867b4a3cf7..8cd5a9e193a 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; + + // EPBS + 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", + + // EPBS + 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 df9b052542f..92bf2904a41 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.epbs: + return createChainForkConfig({ + ALTAIR_FORK_EPOCH: 0, + BELLATRIX_FORK_EPOCH: 0, + CAPELLA_FORK_EPOCH: 0, + DENEB_FORK_EPOCH: 0, + ELECTRA_FORK_EPOCH: 0, + EPBS_FORK_EPOCH: forkEpoch, + }); } } diff --git a/packages/types/src/epbs/index.ts b/packages/types/src/epbs/index.ts new file mode 100644 index 00000000000..7856cd72962 --- /dev/null +++ b/packages/types/src/epbs/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/epbs/sszTypes.ts b/packages/types/src/epbs/sszTypes.ts new file mode 100644 index 00000000000..13dd52d0e6a --- /dev/null +++ b/packages/types/src/epbs/sszTypes.ts @@ -0,0 +1,237 @@ +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"; +import {ssz as electraSsz} from "../electra/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( + { + ...electraSsz.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/epbs/types.ts b/packages/types/src/epbs/types.ts new file mode 100644 index 00000000000..caaa63ad8cb --- /dev/null +++ b/packages/types/src/epbs/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 4399904a94b..4b8a04b3a9f 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 epbs} from "./epbs/index.js"; export * from "./primitive/sszTypes.js"; -export {phase0, altair, bellatrix, capella, deneb, electra}; +export {phase0, altair, bellatrix, capella, deneb, electra, epbs}; /** * 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.epbs]: {...phase0, ...altair, ...bellatrix, ...capella, ...deneb, ...electra, ...epbs}, }; /** diff --git a/packages/types/src/types.ts b/packages/types/src/types.ts index 1071eed79a1..78c5994e454 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 epbs} from "./epbs/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 epbs} from "./epbs/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.epbs]: { + BeaconBlockHeader: phase0.BeaconBlockHeader; + SignedBeaconBlockHeader: phase0.SignedBeaconBlockHeader; + BeaconBlock: epbs.BeaconBlock; + BeaconBlockBody: epbs.BeaconBlockBody; + BeaconState: epbs.BeaconState; + SignedBeaconBlock: epbs.SignedBeaconBlock; + Metadata: altair.Metadata; + LightClientHeader: epbs.LightClientHeader; + LightClientBootstrap: epbs.LightClientBootstrap; + LightClientUpdate: epbs.LightClientUpdate; + LightClientFinalityUpdate: epbs.LightClientFinalityUpdate; + LightClientOptimisticUpdate: epbs.LightClientOptimisticUpdate; + LightClientStore: epbs.LightClientStore; + BlindedBeaconBlock: epbs.BlindedBeaconBlock; + BlindedBeaconBlockBody: epbs.BlindedBeaconBlockBody; + SignedBlindedBeaconBlock: epbs.SignedBlindedBeaconBlock; + ExecutionPayload: epbs.ExecutionPayload; + ExecutionPayloadHeader: epbs.ExecutionPayloadHeader; + BuilderBid: epbs.BuilderBid; + SignedBuilderBid: epbs.SignedBuilderBid; + SSEPayloadAttributes: epbs.SSEPayloadAttributes; + BlockContents: epbs.BlockContents; + SignedBlockContents: epbs.SignedBlockContents; + + ExecutionPayloadAndBlobsBundle: deneb.ExecutionPayloadAndBlobsBundle; + BlobsBundle: deneb.BlobsBundle; + Contents: deneb.Contents; + SyncCommittee: altair.SyncCommittee; + SyncAggregate: altair.SyncAggregate; + Attestation: electra.Attestation; + IndexedAttestation: electra.IndexedAttestation; + IndexedAttestationBigint: electra.IndexedAttestationBigint; + AttesterSlashing: electra.AttesterSlashing; + AggregateAndProof: electra.AggregateAndProof; + SignedAggregateAndProof: electra.SignedAggregateAndProof; + }; }; export type TypesFor = K extends void diff --git a/packages/types/src/utils/typeguards.ts b/packages/types/src/utils/typeguards.ts index 72910645f6e..1047a5ddf47 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 6d6705f512d..43b39813cc3 100644 --- a/packages/validator/src/util/params.ts +++ b/packages/validator/src/util/params.ts @@ -74,6 +74,7 @@ function getSpecCriticalParams(localConfig: ChainConfig): Record