@aztec/ethereum 3.0.3 → 3.9.9-nightly.20260312
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.js +6 -2
- package/dest/config.d.ts +19 -27
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +60 -55
- package/dest/contracts/empire_base.d.ts +4 -1
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/empire_slashing_proposer.d.ts +4 -1
- package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/empire_slashing_proposer.js +31 -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 +4 -1
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +404 -9
- package/dest/contracts/inbox.d.ts +22 -1
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +36 -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/registry.d.ts +3 -1
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/registry.js +30 -1
- package/dest/contracts/rollup.d.ts +163 -81
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +703 -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 +18 -4
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_aztec_l1_contracts.js +117 -35
- 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 +5975 -1575
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_contract_addresses.d.ts +1 -1
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +3 -3
- 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 +8 -2
- package/dest/l1_tx_utils/constants.d.ts.map +1 -1
- package/dest/l1_tx_utils/constants.js +27 -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 +10 -0
- package/dest/l1_tx_utils/fee-strategies/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/index.js +12 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts +8 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive.js +129 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts +23 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.js +191 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts +51 -0
- package/dest/l1_tx_utils/fee-strategies/types.d.ts.map +1 -0
- package/dest/l1_tx_utils/fee-strategies/types.js +3 -0
- 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 +4 -1
- package/dest/l1_tx_utils/index.d.ts.map +1 -1
- package/dest/l1_tx_utils/index.js +3 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts +233 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_fee_analyzer.js +506 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts +18 -7
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +58 -42
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +4 -15
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +43 -147
- 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 +12 -4
- 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/eth_cheat_codes.js +3 -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 +22 -3
- package/dest/test/start_anvil.js +1 -1
- package/dest/test/upgrade_utils.js +2 -2
- package/dest/utils.d.ts +15 -2
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +64 -0
- package/package.json +9 -7
- package/src/client.ts +2 -2
- package/src/config.ts +76 -54
- package/src/contracts/README.md +157 -0
- package/src/contracts/empire_base.ts +3 -1
- package/src/contracts/empire_slashing_proposer.ts +28 -28
- 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 +16 -2
- package/src/contracts/inbox.ts +53 -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/registry.ts +31 -1
- package/src/contracts/rollup.ts +382 -94
- package/src/contracts/tally_slashing_proposer.ts +5 -1
- package/src/deploy_aztec_l1_contracts.ts +147 -44
- package/src/deploy_l1_contract.ts +3 -3
- package/src/generated/l1-contracts-defaults.ts +32 -0
- package/src/l1_contract_addresses.ts +22 -20
- package/src/l1_tx_utils/config.ts +20 -0
- package/src/l1_tx_utils/constants.ts +13 -2
- package/src/l1_tx_utils/factory.ts +31 -31
- package/src/l1_tx_utils/fee-strategies/index.ts +22 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive.ts +163 -0
- package/src/l1_tx_utils/fee-strategies/p75_competitive_blob_txs_only.ts +245 -0
- package/src/l1_tx_utils/fee-strategies/types.ts +56 -0
- 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 +3 -0
- package/src/l1_tx_utils/l1_fee_analyzer.ts +803 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +60 -32
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +56 -190
- package/src/{test → l1_tx_utils}/tx_delayer.ts +78 -50
- package/src/publisher_manager.ts +4 -2
- package/src/queries.ts +11 -3
- package/src/test/chain_monitor.ts +1 -1
- package/src/test/eth_cheat_codes.ts +1 -1
- package/src/test/index.ts +0 -2
- package/src/test/rollup_cheat_codes.ts +22 -4
- package/src/test/start_anvil.ts +1 -1
- package/src/test/upgrade_utils.ts +2 -2
- package/src/utils.ts +82 -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,19 +318,25 @@ 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);
|
|
248
326
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
|
|
327
|
+
// Verify contracts on Etherscan when on mainnet/sepolia and ETHERSCAN_API_KEY is available.
|
|
328
|
+
const isVerifiableChain = chainId === mainnet.id || chainId === sepolia.id;
|
|
329
|
+
const shouldVerify = isVerifiableChain && !!process.env.ETHERSCAN_API_KEY;
|
|
330
|
+
|
|
331
|
+
if (isVerifiableChain && !process.env.ETHERSCAN_API_KEY) {
|
|
332
|
+
logger.warn(
|
|
333
|
+
`Deploying to chain ${chainId} (${chainId === mainnet.id ? 'mainnet' : 'sepolia'}) without ETHERSCAN_API_KEY. ` +
|
|
334
|
+
`Contracts will NOT be verified on Etherscan. Set ETHERSCAN_API_KEY environment variable to enable verification.`,
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
const scriptPath = join(getL1ContractsPath(), 'scripts', 'forge_broadcast.js');
|
|
254
339
|
const forgeArgs = [
|
|
255
|
-
'script',
|
|
256
340
|
FORGE_SCRIPT,
|
|
257
341
|
'--sig',
|
|
258
342
|
'run()',
|
|
@@ -260,8 +344,6 @@ export async function deployAztecL1Contracts(
|
|
|
260
344
|
privateKey,
|
|
261
345
|
'--rpc-url',
|
|
262
346
|
rpcUrl,
|
|
263
|
-
'--broadcast',
|
|
264
|
-
...(chainId === foundry.id ? ['--batch-size', MAGIC_ANVIL_BATCH_SIZE.toString()] : []),
|
|
265
347
|
...(shouldVerify ? ['--verify'] : []),
|
|
266
348
|
];
|
|
267
349
|
const forgeEnv = {
|
|
@@ -270,7 +352,12 @@ export async function deployAztecL1Contracts(
|
|
|
270
352
|
FOUNDRY_PROFILE: chainId === mainnet.id ? 'production' : undefined,
|
|
271
353
|
...getDeployAztecL1ContractsEnvVars(args),
|
|
272
354
|
};
|
|
273
|
-
const result = await runProcess<ForgeL1ContractsDeployResult>(
|
|
355
|
+
const result = await runProcess<ForgeL1ContractsDeployResult>(
|
|
356
|
+
process.execPath,
|
|
357
|
+
[scriptPath, ...forgeArgs],
|
|
358
|
+
forgeEnv,
|
|
359
|
+
l1ContractsPath,
|
|
360
|
+
);
|
|
274
361
|
if (!result) {
|
|
275
362
|
throw new Error('Forge script did not output deployment result');
|
|
276
363
|
}
|
|
@@ -403,7 +490,25 @@ export type VerificationRecord = {
|
|
|
403
490
|
libraries: VerificationLibraryEntry[];
|
|
404
491
|
};
|
|
405
492
|
|
|
406
|
-
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
|
+
> {
|
|
407
512
|
/** The vk tree root. */
|
|
408
513
|
vkTreeRoot: Fr;
|
|
409
514
|
/** The hash of the protocol contracts. */
|
|
@@ -438,6 +543,7 @@ export function getDeployAztecL1ContractsEnvVars(args: DeployAztecL1ContractsArg
|
|
|
438
543
|
AZTEC_EJECTION_THRESHOLD: args.ejectionThreshold?.toString(),
|
|
439
544
|
AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE: args.governanceProposerRoundSize?.toString(),
|
|
440
545
|
AZTEC_GOVERNANCE_PROPOSER_QUORUM: args.governanceProposerQuorum?.toString(),
|
|
546
|
+
AZTEC_GOVERNANCE_VOTING_DURATION: args.governanceVotingDuration?.toString(),
|
|
441
547
|
ZKPASSPORT_DOMAIN: args.zkPassportArgs?.zkPassportDomain,
|
|
442
548
|
ZKPASSPORT_SCOPE: args.zkPassportArgs?.zkPassportScope,
|
|
443
549
|
} as const;
|
|
@@ -468,14 +574,17 @@ export function getDeployRollupForUpgradeEnvVars(
|
|
|
468
574
|
AZTEC_TARGET_COMMITTEE_SIZE: args.aztecTargetCommitteeSize.toString(),
|
|
469
575
|
AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET: args.lagInEpochsForValidatorSet.toString(),
|
|
470
576
|
AZTEC_LAG_IN_EPOCHS_FOR_RANDAO: args.lagInEpochsForRandao.toString(),
|
|
577
|
+
AZTEC_INBOX_LAG: args.inboxLag?.toString(),
|
|
471
578
|
AZTEC_PROOF_SUBMISSION_EPOCHS: args.aztecProofSubmissionEpochs.toString(),
|
|
472
579
|
AZTEC_LOCAL_EJECTION_THRESHOLD: args.localEjectionThreshold.toString(),
|
|
473
580
|
AZTEC_SLASHING_LIFETIME_IN_ROUNDS: args.slashingLifetimeInRounds.toString(),
|
|
581
|
+
AZTEC_SLASHING_EXECUTION_DELAY_IN_ROUNDS: args.slashingExecutionDelayInRounds.toString(),
|
|
474
582
|
AZTEC_SLASHING_VETOER: args.slashingVetoer.toString(),
|
|
475
583
|
AZTEC_SLASHING_DISABLE_DURATION: args.slashingDisableDuration.toString(),
|
|
476
584
|
AZTEC_MANA_TARGET: args.manaTarget.toString(),
|
|
477
585
|
AZTEC_EXIT_DELAY_SECONDS: args.exitDelaySeconds.toString(),
|
|
478
586
|
AZTEC_PROVING_COST_PER_MANA: args.provingCostPerMana.toString(),
|
|
587
|
+
AZTEC_INITIAL_ETH_PER_FEE_ASSET: args.initialEthPerFeeAsset.toString(),
|
|
479
588
|
AZTEC_SLASHER_FLAVOR: args.slasherFlavor,
|
|
480
589
|
AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS: args.slashingRoundSizeInEpochs.toString(),
|
|
481
590
|
AZTEC_SLASHING_QUORUM: args.slashingQuorum?.toString(),
|
|
@@ -503,25 +612,14 @@ export const deployRollupForUpgrade = async (
|
|
|
503
612
|
| 'zkPassportArgs'
|
|
504
613
|
>,
|
|
505
614
|
) => {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
// Relative location of l1-contracts in monorepo or docker image.
|
|
509
|
-
const l1ContractsPath = resolve(currentDir, '..', '..', '..', 'l1-contracts');
|
|
615
|
+
// Use foundry-artifacts from l1-artifacts package
|
|
616
|
+
const l1ContractsPath = prepareL1ContractsForDeployment();
|
|
510
617
|
|
|
511
618
|
const FORGE_SCRIPT = 'script/deploy/DeployRollupForUpgrade.s.sol';
|
|
512
619
|
await maybeForgeForceProductionBuild(l1ContractsPath, FORGE_SCRIPT, chainId);
|
|
513
620
|
|
|
514
|
-
const
|
|
515
|
-
|
|
516
|
-
FORGE_SCRIPT,
|
|
517
|
-
'--sig',
|
|
518
|
-
'run()',
|
|
519
|
-
'--private-key',
|
|
520
|
-
privateKey,
|
|
521
|
-
'--rpc-url',
|
|
522
|
-
rpcUrl,
|
|
523
|
-
'--broadcast',
|
|
524
|
-
];
|
|
621
|
+
const scriptPath = join(getL1ContractsPath(), 'scripts', 'forge_broadcast.js');
|
|
622
|
+
const forgeArgs = [FORGE_SCRIPT, '--sig', 'run()', '--private-key', privateKey, '--rpc-url', rpcUrl];
|
|
525
623
|
const forgeEnv = {
|
|
526
624
|
FOUNDRY_PROFILE: chainId === mainnet.id ? 'production' : undefined,
|
|
527
625
|
// Env vars required by l1-contracts/script/deploy/RollupConfiguration.sol.
|
|
@@ -530,7 +628,12 @@ export const deployRollupForUpgrade = async (
|
|
|
530
628
|
...getDeployRollupForUpgradeEnvVars(args),
|
|
531
629
|
};
|
|
532
630
|
|
|
533
|
-
const result = await runProcess<ForgeRollupUpgradeResult>(
|
|
631
|
+
const result = await runProcess<ForgeRollupUpgradeResult>(
|
|
632
|
+
process.execPath,
|
|
633
|
+
[scriptPath, ...forgeArgs],
|
|
634
|
+
forgeEnv,
|
|
635
|
+
l1ContractsPath,
|
|
636
|
+
);
|
|
534
637
|
if (!result) {
|
|
535
638
|
throw new Error('Forge script did not output deployment result');
|
|
536
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: 72,
|
|
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: 1,
|
|
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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ConfigMappingsType } from '@aztec/foundation/config';
|
|
2
2
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
-
import {
|
|
3
|
+
import { schemas, zodFor } from '@aztec/foundation/schemas';
|
|
4
4
|
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
|
|
@@ -35,25 +35,27 @@ export type L1ContractAddresses = {
|
|
|
35
35
|
dateGatedRelayerAddress?: EthAddress | undefined;
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
export const L1ContractAddressesSchema =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
38
|
+
export const L1ContractAddressesSchema = zodFor<L1ContractAddresses>()(
|
|
39
|
+
z.object({
|
|
40
|
+
rollupAddress: schemas.EthAddress,
|
|
41
|
+
registryAddress: schemas.EthAddress,
|
|
42
|
+
inboxAddress: schemas.EthAddress,
|
|
43
|
+
outboxAddress: schemas.EthAddress,
|
|
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
|
+
);
|
|
57
59
|
|
|
58
60
|
const parseEnv = (val: string) => EthAddress.fromString(val);
|
|
59
61
|
|
|
@@ -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
|
|
@@ -16,3 +16,14 @@ export const MIN_BLOB_REPLACEMENT_BUMP_PERCENTAGE = 100;
|
|
|
16
16
|
|
|
17
17
|
// Avg ethereum block time is ~12s
|
|
18
18
|
export const BLOCK_TIME_MS = 12_000;
|
|
19
|
+
|
|
20
|
+
// Gas per blob (EIP-4844)
|
|
21
|
+
export const GAS_PER_BLOB = 131072n;
|
|
22
|
+
|
|
23
|
+
// Blob capacity schedule based on Ethereum upgrades
|
|
24
|
+
export const BLOB_CAPACITY_SCHEDULE = [
|
|
25
|
+
{ timestamp: 1734357600, target: 14, max: 21 }, // BPO2: Dec 17, 2025
|
|
26
|
+
{ timestamp: 1733752800, target: 10, max: 15 }, // BPO1: Dec 9, 2025
|
|
27
|
+
{ timestamp: 1733234400, target: 6, max: 9 }, // Fusaka: Dec 3, 2025
|
|
28
|
+
{ timestamp: 0, target: 6, max: 9 }, // Pectra/earlier
|
|
29
|
+
];
|
|
@@ -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
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { P75AllTxsPriorityFeeStrategy } from './p75_competitive.js';
|
|
2
|
+
import { P75BlobTxsOnlyPriorityFeeStrategy } from './p75_competitive_blob_txs_only.js';
|
|
3
|
+
import type { PriorityFeeStrategy } from './types.js';
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
HISTORICAL_BLOCK_COUNT,
|
|
7
|
+
type PriorityFeeStrategy,
|
|
8
|
+
type PriorityFeeStrategyContext,
|
|
9
|
+
type PriorityFeeStrategyResult,
|
|
10
|
+
} from './types.js';
|
|
11
|
+
|
|
12
|
+
export { P75AllTxsPriorityFeeStrategy } from './p75_competitive.js';
|
|
13
|
+
export { P75BlobTxsOnlyPriorityFeeStrategy } from './p75_competitive_blob_txs_only.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Default list of priority fee strategies to analyze.
|
|
17
|
+
* Add more strategies here for comparison.
|
|
18
|
+
*/
|
|
19
|
+
export const DEFAULT_PRIORITY_FEE_STRATEGIES: PriorityFeeStrategy[] = [
|
|
20
|
+
P75AllTxsPriorityFeeStrategy,
|
|
21
|
+
P75BlobTxsOnlyPriorityFeeStrategy,
|
|
22
|
+
];
|