Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update configs to be able to support Deneb on all networks #6328

Merged
merged 7 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 2 additions & 2 deletions packages/beacon-node/src/chain/archiver/archiveBlocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {fromHexString} from "@chainsafe/ssz";
import {Epoch, Slot, RootHex} from "@lodestar/types";
import {IForkChoice} from "@lodestar/fork-choice";
import {Logger, toHex} from "@lodestar/utils";
import {ForkSeq, SLOTS_PER_EPOCH, MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS} from "@lodestar/params";
import {ForkSeq, SLOTS_PER_EPOCH} from "@lodestar/params";
import {computeEpochAtSlot, computeStartSlotAtEpoch} from "@lodestar/state-transition";
import {KeyValue} from "@lodestar/db";
import {ChainForkConfig} from "@lodestar/config";
Expand Down Expand Up @@ -83,7 +83,7 @@ export async function archiveBlocks(
// Delete expired blobs
// Keep only `[max(GENESIS_EPOCH, current_epoch - MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS), current_epoch]`
if (finalizedPostDeneb) {
const blobSidecarsMinEpoch = currentEpoch - MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS;
const blobSidecarsMinEpoch = currentEpoch - config.MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS;
if (blobSidecarsMinEpoch >= config.DENEB_FORK_EPOCH) {
const slotsToDelete = await db.blobSidecarsArchive.keys({lt: computeStartSlotAtEpoch(blobSidecarsMinEpoch)});
if (slotsToDelete.length > 0) {
Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/src/chain/blocks/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {CachedBeaconStateAllForks, computeEpochAtSlot, DataAvailableStatus} from "@lodestar/state-transition";
import {MaybeValidExecutionStatus} from "@lodestar/fork-choice";
import {allForks, deneb, Slot} from "@lodestar/types";
import {ForkSeq, MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS} from "@lodestar/params";
import {ForkSeq} from "@lodestar/params";
import {ChainForkConfig} from "@lodestar/config";

export enum BlockInputType {
Expand Down Expand Up @@ -36,7 +36,7 @@ export function blockRequiresBlobs(config: ChainForkConfig, blockSlot: Slot, clo
return (
config.getForkSeq(blockSlot) >= ForkSeq.deneb &&
// Only request blobs if they are recent enough
computeEpochAtSlot(blockSlot) >= computeEpochAtSlot(clockSlot) - MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS
computeEpochAtSlot(blockSlot) >= computeEpochAtSlot(clockSlot) - config.MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {ChainForkConfig} from "@lodestar/config";
import {deneb, Epoch, phase0, allForks, Slot} from "@lodestar/types";
import {ForkSeq, MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS} from "@lodestar/params";
import {ForkSeq} from "@lodestar/params";
import {computeEpochAtSlot} from "@lodestar/state-transition";

import {BlockInput, BlockSource, getBlockInput} from "../../chain/blocks/types.js";
Expand Down Expand Up @@ -37,7 +37,7 @@ export async function beaconBlocksMaybeBlobsByRange(
}

// Only request blobs if they are recent enough
else if (computeEpochAtSlot(startSlot) >= currentEpoch - MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS) {
else if (computeEpochAtSlot(startSlot) >= currentEpoch - config.MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS) {
const [allBlocks, allBlobSidecars] = await Promise.all([
network.sendBeaconBlocksByRange(peerId, request),
network.sendBlobSidecarsByRange(peerId, request),
Expand Down
3 changes: 3 additions & 0 deletions packages/config/src/chainConfig/networks/chiado.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import {PresetName} from "@lodestar/params";
import {ChainConfig} from "../types.js";
import {chainConfig as mainnet} from "../presets/mainnet.js";

// Chiado beacon chain config:
// https://github.com/gnosischain/configs/blob/main/chiado/config.yaml

export const chiadoChainConfig: ChainConfig = {
...mainnet,

Expand Down
3 changes: 3 additions & 0 deletions packages/config/src/chainConfig/networks/gnosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import {PresetName} from "@lodestar/params";
import {ChainConfig} from "../types.js";
import {chainConfig as mainnet} from "../presets/mainnet.js";

// Gnosis beacon chain config:
// https://github.com/gnosischain/configs/blob/main/mainnet/config.yaml

export const gnosisChainConfig: ChainConfig = {
...mainnet,

Expand Down
3 changes: 3 additions & 0 deletions packages/config/src/chainConfig/networks/goerli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import {fromHexString as b} from "@chainsafe/ssz";
import {ChainConfig} from "../types.js";
import {chainConfig as mainnet} from "../presets/mainnet.js";

// Goerli beacon chain config:
// https://github.com/eth-clients/goerli/blob/main/prater/config.yaml

export const goerliChainConfig: ChainConfig = {
...mainnet,

Expand Down
2 changes: 1 addition & 1 deletion packages/config/src/chainConfig/networks/sepolia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {ChainConfig} from "../types.js";
import {chainConfig as mainnet} from "../presets/mainnet.js";

// Sepolia beacon chain config:
// https://github.com/eth-clients/merge-testnets/blob/main/sepolia-beacon-chain/config.yaml
// https://github.com/eth-clients/sepolia/blob/main/bepolia/config.yaml

export const sepoliaChainConfig: ChainConfig = {
...mainnet,
Expand Down
18 changes: 17 additions & 1 deletion packages/config/src/chainConfig/presets/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import {fromHexString as b} from "@chainsafe/ssz";
import {PresetName} from "@lodestar/params";
import {ChainConfig} from "../types.js";

// Mainnet config
// https://github.com/ethereum/consensus-specs/blob/dev/configs/mainnet.yaml

export const chainConfig: ChainConfig = {
// Extends the mainnet preset
PRESET_BASE: PresetName.mainnet,
CONFIG_NAME: "mainnet",

Expand Down Expand Up @@ -41,7 +45,7 @@ export const chainConfig: ChainConfig = {
CAPELLA_FORK_VERSION: b("0x03000000"),
CAPELLA_FORK_EPOCH: 194048, // April 12 (epoch: 194048 slot: 6209536 UTC: 4/12/2023, 10:27:35 PM)

// DENEB
// Deneb
DENEB_FORK_VERSION: b("0x04000000"),
DENEB_FORK_EPOCH: Infinity,

Expand All @@ -68,9 +72,14 @@ export const chainConfig: ChainConfig = {
EJECTION_BALANCE: 16000000000,
// 2**2 (= 4)
MIN_PER_EPOCH_CHURN_LIMIT: 4,
// 2**3 (= 8)
MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: 8,
// 2**16 (= 65,536)
CHURN_LIMIT_QUOTIENT: 65536,

// Fork choice
// ---------------------------------------------------------------
// 40%
PROPOSER_SCORE_BOOST: 40,

// Deposit contract
Expand All @@ -79,4 +88,11 @@ export const chainConfig: ChainConfig = {
DEPOSIT_CHAIN_ID: 1,
DEPOSIT_NETWORK_ID: 1,
DEPOSIT_CONTRACT_ADDRESS: b("0x00000000219ab540356cBB839Cbe05303d7705Fa"),

// Networking
// ---------------------------------------------------------------

// Deneb
// `2**12` (= 4096 epochs, ~18 days)
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 4096,
};
15 changes: 15 additions & 0 deletions packages/config/src/chainConfig/presets/minimal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import {fromHexString as b} from "@chainsafe/ssz";
import {PresetName} from "@lodestar/params";
import {ChainConfig} from "../types.js";

// Minimal config
// https://github.com/ethereum/consensus-specs/blob/dev/configs/minimal.yaml

export const chainConfig: ChainConfig = {
// Extends the minimal preset
PRESET_BASE: PresetName.minimal,
Expand Down Expand Up @@ -66,9 +69,14 @@ export const chainConfig: ChainConfig = {
EJECTION_BALANCE: 16000000000,
// 2**2 (= 4)
MIN_PER_EPOCH_CHURN_LIMIT: 2,
// [customized]
MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: 4,
// [customized] scale queue churn at much lower validator counts for testing
CHURN_LIMIT_QUOTIENT: 32,

// Fork choice
// ---------------------------------------------------------------
// 40%
PROPOSER_SCORE_BOOST: 40,

// Deposit contract
Expand All @@ -78,4 +86,11 @@ export const chainConfig: ChainConfig = {
DEPOSIT_NETWORK_ID: 5,
// Configured on a per testnet basis
DEPOSIT_CONTRACT_ADDRESS: b("0x1234567890123456789012345678901234567890"),

// Networking
// ---------------------------------------------------------------

// Deneb
// `2**12` (= 4096 epochs, ~18 days)
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 4096,
};
10 changes: 8 additions & 2 deletions packages/config/src/chainConfig/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,16 @@ export type ChainConfig = {
MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: number;
CHURN_LIMIT_QUOTIENT: number;

// Proposer boost
// Fork choice
PROPOSER_SCORE_BOOST: number;

// Deposit contract
DEPOSIT_CHAIN_ID: number;
DEPOSIT_NETWORK_ID: number;
DEPOSIT_CONTRACT_ADDRESS: Uint8Array;

// Networking
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: number;
};

export const chainConfigTypes: SpecTypes<ChainConfig> = {
Expand Down Expand Up @@ -109,13 +112,16 @@ export const chainConfigTypes: SpecTypes<ChainConfig> = {
MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: "number",
CHURN_LIMIT_QUOTIENT: "number",

// Proposer boost
// Fork choice
PROPOSER_SCORE_BOOST: "number",

// Deposit contract
DEPOSIT_CHAIN_ID: "number",
DEPOSIT_NETWORK_ID: "number",
DEPOSIT_CONTRACT_ADDRESS: "bytes",

// Networking
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: "number",
};

/** Allows values in a Spec file */
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 @@ -179,7 +179,6 @@ export const SYNC_COMMITTEE_SUBNET_SIZE = Math.floor(SYNC_COMMITTEE_SIZE / SYNC_
export const MAX_REQUEST_BLOCKS = 2 ** 10; // 1024
export const MAX_REQUEST_BLOCKS_DENEB = 2 ** 7; // 128
export const MAX_REQUEST_BLOB_SIDECARS = MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK;
export const MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS = 2 ** 12; // 4096 epochs, ~18 days

// Lightclient pre-computed
/**
Expand Down
3 changes: 3 additions & 0 deletions packages/params/src/presets/gnosis.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {BeaconPreset} from "../types.js";
import {mainnetPreset} from "./mainnet.js";

// Gnosis preset
// https://github.com/gnosischain/specs/tree/master/consensus/preset/gnosis

/* eslint-disable @typescript-eslint/naming-convention */
export const gnosisPreset: BeaconPreset = {
...mainnetPreset,
Expand Down
4 changes: 3 additions & 1 deletion packages/params/src/presets/mainnet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {BeaconPreset} from "../types.js";

// Mainnet preset
// https://github.com/ethereum/consensus-specs/tree/dev/presets/mainnet

/* eslint-disable @typescript-eslint/naming-convention */
export const mainnetPreset: BeaconPreset = {
// Misc
Expand Down Expand Up @@ -111,7 +114,6 @@ export const mainnetPreset: BeaconPreset = {

// DENEB
///////////
// https://github.com/ethereum/consensus-specs/blob/dev/presets/mainnet/eip4844.yaml
FIELD_ELEMENTS_PER_BLOB: 4096,
MAX_BLOB_COMMITMENTS_PER_BLOCK: 4096,
MAX_BLOBS_PER_BLOCK: 6,
Expand Down
10 changes: 3 additions & 7 deletions packages/params/src/presets/minimal.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {BeaconPreset} from "../types.js";

// Minimal preset
// https://github.com/ethereum/consensus-specs/tree/dev/presets/minimal

/* eslint-disable @typescript-eslint/naming-convention */
export const minimalPreset: BeaconPreset = {
// Misc
Expand Down Expand Up @@ -42,12 +45,6 @@ export const minimalPreset: BeaconPreset = {
EPOCHS_PER_ETH1_VOTING_PERIOD: 4,
// [customized] smaller state
SLOTS_PER_HISTORICAL_ROOT: 64,
/*
// 2**8 (= 256) epochs
MIN_VALIDATOR_WITHDRAWABILITY_DELAY: 256,
// [customized] higher frequency of committee turnover and faster time to acceptable voluntary exit
SHARD_COMMITTEE_PERIOD: 64,
*/
// 2**2 (= 4) epochs
MIN_EPOCHS_TO_INACTIVITY_PENALTY: 4,

Expand Down Expand Up @@ -118,7 +115,6 @@ export const minimalPreset: BeaconPreset = {

// DENEB
///////////
// https://github.com/ethereum/consensus-specs/blob/dev/presets/minimal/eip4844.yaml
FIELD_ELEMENTS_PER_BLOB: 4096,
MAX_BLOB_COMMITMENTS_PER_BLOCK: 16,
MAX_BLOBS_PER_BLOCK: 6,
Expand Down
5 changes: 4 additions & 1 deletion packages/validator/src/util/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,17 @@ function getSpecCriticalParams(localConfig: ChainConfig): Record<keyof ConfigWit
MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: denebForkRelevant,
CHURN_LIMIT_QUOTIENT: true,

// Proposer boost
// Fork choice
PROPOSER_SCORE_BOOST: false, // Ignored as it's changing https://github.com/ethereum/consensus-specs/pull/2895

// Deposit contract
DEPOSIT_CHAIN_ID: false, // Non-critical
DEPOSIT_NETWORK_ID: false, // Non-critical
DEPOSIT_CONTRACT_ADDRESS: true,

// Networking
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: false,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@g11tech Based on my understanding of this value it is not critical to verify it here as it is only relevant for the beacon node and as part of networking can't result in a consensus failure.

Maybe you could confirm this, and should we add a comment here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it doesn't affect consensus, adding with false is ok

Copy link
Member Author

@nflaig nflaig Jan 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment in e94355b


// # Phase0Preset
/////////////////

Expand Down
Loading