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
113 changes: 113 additions & 0 deletions yarn-project/cli/src/config/chain_l2_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import publicIncludeMetrics from '../../public_include_metric_prefixes.json' wit
import { cachedFetch } from './cached_fetch.js';
import { enrichEthAddressVar, enrichVar } from './enrich_env.js';

const defaultDBMapSizeKb = 128 * 1_024 * 1_024; // 128 GB
const tbMapSizeKb = 1_024 * 1_024 * 1_024; // 1 TB

export type L2ChainConfig = L1ContractsConfig &
Pick<P2PConfig, 'txPoolDeleteTxsAfterReorg'> &
Omit<SlasherConfig, 'slashValidatorsNever' | 'slashValidatorsAlways'> & {
Expand All @@ -33,6 +36,14 @@ export type L2ChainConfig = L1ContractsConfig &
publicMetricsCollectorUrl?: string;
publicMetricsCollectFrom?: string[];

// Setting the dbMapSize provides the default for every DB in the node.
// Then we explicitly override the sizes for the archiver and the larger trees.
dbMapSizeKb: number;
archiverStoreMapSizeKb: number;
noteHashTreeMapSizeKb: number;
nullifierTreeMapSizeKb: number;
publicDataTreeMapSizeKb: number;

// Control whether sentinel is enabled or not. Needed for slashing
sentinelEnabled: boolean;
};
Expand Down Expand Up @@ -72,6 +83,14 @@ const DefaultSlashConfig = {
slashExecuteRoundsLookBack: 4,
} satisfies Partial<L2ChainConfig>;

const DefaultNetworkDBMapSizeConfig = {
dbMapSizeKb: defaultDBMapSizeKb,
archiverStoreMapSizeKb: tbMapSizeKb,
noteHashTreeMapSizeKb: tbMapSizeKb,
nullifierTreeMapSizeKb: tbMapSizeKb,
publicDataTreeMapSizeKb: tbMapSizeKb,
} satisfies Partial<L2ChainConfig>;

