Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ export async function produceBlockBody<T extends BlockType>(
} else {
blobsResult = {type: BlobsResultType.preDeneb};
}

if (ForkSeq[fork] >= ForkSeq.electra) {
const {executionRequests} = builderRes;
if (executionRequests === undefined) {
throw Error(`Invalid builder getHeader response for fork=${fork}, missing executionRequests`);
}
(blockBody as electra.BlindedBeaconBlockBody).executionRequests = executionRequests;
}
}

// blockType === BlockType.Full
Expand Down Expand Up @@ -455,6 +463,7 @@ async function prepareExecutionPayloadHeader(
header: ExecutionPayloadHeader;
executionPayloadValue: Wei;
blobKzgCommitments?: deneb.BlobKzgCommitments;
executionRequests?: electra.ExecutionRequests;
}> {
if (!chain.executionBuilder) {
throw Error("executionBuilder required");
Expand Down
5 changes: 4 additions & 1 deletion packages/beacon-node/src/execution/builder/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
SignedBeaconBlockOrContents,
SignedBlindedBeaconBlock,
ExecutionPayloadHeader,
electra,
} from "@lodestar/types";
import {parseExecutionPayloadAndBlobsBundle, reconstructFullBlockOrContents} from "@lodestar/state-transition";
import {ChainForkConfig} from "@lodestar/config";
Expand Down Expand Up @@ -114,6 +115,7 @@ export class ExecutionBuilderHttp implements IExecutionBuilder {
header: ExecutionPayloadHeader;
executionPayloadValue: Wei;
blobKzgCommitments?: deneb.BlobKzgCommitments;
executionRequests?: electra.ExecutionRequests;
}> {
const signedBuilderBid = (await this.api.getHeader({slot, parentHash, proposerPubkey})).value();

Expand All @@ -123,7 +125,8 @@ export class ExecutionBuilderHttp implements IExecutionBuilder {

const {header, value: executionPayloadValue} = signedBuilderBid.message;
const {blobKzgCommitments} = signedBuilderBid.message as deneb.BuilderBid;
return {header, executionPayloadValue, blobKzgCommitments};
const {executionRequests} = signedBuilderBid.message as electra.BuilderBid;
return {header, executionPayloadValue, blobKzgCommitments, executionRequests};
}

async submitBlindedBlock(signedBlindedBlock: SignedBlindedBeaconBlock): Promise<SignedBeaconBlockOrContents> {
Expand Down
2 changes: 2 additions & 0 deletions packages/beacon-node/src/execution/builder/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
SignedBeaconBlockOrContents,
ExecutionPayloadHeader,
SignedBlindedBeaconBlock,
electra,
} from "@lodestar/types";
import {ForkExecution} from "@lodestar/params";

Expand Down Expand Up @@ -36,6 +37,7 @@ export interface IExecutionBuilder {
header: ExecutionPayloadHeader;
executionPayloadValue: Wei;
blobKzgCommitments?: deneb.BlobKzgCommitments;
executionRequests?: electra.ExecutionRequests;
}>;
submitBlindedBlock(signedBlock: SignedBlindedBeaconBlock): Promise<SignedBeaconBlockOrContents>;
}
114 changes: 41 additions & 73 deletions packages/beacon-node/src/execution/engine/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {capella, deneb, electra, Wei, bellatrix, Root, ExecutionPayload, ExecutionRequests} from "@lodestar/types";
import {capella, deneb, electra, Wei, bellatrix, Root, ExecutionPayload, ExecutionRequests, ssz} from "@lodestar/types";
import {
BYTES_PER_LOGS_BLOOM,
FIELD_ELEMENTS_PER_BLOB,
Expand Down Expand Up @@ -161,29 +161,17 @@ export type WithdrawalRpc = {
amount: QUANTITY;
};

export type ExecutionRequestsRpc = {
deposits: DepositRequestRpc[];
withdrawals: WithdrawalRequestRpc[];
consolidations: ConsolidationRequestRpc[];
};
/**
* ExecutionRequestsRpc only holds 3 elements in the following order:
* - ssz'ed DepositRequests
* - ssz'ed WithdrawalRequests
* - ssz'ed ConsolidationRequests
*/
export type ExecutionRequestsRpc = [DepositRequestsRpc, WithdrawalRequestsRpc, ConsolidationRequestsRpc];

export type DepositRequestRpc = {
pubkey: DATA;
withdrawalCredentials: DATA;
amount: QUANTITY;
signature: DATA;
index: QUANTITY;
};
export type WithdrawalRequestRpc = {
sourceAddress: DATA;
validatorPubkey: DATA;
amount: QUANTITY;
};
export type ConsolidationRequestRpc = {
sourceAddress: DATA;
sourcePubkey: DATA;
targetPubkey: DATA;
};
export type DepositRequestsRpc = DATA;
export type WithdrawalRequestsRpc = DATA;
export type ConsolidationRequestsRpc = DATA;

export type VersionedHashesRpc = DATA[];

Expand Down Expand Up @@ -406,73 +394,53 @@ export function deserializeWithdrawal(serialized: WithdrawalRpc): capella.Withdr
} as capella.Withdrawal;
}

