@aztec/ethereum 0.0.1-commit.a89ec08 → 0.0.1-commit.aa0c64f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/client.d.ts +17 -3
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +49 -3
- package/dest/config.d.ts +27 -8
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +60 -13
- package/dest/contracts/chain_state_override.d.ts +78 -0
- package/dest/contracts/chain_state_override.d.ts.map +1 -0
- package/dest/contracts/chain_state_override.js +137 -0
- package/dest/contracts/empire_base.d.ts +1 -3
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/fee_asset_price_oracle.d.ts +6 -2
- package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -1
- package/dest/contracts/fee_asset_price_oracle.js +11 -6
- package/dest/contracts/governance.d.ts +108 -33
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +193 -12
- package/dest/contracts/governance_proposer.d.ts +33 -3
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +51 -9
- package/dest/contracts/gse.d.ts +4 -2
- package/dest/contracts/gse.d.ts.map +1 -1
- package/dest/contracts/gse.js +2 -2
- package/dest/contracts/inbox.d.ts +3 -3
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +12 -7
- package/dest/contracts/index.d.ts +3 -3
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +2 -2
- package/dest/contracts/multicall.d.ts +130 -13
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +203 -94
- package/dest/contracts/outbox.d.ts +27 -4
- package/dest/contracts/outbox.d.ts.map +1 -1
- package/dest/contracts/outbox.js +34 -7
- package/dest/contracts/rollup.d.ts +5400 -25
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +341 -66
- package/dest/contracts/{tally_slashing_proposer.d.ts → slashing_proposer.d.ts} +3 -4
- package/dest/contracts/slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/{tally_slashing_proposer.js → slashing_proposer.js} +13 -15
- package/dest/deploy_aztec_l1_contracts.d.ts +18 -10
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +28 -17
- package/dest/foundry_binary.d.ts +13 -0
- package/dest/foundry_binary.d.ts.map +1 -0
- package/dest/foundry_binary.js +52 -0
- package/dest/l1_artifacts.d.ts +14941 -16273
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_artifacts.js +9 -24
- package/dest/l1_contract_addresses.d.ts +61 -65
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +101 -82
- package/dest/l1_reader.d.ts +3 -5
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +3 -6
- package/dest/l1_tx_utils/config.js +3 -3
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +23 -4
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_fee_analyzer.js +65 -3
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +9 -1
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +138 -57
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +2 -1
- package/dest/l1_tx_utils/tx_delayer.d.ts +5 -3
- package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -1
- package/dest/l1_tx_utils/tx_delayer.js +7 -5
- package/dest/l1_tx_utils/types.d.ts +27 -1
- package/dest/l1_tx_utils/types.d.ts.map +1 -1
- package/dest/l1_tx_utils/types.js +10 -0
- package/dest/publisher_manager.d.ts +34 -8
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +119 -8
- package/dest/queries.d.ts +13 -2
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +69 -4
- package/dest/test/blob_kzg_warmup.d.ts +19 -0
- package/dest/test/blob_kzg_warmup.d.ts.map +1 -0
- package/dest/test/blob_kzg_warmup.js +64 -0
- package/dest/test/chain_monitor.d.ts +34 -2
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +76 -6
- package/dest/test/eth_cheat_codes.d.ts +32 -3
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +83 -37
- package/dest/test/index.d.ts +2 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +1 -0
- package/dest/test/rollup_cheat_codes.d.ts +56 -3
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +77 -6
- package/dest/test/start_anvil.d.ts +1 -1
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +41 -5
- package/dest/utils.d.ts +9 -2
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +48 -16
- package/package.json +6 -9
- package/src/client.ts +57 -1
- package/src/config.ts +83 -17
- package/src/contracts/chain_state_override.ts +200 -0
- package/src/contracts/empire_base.ts +0 -2
- package/src/contracts/fee_asset_price_oracle.ts +10 -5
- package/src/contracts/governance.ts +266 -9
- package/src/contracts/governance_proposer.ts +52 -5
- package/src/contracts/gse.ts +7 -2
- package/src/contracts/inbox.ts +13 -5
- package/src/contracts/index.ts +2 -2
- package/src/contracts/multicall.ts +247 -106
- package/src/contracts/outbox.ts +42 -8
- package/src/contracts/rollup.ts +379 -63
- package/src/contracts/{tally_slashing_proposer.ts → slashing_proposer.ts} +14 -16
- package/src/deploy_aztec_l1_contracts.ts +32 -18
- package/src/foundry_binary.ts +57 -0
- package/src/l1_artifacts.ts +12 -35
- package/src/l1_contract_addresses.ts +120 -94
- package/src/l1_reader.ts +4 -9
- package/src/l1_tx_utils/config.ts +3 -3
- package/src/l1_tx_utils/l1_fee_analyzer.ts +75 -3
- package/src/l1_tx_utils/l1_tx_utils.ts +122 -48
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +2 -1
- package/src/l1_tx_utils/tx_delayer.ts +16 -7
- package/src/l1_tx_utils/types.ts +32 -0
- package/src/publisher_manager.ts +143 -12
- package/src/queries.ts +76 -4
- package/src/test/blob_kzg_warmup.ts +65 -0
- package/src/test/chain_monitor.ts +93 -5
- package/src/test/eth_cheat_codes.ts +76 -41
- package/src/test/index.ts +1 -0
- package/src/test/rollup_cheat_codes.ts +104 -5
- package/src/test/start_anvil.ts +38 -6
- package/src/utils.ts +45 -18
- package/dest/contracts/empire_slashing_proposer.d.ts +0 -69
- package/dest/contracts/empire_slashing_proposer.d.ts.map +0 -1
- package/dest/contracts/empire_slashing_proposer.js +0 -216
- package/dest/contracts/tally_slashing_proposer.d.ts.map +0 -1
- package/dest/generated/l1-contracts-defaults.d.ts +0 -30
- package/dest/generated/l1-contracts-defaults.d.ts.map +0 -1
- package/dest/generated/l1-contracts-defaults.js +0 -30
- package/src/contracts/empire_slashing_proposer.ts +0 -265
- package/src/generated/l1-contracts-defaults.ts +0 -32
|
@@ -7,7 +7,7 @@ import { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
7
7
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
8
8
|
import { hexToBuffer } from '@aztec/foundation/string';
|
|
9
9
|
import { SlasherAbi } from '@aztec/l1-artifacts/SlasherAbi';
|
|
10
|
-
import {
|
|
10
|
+
import { SlashingProposerAbi } from '@aztec/l1-artifacts/SlashingProposerAbi';
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
13
|
type GetContractReturnType,
|
|
@@ -19,13 +19,11 @@ import {
|
|
|
19
19
|
} from 'viem';
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* Wrapper around the
|
|
22
|
+
* Wrapper around the SlashingProposer contract that provides
|
|
23
23
|
* a TypeScript interface for interacting with the consensus-based slashing system.
|
|
24
24
|
*/
|
|
25
|
-
export class
|
|
26
|
-
private readonly contract: GetContractReturnType<typeof
|
|
27
|
-
|
|
28
|
-
public readonly type = 'tally' as const;
|
|
25
|
+
export class SlashingProposerContract {
|
|
26
|
+
private readonly contract: GetContractReturnType<typeof SlashingProposerAbi, ViemClient>;
|
|
29
27
|
|
|
30
28
|
constructor(
|
|
31
29
|
public readonly client: ViemClient,
|
|
@@ -33,7 +31,7 @@ export class TallySlashingProposerContract {
|
|
|
33
31
|
) {
|
|
34
32
|
this.contract = getContract({
|
|
35
33
|
address: typeof address === 'string' ? address : address.toString(),
|
|
36
|
-
abi:
|
|
34
|
+
abi: SlashingProposerAbi,
|
|
37
35
|
client,
|
|
38
36
|
});
|
|
39
37
|
}
|
|
@@ -136,12 +134,12 @@ export class TallySlashingProposerContract {
|
|
|
136
134
|
|
|
137
135
|
/** Tries to extract a VoteCast event from the given logs. */
|
|
138
136
|
public tryExtractVoteCastEvent(logs: Log[]) {
|
|
139
|
-
return tryExtractEvent(logs, this.address.toString(),
|
|
137
|
+
return tryExtractEvent(logs, this.address.toString(), SlashingProposerAbi, 'VoteCast');
|
|
140
138
|
}
|
|
141
139
|
|
|
142
140
|
/** Tries to extract a RoundExecuted event from the given logs. */
|
|
143
141
|
public tryExtractRoundExecutedEvent(logs: Log[]) {
|
|
144
|
-
return tryExtractEvent(logs, this.address.toString(),
|
|
142
|
+
return tryExtractEvent(logs, this.address.toString(), SlashingProposerAbi, 'RoundExecuted');
|
|
145
143
|
}
|
|
146
144
|
|
|
147
145
|
/**
|
|
@@ -161,9 +159,9 @@ export class TallySlashingProposerContract {
|
|
|
161
159
|
|
|
162
160
|
return {
|
|
163
161
|
to: this.contract.address,
|
|
164
|
-
abi:
|
|
162
|
+
abi: SlashingProposerAbi,
|
|
165
163
|
data: encodeFunctionData({
|
|
166
|
-
abi:
|
|
164
|
+
abi: SlashingProposerAbi,
|
|
167
165
|
functionName: 'vote',
|
|
168
166
|
args: [votes, signature.toViemSignature()],
|
|
169
167
|
}),
|
|
@@ -173,7 +171,7 @@ export class TallySlashingProposerContract {
|
|
|
173
171
|
/** Returns the typed data definition to EIP712-sign for voting */
|
|
174
172
|
public buildVoteTypedData(votes: Hex, slot: SlotNumber): TypedDataDefinition {
|
|
175
173
|
const domain = {
|
|
176
|
-
name: '
|
|
174
|
+
name: 'SlashingProposer',
|
|
177
175
|
version: '1',
|
|
178
176
|
chainId: this.client.chain.id,
|
|
179
177
|
verifyingContract: this.contract.address,
|
|
@@ -209,9 +207,9 @@ export class TallySlashingProposerContract {
|
|
|
209
207
|
public buildVoteRequestWithSignature(votes: Hex, signature: { v: number; r: Hex; s: Hex }): L1TxRequest {
|
|
210
208
|
return {
|
|
211
209
|
to: this.contract.address,
|
|
212
|
-
abi:
|
|
210
|
+
abi: SlashingProposerAbi,
|
|
213
211
|
data: encodeFunctionData({
|
|
214
|
-
abi:
|
|
212
|
+
abi: SlashingProposerAbi,
|
|
215
213
|
functionName: 'vote',
|
|
216
214
|
args: [votes, signature],
|
|
217
215
|
}),
|
|
@@ -227,9 +225,9 @@ export class TallySlashingProposerContract {
|
|
|
227
225
|
public buildExecuteRoundRequest(round: bigint, committees: EthAddress[][]): L1TxRequest {
|
|
228
226
|
return {
|
|
229
227
|
to: this.contract.address,
|
|
230
|
-
abi: mergeAbis([
|
|
228
|
+
abi: mergeAbis([SlashingProposerAbi, SlasherAbi]),
|
|
231
229
|
data: encodeFunctionData({
|
|
232
|
-
abi:
|
|
230
|
+
abi: SlashingProposerAbi,
|
|
233
231
|
functionName: 'executeRound',
|
|
234
232
|
args: [round, committees.map(c => c.map(addr => addr.toString()))],
|
|
235
233
|
}),
|
|
@@ -5,12 +5,12 @@ import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
|
5
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
6
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
7
7
|
import type { Fr } from '@aztec/foundation/schemas';
|
|
8
|
-
import { fileURLToPath } from '@aztec/foundation/url';
|
|
9
8
|
|
|
10
9
|
import { bn254 } from '@noble/curves/bn254';
|
|
11
10
|
import type { Abi, Narrow } from 'abitype';
|
|
12
11
|
import { spawn } from 'child_process';
|
|
13
12
|
import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'fs';
|
|
13
|
+
import { createRequire } from 'node:module';
|
|
14
14
|
import { tmpdir } from 'os';
|
|
15
15
|
import { dirname, join, resolve } from 'path';
|
|
16
16
|
import readline from 'readline';
|
|
@@ -19,14 +19,17 @@ import { mainnet, sepolia } from 'viem/chains';
|
|
|
19
19
|
|
|
20
20
|
import { createEthereumChain, isAnvilTestChain } from './chain.js';
|
|
21
21
|
import { createExtendedL1Client } from './client.js';
|
|
22
|
-
import type
|
|
22
|
+
import { type L1ContractsConfig, assertValidSlotDurations } from './config.js';
|
|
23
23
|
import { deployMulticall3 } from './contracts/multicall.js';
|
|
24
24
|
import { RollupContract } from './contracts/rollup.js';
|
|
25
|
+
import { resolveFoundryBinary } from './foundry_binary.js';
|
|
25
26
|
import type { L1ContractAddresses } from './l1_contract_addresses.js';
|
|
26
27
|
import type { ExtendedViemWalletClient } from './types.js';
|
|
27
28
|
|
|
28
29
|
const logger = createLogger('ethereum:deploy_aztec_l1_contracts');
|
|
29
30
|
|
|
31
|
+
const require = createRequire(import.meta.url);
|
|
32
|
+
|
|
30
33
|
const JSON_DEPLOY_RESULT_PREFIX = 'JSON DEPLOY RESULT:';
|
|
31
34
|
|
|
32
35
|
/**
|
|
@@ -93,11 +96,16 @@ function runProcess<T>(
|
|
|
93
96
|
|
|
94
97
|
// Covers an edge where where we may have a cached BlobLib that is not meant for production.
|
|
95
98
|
// Despite the profile apparently sometimes cached code remains (so says Lasse after his ignition-monorepo arc).
|
|
96
|
-
async function maybeForgeForceProductionBuild(
|
|
99
|
+
async function maybeForgeForceProductionBuild(
|
|
100
|
+
forgeBin: string,
|
|
101
|
+
l1ContractsPath: string,
|
|
102
|
+
script: string,
|
|
103
|
+
chainId: number,
|
|
104
|
+
) {
|
|
97
105
|
if (chainId === mainnet.id) {
|
|
98
106
|
logger.info(`Recompiling ${script} with production profile for mainnet deployment`);
|
|
99
107
|
logger.info('This may take a minute but ensures production BlobLib is used.');
|
|
100
|
-
await runProcess(
|
|
108
|
+
await runProcess(forgeBin, ['build', script, '--force'], { FOUNDRY_PROFILE: 'production' }, l1ContractsPath);
|
|
101
109
|
}
|
|
102
110
|
}
|
|
103
111
|
|
|
@@ -123,15 +131,13 @@ export interface ValidatorJson {
|
|
|
123
131
|
}
|
|
124
132
|
|
|
125
133
|
/**
|
|
126
|
-
* Gets the path to the l1-contracts foundry artifacts directory.
|
|
127
|
-
*
|
|
128
|
-
*
|
|
134
|
+
* Gets the path to the l1-contracts foundry artifacts directory bundled inside @aztec/l1-artifacts.
|
|
135
|
+
* Resolved through the package (its "." export -> dest/index.js) so it works whether the package is
|
|
136
|
+
* linked via portal (monorepo) or installed under node_modules (published npm) — resolution follows
|
|
137
|
+
* the symlink in the portal case. The bundled foundry subtree sits alongside dest/, at <pkg>/l1-contracts.
|
|
129
138
|
*/
|
|
130
139
|
export function getL1ContractsPath(): string {
|
|
131
|
-
|
|
132
|
-
// Go up from yarn-project/ethereum/dest to yarn-project, then to l1-artifacts/l1-contracts
|
|
133
|
-
const l1ContractsPath = resolve(currentDir, '..', '..', 'l1-artifacts', 'l1-contracts');
|
|
134
|
-
return l1ContractsPath;
|
|
140
|
+
return resolve(dirname(require.resolve('@aztec/l1-artifacts')), '..', 'l1-contracts');
|
|
135
141
|
}
|
|
136
142
|
|
|
137
143
|
// Cached deployment directory
|
|
@@ -230,7 +236,6 @@ export function computeValidatorData(operator: Operator): ValidatorJson {
|
|
|
230
236
|
export interface RollupUpgradeAddresses {
|
|
231
237
|
rollupAddress: string;
|
|
232
238
|
verifierAddress: string;
|
|
233
|
-
slashFactoryAddress: string;
|
|
234
239
|
inboxAddress: string;
|
|
235
240
|
outboxAddress: string;
|
|
236
241
|
feeJuicePortalAddress: string;
|
|
@@ -243,7 +248,6 @@ export interface RollupUpgradeAddresses {
|
|
|
243
248
|
export interface ForgeRollupUpgradeResult {
|
|
244
249
|
rollupAddress: Hex;
|
|
245
250
|
verifierAddress: Hex;
|
|
246
|
-
slashFactoryAddress: Hex;
|
|
247
251
|
inboxAddress: Hex;
|
|
248
252
|
outboxAddress: Hex;
|
|
249
253
|
feeJuicePortalAddress: Hex;
|
|
@@ -284,6 +288,7 @@ export async function deployAztecL1Contracts(
|
|
|
284
288
|
args: DeployAztecL1ContractsArgs,
|
|
285
289
|
): Promise<DeployAztecL1ContractsReturnType> {
|
|
286
290
|
logger.info(`Deploying L1 contracts with config: ${jsonStringify(args)}`);
|
|
291
|
+
assertValidSlotDurations(args);
|
|
287
292
|
if (args.initialValidators && args.initialValidators.length > 0 && args.existingTokenAddress) {
|
|
288
293
|
throw new Error(
|
|
289
294
|
'Cannot deploy with both initialValidators and existingTokenAddress. ' +
|
|
@@ -321,8 +326,9 @@ export async function deployAztecL1Contracts(
|
|
|
321
326
|
// Use foundry-artifacts from l1-artifacts package
|
|
322
327
|
const l1ContractsPath = prepareL1ContractsForDeployment();
|
|
323
328
|
|
|
329
|
+
const forgeBin = resolveFoundryBinary('forge');
|
|
324
330
|
const FORGE_SCRIPT = 'script/deploy/DeployAztecL1Contracts.s.sol';
|
|
325
|
-
await maybeForgeForceProductionBuild(l1ContractsPath, FORGE_SCRIPT, chainId);
|
|
331
|
+
await maybeForgeForceProductionBuild(forgeBin, l1ContractsPath, FORGE_SCRIPT, chainId);
|
|
326
332
|
|
|
327
333
|
// Verify contracts on Etherscan when on mainnet/sepolia and ETHERSCAN_API_KEY is available.
|
|
328
334
|
const isVerifiableChain = chainId === mainnet.id || chainId === sepolia.id;
|
|
@@ -347,6 +353,8 @@ export async function deployAztecL1Contracts(
|
|
|
347
353
|
...(shouldVerify ? ['--verify'] : []),
|
|
348
354
|
];
|
|
349
355
|
const forgeEnv = {
|
|
356
|
+
// Resolved forge binary picked up by forge_broadcast.js, so it works without forge on PATH.
|
|
357
|
+
FORGE_BIN: forgeBin,
|
|
350
358
|
// Env vars required by l1-contracts/script/deploy/DeploymentConfiguration.sol.
|
|
351
359
|
NETWORK: getActiveNetworkName(),
|
|
352
360
|
FOUNDRY_PROFILE: chainId === mainnet.id ? 'production' : undefined,
|
|
@@ -403,7 +411,6 @@ export async function deployAztecL1Contracts(
|
|
|
403
411
|
governanceProposerAddress: EthAddress.fromString(result.governanceProposerAddress),
|
|
404
412
|
governanceAddress: EthAddress.fromString(result.governanceAddress),
|
|
405
413
|
stakingAssetAddress: EthAddress.fromString(result.stakingAssetAddress),
|
|
406
|
-
slashFactoryAddress: result.slashFactoryAddress ? EthAddress.fromString(result.slashFactoryAddress) : undefined,
|
|
407
414
|
feeAssetHandlerAddress: result.feeAssetHandlerAddress
|
|
408
415
|
? EthAddress.fromString(result.feeAssetHandlerAddress)
|
|
409
416
|
: undefined,
|
|
@@ -585,13 +592,18 @@ export function getDeployRollupForUpgradeEnvVars(
|
|
|
585
592
|
AZTEC_EXIT_DELAY_SECONDS: args.exitDelaySeconds.toString(),
|
|
586
593
|
AZTEC_PROVING_COST_PER_MANA: args.provingCostPerMana.toString(),
|
|
587
594
|
AZTEC_INITIAL_ETH_PER_FEE_ASSET: args.initialEthPerFeeAsset.toString(),
|
|
588
|
-
|
|
595
|
+
AZTEC_SLASHER_ENABLED: args.slasherEnabled ? 'true' : 'false',
|
|
589
596
|
AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS: args.slashingRoundSizeInEpochs.toString(),
|
|
590
597
|
AZTEC_SLASHING_QUORUM: args.slashingQuorum?.toString(),
|
|
591
598
|
AZTEC_SLASHING_OFFSET_IN_ROUNDS: args.slashingOffsetInRounds.toString(),
|
|
592
599
|
AZTEC_SLASH_AMOUNT_SMALL: args.slashAmountSmall.toString(),
|
|
593
600
|
AZTEC_SLASH_AMOUNT_MEDIUM: args.slashAmountMedium.toString(),
|
|
594
601
|
AZTEC_SLASH_AMOUNT_LARGE: args.slashAmountLarge.toString(),
|
|
602
|
+
AZTEC_ENTRY_QUEUE_BOOTSTRAP_VALIDATOR_SET_SIZE: args.entryQueueBootstrapValidatorSetSize.toString(),
|
|
603
|
+
AZTEC_ENTRY_QUEUE_BOOTSTRAP_FLUSH_SIZE: args.entryQueueBootstrapFlushSize.toString(),
|
|
604
|
+
AZTEC_ENTRY_QUEUE_FLUSH_SIZE_MIN: args.entryQueueFlushSizeMin.toString(),
|
|
605
|
+
AZTEC_ENTRY_QUEUE_FLUSH_SIZE_QUOTIENT: args.entryQueueFlushSizeQuotient.toString(),
|
|
606
|
+
AZTEC_ENTRY_QUEUE_MAX_FLUSH_SIZE: args.entryQueueMaxFlushSize.toString(),
|
|
595
607
|
} as const;
|
|
596
608
|
}
|
|
597
609
|
|
|
@@ -615,12 +627,15 @@ export const deployRollupForUpgrade = async (
|
|
|
615
627
|
// Use foundry-artifacts from l1-artifacts package
|
|
616
628
|
const l1ContractsPath = prepareL1ContractsForDeployment();
|
|
617
629
|
|
|
630
|
+
const forgeBin = resolveFoundryBinary('forge');
|
|
618
631
|
const FORGE_SCRIPT = 'script/deploy/DeployRollupForUpgrade.s.sol';
|
|
619
|
-
await maybeForgeForceProductionBuild(l1ContractsPath, FORGE_SCRIPT, chainId);
|
|
632
|
+
await maybeForgeForceProductionBuild(forgeBin, l1ContractsPath, FORGE_SCRIPT, chainId);
|
|
620
633
|
|
|
621
634
|
const scriptPath = join(getL1ContractsPath(), 'scripts', 'forge_broadcast.js');
|
|
622
635
|
const forgeArgs = [FORGE_SCRIPT, '--sig', 'run()', '--private-key', privateKey, '--rpc-url', rpcUrl];
|
|
623
636
|
const forgeEnv = {
|
|
637
|
+
// Resolved forge binary picked up by forge_broadcast.js, so it works without forge on PATH.
|
|
638
|
+
FORGE_BIN: forgeBin,
|
|
624
639
|
FOUNDRY_PROFILE: chainId === mainnet.id ? 'production' : undefined,
|
|
625
640
|
// Env vars required by l1-contracts/script/deploy/RollupConfiguration.sol.
|
|
626
641
|
REGISTRY_ADDRESS: registryAddress.toString(),
|
|
@@ -645,6 +660,5 @@ export const deployRollupForUpgrade = async (
|
|
|
645
660
|
|
|
646
661
|
return {
|
|
647
662
|
rollup,
|
|
648
|
-
slashFactoryAddress: result.slashFactoryAddress,
|
|
649
663
|
};
|
|
650
664
|
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { spawnSync } from 'child_process';
|
|
2
|
+
import { accessSync, constants } from 'fs';
|
|
3
|
+
import { homedir } from 'os';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
|
|
6
|
+
function isExecutable(path: string): boolean {
|
|
7
|
+
try {
|
|
8
|
+
accessSync(path, constants.X_OK);
|
|
9
|
+
return true;
|
|
10
|
+
} catch {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Locate a Foundry binary (`anvil`, `forge`, ...) without relying on the caller's PATH. Order:
|
|
17
|
+
* 1. `$<NAME>_BIN` (e.g. `$ANVIL_BIN`, `$FORGE_BIN`) — explicit override, e.g. for CI with a pinned
|
|
18
|
+
* version. Throws if set but not pointing at an executable, instead of silently falling back.
|
|
19
|
+
* 2. `~/.aztec/current/internal-bin/<name>` — where aztec-up installs it.
|
|
20
|
+
* 3. `~/.aztec/current/bin/aztec-<name>` — the publicly-exposed symlink.
|
|
21
|
+
* 4. `~/.foundry/bin/<name>` — standalone foundryup install.
|
|
22
|
+
* 5. `command -v <name>` — anything else on PATH.
|
|
23
|
+
*
|
|
24
|
+
* Throws with a directive message if none work.
|
|
25
|
+
*/
|
|
26
|
+
export function resolveFoundryBinary(name: string): string {
|
|
27
|
+
const envVar = `${name.toUpperCase()}_BIN`;
|
|
28
|
+
const envBin = process.env[envVar];
|
|
29
|
+
if (envBin) {
|
|
30
|
+
if (!isExecutable(envBin)) {
|
|
31
|
+
throw new Error(`$${envVar} is set to ${envBin}, which does not exist or is not executable.`);
|
|
32
|
+
}
|
|
33
|
+
return envBin;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const candidates = [
|
|
37
|
+
join(homedir(), '.aztec', 'current', 'internal-bin', name),
|
|
38
|
+
join(homedir(), '.aztec', 'current', 'bin', `aztec-${name}`),
|
|
39
|
+
join(homedir(), '.foundry', 'bin', name),
|
|
40
|
+
];
|
|
41
|
+
for (const path of candidates) {
|
|
42
|
+
if (isExecutable(path)) {
|
|
43
|
+
return path;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const which = spawnSync('sh', ['-c', `command -v ${name}`], { encoding: 'utf8' });
|
|
48
|
+
if (which.status === 0 && which.stdout.trim()) {
|
|
49
|
+
return which.stdout.trim();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
throw new Error(
|
|
53
|
+
`${name} binary not found. Tried $${envVar}, ~/.aztec/current/internal-bin/${name}, ` +
|
|
54
|
+
`~/.aztec/current/bin/aztec-${name}, ~/.foundry/bin/${name}, and $PATH. ` +
|
|
55
|
+
`Install via \`aztec-up\` or set ${envVar} to a working binary.`,
|
|
56
|
+
);
|
|
57
|
+
}
|
package/src/l1_artifacts.ts
CHANGED
|
@@ -3,10 +3,6 @@ import {
|
|
|
3
3
|
CoinIssuerBytecode,
|
|
4
4
|
DateGatedRelayerAbi,
|
|
5
5
|
DateGatedRelayerBytecode,
|
|
6
|
-
EmpireSlasherDeploymentExtLibAbi,
|
|
7
|
-
EmpireSlasherDeploymentExtLibBytecode,
|
|
8
|
-
EmpireSlashingProposerAbi,
|
|
9
|
-
EmpireSlashingProposerBytecode,
|
|
10
6
|
FeeAssetHandlerAbi,
|
|
11
7
|
FeeAssetHandlerBytecode,
|
|
12
8
|
FeeJuicePortalAbi,
|
|
@@ -42,16 +38,14 @@ import {
|
|
|
42
38
|
RollupLinkReferences,
|
|
43
39
|
RollupOperationsExtLibAbi,
|
|
44
40
|
RollupOperationsExtLibBytecode,
|
|
45
|
-
SlashFactoryAbi,
|
|
46
|
-
SlashFactoryBytecode,
|
|
47
41
|
SlasherAbi,
|
|
48
42
|
SlasherBytecode,
|
|
43
|
+
SlasherDeploymentExtLibAbi,
|
|
44
|
+
SlasherDeploymentExtLibBytecode,
|
|
45
|
+
SlashingProposerAbi,
|
|
46
|
+
SlashingProposerBytecode,
|
|
49
47
|
StakingAssetHandlerAbi,
|
|
50
48
|
StakingAssetHandlerBytecode,
|
|
51
|
-
TallySlasherDeploymentExtLibAbi,
|
|
52
|
-
TallySlasherDeploymentExtLibBytecode,
|
|
53
|
-
TallySlashingProposerAbi,
|
|
54
|
-
TallySlashingProposerBytecode,
|
|
55
49
|
TestERC20Abi,
|
|
56
50
|
TestERC20Bytecode,
|
|
57
51
|
ValidatorOperationsExtLibAbi,
|
|
@@ -107,15 +101,10 @@ export const RollupArtifact = {
|
|
|
107
101
|
contractAbi: RewardExtLibAbi,
|
|
108
102
|
contractBytecode: RewardExtLibBytecode as Hex,
|
|
109
103
|
},
|
|
110
|
-
|
|
111
|
-
name: '
|
|
112
|
-
contractAbi:
|
|
113
|
-
contractBytecode:
|
|
114
|
-
},
|
|
115
|
-
EmpireSlasherDeploymentExtLib: {
|
|
116
|
-
name: 'EmpireSlasherDeploymentExtLib',
|
|
117
|
-
contractAbi: EmpireSlasherDeploymentExtLibAbi,
|
|
118
|
-
contractBytecode: EmpireSlasherDeploymentExtLibBytecode as Hex,
|
|
104
|
+
SlasherDeploymentExtLib: {
|
|
105
|
+
name: 'SlasherDeploymentExtLib',
|
|
106
|
+
contractAbi: SlasherDeploymentExtLibAbi,
|
|
107
|
+
contractBytecode: SlasherDeploymentExtLibBytecode as Hex,
|
|
119
108
|
},
|
|
120
109
|
},
|
|
121
110
|
},
|
|
@@ -175,22 +164,10 @@ export const SlasherArtifact = {
|
|
|
175
164
|
contractBytecode: SlasherBytecode as Hex,
|
|
176
165
|
};
|
|
177
166
|
|
|
178
|
-
export const
|
|
179
|
-
name: '
|
|
180
|
-
contractAbi:
|
|
181
|
-
contractBytecode:
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
export const TallySlashingProposerArtifact = {
|
|
185
|
-
name: 'TallySlashingProposer',
|
|
186
|
-
contractAbi: TallySlashingProposerAbi,
|
|
187
|
-
contractBytecode: TallySlashingProposerBytecode as Hex,
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
export const SlashFactoryArtifact = {
|
|
191
|
-
name: 'SlashFactory',
|
|
192
|
-
contractAbi: SlashFactoryAbi,
|
|
193
|
-
contractBytecode: SlashFactoryBytecode as Hex,
|
|
167
|
+
export const SlashingProposerArtifact = {
|
|
168
|
+
name: 'SlashingProposer',
|
|
169
|
+
contractAbi: SlashingProposerAbi,
|
|
170
|
+
contractBytecode: SlashingProposerBytecode as Hex,
|
|
194
171
|
};
|
|
195
172
|
|
|
196
173
|
export const RegisterNewRollupVersionPayloadArtifact = {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { ConfigMappingsType } from '@aztec/foundation/config';
|
|
1
|
+
import type { ConfigMapping, ConfigMappingsType } from '@aztec/foundation/config';
|
|
2
2
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
-
import { schemas
|
|
3
|
+
import { schemas } from '@aztec/foundation/schemas';
|
|
4
4
|
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Required L1 contract address keys.
|
|
9
9
|
* NOTE: When changing this list, make sure to update CLI & CI scripts accordingly.
|
|
10
10
|
* For reference: https://github.com/AztecProtocol/aztec-packages/pull/5553
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
const REQUIRED_L1_CONTRACT_ADDRESS_KEYS = [
|
|
13
13
|
'rollupAddress',
|
|
14
14
|
'registryAddress',
|
|
15
15
|
'inboxAddress',
|
|
@@ -23,102 +23,128 @@ export const L1ContractsNames = [
|
|
|
23
23
|
'stakingAssetAddress',
|
|
24
24
|
] as const;
|
|
25
25
|
|
|
26
|
+
/** Optional L1 contract address keys — present only in some deployments. */
|
|
27
|
+
export const OPTIONAL_L1_CONTRACT_ADDRESS_KEYS = [
|
|
28
|
+
'feeAssetHandlerAddress',
|
|
29
|
+
'stakingAssetHandlerAddress',
|
|
30
|
+
'zkPassportVerifierAddress',
|
|
31
|
+
'gseAddress',
|
|
32
|
+
'dateGatedRelayerAddress',
|
|
33
|
+
] as const;
|
|
34
|
+
|
|
35
|
+
type RequiredContractKey = (typeof REQUIRED_L1_CONTRACT_ADDRESS_KEYS)[number];
|
|
36
|
+
type OptionalContractKey = (typeof OPTIONAL_L1_CONTRACT_ADDRESS_KEYS)[number];
|
|
37
|
+
|
|
26
38
|
/** Provides the directory of current L1 contract addresses */
|
|
27
39
|
export type L1ContractAddresses = {
|
|
28
|
-
[K in
|
|
40
|
+
[K in RequiredContractKey]: EthAddress;
|
|
29
41
|
} & {
|
|
30
|
-
|
|
31
|
-
feeAssetHandlerAddress?: EthAddress | undefined;
|
|
32
|
-
stakingAssetHandlerAddress?: EthAddress | undefined;
|
|
33
|
-
zkPassportVerifierAddress?: EthAddress | undefined;
|
|
34
|
-
gseAddress?: EthAddress | undefined;
|
|
35
|
-
dateGatedRelayerAddress?: EthAddress | undefined;
|
|
42
|
+
[K in OptionalContractKey]?: EthAddress;
|
|
36
43
|
};
|
|
37
44
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
feeJuiceAddress: schemas.EthAddress,
|
|
45
|
-
stakingAssetAddress: schemas.EthAddress,
|
|
46
|
-
feeJuicePortalAddress: schemas.EthAddress,
|
|
47
|
-
coinIssuerAddress: schemas.EthAddress,
|
|
48
|
-
rewardDistributorAddress: schemas.EthAddress,
|
|
49
|
-
governanceProposerAddress: schemas.EthAddress,
|
|
50
|
-
governanceAddress: schemas.EthAddress,
|
|
51
|
-
slashFactoryAddress: schemas.EthAddress.optional(),
|
|
52
|
-
feeAssetHandlerAddress: schemas.EthAddress.optional(),
|
|
53
|
-
stakingAssetHandlerAddress: schemas.EthAddress.optional(),
|
|
54
|
-
zkPassportVerifierAddress: schemas.EthAddress.optional(),
|
|
55
|
-
gseAddress: schemas.EthAddress.optional(),
|
|
56
|
-
dateGatedRelayerAddress: schemas.EthAddress.optional(),
|
|
57
|
-
}),
|
|
58
|
-
);
|
|
45
|
+
/**
|
|
46
|
+
* Names of required L1 contract addresses.
|
|
47
|
+
* NOTE: When changing the set of contracts, update CLI & CI scripts accordingly.
|
|
48
|
+
* For reference: https://github.com/AztecProtocol/aztec-packages/pull/5553
|
|
49
|
+
*/
|
|
50
|
+
export const L1ContractsNames = REQUIRED_L1_CONTRACT_ADDRESS_KEYS;
|
|
59
51
|
|
|
60
52
|
const parseEnv = (val: string) => EthAddress.fromString(val);
|
|
53
|
+
const addrEnv = (description: string, env?: ConfigMapping<EthAddress>['env']): ConfigMapping<EthAddress> => ({
|
|
54
|
+
description,
|
|
55
|
+
parseEnv,
|
|
56
|
+
...(env && { env }),
|
|
57
|
+
});
|
|
61
58
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
parseEnv,
|
|
87
|
-
},
|
|
88
|
-
outboxAddress: {
|
|
89
|
-
description: 'The deployed L1 outbox contract address.',
|
|
90
|
-
parseEnv,
|
|
91
|
-
},
|
|
92
|
-
feeJuiceAddress: {
|
|
93
|
-
description: 'The deployed L1 Fee Juice contract address.',
|
|
94
|
-
parseEnv,
|
|
95
|
-
},
|
|
96
|
-
stakingAssetAddress: {
|
|
97
|
-
description: 'The deployed L1 staking asset contract address.',
|
|
98
|
-
parseEnv,
|
|
99
|
-
},
|
|
100
|
-
feeJuicePortalAddress: {
|
|
101
|
-
description: 'The deployed L1 Fee Juice portal contract address.',
|
|
102
|
-
parseEnv,
|
|
103
|
-
},
|
|
104
|
-
coinIssuerAddress: {
|
|
105
|
-
description: 'The deployed L1 coinIssuer contract address',
|
|
106
|
-
parseEnv,
|
|
107
|
-
},
|
|
108
|
-
rewardDistributorAddress: {
|
|
109
|
-
description: 'The deployed L1 rewardDistributor contract address',
|
|
110
|
-
parseEnv,
|
|
111
|
-
},
|
|
112
|
-
governanceProposerAddress: {
|
|
113
|
-
description: 'The deployed L1 governanceProposer contract address',
|
|
114
|
-
parseEnv,
|
|
115
|
-
},
|
|
116
|
-
governanceAddress: {
|
|
117
|
-
description: 'The deployed L1 governance contract address',
|
|
118
|
-
parseEnv,
|
|
119
|
-
},
|
|
120
|
-
stakingAssetHandlerAddress: {
|
|
121
|
-
description: 'The deployed L1 stakingAssetHandler contract address',
|
|
122
|
-
parseEnv,
|
|
123
|
-
},
|
|
59
|
+
/**
|
|
60
|
+
* Config mapping for all L1 contract addresses.
|
|
61
|
+
* This is the single source of truth for which contract addresses exist and how to parse them.
|
|
62
|
+
*/
|
|
63
|
+
export const l1ContractAddressesMapping: ConfigMappingsType<L1ContractAddresses> = {
|
|
64
|
+
rollupAddress: addrEnv('The deployed L1 rollup contract address.'),
|
|
65
|
+
registryAddress: addrEnv('The deployed L1 registry contract address.', 'REGISTRY_CONTRACT_ADDRESS'),
|
|
66
|
+
inboxAddress: addrEnv('The deployed L1 inbox contract address.'),
|
|
67
|
+
outboxAddress: addrEnv('The deployed L1 outbox contract address.'),
|
|
68
|
+
feeJuiceAddress: addrEnv('The deployed L1 Fee Juice contract address.'),
|
|
69
|
+
feeJuicePortalAddress: addrEnv('The deployed L1 Fee Juice portal contract address.'),
|
|
70
|
+
coinIssuerAddress: addrEnv('The deployed L1 coinIssuer contract address'),
|
|
71
|
+
rewardDistributorAddress: addrEnv('The deployed L1 rewardDistributor contract address'),
|
|
72
|
+
governanceProposerAddress: addrEnv('The deployed L1 governanceProposer contract address'),
|
|
73
|
+
governanceAddress: addrEnv('The deployed L1 governance contract address'),
|
|
74
|
+
stakingAssetAddress: addrEnv('The deployed L1 staking asset contract address.'),
|
|
75
|
+
feeAssetHandlerAddress: addrEnv(
|
|
76
|
+
'The deployed L1 feeAssetHandler contract address',
|
|
77
|
+
'FEE_ASSET_HANDLER_CONTRACT_ADDRESS',
|
|
78
|
+
),
|
|
79
|
+
stakingAssetHandlerAddress: addrEnv('The deployed L1 stakingAssetHandler contract address'),
|
|
80
|
+
zkPassportVerifierAddress: addrEnv('The deployed L1 ZK passport verifier contract address'),
|
|
81
|
+
gseAddress: addrEnv('The deployed L1 GSE contract address'),
|
|
82
|
+
dateGatedRelayerAddress: addrEnv('The deployed L1 date-gated relayer contract address'),
|
|
124
83
|
};
|
|
84
|
+
|
|
85
|
+
/** Keys present in {@link l1ContractAddressesMapping}. */
|
|
86
|
+
export type L1ContractAddressMappingKey = keyof typeof l1ContractAddressesMapping;
|
|
87
|
+
|
|
88
|
+
type RequiredAddressShape = { [K in RequiredContractKey]: typeof schemas.EthAddress };
|
|
89
|
+
type OptionalAddressShape = { [K in OptionalContractKey]: ReturnType<typeof schemas.EthAddress.optional> };
|
|
90
|
+
|
|
91
|
+
export const L1ContractAddressesSchema = z.object({
|
|
92
|
+
...(Object.fromEntries(REQUIRED_L1_CONTRACT_ADDRESS_KEYS.map(k => [k, schemas.EthAddress])) as RequiredAddressShape),
|
|
93
|
+
...(Object.fromEntries(
|
|
94
|
+
OPTIONAL_L1_CONTRACT_ADDRESS_KEYS.map(k => [k, schemas.EthAddress.optional()]),
|
|
95
|
+
) as OptionalAddressShape),
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Selects entries from {@link l1ContractAddressesMapping} so composed configs can reuse the same
|
|
100
|
+
* env vars, descriptions, and parsers without duplicating definitions.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* const mappings = {
|
|
105
|
+
* ...pickL1ContractAddressMappings('rollupAddress'),
|
|
106
|
+
* nodeId: { ... },
|
|
107
|
+
* };
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export function pickL1ContractAddressMappings<const K extends readonly L1ContractAddressMappingKey[]>(
|
|
111
|
+
...keys: K
|
|
112
|
+
): Pick<typeof l1ContractAddressesMapping, K[number]> {
|
|
113
|
+
return Object.fromEntries(keys.map(key => [key, l1ContractAddressesMapping[key]] as const)) as Pick<
|
|
114
|
+
typeof l1ContractAddressesMapping,
|
|
115
|
+
K[number]
|
|
116
|
+
>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Like {@link pickL1ContractAddressMappings}, but returns a fragment of {@link L1ContractAddressesSchema}'s shape for
|
|
121
|
+
* spreading into `z.object({ ...pickL1ContractAddressesSchemaShape('rollupAddress'), localField: z... })`.
|
|
122
|
+
*/
|
|
123
|
+
export function pickL1ContractAddressesSchema<const K extends readonly L1ContractAddressMappingKey[]>(
|
|
124
|
+
...keys: K
|
|
125
|
+
): Pick<typeof L1ContractAddressesSchema.shape, K[number]> {
|
|
126
|
+
return Object.fromEntries(keys.map(key => [key, L1ContractAddressesSchema.shape[key]])) as Pick<
|
|
127
|
+
typeof L1ContractAddressesSchema.shape,
|
|
128
|
+
K[number]
|
|
129
|
+
>;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Builds an {@link L1ContractAddresses} object from config that stores those fields at the top level. */
|
|
133
|
+
export function pickL1ContractAddresses<T extends L1ContractAddresses>(config: T): L1ContractAddresses {
|
|
134
|
+
const result: Partial<L1ContractAddresses> = {};
|
|
135
|
+
for (const key of REQUIRED_L1_CONTRACT_ADDRESS_KEYS) {
|
|
136
|
+
result[key] = config[key];
|
|
137
|
+
}
|
|
138
|
+
for (const key of OPTIONAL_L1_CONTRACT_ADDRESS_KEYS) {
|
|
139
|
+
const v = config[key];
|
|
140
|
+
if (v !== undefined) {
|
|
141
|
+
result[key] = v;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return result as L1ContractAddresses;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function randomL1ContractAddresses(includeOptional: boolean = false): L1ContractAddresses {
|
|
148
|
+
const keys = includeOptional ? [...L1ContractsNames, ...OPTIONAL_L1_CONTRACT_ADDRESS_KEYS] : L1ContractsNames;
|
|
149
|
+
return Object.fromEntries(keys.map(name => [name, EthAddress.random()])) as L1ContractAddresses;
|
|
150
|
+
}
|
package/src/l1_reader.ts
CHANGED
|
@@ -8,29 +8,23 @@ import {
|
|
|
8
8
|
import { type L1ContractAddresses, l1ContractAddressesMapping } from './l1_contract_addresses.js';
|
|
9
9
|
|
|
10
10
|
/** Configuration of the L1GlobalReader. */
|
|
11
|
-
export
|
|
11
|
+
export type L1ReaderConfig = {
|
|
12
12
|
/** List of URLs of Ethereum RPC nodes that services will connect to (comma separated). */
|
|
13
13
|
l1RpcUrls: string[];
|
|
14
14
|
/** The RPC Url of the ethereum debug host for trace and debug methods. */
|
|
15
15
|
l1DebugRpcUrls: string[];
|
|
16
16
|
/** The chain ID of the ethereum host. */
|
|
17
17
|
l1ChainId: number;
|
|
18
|
-
/** The deployed l1 contract addresses */
|
|
19
|
-
l1Contracts: L1ContractAddresses;
|
|
20
18
|
/** The polling interval viem uses in ms */
|
|
21
19
|
viemPollingIntervalMS: number;
|
|
22
20
|
/** Timeout for HTTP requests to the L1 RPC node in ms. */
|
|
23
21
|
l1HttpTimeoutMS?: number;
|
|
24
|
-
}
|
|
22
|
+
} & L1ContractAddresses;
|
|
25
23
|
|
|
26
24
|
export const l1ReaderConfigMappings: ConfigMappingsType<L1ReaderConfig> = {
|
|
27
|
-
l1Contracts: {
|
|
28
|
-
description: 'The deployed L1 contract addresses',
|
|
29
|
-
nested: l1ContractAddressesMapping,
|
|
30
|
-
},
|
|
31
25
|
l1ChainId: {
|
|
32
26
|
env: 'L1_CHAIN_ID',
|
|
33
|
-
|
|
27
|
+
...optionalNumberConfigHelper(),
|
|
34
28
|
description: 'The chain ID of the ethereum host.',
|
|
35
29
|
},
|
|
36
30
|
l1RpcUrls: {
|
|
@@ -55,6 +49,7 @@ export const l1ReaderConfigMappings: ConfigMappingsType<L1ReaderConfig> = {
|
|
|
55
49
|
description: 'Timeout for HTTP requests to the L1 RPC node in ms.',
|
|
56
50
|
...optionalNumberConfigHelper(),
|
|
57
51
|
},
|
|
52
|
+
...l1ContractAddressesMapping,
|
|
58
53
|
};
|
|
59
54
|
|
|
60
55
|
export function getL1ReaderConfigFromEnv(): L1ReaderConfig {
|