export const stagingIgnitionL2ChainConfig: L2ChainConfig = {
l1ChainId: 11155111,
testAccounts: false,
Expand Down Expand Up @@ -148,6 +167,8 @@ export const stagingIgnitionL2ChainConfig: L2ChainConfig = {
slashOffenseExpirationRounds: 8,
sentinelEnabled: true,
slashExecuteRoundsLookBack: 4,

...DefaultNetworkDBMapSizeConfig,
};

export const stagingPublicL2ChainConfig: L2ChainConfig = {
Expand Down Expand Up @@ -198,6 +219,8 @@ export const stagingPublicL2ChainConfig: L2ChainConfig = {
exitDelaySeconds: DefaultL1ContractsConfig.exitDelaySeconds,

...DefaultSlashConfig,

...DefaultNetworkDBMapSizeConfig,
};

export const testnetL2ChainConfig: L2ChainConfig = {
Expand Down Expand Up @@ -251,6 +274,88 @@ export const testnetL2ChainConfig: L2ChainConfig = {
slashPrunePenalty: 0n,
slashDataWithholdingPenalty: 0n,
slashInactivityPenalty: DefaultL1ContractsConfig.slashAmountMedium,

...DefaultNetworkDBMapSizeConfig,
};

export const ignitionL2ChainConfig: L2ChainConfig = {
l1ChainId: 1,
testAccounts: false,
sponsoredFPC: false,
p2pEnabled: true,
p2pBootstrapNodes: [],
registryAddress: '',
slashFactoryAddress: '',
feeAssetHandlerAddress: '',
seqMinTxsPerBlock: 0,
seqMaxTxsPerBlock: 0,
realProofs: true,
snapshotsUrl: 'https://storage.googleapis.com/aztec-testnet/snapshots/ignition/',
autoUpdate: 'notify',
autoUpdateUrl: 'https://storage.googleapis.com/aztec-testnet/auto-update/ignition.json',
maxTxPoolSize: 100_000_000, // 100MB
publicIncludeMetrics,
publicMetricsCollectorUrl: 'https://telemetry.alpha-testnet.aztec-labs.com/v1/metrics',
publicMetricsCollectFrom: ['sequencer'],
txPoolDeleteTxsAfterReorg: false,

/** How many seconds an L1 slot lasts. */
ethereumSlotDuration: 12,
/** How many seconds an L2 slots lasts (must be multiple of ethereum slot duration). */
aztecSlotDuration: 72,
/** How many L2 slots an epoch lasts. */
aztecEpochDuration: 32,
/** The target validator committee size. */
aztecTargetCommitteeSize: 24,
/** The number of epochs after an epoch ends that proofs are still accepted. */
aztecProofSubmissionEpochs: 1,
/** How many sequencers must agree with a slash for it to be executed. */
slashingQuorum: 65,

slashingRoundSizeInEpochs: 4,
slashingLifetimeInRounds: 40,
slashingExecutionDelayInRounds: 28,
slashAmountSmall: 2_000n * 10n ** 18n,
slashAmountMedium: 10_000n * 10n ** 18n,
slashAmountLarge: 50_000n * 10n ** 18n,
slashingOffsetInRounds: 2,
slasherFlavor: 'tally',
slashingVetoer: EthAddress.ZERO, // TODO TMNT-329

/** The mana target for the rollup */
manaTarget: 0n,

exitDelaySeconds: 5 * 24 * 60 * 60,

/** The proving cost per mana */
provingCostPerMana: 0n,

ejectionThreshold: 100_000n * 10n ** 18n,
activationThreshold: 200_000n * 10n ** 18n,

governanceProposerRoundSize: 300, // TODO TMNT-322
governanceProposerQuorum: 151, // TODO TMNT-322

// Node slashing config
// TODO TMNT-330
slashMinPenaltyPercentage: 0.5,
slashMaxPenaltyPercentage: 2.0,
slashInactivityTargetPercentage: 0.7,
slashInactivityConsecutiveEpochThreshold: 2,
slashInactivityPenalty: 2_000n * 10n ** 18n,
slashPrunePenalty: 0n, // 2_000n * 10n ** 18n, We disable slashing for prune offenses right now
slashDataWithholdingPenalty: 0n, // 2_000n * 10n ** 18n, We disable slashing for data withholding offenses right now
slashProposeInvalidAttestationsPenalty: 50_000n * 10n ** 18n,
slashAttestDescendantOfInvalidPenalty: 50_000n * 10n ** 18n,
slashUnknownPenalty: 2_000n * 10n ** 18n,
slashBroadcastedInvalidBlockPenalty: 0n, // 10_000n * 10n ** 18n, Disabled for now until further testing
slashMaxPayloadSize: 50,
slashGracePeriodL2Slots: 32 * 4, // One round from genesis
slashOffenseExpirationRounds: 8,
sentinelEnabled: true,
slashExecuteRoundsLookBack: 4,

...DefaultNetworkDBMapSizeConfig,
};

const BOOTNODE_CACHE_DURATION_MS = 60 * 60 * 1000; // 1 hour;
Expand All @@ -276,6 +381,8 @@ export async function getL2ChainConfig(
config = { ...testnetL2ChainConfig };
} else if (networkName === 'staging-ignition') {
config = { ...stagingIgnitionL2ChainConfig };
} else if (networkName === 'ignition') {
config = { ...ignitionL2ChainConfig };
}
if (!config) {
return undefined;
Expand Down Expand Up @@ -317,6 +424,12 @@ export async function enrichEnvironmentWithChainConfig(networkName: NetworkNames
enrichVar('SYNC_SNAPSHOTS_URL', config.snapshotsUrl);
enrichVar('P2P_MAX_TX_POOL_SIZE', config.maxTxPoolSize.toString());

enrichVar('DATA_STORE_MAP_SIZE_KB', config.dbMapSizeKb.toString());
enrichVar('ARCHIVER_STORE_MAP_SIZE_KB', config.archiverStoreMapSizeKb.toString());
enrichVar('NOTE_HASH_TREE_MAP_SIZE_KB', config.noteHashTreeMapSizeKb.toString());
enrichVar('NULLIFIER_TREE_MAP_SIZE_KB', config.nullifierTreeMapSizeKb.toString());
enrichVar('PUBLIC_DATA_TREE_MAP_SIZE_KB', config.publicDataTreeMapSizeKb.toString());

if (config.autoUpdate) {
enrichVar('AUTO_UPDATE', config.autoUpdate?.toString());
}
Expand Down
4 changes: 3 additions & 1 deletion yarn-project/foundation/src/config/network_name.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export type NetworkNames = 'local' | 'staging-ignition' | 'staging-public' | 'testnet';
export type NetworkNames = 'local' | 'staging-ignition' | 'staging-public' | 'testnet' | 'ignition';

export function getActiveNetworkName(name?: string): NetworkNames {
const network = name || process.env.NETWORK;
Expand All @@ -10,6 +10,8 @@ export function getActiveNetworkName(name?: string): NetworkNames {
return network;
} else if (network === 'testnet' || network === 'alpha-testnet') {
return 'testnet';
} else if (network === 'ignition') {
return 'ignition';
}
throw new Error(`Unknown network: ${network}`);
}
22 changes: 12 additions & 10 deletions yarn-project/world-state/src/native/native_world_state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ describe('NativeWorldState', () => {
let dataDir: string;
let backupDir: string | undefined;
let rollupAddress: EthAddress;
const defaultDBMapSize = 25 * 1024 * 1024;
const defaultDBMapSize = 128 * 1024 * 1024; // 128 GB
const tbMapSize = 1024 * 1024 * 1024; // 1 TB
const wsTreeMapSizes: WorldStateTreeMapSizes = {
archiveTreeMapSizeKb: defaultDBMapSize,
nullifierTreeMapSizeKb: defaultDBMapSize,
noteHashTreeMapSizeKb: defaultDBMapSize,
nullifierTreeMapSizeKb: tbMapSize,
noteHashTreeMapSizeKb: tbMapSize,
messageTreeMapSizeKb: defaultDBMapSize,
publicDataTreeMapSizeKb: defaultDBMapSize,
publicDataTreeMapSizeKb: tbMapSize,
};

beforeAll(async () => {
Expand Down Expand Up @@ -1196,12 +1197,13 @@ describe('NativeWorldState', () => {
statuses[0].dbStats.publicDataTreeStats.blocksDBStats.numDataItems,
);

const mapSizeBytes = BigInt(1024 * defaultDBMapSize);
expect(statuses[0].dbStats.archiveTreeStats.mapSize).toBe(mapSizeBytes);
expect(statuses[0].dbStats.messageTreeStats.mapSize).toBe(mapSizeBytes);
expect(statuses[0].dbStats.nullifierTreeStats.mapSize).toBe(mapSizeBytes);
expect(statuses[0].dbStats.noteHashTreeStats.mapSize).toBe(mapSizeBytes);
expect(statuses[0].dbStats.publicDataTreeStats.mapSize).toBe(mapSizeBytes);
const defaultMapSizeBytes = BigInt(1024 * defaultDBMapSize);
const tbMapSizeBytes = BigInt(1024 * tbMapSize);
expect(statuses[0].dbStats.archiveTreeStats.mapSize).toBe(defaultMapSizeBytes);
expect(statuses[0].dbStats.messageTreeStats.mapSize).toBe(defaultMapSizeBytes);
expect(statuses[0].dbStats.nullifierTreeStats.mapSize).toBe(tbMapSizeBytes);
expect(statuses[0].dbStats.noteHashTreeStats.mapSize).toBe(tbMapSizeBytes);
expect(statuses[0].dbStats.publicDataTreeStats.mapSize).toBe(tbMapSizeBytes);

await ws.close();
});
Expand Down
Loading