@aztec/ethereum 0.0.1-commit.1a99e26c → 0.0.1-commit.1bb068fb5
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/config.js +1 -1
- package/dest/contracts/empire_slashing_proposer.d.ts +1 -1
- package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/empire_slashing_proposer.js +13 -15
- package/dest/contracts/fee_asset_handler.d.ts +1 -1
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
- package/dest/contracts/fee_asset_handler.js +2 -0
- package/dest/contracts/fee_asset_price_oracle.d.ts +101 -0
- package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
- package/dest/contracts/fee_asset_price_oracle.js +651 -0
- package/dest/contracts/governance.d.ts +1 -1
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +2 -0
- package/dest/contracts/governance_proposer.d.ts +1 -1
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +4 -1
- package/dest/contracts/index.d.ts +2 -1
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +1 -0
- package/dest/contracts/multicall.d.ts +1 -1
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +2 -1
- package/dest/contracts/rollup.d.ts +2 -1
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +9 -3
- package/dest/contracts/tally_slashing_proposer.d.ts +1 -1
- package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/tally_slashing_proposer.js +8 -1
- package/dest/deploy_aztec_l1_contracts.d.ts +1 -1
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +37 -22
- package/dest/l1_artifacts.d.ts +722 -40
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_tx_utils/constants.d.ts +1 -1
- package/dest/l1_tx_utils/constants.js +2 -2
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +1 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +6 -6
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +3 -3
- package/dest/utils.d.ts +2 -1
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +46 -0
- package/package.json +5 -5
- package/src/config.ts +1 -1
- package/src/contracts/empire_slashing_proposer.ts +16 -27
- package/src/contracts/fee_asset_handler.ts +2 -0
- package/src/contracts/fee_asset_price_oracle.ts +280 -0
- package/src/contracts/governance.ts +2 -0
- package/src/contracts/governance_proposer.ts +4 -1
- package/src/contracts/index.ts +1 -0
- package/src/contracts/multicall.ts +5 -2
- package/src/contracts/rollup.ts +15 -7
- package/src/contracts/tally_slashing_proposer.ts +5 -1
- package/src/deploy_aztec_l1_contracts.ts +41 -27
- package/src/l1_tx_utils/constants.ts +2 -2
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +1 -1
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +1 -1
- package/src/l1_tx_utils/l1_tx_utils.ts +6 -6
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +3 -3
- package/src/utils.ts +53 -0
|
@@ -15,7 +15,7 @@ import { tmpdir } from 'os';
|
|
|
15
15
|
import { dirname, join, resolve } from 'path';
|
|
16
16
|
import readline from 'readline';
|
|
17
17
|
import type { Hex } from 'viem';
|
|
18
|
-
import {
|
|
18
|
+
import { mainnet, sepolia } from 'viem/chains';
|
|
19
19
|
|
|
20
20
|
import { createEthereumChain, isAnvilTestChain } from './chain.js';
|
|
21
21
|
import { createExtendedL1Client } from './client.js';
|
|
@@ -31,9 +31,9 @@ const logger = createLogger('ethereum:deploy_aztec_l1_contracts');
|
|
|
31
31
|
const JSON_DEPLOY_RESULT_PREFIX = 'JSON DEPLOY RESULT:';
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* Runs a process
|
|
35
|
-
*
|
|
36
|
-
*
|
|
34
|
+
* Runs a process and parses JSON deploy results from stdout.
|
|
35
|
+
* Lines starting with JSON_DEPLOY_RESULT_PREFIX are parsed and returned.
|
|
36
|
+
* All other stdout goes to logger.info, stderr goes to logger.warn.
|
|
37
37
|
*/
|
|
38
38
|
function runProcess<T>(
|
|
39
39
|
command: string,
|
|
@@ -49,26 +49,41 @@ function runProcess<T>(
|
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
let result: T | undefined;
|
|
52
|
+
let parseError: Error | undefined;
|
|
53
|
+
let settled = false;
|
|
52
54
|
|
|
53
55
|
readline.createInterface({ input: proc.stdout }).on('line', line => {
|
|
54
56
|
const trimmedLine = line.trim();
|
|
55
57
|
if (trimmedLine.startsWith(JSON_DEPLOY_RESULT_PREFIX)) {
|
|
56
58
|
const jsonStr = trimmedLine.slice(JSON_DEPLOY_RESULT_PREFIX.length).trim();
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
try {
|
|
60
|
+
result = JSON.parse(jsonStr);
|
|
61
|
+
} catch {
|
|
62
|
+
parseError = new Error(`Failed to parse deploy result JSON: ${jsonStr.slice(0, 200)}`);
|
|
63
|
+
}
|
|
59
64
|
} else {
|
|
60
65
|
logger.info(line);
|
|
61
66
|
}
|
|
62
67
|
});
|
|
63
|
-
readline.createInterface({ input: proc.stderr }).on('line', logger.
|
|
68
|
+
readline.createInterface({ input: proc.stderr }).on('line', logger.warn.bind(logger));
|
|
64
69
|
|
|
65
70
|
proc.on('error', error => {
|
|
71
|
+
if (settled) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
settled = true;
|
|
66
75
|
reject(new Error(`Failed to spawn ${command}: ${error.message}`));
|
|
67
76
|
});
|
|
68
77
|
|
|
69
78
|
proc.on('close', code => {
|
|
79
|
+
if (settled) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
settled = true;
|
|
70
83
|
if (code !== 0) {
|
|
71
|
-
reject(new Error(`${command} exited with code ${code}
|
|
84
|
+
reject(new Error(`${command} exited with code ${code}`));
|
|
85
|
+
} else if (parseError) {
|
|
86
|
+
reject(parseError);
|
|
72
87
|
} else {
|
|
73
88
|
resolve(result);
|
|
74
89
|
}
|
|
@@ -168,6 +183,9 @@ export function prepareL1ContractsForDeployment(): string {
|
|
|
168
183
|
const foundryTomlPath = join(basePath, 'foundry.toml');
|
|
169
184
|
let foundryToml = readFileSync(foundryTomlPath, 'utf-8');
|
|
170
185
|
const solcPathMatch = foundryToml.match(/solc\s*=\s*"\.\/solc-([^"]+)"/);
|
|
186
|
+
// Did we find a hardcoded solc path that we need to make absolute?
|
|
187
|
+
// This code path happens in CI currently as we bundle solc there to avoid race conditions when
|
|
188
|
+
// downloading solc.
|
|
171
189
|
if (solcPathMatch) {
|
|
172
190
|
const solcVersion = solcPathMatch[1];
|
|
173
191
|
const absoluteSolcPath = join(basePath, `solc-${solcVersion}`);
|
|
@@ -318,11 +336,8 @@ export async function deployAztecL1Contracts(
|
|
|
318
336
|
);
|
|
319
337
|
}
|
|
320
338
|
|
|
321
|
-
|
|
322
|
-
const MAGIC_ANVIL_BATCH_SIZE = 8;
|
|
323
|
-
// Anvil seems to stall with unbounded batch size. Otherwise no max batch size is desirable.
|
|
339
|
+
const scriptPath = join(getL1ContractsPath(), 'scripts', 'forge_broadcast.js');
|
|
324
340
|
const forgeArgs = [
|
|
325
|
-
'script',
|
|
326
341
|
FORGE_SCRIPT,
|
|
327
342
|
'--sig',
|
|
328
343
|
'run()',
|
|
@@ -330,8 +345,6 @@ export async function deployAztecL1Contracts(
|
|
|
330
345
|
privateKey,
|
|
331
346
|
'--rpc-url',
|
|
332
347
|
rpcUrl,
|
|
333
|
-
'--broadcast',
|
|
334
|
-
...(chainId === foundry.id ? ['--batch-size', MAGIC_ANVIL_BATCH_SIZE.toString()] : []),
|
|
335
348
|
...(shouldVerify ? ['--verify'] : []),
|
|
336
349
|
];
|
|
337
350
|
const forgeEnv = {
|
|
@@ -340,7 +353,12 @@ export async function deployAztecL1Contracts(
|
|
|
340
353
|
FOUNDRY_PROFILE: chainId === mainnet.id ? 'production' : undefined,
|
|
341
354
|
...getDeployAztecL1ContractsEnvVars(args),
|
|
342
355
|
};
|
|
343
|
-
const result = await runProcess<ForgeL1ContractsDeployResult>(
|
|
356
|
+
const result = await runProcess<ForgeL1ContractsDeployResult>(
|
|
357
|
+
process.execPath,
|
|
358
|
+
[scriptPath, ...forgeArgs],
|
|
359
|
+
forgeEnv,
|
|
360
|
+
l1ContractsPath,
|
|
361
|
+
);
|
|
344
362
|
if (!result) {
|
|
345
363
|
throw new Error('Forge script did not output deployment result');
|
|
346
364
|
}
|
|
@@ -583,17 +601,8 @@ export const deployRollupForUpgrade = async (
|
|
|
583
601
|
const FORGE_SCRIPT = 'script/deploy/DeployRollupForUpgrade.s.sol';
|
|
584
602
|
await maybeForgeForceProductionBuild(l1ContractsPath, FORGE_SCRIPT, chainId);
|
|
585
603
|
|
|
586
|
-
const
|
|
587
|
-
|
|
588
|
-
FORGE_SCRIPT,
|
|
589
|
-
'--sig',
|
|
590
|
-
'run()',
|
|
591
|
-
'--private-key',
|
|
592
|
-
privateKey,
|
|
593
|
-
'--rpc-url',
|
|
594
|
-
rpcUrl,
|
|
595
|
-
'--broadcast',
|
|
596
|
-
];
|
|
604
|
+
const scriptPath = join(getL1ContractsPath(), 'scripts', 'forge_broadcast.js');
|
|
605
|
+
const forgeArgs = [FORGE_SCRIPT, '--sig', 'run()', '--private-key', privateKey, '--rpc-url', rpcUrl];
|
|
597
606
|
const forgeEnv = {
|
|
598
607
|
FOUNDRY_PROFILE: chainId === mainnet.id ? 'production' : undefined,
|
|
599
608
|
// Env vars required by l1-contracts/script/deploy/RollupConfiguration.sol.
|
|
@@ -602,7 +611,12 @@ export const deployRollupForUpgrade = async (
|
|
|
602
611
|
...getDeployRollupForUpgradeEnvVars(args),
|
|
603
612
|
};
|
|
604
613
|
|
|
605
|
-
const result = await runProcess<ForgeRollupUpgradeResult>(
|
|
614
|
+
const result = await runProcess<ForgeRollupUpgradeResult>(
|
|
615
|
+
process.execPath,
|
|
616
|
+
[scriptPath, ...forgeArgs],
|
|
617
|
+
forgeEnv,
|
|
618
|
+
l1ContractsPath,
|
|
619
|
+
);
|
|
606
620
|
if (!result) {
|
|
607
621
|
throw new Error('Forge script did not output deployment result');
|
|
608
622
|
}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
// 1_000_000_000_000_000_000 Wei = 1 ETH
|
|
4
4
|
export const WEI_CONST = 1_000_000_000n;
|
|
5
5
|
|
|
6
|
-
//
|
|
7
|
-
export const
|
|
6
|
+
// EIP-7825: protocol-level cap on tx gas limit (2^24). Clients reject above this.
|
|
7
|
+
export const MAX_L1_TX_LIMIT = 16_777_216n;
|
|
8
8
|
|
|
9
9
|
// setting a minimum bump percentage to 10% due to geth's implementation
|
|
10
10
|
// https://github.com/ethereum/go-ethereum/blob/e3d61e6db028c412f74bc4d4c7e117a9e29d0de0/core/txpool/legacypool/list.go#L298
|
|
@@ -134,7 +134,7 @@ export const P75AllTxsPriorityFeeStrategy: PriorityFeeStrategy = {
|
|
|
134
134
|
// Sanity check: cap competitive fee at 100x network estimate to avoid using unrealistic fees
|
|
135
135
|
const maxReasonableFee = networkEstimate * 100n;
|
|
136
136
|
if (competitiveFee > maxReasonableFee && networkEstimate > 0n) {
|
|
137
|
-
logger?.
|
|
137
|
+
logger?.debug('Competitive fee exceeds sanity cap, using capped value', {
|
|
138
138
|
competitiveFee: formatGwei(competitiveFee),
|
|
139
139
|
networkEstimate: formatGwei(networkEstimate),
|
|
140
140
|
cappedTo: formatGwei(maxReasonableFee),
|
|
@@ -207,7 +207,7 @@ export const P75BlobTxsOnlyPriorityFeeStrategy: PriorityFeeStrategy = {
|
|
|
207
207
|
|
|
208
208
|
// Debug: Log suspicious fees from history
|
|
209
209
|
if (medianHistoricalFee > 100n * WEI_CONST) {
|
|
210
|
-
logger?.
|
|
210
|
+
logger?.debug('Suspicious high fee in history', {
|
|
211
211
|
historicalMedian: formatGwei(medianHistoricalFee),
|
|
212
212
|
allP75Fees: percentile75Fees.map(f => formatGwei(f)),
|
|
213
213
|
});
|
|
@@ -27,7 +27,7 @@ import { jsonRpc } from 'viem/nonce';
|
|
|
27
27
|
import type { ViemClient } from '../types.js';
|
|
28
28
|
import { formatViemError } from '../utils.js';
|
|
29
29
|
import { type L1TxUtilsConfig, l1TxUtilsConfigMappings } from './config.js';
|
|
30
|
-
import {
|
|
30
|
+
import { MAX_L1_TX_LIMIT } from './constants.js';
|
|
31
31
|
import type { IL1TxMetrics, IL1TxStore } from './interfaces.js';
|
|
32
32
|
import { ReadOnlyL1TxUtils } from './readonly_l1_tx_utils.js';
|
|
33
33
|
import {
|
|
@@ -207,7 +207,7 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
207
207
|
|
|
208
208
|
let gasLimit: bigint;
|
|
209
209
|
if (this.debugMaxGasLimit) {
|
|
210
|
-
gasLimit =
|
|
210
|
+
gasLimit = MAX_L1_TX_LIMIT;
|
|
211
211
|
} else if (gasConfig.gasLimit) {
|
|
212
212
|
gasLimit = gasConfig.gasLimit;
|
|
213
213
|
} else {
|
|
@@ -283,7 +283,7 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
283
283
|
return { txHash, state: l1TxState };
|
|
284
284
|
} catch (err: any) {
|
|
285
285
|
const viemError = formatViemError(err, request.abi);
|
|
286
|
-
this.logger.error(`Failed to send L1 transaction`, viemError, {
|
|
286
|
+
this.logger.error(`Failed to send L1 transaction: ${viemError.message}`, viemError, {
|
|
287
287
|
request: pick(request, 'to', 'value'),
|
|
288
288
|
});
|
|
289
289
|
throw viemError;
|
|
@@ -631,12 +631,12 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
631
631
|
from: request.from ?? this.getSenderAddress().toString(),
|
|
632
632
|
maxFeePerGas: gasPrice.maxFeePerGas,
|
|
633
633
|
maxPriorityFeePerGas: gasPrice.maxPriorityFeePerGas,
|
|
634
|
-
gas: request.gas ??
|
|
634
|
+
gas: request.gas ?? MAX_L1_TX_LIMIT,
|
|
635
635
|
};
|
|
636
636
|
|
|
637
637
|
if (!request.gas && !gasConfig.ignoreBlockGasLimit) {
|
|
638
|
-
//
|
|
639
|
-
blockOverrides.gasLimit =
|
|
638
|
+
// MAX_L1_TX_LIMIT is set as call.gas, ensure block gasLimit is sufficient
|
|
639
|
+
blockOverrides.gasLimit = MAX_L1_TX_LIMIT;
|
|
640
640
|
}
|
|
641
641
|
|
|
642
642
|
return this._simulate(call, blockOverrides, stateOverrides, gasConfig, abi);
|
|
@@ -27,7 +27,7 @@ import type { ViemClient } from '../types.js';
|
|
|
27
27
|
import { type L1TxUtilsConfig, defaultL1TxUtilsConfig, l1TxUtilsConfigMappings } from './config.js';
|
|
28
28
|
import {
|
|
29
29
|
BLOCK_TIME_MS,
|
|
30
|
-
|
|
30
|
+
MAX_L1_TX_LIMIT,
|
|
31
31
|
MIN_BLOB_REPLACEMENT_BUMP_PERCENTAGE,
|
|
32
32
|
MIN_REPLACEMENT_BUMP_PERCENTAGE,
|
|
33
33
|
WEI_CONST,
|
|
@@ -249,7 +249,7 @@ export class ReadOnlyL1TxUtils {
|
|
|
249
249
|
...request,
|
|
250
250
|
..._blobInputs,
|
|
251
251
|
maxFeePerBlobGas: gasPrice.maxFeePerBlobGas!,
|
|
252
|
-
gas:
|
|
252
|
+
gas: MAX_L1_TX_LIMIT,
|
|
253
253
|
blockTag: 'latest',
|
|
254
254
|
});
|
|
255
255
|
|
|
@@ -258,7 +258,7 @@ export class ReadOnlyL1TxUtils {
|
|
|
258
258
|
initialEstimate = await this.client.estimateGas({
|
|
259
259
|
account,
|
|
260
260
|
...request,
|
|
261
|
-
gas:
|
|
261
|
+
gas: MAX_L1_TX_LIMIT,
|
|
262
262
|
blockTag: 'latest',
|
|
263
263
|
});
|
|
264
264
|
this.logger?.trace(`Estimated gas for non-blob tx: ${initialEstimate}`);
|
package/src/utils.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { ErrorsAbi } from '@aztec/l1-artifacts/ErrorsAbi';
|
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
type Abi,
|
|
7
|
+
type AbiItem,
|
|
7
8
|
BaseError,
|
|
8
9
|
type ContractEventName,
|
|
9
10
|
ContractFunctionRevertedError,
|
|
@@ -14,6 +15,7 @@ import {
|
|
|
14
15
|
decodeErrorResult,
|
|
15
16
|
decodeEventLog,
|
|
16
17
|
} from 'viem';
|
|
18
|
+
import { formatAbiItem, formatAbiParams } from 'viem/utils';
|
|
17
19
|
|
|
18
20
|
export interface L2Claim {
|
|
19
21
|
claimSecret: Fr;
|
|
@@ -93,6 +95,57 @@ export function prettyLogViemErrorMsg(err: any) {
|
|
|
93
95
|
return err?.message ?? err;
|
|
94
96
|
}
|
|
95
97
|
|
|
98
|
+
export function mergeAbis(abis: Abi[]): Abi {
|
|
99
|
+
let merged: Abi = [];
|
|
100
|
+
const seen = new Set<string>();
|
|
101
|
+
|
|
102
|
+
for (const abi of abis) {
|
|
103
|
+
for (const item of abi) {
|
|
104
|
+
const key = getAbiItemKey(item);
|
|
105
|
+
if (!seen.has(key)) {
|
|
106
|
+
seen.add(key);
|
|
107
|
+
merged = [...merged, item];
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return merged;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function getAbiItemKey(item: AbiItem): string {
|
|
116
|
+
if (item.type === 'function') {
|
|
117
|
+
const signature = formatAbiItem(item);
|
|
118
|
+
const outputs = formatAbiParams(item.outputs);
|
|
119
|
+
const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
|
|
120
|
+
return `function:${signature}:${outputs}:${stateMutability}`;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (item.type === 'event') {
|
|
124
|
+
const signature = formatAbiItem(item);
|
|
125
|
+
const indexed = (item.inputs ?? []).map(input => ((input as { indexed?: boolean }).indexed ? '1' : '0')).join('');
|
|
126
|
+
const anonymous = item.anonymous ? 'anonymous' : 'not-anonymous';
|
|
127
|
+
return `event:${signature}:${indexed}:${anonymous}`;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (item.type === 'error') {
|
|
131
|
+
const signature = formatAbiItem(item);
|
|
132
|
+
return `error:${signature}`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (item.type === 'constructor') {
|
|
136
|
+
const inputs = formatAbiParams(item.inputs);
|
|
137
|
+
const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
|
|
138
|
+
return `constructor::${inputs}:${stateMutability}`;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (item.type === 'fallback' || item.type === 'receive') {
|
|
142
|
+
const stateMutability = typeof item.stateMutability === 'string' ? item.stateMutability : '';
|
|
143
|
+
return `${item.type}:::${stateMutability}`;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return 'unknown';
|
|
147
|
+
}
|
|
148
|
+
|
|
96
149
|
function getNestedErrorData(error: unknown): string | undefined {
|
|
97
150
|
// If nothing, bail
|
|
98
151
|
if (!error) {
|