Skip to content
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
3 changes: 0 additions & 3 deletions packages/beacon-node/src/chain/validation/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
MAX_BUILDER_DEPOSIT_REQUESTS_PER_PAYLOAD,
MAX_BUILDER_EXIT_REQUESTS_PER_PAYLOAD,
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD,
MAX_DEPOSIT_REQUESTS_PER_PAYLOAD,
MAX_PAYLOAD_ATTESTATIONS,
MAX_PROPOSER_SLASHINGS,
MAX_VOLUNTARY_EXITS,
Expand Down Expand Up @@ -182,7 +181,6 @@ export async function validateGossipBlock(

// [REJECT] The counts of `block.body.parent_execution_requests` are within
// their respective limits -- i.e. validate that
// `len(block.body.parent_execution_requests.deposits) <= MAX_DEPOSIT_REQUESTS_PER_PAYLOAD`,
// `len(block.body.parent_execution_requests.withdrawals) <= MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD`,
// `len(block.body.parent_execution_requests.consolidations) <= MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD`,
// `len(block.body.parent_execution_requests.builder_deposits) <= MAX_BUILDER_DEPOSIT_REQUESTS_PER_PAYLOAD`,
Expand All @@ -200,7 +198,6 @@ export async function validateGossipBlock(
const body = (block as gloas.BeaconBlock).body;
const requests = body.parentExecutionRequests;
const countLimits: [string, number, number][] = [
["parentExecutionRequests.deposits", requests.deposits.length, MAX_DEPOSIT_REQUESTS_PER_PAYLOAD],
["parentExecutionRequests.withdrawals", requests.withdrawals.length, MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD],
[
"parentExecutionRequests.consolidations",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
MAX_BUILDER_DEPOSIT_REQUESTS_PER_PAYLOAD,
MAX_BUILDER_EXIT_REQUESTS_PER_PAYLOAD,
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD,
MAX_DEPOSIT_REQUESTS_PER_PAYLOAD,
MAX_WITHDRAWALS_PER_PAYLOAD,
MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD,
} from "@lodestar/params";
Expand Down Expand Up @@ -123,12 +122,11 @@ async function validateExecutionPayloadEnvelope(
});
}

// [REJECT] The counts of `execution_requests` are within their respective limits.
// [REJECT] The non-deposit counts of `execution_requests` are within their respective limits.
// New in Gloas:EIP7688 — progressive lists are unbounded at the type level, so bounds
// are enforced here in gossip validation.
const {executionRequests} = envelope;
const requestCountLimits: [string, number, number][] = [
["deposits", executionRequests.deposits.length, MAX_DEPOSIT_REQUESTS_PER_PAYLOAD],
["withdrawals", executionRequests.withdrawals.length, MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD],
["consolidations", executionRequests.consolidations.length, MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD],
["builderDeposits", executionRequests.builderDeposits.length, MAX_BUILDER_DEPOSIT_REQUESTS_PER_PAYLOAD],
Expand Down
23 changes: 17 additions & 6 deletions packages/beacon-node/src/execution/engine/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,13 +510,24 @@ function prefixRequests(requestsBytes: Uint8Array, requestType: ExecutionRequest
return prefixedRequests;
}

function serializeDepositRequests(depositRequests: electra.DepositRequests): DepositRequestsRpc {
const requestsBytes = ssz.electra.DepositRequests.serialize(depositRequests);
function serializeDepositRequests(
fork: ForkName,
depositRequests: electra.DepositRequests | gloas.DepositRequests
): DepositRequestsRpc {
const requestsBytes =
ForkSeq[fork] >= ForkSeq.gloas
? ssz.gloas.DepositRequests.serialize(depositRequests)
Comment thread
nflaig marked this conversation as resolved.
: ssz.electra.DepositRequests.serialize(depositRequests);
Comment thread
nflaig marked this conversation as resolved.
return bytesToData(prefixRequests(requestsBytes, DEPOSIT_REQUEST_TYPE));
}

function deserializeDepositRequests(serialized: DepositRequestsRpc): electra.DepositRequests {
return ssz.electra.DepositRequests.deserialize(dataToBytes(serialized, null));
function deserializeDepositRequests(
fork: ForkName,
serialized: DepositRequestsRpc
): electra.DepositRequests | gloas.DepositRequests {
return ForkSeq[fork] >= ForkSeq.gloas
? ssz.gloas.DepositRequests.deserialize(dataToBytes(serialized, null))
: ssz.electra.DepositRequests.deserialize(dataToBytes(serialized, null));
}

function serializeWithdrawalRequests(withdrawalRequests: electra.WithdrawalRequests): WithdrawalRequestsRpc {
Expand Down Expand Up @@ -571,7 +582,7 @@ export function serializeExecutionRequests(fork: ForkName, executionRequests: Ex
const result: ExecutionRequestsRpc = [];

if (deposits.length !== 0) {
result.push(serializeDepositRequests(deposits));
result.push(serializeDepositRequests(fork, deposits));
}

if (withdrawals.length !== 0) {
Expand Down Expand Up @@ -637,7 +648,7 @@ export function deserializeExecutionRequests(fork: ForkName, serialized: Executi

switch (currentRequestType) {
case DEPOSIT_REQUEST_TYPE: {
result.deposits = deserializeDepositRequests(requests);
result.deposits = deserializeDepositRequests(fork, requests);
break;
}
case WITHDRAWAL_REQUEST_TYPE: {
Expand Down
5 changes: 2 additions & 3 deletions packages/beacon-node/src/network/gossip/topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
MAX_ATTESTER_SLASHING_SIZE,
MAX_DATA_COLUMN_SIDECAR_SIZE,
MAX_SIGNED_AGGREGATE_AND_PROOF_SIZE,
MAX_SIGNED_BEACON_BLOCK_SIZE,
MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE,
SYNC_COMMITTEE_SUBNET_COUNT,
isForkPostAltair,
Expand Down Expand Up @@ -142,10 +141,10 @@ export function getGossipSSZType(topic: GossipTopic): CompositeTypeAny {
*/
export function getGossipSSZMaxSize(topic: GossipTopic, maxPayloadSize: number, sszType?: CompositeTypeAny): number {
const {fork} = topic.boundary;
// Gloas progressive containers have broad theoretical SSZ max sizes; use the preset p2p bounds instead.
// Gloas progressive containers have broad theoretical SSZ max sizes; use preset p2p bounds where specified.
switch (topic.type) {
case GossipType.beacon_block:
return isForkPostGloas(fork) ? MAX_SIGNED_BEACON_BLOCK_SIZE : maxPayloadSize;
return maxPayloadSize;
case GossipType.beacon_aggregate_and_proof:
return isForkPostGloas(fork) ? MAX_SIGNED_AGGREGATE_AND_PROOF_SIZE : (sszType ?? getGossipSSZType(topic)).maxSize;
case GossipType.attester_slashing:
Expand Down
19 changes: 19 additions & 0 deletions packages/beacon-node/test/unit/execution/engine/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
CONSOLIDATION_REQUEST_TYPE,
DEPOSIT_REQUEST_TYPE,
ForkName,
MAX_DEPOSIT_REQUESTS_PER_PAYLOAD,
WITHDRAWAL_REQUEST_TYPE,
} from "@lodestar/params";
import {ExecutionRequests, gloas, ssz} from "@lodestar/types";
Expand Down Expand Up @@ -75,6 +76,24 @@ describe("execution / engine / types", () => {
expect(serialized.length).toBe(0);
});

it("should serialize Gloas deposit requests beyond the Electra limit", () => {
const expectedLength = MAX_DEPOSIT_REQUESTS_PER_PAYLOAD + 1;
const executionRequests: gloas.ExecutionRequests = {
deposits: Array.from({length: expectedLength}, () => ssz.gloas.DepositRequest.defaultValue()),
withdrawals: [],
consolidations: [],
builderDeposits: [],
builderExits: [],
};

const serialized = serializeExecutionRequests(ForkName.gloas, executionRequests);
const deserialized = deserializeExecutionRequests(ForkName.gloas, serialized) as gloas.ExecutionRequests;

expect(serialized.length).toBe(1);
expect(deserialized.deposits.length).toBe(expectedLength);
expect(serializeExecutionRequests(ForkName.gloas, deserialized)).toEqual(serialized);
});

it("should serialize builder requests post-gloas", () => {
const executionRequests: gloas.ExecutionRequests = {
deposits: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
MAX_ATTESTER_SLASHING_SIZE,
MAX_DATA_COLUMN_SIDECAR_SIZE,
MAX_SIGNED_AGGREGATE_AND_PROOF_SIZE,
MAX_SIGNED_BEACON_BLOCK_SIZE,
MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE,
ZERO_HASH,
} from "@lodestar/params";
Expand Down Expand Up @@ -267,7 +266,7 @@ describe("network / gossip / topic", () => {
config.MAX_PAYLOAD_SIZE
),
}).toEqual({
[GossipType.beacon_block]: MAX_SIGNED_BEACON_BLOCK_SIZE,
[GossipType.beacon_block]: config.MAX_PAYLOAD_SIZE,
[GossipType.data_column_sidecar]: MAX_DATA_COLUMN_SIDECAR_SIZE,
[GossipType.beacon_aggregate_and_proof]: MAX_SIGNED_AGGREGATE_AND_PROOF_SIZE,
[GossipType.attester_slashing]: MAX_ATTESTER_SLASHING_SIZE,
Expand Down
1 change: 0 additions & 1 deletion packages/params/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ export const {
MAX_DATA_COLUMN_SIDECAR_SIZE,
MAX_PARTIAL_DATA_COLUMN_SIDECAR_SIZE,
MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE,
MAX_SIGNED_BEACON_BLOCK_SIZE,
} = activePreset;

////////////
Expand Down
1 change: 0 additions & 1 deletion packages/params/src/presets/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,4 @@ export const mainnetPreset: BeaconPreset = {
MAX_DATA_COLUMN_SIDECAR_SIZE: 8585272,
MAX_PARTIAL_DATA_COLUMN_SIDECAR_SIZE: 8585741,
MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE: 196932,
MAX_SIGNED_BEACON_BLOCK_SIZE: 4027336,
};
1 change: 0 additions & 1 deletion packages/params/src/presets/minimal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,4 @@ export const minimalPreset: BeaconPreset = {
MAX_DATA_COLUMN_SIDECAR_SIZE: 8585272,
MAX_PARTIAL_DATA_COLUMN_SIDECAR_SIZE: 8585741,
MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE: 196932,
MAX_SIGNED_BEACON_BLOCK_SIZE: 1938012,
};
2 changes: 0 additions & 2 deletions packages/params/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export type BeaconPreset = {
MAX_DATA_COLUMN_SIDECAR_SIZE: number;
MAX_PARTIAL_DATA_COLUMN_SIDECAR_SIZE: number;
MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE: number;
MAX_SIGNED_BEACON_BLOCK_SIZE: number;
};

/**
Expand Down Expand Up @@ -236,7 +235,6 @@ export const beaconPresetTypes: BeaconPresetTypes = {
MAX_DATA_COLUMN_SIDECAR_SIZE: "number",
MAX_PARTIAL_DATA_COLUMN_SIDECAR_SIZE: "number",
MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE: "number",
MAX_SIGNED_BEACON_BLOCK_SIZE: "number",
};

type BeaconPresetTypes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
MAX_BUILDER_DEPOSIT_REQUESTS_PER_PAYLOAD,
MAX_BUILDER_EXIT_REQUESTS_PER_PAYLOAD,
MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD,
MAX_DEPOSIT_REQUESTS_PER_PAYLOAD,
MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD,
SLOTS_PER_EPOCH,
SLOTS_PER_HISTORICAL_ROOT,
Expand Down Expand Up @@ -128,7 +127,6 @@ function settleBuilderPayment(state: CachedBeaconStateGloas, paymentIndex: numbe
}

function assertExecutionRequestsWithinLimits(requests: gloas.ExecutionRequests): void {
assertMaxLength("deposits", requests.deposits.length, MAX_DEPOSIT_REQUESTS_PER_PAYLOAD);
assertMaxLength("withdrawals", requests.withdrawals.length, MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD);
assertMaxLength("consolidations", requests.consolidations.length, MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD);
// New in GLOAS:EIP8282
Expand Down
1 change: 0 additions & 1 deletion packages/validator/src/util/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,6 @@ function getSpecCriticalParams(localConfig: ChainConfig): Record<keyof ConfigWit
MAX_DATA_COLUMN_SIDECAR_SIZE: false,
MAX_PARTIAL_DATA_COLUMN_SIDECAR_SIZE: false,
MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE: false,
MAX_SIGNED_BEACON_BLOCK_SIZE: false,
MIN_BUILDER_WITHDRAWABILITY_DELAY: gloasForkRelevant,

// FastConfirmationRule
Expand Down
1 change: 0 additions & 1 deletion specrefs/.ethspecify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ exceptions:
presets:
# heze (not implemented)
- INCLUSION_LIST_COMMITTEE_SIZE#heze
- MAX_SIGNED_BEACON_BLOCK_SIZE_HEZE#heze
- MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE_HEZE#heze
- MAX_SIGNED_INCLUSION_LIST_SIZE#heze

Expand Down
5 changes: 0 additions & 5 deletions specrefs/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,9 @@
parent_slot = parent_bid.slot
parent_epoch = compute_epoch_at_slot(parent_slot)

assert len(requests.deposits) <= MAX_DEPOSIT_REQUESTS_PER_PAYLOAD
assert len(requests.withdrawals) <= MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD
assert len(requests.consolidations) <= MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD
# [New in Gloas:EIP8282]
assert len(requests.builder_deposits) <= MAX_BUILDER_DEPOSIT_REQUESTS_PER_PAYLOAD
# [New in Gloas:EIP8282]
assert len(requests.builder_exits) <= MAX_BUILDER_EXIT_REQUESTS_PER_PAYLOAD

# Process execution requests from parent's payload. The execution
Expand All @@ -221,9 +218,7 @@
for_ops(requests.deposits, process_deposit_request)
for_ops(requests.withdrawals, process_withdrawal_request)
for_ops(requests.consolidations, process_consolidation_request)
# [New in Gloas:EIP8282]
for_ops(requests.builder_deposits, process_builder_deposit_request)
# [New in Gloas:EIP8282]
for_ops(requests.builder_exits, process_builder_exit_request)

# Settle the builder payment
Expand Down
16 changes: 0 additions & 16 deletions specrefs/presets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -419,22 +419,6 @@
MAX_SIGNED_AGGREGATE_AND_PROOF_SIZE: uint64 = 16829
</spec>

- name: MAX_SIGNED_BEACON_BLOCK_SIZE#gloas
sources:
- file: packages/params/src/presets/mainnet.ts
search: "MAX_SIGNED_BEACON_BLOCK_SIZE:"
spec: |
<spec preset_var="MAX_SIGNED_BEACON_BLOCK_SIZE" fork="gloas" hash="39e62604">
MAX_SIGNED_BEACON_BLOCK_SIZE: uint64 = 4027336
</spec>

- name: MAX_SIGNED_BEACON_BLOCK_SIZE_HEZE#heze
sources: []
spec: |
<spec preset_var="MAX_SIGNED_BEACON_BLOCK_SIZE_HEZE" fork="heze" hash="cee41726">
MAX_SIGNED_BEACON_BLOCK_SIZE_HEZE: uint64 = 4027338
</spec>

- name: MAX_SIGNED_EXECUTION_PAYLOAD_BID_SIZE#gloas
sources:
- file: packages/params/src/presets/mainnet.ts
Expand Down
Loading