function serializeDepositRequest(depositRequest: electra.DepositRequest): DepositRequestRpc {
return {
pubkey: bytesToData(depositRequest.pubkey),
withdrawalCredentials: bytesToData(depositRequest.withdrawalCredentials),
amount: numToQuantity(depositRequest.amount),
signature: bytesToData(depositRequest.signature),
index: numToQuantity(depositRequest.index),
};
function serializeDepositRequests(depositRequests: electra.DepositRequests): DepositRequestsRpc {
return bytesToData(ssz.electra.DepositRequests.serialize(depositRequests));
}

function deserializeDepositRequest(serialized: DepositRequestRpc): electra.DepositRequest {
return {
pubkey: dataToBytes(serialized.pubkey, 48),
withdrawalCredentials: dataToBytes(serialized.withdrawalCredentials, 32),
amount: quantityToNum(serialized.amount),
signature: dataToBytes(serialized.signature, 96),
index: quantityToNum(serialized.index),
} as electra.DepositRequest;
function deserializeDepositRequests(serialized: DepositRequestsRpc): electra.DepositRequests {
return ssz.electra.DepositRequests.deserialize(dataToBytes(serialized, null));
}

function serializeWithdrawalRequest(withdrawalRequest: electra.WithdrawalRequest): WithdrawalRequestRpc {
return {
sourceAddress: bytesToData(withdrawalRequest.sourceAddress),
validatorPubkey: bytesToData(withdrawalRequest.validatorPubkey),
amount: numToQuantity(withdrawalRequest.amount),
};
function serializeWithdrawalRequests(withdrawalRequests: electra.WithdrawalRequests): WithdrawalRequestsRpc {
return bytesToData(ssz.electra.WithdrawalRequests.serialize(withdrawalRequests));
}

function deserializeWithdrawalRequest(withdrawalRequest: WithdrawalRequestRpc): electra.WithdrawalRequest {
return {
sourceAddress: dataToBytes(withdrawalRequest.sourceAddress, 20),
validatorPubkey: dataToBytes(withdrawalRequest.validatorPubkey, 48),
amount: quantityToBigint(withdrawalRequest.amount),
};
function deserializeWithdrawalRequest(serialized: WithdrawalRequestsRpc): electra.WithdrawalRequests {
return ssz.electra.WithdrawalRequests.deserialize(dataToBytes(serialized, null));
}

function serializeConsolidationRequest(consolidationRequest: electra.ConsolidationRequest): ConsolidationRequestRpc {
return {
sourceAddress: bytesToData(consolidationRequest.sourceAddress),
sourcePubkey: bytesToData(consolidationRequest.sourcePubkey),
targetPubkey: bytesToData(consolidationRequest.targetPubkey),
};
function serializeConsolidationRequests(
consolidationRequests: electra.ConsolidationRequests
): ConsolidationRequestsRpc {
return bytesToData(ssz.electra.ConsolidationRequests.serialize(consolidationRequests));
}

function deserializeConsolidationRequest(consolidationRequest: ConsolidationRequestRpc): electra.ConsolidationRequest {
return {
sourceAddress: dataToBytes(consolidationRequest.sourceAddress, 20),
sourcePubkey: dataToBytes(consolidationRequest.sourcePubkey, 48),
targetPubkey: dataToBytes(consolidationRequest.targetPubkey, 48),
};
function deserializeConsolidationRequests(serialized: ConsolidationRequestsRpc): electra.ConsolidationRequests {
return ssz.electra.ConsolidationRequests.deserialize(dataToBytes(serialized, null));
}

/**
* This is identical to get_execution_requests_list in
* https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.8/specs/electra/beacon-chain.md#new-get_execution_requests_list
*/
export function serializeExecutionRequests(executionRequests: ExecutionRequests): ExecutionRequestsRpc {
const {deposits, withdrawals, consolidations} = executionRequests;
return {
deposits: deposits.map(serializeDepositRequest),
withdrawals: withdrawals.map(serializeWithdrawalRequest),
consolidations: consolidations.map(serializeConsolidationRequest),
};

return [
serializeDepositRequests(deposits),
serializeWithdrawalRequests(withdrawals),
serializeConsolidationRequests(consolidations),
];
}

export function deserializeExecutionRequests(executionRequests: ExecutionRequestsRpc): ExecutionRequests {
const {deposits, withdrawals, consolidations} = executionRequests;
export function deserializeExecutionRequests(serialized: ExecutionRequestsRpc): ExecutionRequests {
const [deposits, withdrawals, consolidations] = serialized;

return {
deposits: deposits.map(deserializeDepositRequest),
withdrawals: withdrawals.map(deserializeWithdrawalRequest),
consolidations: consolidations.map(deserializeConsolidationRequest),
deposits: deserializeDepositRequests(deposits),
withdrawals: deserializeWithdrawalRequest(withdrawals),
consolidations: deserializeConsolidationRequests(consolidations),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const epochTransitionFns: Record<string, EpochTransitionFn> = {
epochFns.processSyncCommitteeUpdates(fork, state as CachedBeaconStateAltair);
},
historical_summaries_update: epochFns.processHistoricalSummariesUpdate as EpochTransitionFn,
pending_balance_deposits: epochFns.processPendingBalanceDeposits as EpochTransitionFn,
pending_deposits: epochFns.processPendingDeposits as EpochTransitionFn,
pending_consolidations: epochFns.processPendingConsolidations as EpochTransitionFn,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/beacon-node/test/spec/specTestVersioning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {DownloadTestsOptions} from "@lodestar/spec-test-util/downloadTests";
const __dirname = path.dirname(fileURLToPath(import.meta.url));

export const ethereumConsensusSpecsTests: DownloadTestsOptions = {
specVersion: "v1.5.0-alpha.6",
specVersion: "v1.5.0-alpha.8",
// Target directory is the host package root: 'packages/*/spec-tests'
outputDir: path.join(__dirname, "../../spec-tests"),
specTestsRepoUrl: "https://github.com/ethereum/consensus-spec-tests",
Expand Down
3 changes: 2 additions & 1 deletion packages/params/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const {

MAX_EFFECTIVE_BALANCE_ELECTRA,
MIN_ACTIVATION_BALANCE,
PENDING_BALANCE_DEPOSITS_LIMIT,
PENDING_DEPOSITS_LIMIT,
PENDING_PARTIAL_WITHDRAWALS_LIMIT,
PENDING_CONSOLIDATIONS_LIMIT,
MIN_SLASHING_PENALTY_QUOTIENT_ELECTRA,
Expand All @@ -107,6 +107,7 @@ export const {
MAX_ATTESTER_SLASHINGS_ELECTRA,
MAX_ATTESTATIONS_ELECTRA,
MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP,
MAX_PENDING_DEPOSITS_PER_EPOCH,
WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA,
} = activePreset;

Expand Down
3 changes: 2 additions & 1 deletion packages/params/src/presets/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,12 @@ export const mainnetPreset: BeaconPreset = {
MAX_ATTESTER_SLASHINGS_ELECTRA: 1,
MAX_ATTESTATIONS_ELECTRA: 8,
MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: 8,
MAX_PENDING_DEPOSITS_PER_EPOCH: 16,
// 2**11 * 10**9 (= 2,048,000,000,000) Gwei
MAX_EFFECTIVE_BALANCE_ELECTRA: 2048000000000,
MIN_SLASHING_PENALTY_QUOTIENT_ELECTRA: 4096,
MIN_ACTIVATION_BALANCE: 32000000000,
PENDING_BALANCE_DEPOSITS_LIMIT: 134217728,
PENDING_DEPOSITS_LIMIT: 134217728,
PENDING_PARTIAL_WITHDRAWALS_LIMIT: 134217728,
PENDING_CONSOLIDATIONS_LIMIT: 262144,
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 1,
Expand Down
5 changes: 3 additions & 2 deletions packages/params/src/presets/minimal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,13 @@ export const minimalPreset: BeaconPreset = {
MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD: 2,
MAX_ATTESTER_SLASHINGS_ELECTRA: 1,
MAX_ATTESTATIONS_ELECTRA: 8,
MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: 1,
MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: 2,
MAX_PENDING_DEPOSITS_PER_EPOCH: 16,
// 2**11 * 10**9 (= 2,048,000,000,000) Gwei
MAX_EFFECTIVE_BALANCE_ELECTRA: 2048000000000,
MIN_SLASHING_PENALTY_QUOTIENT_ELECTRA: 4096,
MIN_ACTIVATION_BALANCE: 32000000000,
PENDING_BALANCE_DEPOSITS_LIMIT: 134217728,
PENDING_DEPOSITS_LIMIT: 134217728,
PENDING_PARTIAL_WITHDRAWALS_LIMIT: 64,
PENDING_CONSOLIDATIONS_LIMIT: 64,
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 1,
Expand Down
6 changes: 4 additions & 2 deletions packages/params/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ export type BeaconPreset = {
MAX_ATTESTER_SLASHINGS_ELECTRA: number;
MAX_ATTESTATIONS_ELECTRA: number;
MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: number;
MAX_PENDING_DEPOSITS_PER_EPOCH: number;
MAX_EFFECTIVE_BALANCE_ELECTRA: number;
MIN_SLASHING_PENALTY_QUOTIENT_ELECTRA: number;
MIN_ACTIVATION_BALANCE: number;
PENDING_BALANCE_DEPOSITS_LIMIT: number;
PENDING_DEPOSITS_LIMIT: number;
PENDING_PARTIAL_WITHDRAWALS_LIMIT: number;
PENDING_CONSOLIDATIONS_LIMIT: number;
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: number;
Expand Down Expand Up @@ -189,10 +190,11 @@ export const beaconPresetTypes: BeaconPresetTypes = {
MAX_ATTESTER_SLASHINGS_ELECTRA: "number",
MAX_ATTESTATIONS_ELECTRA: "number",
MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: "number",
MAX_PENDING_DEPOSITS_PER_EPOCH: "number",
MAX_EFFECTIVE_BALANCE_ELECTRA: "number",
MIN_SLASHING_PENALTY_QUOTIENT_ELECTRA: "number",
MIN_ACTIVATION_BALANCE: "number",
PENDING_BALANCE_DEPOSITS_LIMIT: "number",
PENDING_DEPOSITS_LIMIT: "number",
PENDING_PARTIAL_WITHDRAWALS_LIMIT: "number",
PENDING_CONSOLIDATIONS_LIMIT: "number",
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: "number",
Expand Down
Loading