diff --git a/packages/params/src/forkName.ts b/packages/params/src/forkName.ts index 76f0db8e1f00..4cdc7bc5bb12 100644 --- a/packages/params/src/forkName.ts +++ b/packages/params/src/forkName.ts @@ -18,8 +18,9 @@ export enum ForkSeq { altair = 1, bellatrix = 2, capella = 3, - deneb = 4, - verge = 5, + // Verge is scheduled after capella for now + verge = 4, + deneb = 5, } export type ForkLightClient = Exclude; @@ -37,7 +38,13 @@ export function isForkWithdrawals(fork: ForkName): fork is ForkWithdrawals { return isForkExecution(fork) && fork !== ForkName.bellatrix; } -export type ForkBlobs = Exclude; +// Verge is right now scheduled after capella +export type ForkVerge = Exclude; +export function isForkVerge(fork: ForkName): fork is ForkBlobs { + return isForkWithdrawals(fork) && fork !== ForkName.capella; +} + +export type ForkBlobs = Exclude; export function isForkBlobs(fork: ForkName): fork is ForkBlobs { return isForkWithdrawals(fork) && fork !== ForkName.capella; } diff --git a/packages/state-transition/src/block/processExecutionPayload.ts b/packages/state-transition/src/block/processExecutionPayload.ts index c2644fc77c7a..fb9978143668 100644 --- a/packages/state-transition/src/block/processExecutionPayload.ts +++ b/packages/state-transition/src/block/processExecutionPayload.ts @@ -119,7 +119,8 @@ export function executionPayloadToPayloadHeader( if (fork >= ForkSeq.verge) { // https://github.com/ethereum/consensus-specs/blob/db74090c1e8dc1fb2c052bae268e22dc63061e32/specs/verge/beacon-chain.md#process_execution_payload - (bellatrixPayloadFields as verge.ExecutionPayloadHeader).executionWitness = (payload as verge.ExecutionPayload).executionWitness; + (bellatrixPayloadFields as verge.ExecutionPayloadHeader).executionWitnessRoot = + ssz.verge.ExecutionWitness.hashTreeRoot((payload as verge.ExecutionPayload).executionWitness); } return bellatrixPayloadFields; diff --git a/packages/state-transition/src/slot/upgradeStateToVerge.ts b/packages/state-transition/src/slot/upgradeStateToVerge.ts index e19d500ec949..0a7e60c81d8d 100644 --- a/packages/state-transition/src/slot/upgradeStateToVerge.ts +++ b/packages/state-transition/src/slot/upgradeStateToVerge.ts @@ -19,10 +19,8 @@ export function upgradeStateToVerge(stateDeneb: CachedBeaconStateDeneb): CachedB epoch: stateDeneb.epochCtx.epoch, }); - // Initialize ExecutionWitness empty List - stateVerge.latestExecutionPayloadHeader.executionWitness = ssz.verge.ExecutionWitness.defaultViewDU(); + // latestExecutionPayloadHeader's executionWitnessRoot will have default zero root stateVerge.commit(); - return stateVerge; } diff --git a/packages/types/src/allForks/sszTypes.ts b/packages/types/src/allForks/sszTypes.ts index c36e8a92530f..32acc4519738 100644 --- a/packages/types/src/allForks/sszTypes.ts +++ b/packages/types/src/allForks/sszTypes.ts @@ -193,6 +193,8 @@ export const allForksBlobs = { BlindedBlobSidecar: deneb.BlindedBlobSidecar, }, verge: { - SignedBeaconBlockAndBlobsSidecar: deneb.SignedBeaconBlockAndBlobsSidecar, + SignedBeaconBlockAndBlobSidecars: deneb.SignedBeaconBlockAndBlobSidecars, + BlobSidecar: deneb.BlobSidecar, + BlindedBlobSidecar: deneb.BlindedBlobSidecar, }, }; diff --git a/packages/types/src/verge/sszTypes.ts b/packages/types/src/verge/sszTypes.ts index c7e15942e7dd..dd5f5168c25f 100644 --- a/packages/types/src/verge/sszTypes.ts +++ b/packages/types/src/verge/sszTypes.ts @@ -4,7 +4,7 @@ import { ByteVectorType, VectorCompositeType, ByteListType, - OptionalType, + OptionalType } from "@chainsafe/ssz"; import { HISTORICAL_ROOTS_LIMIT, @@ -17,7 +17,7 @@ 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 bellatrixSsz} from "../bellatrix/index.js"; -// import {ssz as capellaSsz} from "../capella/index.js"; +import {ssz as capellaSsz} from "../capella/index.js"; // import {ssz as denebSsz} from "../deneb/index.js"; const {UintNum64, Root, BLSSignature} = primitiveSsz; @@ -37,19 +37,16 @@ export const SuffixStateDiff = new ContainerType( { suffix: primitiveSsz.Byte, // Null means not currently present - // TODO: Use new SSZ type Optional: https://github.com/ethereum/consensus-specs/commit/db74090c1e8dc1fb2c052bae268e22dc63061e32 currentValue: new OptionalType(primitiveSsz.Bytes32), - // newValue not present for the kaustenine network // Null means value not updated - // newValue: new OptionalType(primitiveSsz.Bytes32), + newValue: new OptionalType(primitiveSsz.Bytes32), }, { typeName: "SuffixStateDiff", casingMap: { suffix: "suffix", currentValue: "currentValue", - // newValue not present for the kaustenine network - // newValue: "newValue" + newValue: "newValue" }, } ); @@ -108,7 +105,7 @@ export const ExecutionWitness = new ContainerType( export const ExecutionPayload = new ContainerType( { - ...bellatrixSsz.ExecutionPayload.fields, + ...capellaSsz.ExecutionPayload.fields, executionWitness: ExecutionWitness, // New in verge }, {typeName: "ExecutionPayload", jsonCase: "eth2"} @@ -116,7 +113,7 @@ export const ExecutionPayload = new ContainerType( export const ExecutionPayloadHeader = new ContainerType( { - ...bellatrixSsz.ExecutionPayloadHeader.fields, + ...capellaSsz.ExecutionPayloadHeader.fields, executionWitnessRoot: Root, // New in verge }, {typeName: "ExecutionPayloadHeader", jsonCase: "eth2"} @@ -127,7 +124,7 @@ export const BeaconBlockBody = new ContainerType( { ...altairSsz.BeaconBlockBody.fields, executionPayload: ExecutionPayload, // Modified in verge - // blsToExecutionChanges: capellaSsz.BeaconBlockBody.fields.blsToExecutionChanges, + blsToExecutionChanges: capellaSsz.BeaconBlockBody.fields.blsToExecutionChanges, // blobKzgCommitments: denebSsz.BlobKzgCommitments, }, {typeName: "BeaconBlockBody", jsonCase: "eth2", cachePermanentRootStruct: true} @@ -135,7 +132,7 @@ export const BeaconBlockBody = new ContainerType( export const BeaconBlock = new ContainerType( { - ...bellatrixSsz.BeaconBlock.fields, + ...capellaSsz.BeaconBlock.fields, body: BeaconBlockBody, // Modified in verge }, {typeName: "BeaconBlock", jsonCase: "eth2", cachePermanentRootStruct: true} @@ -151,8 +148,9 @@ export const SignedBeaconBlock = new ContainerType( export const BlindedBeaconBlockBody = new ContainerType( { - ...BeaconBlockBody.fields, + ...altairSsz.BeaconBlockBody.fields, executionPayloadHeader: ExecutionPayloadHeader, // Modified in verge + blsToExecutionChanges: capellaSsz.BeaconBlockBody.fields.blsToExecutionChanges, // blobKzgCommitments: denebSsz.BlobKzgCommitments, }, {typeName: "BlindedBeaconBlockBody", jsonCase: "eth2", cachePermanentRootStruct: true} @@ -214,10 +212,10 @@ export const BeaconState = new ContainerType( // Execution latestExecutionPayloadHeader: ExecutionPayloadHeader, // Modified in verge // Withdrawals - // nextWithdrawalIndex: capellaSsz.BeaconState.fields.nextWithdrawalIndex, - // nextWithdrawalValidatorIndex: capellaSsz.BeaconState.fields.nextWithdrawalValidatorIndex, + nextWithdrawalIndex: capellaSsz.BeaconState.fields.nextWithdrawalIndex, + nextWithdrawalValidatorIndex: capellaSsz.BeaconState.fields.nextWithdrawalValidatorIndex, // Deep history valid from Capella onwards - // historicalSummaries: capellaSsz.BeaconState.fields.historicalSummaries, + historicalSummaries: capellaSsz.BeaconState.fields.historicalSummaries, }, {typeName: "BeaconState", jsonCase: "eth2"} );