@aztec/ethereum 0.0.1-commit.fcb71a6 → 0.0.1-commit.ff7989d6c
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.d.ts +15 -28
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +50 -57
- package/dest/contracts/empire_base.d.ts +3 -1
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/empire_slashing_proposer.d.ts +3 -1
- package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/empire_slashing_proposer.js +22 -15
- package/dest/contracts/fee_asset_handler.d.ts +6 -5
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
- package/dest/contracts/fee_asset_handler.js +11 -9
- 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 +3 -1
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +14 -4
- package/dest/contracts/governance_proposer.d.ts +3 -1
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +395 -9
- package/dest/contracts/inbox.d.ts +18 -1
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +32 -1
- package/dest/contracts/index.d.ts +4 -1
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +3 -0
- package/dest/contracts/log.d.ts +13 -0
- package/dest/contracts/log.d.ts.map +1 -0
- package/dest/contracts/log.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/outbox.d.ts +41 -0
- package/dest/contracts/outbox.d.ts.map +1 -0
- package/dest/contracts/outbox.js +86 -0
- package/dest/contracts/rollup.d.ts +161 -96
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +677 -132
- 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 +16 -4
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +110 -33
- package/dest/deploy_l1_contract.js +3 -3
- package/dest/generated/l1-contracts-defaults.d.ts +30 -0
- package/dest/generated/l1-contracts-defaults.d.ts.map +1 -0
- package/dest/generated/l1-contracts-defaults.js +30 -0
- package/dest/l1_artifacts.d.ts +5877 -1515
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_tx_utils/config.d.ts +7 -1
- package/dest/l1_tx_utils/config.d.ts.map +1 -1
- package/dest/l1_tx_utils/config.js +14 -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/factory.d.ts +18 -10
- package/dest/l1_tx_utils/factory.d.ts.map +1 -1
- package/dest/l1_tx_utils/factory.js +17 -7
- package/dest/l1_tx_utils/fee-strategies/index.d.ts +3 -2
- package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/index.js +2 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +2 -12
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +36 -18
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +2 -11
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +37 -19
- package/dest/l1_tx_utils/fee-strategies/types.d.ts +14 -27
- package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -1
- package/dest/l1_tx_utils/fee-strategies/types.js +0 -21
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts +15 -15
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +9 -15
- package/dest/l1_tx_utils/index-blobs.d.ts +3 -3
- package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -1
- package/dest/l1_tx_utils/index-blobs.js +2 -2
- package/dest/l1_tx_utils/index.d.ts +2 -1
- package/dest/l1_tx_utils/index.d.ts.map +1 -1
- package/dest/l1_tx_utils/index.js +1 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +2 -2
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_fee_analyzer.js +3 -3
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +15 -5
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +47 -13
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +1 -5
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +17 -54
- package/dest/l1_tx_utils/tx_delayer.d.ts +56 -0
- package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
- package/dest/{test → l1_tx_utils}/tx_delayer.js +62 -34
- package/dest/publisher_manager.d.ts +3 -2
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +2 -2
- package/dest/queries.d.ts +2 -2
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +6 -3
- package/dest/test/chain_monitor.js +1 -2
- package/dest/test/eth_cheat_codes.d.ts +13 -1
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/index.d.ts +1 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +0 -2
- package/dest/test/rollup_cheat_codes.d.ts +5 -2
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +19 -2
- package/dest/test/start_anvil.js +1 -1
- package/dest/test/upgrade_utils.js +2 -2
- package/dest/utils.d.ts +2 -1
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +46 -0
- package/package.json +8 -7
- package/src/config.ts +58 -56
- package/src/contracts/README.md +157 -0
- package/src/contracts/empire_base.ts +2 -0
- package/src/contracts/empire_slashing_proposer.ts +22 -27
- package/src/contracts/fee_asset_handler.ts +10 -7
- package/src/contracts/fee_asset_price_oracle.ts +280 -0
- package/src/contracts/governance.ts +13 -4
- package/src/contracts/governance_proposer.ts +10 -1
- package/src/contracts/inbox.ts +48 -1
- package/src/contracts/index.ts +3 -0
- package/src/contracts/log.ts +13 -0
- package/src/contracts/multicall.ts +5 -2
- package/src/contracts/outbox.ts +98 -0
- package/src/contracts/rollup.ts +348 -100
- package/src/contracts/tally_slashing_proposer.ts +5 -1
- package/src/deploy_aztec_l1_contracts.ts +135 -42
- package/src/deploy_l1_contract.ts +3 -3
- package/src/generated/l1-contracts-defaults.ts +32 -0
- package/src/l1_tx_utils/config.ts +20 -0
- package/src/l1_tx_utils/constants.ts +2 -2
- package/src/l1_tx_utils/factory.ts +31 -31
- package/src/l1_tx_utils/fee-strategies/index.ts +1 -1
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +46 -42
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +49 -45
- package/src/l1_tx_utils/fee-strategies/types.ts +14 -46
- package/src/l1_tx_utils/forwarder_l1_tx_utils.ts +43 -54
- package/src/l1_tx_utils/index-blobs.ts +2 -2
- package/src/l1_tx_utils/index.ts +1 -0
- package/src/l1_tx_utils/l1_fee_analyzer.ts +2 -3
- package/src/l1_tx_utils/l1_tx_utils.ts +52 -17
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +23 -62
- package/src/{test → l1_tx_utils}/tx_delayer.ts +78 -50
- package/src/publisher_manager.ts +4 -2
- package/src/queries.ts +5 -3
- package/src/test/chain_monitor.ts +1 -1
- package/src/test/index.ts +0 -2
- package/src/test/rollup_cheat_codes.ts +21 -3
- package/src/test/start_anvil.ts +1 -1
- package/src/test/upgrade_utils.ts +2 -2
- package/src/utils.ts +53 -0
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +0 -26
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +0 -1
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +0 -26
- package/dest/test/delayed_tx_utils.d.ts +0 -13
- package/dest/test/delayed_tx_utils.d.ts.map +0 -1
- package/dest/test/delayed_tx_utils.js +0 -28
- package/dest/test/tx_delayer.d.ts +0 -36
- package/dest/test/tx_delayer.d.ts.map +0 -1
- package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +0 -77
- package/src/test/delayed_tx_utils.ts +0 -52
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { L1TxRequest } from '@aztec/ethereum/l1-tx-utils';
|
|
2
2
|
import type { ViemClient } from '@aztec/ethereum/types';
|
|
3
|
-
import { tryExtractEvent } from '@aztec/ethereum/utils';
|
|
3
|
+
import { mergeAbis, tryExtractEvent } from '@aztec/ethereum/utils';
|
|
4
4
|
import { SlotNumber } from '@aztec/foundation/branded-types';
|
|
5
5
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
6
6
|
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
|
+
import { SlasherAbi } from '@aztec/l1-artifacts/SlasherAbi';
|
|
9
10
|
import { TallySlashingProposerAbi } from '@aztec/l1-artifacts/TallySlashingProposerAbi';
|
|
10
11
|
|
|
11
12
|
import {
|
|
@@ -160,6 +161,7 @@ export class TallySlashingProposerContract {
|
|
|
160
161
|
|
|
161
162
|
return {
|
|
162
163
|
to: this.contract.address,
|
|
164
|
+
abi: TallySlashingProposerAbi,
|
|
163
165
|
data: encodeFunctionData({
|
|
164
166
|
abi: TallySlashingProposerAbi,
|
|
165
167
|
functionName: 'vote',
|
|
@@ -207,6 +209,7 @@ export class TallySlashingProposerContract {
|
|
|
207
209
|
public buildVoteRequestWithSignature(votes: Hex, signature: { v: number; r: Hex; s: Hex }): L1TxRequest {
|
|
208
210
|
return {
|
|
209
211
|
to: this.contract.address,
|
|
212
|
+
abi: TallySlashingProposerAbi,
|
|
210
213
|
data: encodeFunctionData({
|
|
211
214
|
abi: TallySlashingProposerAbi,
|
|
212
215
|
functionName: 'vote',
|
|
@@ -224,6 +227,7 @@ export class TallySlashingProposerContract {
|
|
|
224
227
|
public buildExecuteRoundRequest(round: bigint, committees: EthAddress[][]): L1TxRequest {
|
|
225
228
|
return {
|
|
226
229
|
to: this.contract.address,
|
|
230
|
+
abi: mergeAbis([TallySlashingProposerAbi, SlasherAbi]),
|
|
227
231
|
data: encodeFunctionData({
|
|
228
232
|
abi: TallySlashingProposerAbi,
|
|
229
233
|
functionName: 'executeRound',
|
|
@@ -10,10 +10,12 @@ import { fileURLToPath } from '@aztec/foundation/url';
|
|
|
10
10
|
import { bn254 } from '@noble/curves/bn254';
|
|
11
11
|
import type { Abi, Narrow } from 'abitype';
|
|
12
12
|
import { spawn } from 'child_process';
|
|
13
|
-
import {
|
|
13
|
+
import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'fs';
|
|
14
|
+
import { tmpdir } from 'os';
|
|
15
|
+
import { dirname, join, resolve } from 'path';
|
|
14
16
|
import readline from 'readline';
|
|
15
17
|
import type { Hex } from 'viem';
|
|
16
|
-
import {
|
|
18
|
+
import { mainnet, sepolia } from 'viem/chains';
|
|
17
19
|
|
|
18
20
|
import { createEthereumChain, isAnvilTestChain } from './chain.js';
|
|
19
21
|
import { createExtendedL1Client } from './client.js';
|
|
@@ -21,7 +23,6 @@ import type { L1ContractsConfig } from './config.js';
|
|
|
21
23
|
import { deployMulticall3 } from './contracts/multicall.js';
|
|
22
24
|
import { RollupContract } from './contracts/rollup.js';
|
|
23
25
|
import type { L1ContractAddresses } from './l1_contract_addresses.js';
|
|
24
|
-
import type { L1TxUtilsConfig } from './l1_tx_utils/config.js';
|
|
25
26
|
import type { ExtendedViemWalletClient } from './types.js';
|
|
26
27
|
|
|
27
28
|
const logger = createLogger('ethereum:deploy_aztec_l1_contracts');
|
|
@@ -29,9 +30,9 @@ const logger = createLogger('ethereum:deploy_aztec_l1_contracts');
|
|
|
29
30
|
const JSON_DEPLOY_RESULT_PREFIX = 'JSON DEPLOY RESULT:';
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
|
-
* Runs a process
|
|
33
|
-
*
|
|
34
|
-
*
|
|
33
|
+
* Runs a process and parses JSON deploy results from stdout.
|
|
34
|
+
* Lines starting with JSON_DEPLOY_RESULT_PREFIX are parsed and returned.
|
|
35
|
+
* All other stdout goes to logger.info, stderr goes to logger.warn.
|
|
35
36
|
*/
|
|
36
37
|
function runProcess<T>(
|
|
37
38
|
command: string,
|
|
@@ -47,26 +48,41 @@ function runProcess<T>(
|
|
|
47
48
|
});
|
|
48
49
|
|
|
49
50
|
let result: T | undefined;
|
|
51
|
+
let parseError: Error | undefined;
|
|
52
|
+
let settled = false;
|
|
50
53
|
|
|
51
54
|
readline.createInterface({ input: proc.stdout }).on('line', line => {
|
|
52
55
|
const trimmedLine = line.trim();
|
|
53
56
|
if (trimmedLine.startsWith(JSON_DEPLOY_RESULT_PREFIX)) {
|
|
54
57
|
const jsonStr = trimmedLine.slice(JSON_DEPLOY_RESULT_PREFIX.length).trim();
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
try {
|
|
59
|
+
result = JSON.parse(jsonStr);
|
|
60
|
+
} catch {
|
|
61
|
+
parseError = new Error(`Failed to parse deploy result JSON: ${jsonStr.slice(0, 200)}`);
|
|
62
|
+
}
|
|
57
63
|
} else {
|
|
58
64
|
logger.info(line);
|
|
59
65
|
}
|
|
60
66
|
});
|
|
61
|
-
readline.createInterface({ input: proc.stderr }).on('line', logger.
|
|
67
|
+
readline.createInterface({ input: proc.stderr }).on('line', logger.warn.bind(logger));
|
|
62
68
|
|
|
63
69
|
proc.on('error', error => {
|
|
70
|
+
if (settled) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
settled = true;
|
|
64
74
|
reject(new Error(`Failed to spawn ${command}: ${error.message}`));
|
|
65
75
|
});
|
|
66
76
|
|
|
67
77
|
proc.on('close', code => {
|
|
78
|
+
if (settled) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
settled = true;
|
|
68
82
|
if (code !== 0) {
|
|
69
|
-
reject(new Error(`${command} exited with code ${code}
|
|
83
|
+
reject(new Error(`${command} exited with code ${code}`));
|
|
84
|
+
} else if (parseError) {
|
|
85
|
+
reject(parseError);
|
|
70
86
|
} else {
|
|
71
87
|
resolve(result);
|
|
72
88
|
}
|
|
@@ -107,17 +123,80 @@ export interface ValidatorJson {
|
|
|
107
123
|
}
|
|
108
124
|
|
|
109
125
|
/**
|
|
110
|
-
* Gets the path to the l1-contracts directory.
|
|
126
|
+
* Gets the path to the l1-contracts foundry artifacts directory.
|
|
127
|
+
* These are copied from l1-contracts to yarn-project/l1-artifacts/l1-contracts
|
|
128
|
+
* during build to make yarn-project self-contained.
|
|
111
129
|
*/
|
|
112
130
|
export function getL1ContractsPath(): string {
|
|
113
|
-
// Try to find l1-contracts relative to this file
|
|
114
131
|
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const l1ContractsPath = resolve(currentDir, '..', '..', '..', 'l1-contracts');
|
|
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');
|
|
118
134
|
return l1ContractsPath;
|
|
119
135
|
}
|
|
120
136
|
|
|
137
|
+
// Cached deployment directory
|
|
138
|
+
let preparedDeployDir: string | undefined;
|
|
139
|
+
|
|
140
|
+
function cleanupDeployDir() {
|
|
141
|
+
if (preparedDeployDir) {
|
|
142
|
+
try {
|
|
143
|
+
rmSync(preparedDeployDir, { recursive: true, force: true });
|
|
144
|
+
} catch {
|
|
145
|
+
// ignore cleanup errors
|
|
146
|
+
}
|
|
147
|
+
preparedDeployDir = undefined;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Prepares a temp directory for forge deployment.
|
|
153
|
+
* Copies all artifacts with preserved timestamps (required for forge cache validity).
|
|
154
|
+
* A fresh broadcast/ directory is created for deployment outputs.
|
|
155
|
+
*/
|
|
156
|
+
export function prepareL1ContractsForDeployment(): string {
|
|
157
|
+
if (preparedDeployDir && existsSync(preparedDeployDir)) {
|
|
158
|
+
logger.verbose(`Using cached deployment directory: ${preparedDeployDir}`);
|
|
159
|
+
return preparedDeployDir;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const basePath = getL1ContractsPath();
|
|
163
|
+
logger.verbose(`Preparing L1 contracts from: ${basePath}`);
|
|
164
|
+
const tempDir = mkdtempSync(join(tmpdir(), '.foundry-deploy-'));
|
|
165
|
+
logger.verbose(`Created temp directory for deployment: ${tempDir}`);
|
|
166
|
+
preparedDeployDir = tempDir;
|
|
167
|
+
process.on('exit', cleanupDeployDir);
|
|
168
|
+
|
|
169
|
+
// Copy all dirs with preserved timestamps (required for forge cache validity)
|
|
170
|
+
const copyOpts = { recursive: true, preserveTimestamps: true };
|
|
171
|
+
cpSync(join(basePath, 'out'), join(tempDir, 'out'), copyOpts);
|
|
172
|
+
cpSync(join(basePath, 'lib'), join(tempDir, 'lib'), copyOpts);
|
|
173
|
+
cpSync(join(basePath, 'cache'), join(tempDir, 'cache'), copyOpts);
|
|
174
|
+
cpSync(join(basePath, 'src'), join(tempDir, 'src'), copyOpts);
|
|
175
|
+
cpSync(join(basePath, 'script'), join(tempDir, 'script'), copyOpts);
|
|
176
|
+
cpSync(join(basePath, 'generated'), join(tempDir, 'generated'), copyOpts);
|
|
177
|
+
// Kludge: copy test/ to appease forge cache which references test/shouting.t.sol
|
|
178
|
+
cpSync(join(basePath, 'test'), join(tempDir, 'test'), copyOpts);
|
|
179
|
+
cpSync(join(basePath, 'foundry.lock'), join(tempDir, 'foundry.lock'));
|
|
180
|
+
|
|
181
|
+
// Update foundry.toml to use absolute path to solc binary (avoids copying to noexec tmpfs)
|
|
182
|
+
const foundryTomlPath = join(basePath, 'foundry.toml');
|
|
183
|
+
let foundryToml = readFileSync(foundryTomlPath, 'utf-8');
|
|
184
|
+
const solcPathMatch = foundryToml.match(/solc\s*=\s*"\.\/solc-([^"]+)"/);
|
|
185
|
+
// Did we find a hardcoded solc path that we need to make absolute?
|
|
186
|
+
// This code path happens in CI currently as we bundle solc there to avoid race conditions when
|
|
187
|
+
// downloading solc.
|
|
188
|
+
if (solcPathMatch) {
|
|
189
|
+
const solcVersion = solcPathMatch[1];
|
|
190
|
+
const absoluteSolcPath = join(basePath, `solc-${solcVersion}`);
|
|
191
|
+
foundryToml = foundryToml.replace(/solc\s*=\s*"\.\/solc-[^"]+"/, `solc = "${absoluteSolcPath}"`);
|
|
192
|
+
logger.verbose(`Updated solc path in foundry.toml to: ${absoluteSolcPath}`);
|
|
193
|
+
}
|
|
194
|
+
writeFileSync(join(tempDir, 'foundry.toml'), foundryToml);
|
|
195
|
+
|
|
196
|
+
mkdirSync(join(tempDir, 'broadcast'));
|
|
197
|
+
return tempDir;
|
|
198
|
+
}
|
|
199
|
+
|
|
121
200
|
/**
|
|
122
201
|
* Computes the validator data for passing to Solidity.
|
|
123
202
|
* Only computes the G2 public key (which requires scalar multiplication on G2, not available in EVM).
|
|
@@ -211,7 +290,6 @@ export async function deployAztecL1Contracts(
|
|
|
211
290
|
'Initial validator funding requires minting tokens, which is not possible with an external token.',
|
|
212
291
|
);
|
|
213
292
|
}
|
|
214
|
-
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
215
293
|
const chain = createEthereumChain([rpcUrl], chainId);
|
|
216
294
|
|
|
217
295
|
const l1Client = createExtendedL1Client([rpcUrl], privateKey, chain.chainInfo);
|
|
@@ -240,8 +318,8 @@ export async function deployAztecL1Contracts(
|
|
|
240
318
|
}
|
|
241
319
|
}
|
|
242
320
|
|
|
243
|
-
//
|
|
244
|
-
const l1ContractsPath =
|
|
321
|
+
// Use foundry-artifacts from l1-artifacts package
|
|
322
|
+
const l1ContractsPath = prepareL1ContractsForDeployment();
|
|
245
323
|
|
|
246
324
|
const FORGE_SCRIPT = 'script/deploy/DeployAztecL1Contracts.s.sol';
|
|
247
325
|
await maybeForgeForceProductionBuild(l1ContractsPath, FORGE_SCRIPT, chainId);
|
|
@@ -257,11 +335,8 @@ export async function deployAztecL1Contracts(
|
|
|
257
335
|
);
|
|
258
336
|
}
|
|
259
337
|
|
|
260
|
-
|
|
261
|
-
const MAGIC_ANVIL_BATCH_SIZE = 12;
|
|
262
|
-
// Anvil seems to stall with unbounded batch size. Otherwise no max batch size is desirable.
|
|
338
|
+
const scriptPath = join(getL1ContractsPath(), 'scripts', 'forge_broadcast.js');
|
|
263
339
|
const forgeArgs = [
|
|
264
|
-
'script',
|
|
265
340
|
FORGE_SCRIPT,
|
|
266
341
|
'--sig',
|
|
267
342
|
'run()',
|
|
@@ -269,8 +344,6 @@ export async function deployAztecL1Contracts(
|
|
|
269
344
|
privateKey,
|
|
270
345
|
'--rpc-url',
|
|
271
346
|
rpcUrl,
|
|
272
|
-
'--broadcast',
|
|
273
|
-
...(chainId === foundry.id ? ['--batch-size', MAGIC_ANVIL_BATCH_SIZE.toString()] : []),
|
|
274
347
|
...(shouldVerify ? ['--verify'] : []),
|
|
275
348
|
];
|
|
276
349
|
const forgeEnv = {
|
|
@@ -279,7 +352,12 @@ export async function deployAztecL1Contracts(
|
|
|
279
352
|
FOUNDRY_PROFILE: chainId === mainnet.id ? 'production' : undefined,
|
|
280
353
|
...getDeployAztecL1ContractsEnvVars(args),
|
|
281
354
|
};
|
|
282
|
-
const result = await runProcess<ForgeL1ContractsDeployResult>(
|
|
355
|
+
const result = await runProcess<ForgeL1ContractsDeployResult>(
|
|
356
|
+
process.execPath,
|
|
357
|
+
[scriptPath, ...forgeArgs],
|
|
358
|
+
forgeEnv,
|
|
359
|
+
l1ContractsPath,
|
|
360
|
+
);
|
|
283
361
|
if (!result) {
|
|
284
362
|
throw new Error('Forge script did not output deployment result');
|
|
285
363
|
}
|
|
@@ -412,7 +490,25 @@ export type VerificationRecord = {
|
|
|
412
490
|
libraries: VerificationLibraryEntry[];
|
|
413
491
|
};
|
|
414
492
|
|
|
415
|
-
export interface DeployAztecL1ContractsArgs
|
|
493
|
+
export interface DeployAztecL1ContractsArgs
|
|
494
|
+
extends Omit<
|
|
495
|
+
L1ContractsConfig,
|
|
496
|
+
| 'gasLimitBufferPercentage'
|
|
497
|
+
| 'maxGwei'
|
|
498
|
+
| 'maxBlobGwei'
|
|
499
|
+
| 'priorityFeeBumpPercentage'
|
|
500
|
+
| 'priorityFeeRetryBumpPercentage'
|
|
501
|
+
| 'minimumPriorityFeePerGas'
|
|
502
|
+
| 'maxSpeedUpAttempts'
|
|
503
|
+
| 'checkIntervalMs'
|
|
504
|
+
| 'stallTimeMs'
|
|
505
|
+
| 'txTimeoutMs'
|
|
506
|
+
| 'cancelTxOnTimeout'
|
|
507
|
+
| 'txCancellationFinalTimeoutMs'
|
|
508
|
+
| 'txUnseenConsideredDroppedMs'
|
|
509
|
+
| 'enableDelayer'
|
|
510
|
+
| 'txDelayerMaxInclusionTimeIntoSlot'
|
|
511
|
+
> {
|
|
416
512
|
/** The vk tree root. */
|
|
417
513
|
vkTreeRoot: Fr;
|
|
418
514
|
/** The hash of the protocol contracts. */
|
|
@@ -447,6 +543,7 @@ export function getDeployAztecL1ContractsEnvVars(args: DeployAztecL1ContractsArg
|
|
|
447
543
|
AZTEC_EJECTION_THRESHOLD: args.ejectionThreshold?.toString(),
|
|
448
544
|
AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE: args.governanceProposerRoundSize?.toString(),
|
|
449
545
|
AZTEC_GOVERNANCE_PROPOSER_QUORUM: args.governanceProposerQuorum?.toString(),
|
|
546
|
+
AZTEC_GOVERNANCE_VOTING_DURATION: args.governanceVotingDuration?.toString(),
|
|
450
547
|
ZKPASSPORT_DOMAIN: args.zkPassportArgs?.zkPassportDomain,
|
|
451
548
|
ZKPASSPORT_SCOPE: args.zkPassportArgs?.zkPassportScope,
|
|
452
549
|
} as const;
|
|
@@ -481,11 +578,13 @@ export function getDeployRollupForUpgradeEnvVars(
|
|
|
481
578
|
AZTEC_PROOF_SUBMISSION_EPOCHS: args.aztecProofSubmissionEpochs.toString(),
|
|
482
579
|
AZTEC_LOCAL_EJECTION_THRESHOLD: args.localEjectionThreshold.toString(),
|
|
483
580
|
AZTEC_SLASHING_LIFETIME_IN_ROUNDS: args.slashingLifetimeInRounds.toString(),
|
|
581
|
+
AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS: args.slashingExecutionDelayInRounds.toString(),
|
|
484
582
|
AZTEC_SLASHING_VETOER: args.slashingVetoer.toString(),
|
|
485
583
|
AZTEC_SLASHING_DISABLE_DURATION: args.slashingDisableDuration.toString(),
|
|
486
584
|
AZTEC_MANA_TARGET: args.manaTarget.toString(),
|
|
487
585
|
AZTEC_EXIT_DELAY_SECONDS: args.exitDelaySeconds.toString(),
|
|
488
586
|
AZTEC_PROVING_COST_PER_MANA: args.provingCostPerMana.toString(),
|
|
587
|
+
AZTEC_INITIAL_ETH_PER_FEE_ASSET: args.initialEthPerFeeAsset.toString(),
|
|
489
588
|
AZTEC_SLASHER_FLAVOR: args.slasherFlavor,
|
|
490
589
|
AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS: args.slashingRoundSizeInEpochs.toString(),
|
|
491
590
|
AZTEC_SLASHING_QUORUM: args.slashingQuorum?.toString(),
|
|
@@ -513,25 +612,14 @@ export const deployRollupForUpgrade = async (
|
|
|
513
612
|
| 'zkPassportArgs'
|
|
514
613
|
>,
|
|
515
614
|
) => {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
// Relative location of l1-contracts in monorepo or docker image.
|
|
519
|
-
const l1ContractsPath = resolve(currentDir, '..', '..', '..', 'l1-contracts');
|
|
615
|
+
// Use foundry-artifacts from l1-artifacts package
|
|
616
|
+
const l1ContractsPath = prepareL1ContractsForDeployment();
|
|
520
617
|
|
|
521
618
|
const FORGE_SCRIPT = 'script/deploy/DeployRollupForUpgrade.s.sol';
|
|
522
619
|
await maybeForgeForceProductionBuild(l1ContractsPath, FORGE_SCRIPT, chainId);
|
|
523
620
|
|
|
524
|
-
const
|
|
525
|
-
|
|
526
|
-
FORGE_SCRIPT,
|
|
527
|
-
'--sig',
|
|
528
|
-
'run()',
|
|
529
|
-
'--private-key',
|
|
530
|
-
privateKey,
|
|
531
|
-
'--rpc-url',
|
|
532
|
-
rpcUrl,
|
|
533
|
-
'--broadcast',
|
|
534
|
-
];
|
|
621
|
+
const scriptPath = join(getL1ContractsPath(), 'scripts', 'forge_broadcast.js');
|
|
622
|
+
const forgeArgs = [FORGE_SCRIPT, '--sig', 'run()', '--private-key', privateKey, '--rpc-url', rpcUrl];
|
|
535
623
|
const forgeEnv = {
|
|
536
624
|
FOUNDRY_PROFILE: chainId === mainnet.id ? 'production' : undefined,
|
|
537
625
|
// Env vars required by l1-contracts/script/deploy/RollupConfiguration.sol.
|
|
@@ -540,7 +628,12 @@ export const deployRollupForUpgrade = async (
|
|
|
540
628
|
...getDeployRollupForUpgradeEnvVars(args),
|
|
541
629
|
};
|
|
542
630
|
|
|
543
|
-
const result = await runProcess<ForgeRollupUpgradeResult>(
|
|
631
|
+
const result = await runProcess<ForgeRollupUpgradeResult>(
|
|
632
|
+
process.execPath,
|
|
633
|
+
[scriptPath, ...forgeArgs],
|
|
634
|
+
forgeEnv,
|
|
635
|
+
l1ContractsPath,
|
|
636
|
+
);
|
|
544
637
|
if (!result) {
|
|
545
638
|
throw new Error('Forge script did not output deployment result');
|
|
546
639
|
}
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
} from './deploy_aztec_l1_contracts.js';
|
|
25
25
|
import { RegisterNewRollupVersionPayloadArtifact } from './l1_artifacts.js';
|
|
26
26
|
import { type L1TxUtilsConfig, getL1TxUtilsConfigEnvVars } from './l1_tx_utils/config.js';
|
|
27
|
-
import {
|
|
27
|
+
import { createL1TxUtils } from './l1_tx_utils/factory.js';
|
|
28
28
|
import type { L1TxUtils } from './l1_tx_utils/l1_tx_utils.js';
|
|
29
29
|
import type { GasPrice, L1TxConfig, L1TxRequest } from './l1_tx_utils/types.js';
|
|
30
30
|
import type { ExtendedViemWalletClient } from './types.js';
|
|
@@ -46,7 +46,7 @@ export class L1Deployer {
|
|
|
46
46
|
private createVerificationJson: boolean = false,
|
|
47
47
|
) {
|
|
48
48
|
this.salt = maybeSalt ? padHex(numberToHex(maybeSalt), { size: 32 }) : undefined;
|
|
49
|
-
this.l1TxUtils =
|
|
49
|
+
this.l1TxUtils = createL1TxUtils(
|
|
50
50
|
this.client,
|
|
51
51
|
{ logger: this.logger, dateProvider },
|
|
52
52
|
{ ...this.txUtilsConfig, debugMaxGasLimit: acceleratedTestDeployments },
|
|
@@ -179,7 +179,7 @@ export async function deployL1Contract(
|
|
|
179
179
|
|
|
180
180
|
if (!l1TxUtils) {
|
|
181
181
|
const config = getL1TxUtilsConfigEnvVars();
|
|
182
|
-
l1TxUtils =
|
|
182
|
+
l1TxUtils = createL1TxUtils(
|
|
183
183
|
extendedClient,
|
|
184
184
|
{ logger },
|
|
185
185
|
{ ...config, debugMaxGasLimit: acceleratedTestDeployments },
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Auto-generated from spartan/environments/network-defaults.yml
|
|
2
|
+
// Do not edit manually - run yarn generate to regenerate
|
|
3
|
+
|
|
4
|
+
/** Default L1 contracts configuration values from network-defaults.yml */
|
|
5
|
+
export const l1ContractsDefaultEnv = {
|
|
6
|
+
ETHEREUM_SLOT_DURATION: 12,
|
|
7
|
+
AZTEC_SLOT_DURATION: 36,
|
|
8
|
+
AZTEC_EPOCH_DURATION: 32,
|
|
9
|
+
AZTEC_TARGET_COMMITTEE_SIZE: 48,
|
|
10
|
+
AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET: 2,
|
|
11
|
+
AZTEC_LAG_IN_EPOCHS_FOR_RANDAO: 2,
|
|
12
|
+
AZTEC_ACTIVATION_THRESHOLD: 100000000000000000000,
|
|
13
|
+
AZTEC_EJECTION_THRESHOLD: 50000000000000000000,
|
|
14
|
+
AZTEC_LOCAL_EJECTION_THRESHOLD: 98000000000000000000,
|
|
15
|
+
AZTEC_EXIT_DELAY_SECONDS: 172800,
|
|
16
|
+
AZTEC_INBOX_LAG: 1,
|
|
17
|
+
AZTEC_PROOF_SUBMISSION_EPOCHS: 1,
|
|
18
|
+
AZTEC_MANA_TARGET: 100000000,
|
|
19
|
+
AZTEC_PROVING_COST_PER_MANA: 100,
|
|
20
|
+
AZTEC_INITIAL_ETH_PER_FEE_ASSET: 10000000,
|
|
21
|
+
AZTEC_SLASHER_FLAVOR: 'tally',
|
|
22
|
+
AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS: 4,
|
|
23
|
+
AZTEC_SLASHING_LIFETIME_IN_ROUNDS: 5,
|
|
24
|
+
AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS: 0,
|
|
25
|
+
AZTEC_SLASHING_OFFSET_IN_ROUNDS: 2,
|
|
26
|
+
AZTEC_SLASHING_VETOER: '0x0000000000000000000000000000000000000000',
|
|
27
|
+
AZTEC_SLASHING_DISABLE_DURATION: 432000,
|
|
28
|
+
AZTEC_SLASH_AMOUNT_SMALL: 10000000000000000000,
|
|
29
|
+
AZTEC_SLASH_AMOUNT_MEDIUM: 20000000000000000000,
|
|
30
|
+
AZTEC_SLASH_AMOUNT_LARGE: 50000000000000000000,
|
|
31
|
+
AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE: 300,
|
|
32
|
+
} as const;
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
getConfigFromMappings,
|
|
6
6
|
getDefaultConfig,
|
|
7
7
|
numberConfigHelper,
|
|
8
|
+
optionalNumberConfigHelper,
|
|
8
9
|
} from '@aztec/foundation/config';
|
|
9
10
|
|
|
10
11
|
export interface L1TxUtilsConfig {
|
|
@@ -60,6 +61,12 @@ export interface L1TxUtilsConfig {
|
|
|
60
61
|
* How long a tx nonce can be unseen in the mempool before considering it dropped
|
|
61
62
|
*/
|
|
62
63
|
txUnseenConsideredDroppedMs?: number;
|
|
64
|
+
/** Enable tx delayer. When true, wraps the viem client to intercept and delay txs. Test-only. */
|
|
65
|
+
enableDelayer?: boolean;
|
|
66
|
+
/** Max seconds into an L1 slot for tx inclusion. Txs sent later are deferred to next slot. Only used when enableDelayer is true. */
|
|
67
|
+
txDelayerMaxInclusionTimeIntoSlot?: number;
|
|
68
|
+
/** How many seconds an L1 slot lasts. */
|
|
69
|
+
ethereumSlotDuration?: number;
|
|
63
70
|
}
|
|
64
71
|
|
|
65
72
|
export const l1TxUtilsConfigMappings: ConfigMappingsType<L1TxUtilsConfig> = {
|
|
@@ -142,6 +149,19 @@ export const l1TxUtilsConfigMappings: ConfigMappingsType<L1TxUtilsConfig> = {
|
|
|
142
149
|
env: 'L1_TX_MONITOR_TX_UNSEEN_CONSIDERED_DROPPED_MS',
|
|
143
150
|
...numberConfigHelper(6 * 12 * 1000), // 6 L1 blocks
|
|
144
151
|
},
|
|
152
|
+
enableDelayer: {
|
|
153
|
+
description: 'Enable tx delayer for testing.',
|
|
154
|
+
...booleanConfigHelper(false),
|
|
155
|
+
},
|
|
156
|
+
txDelayerMaxInclusionTimeIntoSlot: {
|
|
157
|
+
description: 'Max seconds into L1 slot for tx inclusion when delayer is enabled.',
|
|
158
|
+
...optionalNumberConfigHelper(),
|
|
159
|
+
},
|
|
160
|
+
ethereumSlotDuration: {
|
|
161
|
+
env: 'ETHEREUM_SLOT_DURATION',
|
|
162
|
+
description: 'How many seconds an L1 slot lasts.',
|
|
163
|
+
...numberConfigHelper(12),
|
|
164
|
+
},
|
|
145
165
|
};
|
|
146
166
|
|
|
147
167
|
// We abuse the fact that all mappings above have a non null default value and force-type this to Required
|
|
@@ -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
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
+
import type { BlobKzgInstance } from '@aztec/blob-lib/types';
|
|
1
2
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
3
|
import type { Logger } from '@aztec/foundation/log';
|
|
3
4
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
4
5
|
|
|
5
|
-
import type { TransactionSerializable } from 'viem';
|
|
6
|
-
|
|
7
6
|
import type { EthSigner } from '../eth-signer/eth-signer.js';
|
|
8
7
|
import type { ExtendedViemWalletClient, ViemClient } from '../types.js';
|
|
9
8
|
import type { L1TxUtilsConfig } from './config.js';
|
|
10
9
|
import type { IL1TxMetrics, IL1TxStore } from './interfaces.js';
|
|
11
10
|
import { L1TxUtils } from './l1_tx_utils.js';
|
|
12
11
|
import { createViemSigner } from './signer.js';
|
|
12
|
+
import { Delayer } from './tx_delayer.js';
|
|
13
13
|
import type { SigningCallback } from './types.js';
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
/** Source of signing capability: either a wallet client or a separate client + signer. */
|
|
16
|
+
export type L1SignerSource = ExtendedViemWalletClient | { client: ViemClient; signer: EthSigner };
|
|
17
|
+
|
|
18
|
+
export function resolveSignerSource(source: L1SignerSource): {
|
|
19
|
+
client: ViemClient;
|
|
20
|
+
address: EthAddress;
|
|
21
|
+
signingCallback: SigningCallback;
|
|
22
|
+
} {
|
|
23
|
+
if ('account' in source && source.account) {
|
|
24
|
+
return {
|
|
25
|
+
client: source as ExtendedViemWalletClient,
|
|
26
|
+
address: EthAddress.fromString((source as ExtendedViemWalletClient).account.address),
|
|
27
|
+
signingCallback: createViemSigner(source as ExtendedViemWalletClient),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const { client, signer } = source as { client: ViemClient; signer: EthSigner };
|
|
31
|
+
return {
|
|
26
32
|
client,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
deps?.dateProvider,
|
|
31
|
-
config,
|
|
32
|
-
config?.debugMaxGasLimit ?? false,
|
|
33
|
-
deps?.store,
|
|
34
|
-
deps?.metrics,
|
|
35
|
-
);
|
|
33
|
+
address: signer.address,
|
|
34
|
+
signingCallback: async (tx, _addr) => (await signer.signTransaction(tx)).toViemTransactionSignature(),
|
|
35
|
+
};
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export function
|
|
39
|
-
|
|
40
|
-
signer: EthSigner,
|
|
38
|
+
export function createL1TxUtils(
|
|
39
|
+
source: L1SignerSource,
|
|
41
40
|
deps?: {
|
|
42
41
|
logger?: Logger;
|
|
43
42
|
dateProvider?: DateProvider;
|
|
44
43
|
store?: IL1TxStore;
|
|
45
44
|
metrics?: IL1TxMetrics;
|
|
45
|
+
kzg?: BlobKzgInstance;
|
|
46
|
+
delayer?: Delayer;
|
|
46
47
|
},
|
|
47
48
|
config?: Partial<L1TxUtilsConfig> & { debugMaxGasLimit?: boolean },
|
|
48
49
|
): L1TxUtils {
|
|
49
|
-
const
|
|
50
|
-
return (await signer.signTransaction(transaction)).toViemTransactionSignature();
|
|
51
|
-
};
|
|
52
|
-
|
|
50
|
+
const { client, address, signingCallback } = resolveSignerSource(source);
|
|
53
51
|
return new L1TxUtils(
|
|
54
52
|
client,
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
address,
|
|
54
|
+
signingCallback,
|
|
57
55
|
deps?.logger,
|
|
58
56
|
deps?.dateProvider,
|
|
59
57
|
config,
|
|
60
58
|
config?.debugMaxGasLimit ?? false,
|
|
61
59
|
deps?.store,
|
|
62
60
|
deps?.metrics,
|
|
61
|
+
deps?.kzg,
|
|
62
|
+
deps?.delayer,
|
|
63
63
|
);
|
|
64
64
|
}
|
|
@@ -4,13 +4,13 @@ import type { PriorityFeeStrategy } from './types.js';
|
|
|
4
4
|
|
|
5
5
|
export {
|
|
6
6
|
HISTORICAL_BLOCK_COUNT,
|
|
7
|
-
executeStrategy,
|
|
8
7
|
type PriorityFeeStrategy,
|
|
9
8
|
type PriorityFeeStrategyContext,
|
|
10
9
|
type PriorityFeeStrategyResult,
|
|
11
10
|
} from './types.js';
|
|
12
11
|
|
|
13
12
|
export { P75AllTxsPriorityFeeStrategy } from './p75_competitive.js';
|
|
13
|
+
export { P75BlobTxsOnlyPriorityFeeStrategy } from './p75_competitive_blob_txs_only.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Default list of priority fee strategies to analyze.
|