@aztec/ethereum 4.0.0-nightly.20250907 → 4.0.0-nightly.20260107
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/account.d.ts +1 -1
- package/dest/chain.d.ts +1 -1
- package/dest/client.d.ts +2 -2
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +6 -2
- package/dest/config.d.ts +18 -46
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +40 -285
- package/dest/constants.d.ts +1 -1
- package/dest/contracts/empire_base.d.ts +8 -6
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/empire_base.js +1 -1
- package/dest/contracts/empire_slashing_proposer.d.ts +8 -6
- package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/empire_slashing_proposer.js +18 -3
- package/dest/contracts/errors.d.ts +1 -1
- package/dest/contracts/errors.d.ts.map +1 -1
- package/dest/contracts/fee_asset_handler.d.ts +4 -4
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -1
- package/dest/contracts/fee_juice.d.ts +1 -1
- package/dest/contracts/fee_juice.d.ts.map +1 -1
- package/dest/contracts/governance.d.ts +16 -16
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +7 -3
- package/dest/contracts/governance_proposer.d.ts +7 -6
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +400 -12
- package/dest/contracts/gse.d.ts +1 -1
- package/dest/contracts/gse.d.ts.map +1 -1
- package/dest/contracts/inbox.d.ts +7 -3
- package/dest/contracts/inbox.d.ts.map +1 -1
- package/dest/contracts/inbox.js +4 -0
- package/dest/contracts/index.d.ts +1 -1
- package/dest/contracts/multicall.d.ts +5 -7
- package/dest/contracts/multicall.d.ts.map +1 -1
- package/dest/contracts/multicall.js +6 -4
- package/dest/contracts/registry.d.ts +1 -1
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/rollup.d.ts +168 -117
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +712 -241
- package/dest/contracts/slasher_contract.d.ts +11 -1
- package/dest/contracts/slasher_contract.d.ts.map +1 -1
- package/dest/contracts/slasher_contract.js +18 -0
- package/dest/contracts/tally_slashing_proposer.d.ts +15 -7
- package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -1
- package/dest/contracts/tally_slashing_proposer.js +15 -5
- package/dest/contracts/utils.d.ts +1 -1
- package/dest/deploy_aztec_l1_contracts.d.ts +247 -0
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
- package/dest/deploy_aztec_l1_contracts.js +336 -0
- package/dest/deploy_l1_contract.d.ts +68 -0
- package/dest/deploy_l1_contract.d.ts.map +1 -0
- package/dest/deploy_l1_contract.js +312 -0
- package/dest/eth-signer/eth-signer.d.ts +1 -1
- package/dest/eth-signer/index.d.ts +1 -1
- package/dest/forwarder_proxy.d.ts +32 -0
- package/dest/forwarder_proxy.d.ts.map +1 -0
- package/dest/forwarder_proxy.js +93 -0
- package/dest/l1_artifacts.d.ts +17698 -6245
- package/dest/l1_artifacts.d.ts.map +1 -1
- package/dest/l1_artifacts.js +10 -5
- package/dest/l1_contract_addresses.d.ts +8 -4
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +5 -4
- package/dest/l1_reader.d.ts +4 -2
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +7 -1
- package/dest/l1_tx_utils/config.d.ts +59 -0
- package/dest/l1_tx_utils/config.d.ts.map +1 -0
- package/dest/l1_tx_utils/config.js +96 -0
- package/dest/l1_tx_utils/constants.d.ts +12 -0
- package/dest/l1_tx_utils/constants.d.ts.map +1 -0
- package/dest/l1_tx_utils/constants.js +39 -0
- package/dest/l1_tx_utils/factory.d.ts +24 -0
- package/dest/l1_tx_utils/factory.d.ts.map +1 -0
- package/dest/l1_tx_utils/factory.js +12 -0
- 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 +41 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/forwarder_l1_tx_utils.js +48 -0
- package/dest/l1_tx_utils/index-blobs.d.ts +3 -0
- package/dest/l1_tx_utils/index-blobs.d.ts.map +1 -0
- package/dest/l1_tx_utils/index-blobs.js +2 -0
- package/dest/l1_tx_utils/index.d.ts +12 -0
- package/dest/l1_tx_utils/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/index.js +12 -0
- package/dest/l1_tx_utils/interfaces.d.ts +76 -0
- package/dest/l1_tx_utils/interfaces.d.ts.map +1 -0
- package/dest/l1_tx_utils/interfaces.js +4 -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 +94 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_tx_utils.js +623 -0
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts +26 -0
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_tx_utils_with_blobs.js +26 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +83 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +323 -0
- package/dest/l1_tx_utils/signer.d.ts +4 -0
- package/dest/l1_tx_utils/signer.d.ts.map +1 -0
- package/dest/l1_tx_utils/signer.js +16 -0
- package/dest/l1_tx_utils/types.d.ts +67 -0
- package/dest/l1_tx_utils/types.d.ts.map +1 -0
- package/dest/l1_tx_utils/types.js +26 -0
- package/dest/l1_tx_utils/utils.d.ts +4 -0
- package/dest/l1_tx_utils/utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/utils.js +14 -0
- package/dest/l1_types.d.ts +1 -1
- package/dest/publisher_manager.d.ts +8 -3
- package/dest/publisher_manager.d.ts.map +1 -1
- package/dest/publisher_manager.js +36 -8
- package/dest/queries.d.ts +1 -1
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +20 -14
- package/dest/test/chain_monitor.d.ts +29 -22
- package/dest/test/chain_monitor.d.ts.map +1 -1
- package/dest/test/chain_monitor.js +81 -38
- package/dest/test/delayed_tx_utils.d.ts +3 -3
- package/dest/test/delayed_tx_utils.d.ts.map +1 -1
- package/dest/test/delayed_tx_utils.js +2 -2
- package/dest/test/eth_cheat_codes.d.ts +36 -14
- package/dest/test/eth_cheat_codes.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes.js +126 -31
- package/dest/test/eth_cheat_codes_with_state.d.ts +1 -1
- package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
- package/dest/test/index.d.ts +1 -1
- package/dest/test/rollup_cheat_codes.d.ts +23 -20
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -1
- package/dest/test/rollup_cheat_codes.js +82 -43
- package/dest/test/start_anvil.d.ts +4 -1
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +2 -1
- package/dest/test/tx_delayer.d.ts +1 -1
- package/dest/test/tx_delayer.d.ts.map +1 -1
- package/dest/test/tx_delayer.js +4 -3
- package/dest/test/upgrade_utils.d.ts +1 -1
- package/dest/test/upgrade_utils.d.ts.map +1 -1
- package/dest/test/upgrade_utils.js +3 -2
- package/dest/types.d.ts +57 -2
- package/dest/types.d.ts.map +1 -1
- package/dest/utils.d.ts +15 -3
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +28 -161
- package/dest/zkPassportVerifierAddress.d.ts +1 -1
- package/dest/zkPassportVerifierAddress.js +1 -1
- package/package.json +33 -14
- package/src/client.ts +3 -3
- package/src/config.ts +49 -358
- package/src/contracts/empire_base.ts +7 -6
- package/src/contracts/empire_slashing_proposer.ts +23 -8
- package/src/contracts/fee_asset_handler.ts +1 -1
- package/src/contracts/governance.ts +3 -3
- package/src/contracts/governance_proposer.ts +19 -9
- package/src/contracts/inbox.ts +7 -2
- package/src/contracts/multicall.ts +12 -10
- package/src/contracts/rollup.ts +373 -235
- package/src/contracts/slasher_contract.ts +22 -0
- package/src/contracts/tally_slashing_proposer.ts +21 -9
- package/src/deploy_aztec_l1_contracts.ts +557 -0
- package/src/deploy_l1_contract.ts +362 -0
- package/src/forwarder_proxy.ts +108 -0
- package/src/l1_artifacts.ts +14 -6
- package/src/l1_contract_addresses.ts +24 -20
- package/src/l1_reader.ts +10 -2
- package/src/l1_tx_utils/README.md +177 -0
- package/src/l1_tx_utils/config.ts +161 -0
- package/src/l1_tx_utils/constants.ts +29 -0
- package/src/l1_tx_utils/factory.ts +64 -0
- 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 +119 -0
- package/src/l1_tx_utils/index-blobs.ts +2 -0
- package/src/l1_tx_utils/index.ts +14 -0
- package/src/l1_tx_utils/interfaces.ts +86 -0
- package/src/l1_tx_utils/l1_fee_analyzer.ts +803 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +738 -0
- package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +77 -0
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +419 -0
- package/src/l1_tx_utils/signer.ts +28 -0
- package/src/l1_tx_utils/types.ts +85 -0
- package/src/l1_tx_utils/utils.ts +16 -0
- package/src/publisher_manager.ts +51 -9
- package/src/queries.ts +24 -10
- package/src/test/chain_monitor.ts +102 -44
- package/src/test/delayed_tx_utils.ts +2 -2
- package/src/test/eth_cheat_codes.ts +150 -31
- package/src/test/rollup_cheat_codes.ts +95 -53
- package/src/test/start_anvil.ts +4 -0
- package/src/test/tx_delayer.ts +5 -3
- package/src/test/upgrade_utils.ts +3 -2
- package/src/types.ts +62 -0
- package/src/utils.ts +41 -184
- package/src/zkPassportVerifierAddress.ts +1 -1
- package/dest/deploy_l1_contracts.d.ts +0 -211
- package/dest/deploy_l1_contracts.d.ts.map +0 -1
- package/dest/deploy_l1_contracts.js +0 -1267
- package/dest/index.d.ts +0 -18
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -17
- package/dest/l1_tx_utils.d.ts +0 -250
- package/dest/l1_tx_utils.d.ts.map +0 -1
- package/dest/l1_tx_utils.js +0 -826
- package/dest/l1_tx_utils_with_blobs.d.ts +0 -19
- package/dest/l1_tx_utils_with_blobs.d.ts.map +0 -1
- package/dest/l1_tx_utils_with_blobs.js +0 -85
- package/src/deploy_l1_contracts.ts +0 -1596
- package/src/index.ts +0 -17
- package/src/l1_tx_utils.ts +0 -1105
- package/src/l1_tx_utils_with_blobs.ts +0 -144
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
4
|
+
import { concatHex, encodeAbiParameters, encodeDeployData, getContractAddress, numberToHex, padHex } from 'viem';
|
|
5
|
+
import { DEPLOYER_ADDRESS } from './deploy_aztec_l1_contracts.js';
|
|
6
|
+
import { RegisterNewRollupVersionPayloadArtifact } from './l1_artifacts.js';
|
|
7
|
+
import { getL1TxUtilsConfigEnvVars } from './l1_tx_utils/config.js';
|
|
8
|
+
import { createL1TxUtilsFromViemWallet } from './l1_tx_utils/factory.js';
|
|
9
|
+
import { formatViemError } from './utils.js';
|
|
10
|
+
export class L1Deployer {
|
|
11
|
+
client;
|
|
12
|
+
acceleratedTestDeployments;
|
|
13
|
+
logger;
|
|
14
|
+
txUtilsConfig;
|
|
15
|
+
createVerificationJson;
|
|
16
|
+
salt;
|
|
17
|
+
txHashes;
|
|
18
|
+
l1TxUtils;
|
|
19
|
+
verificationRecords;
|
|
20
|
+
constructor(client, maybeSalt, dateProvider = new DateProvider(), acceleratedTestDeployments = false, logger = createLogger('L1Deployer'), txUtilsConfig, createVerificationJson = false){
|
|
21
|
+
this.client = client;
|
|
22
|
+
this.acceleratedTestDeployments = acceleratedTestDeployments;
|
|
23
|
+
this.logger = logger;
|
|
24
|
+
this.txUtilsConfig = txUtilsConfig;
|
|
25
|
+
this.createVerificationJson = createVerificationJson;
|
|
26
|
+
this.txHashes = [];
|
|
27
|
+
this.verificationRecords = [];
|
|
28
|
+
this.salt = maybeSalt ? padHex(numberToHex(maybeSalt), {
|
|
29
|
+
size: 32
|
|
30
|
+
}) : undefined;
|
|
31
|
+
this.l1TxUtils = createL1TxUtilsFromViemWallet(this.client, {
|
|
32
|
+
logger: this.logger,
|
|
33
|
+
dateProvider
|
|
34
|
+
}, {
|
|
35
|
+
...this.txUtilsConfig,
|
|
36
|
+
debugMaxGasLimit: acceleratedTestDeployments
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
async deploy(params, args, opts = {}) {
|
|
40
|
+
this.logger.debug(`Deploying ${params.name} contract`, {
|
|
41
|
+
args
|
|
42
|
+
});
|
|
43
|
+
try {
|
|
44
|
+
const { txHash, address, deployedLibraries, existed } = await deployL1Contract(this.client, params.contractAbi, params.contractBytecode, args ?? [], {
|
|
45
|
+
salt: this.salt,
|
|
46
|
+
libraries: params.libraries,
|
|
47
|
+
logger: this.logger,
|
|
48
|
+
l1TxUtils: this.l1TxUtils,
|
|
49
|
+
acceleratedTestDeployments: this.acceleratedTestDeployments,
|
|
50
|
+
gasLimit: opts.gasLimit,
|
|
51
|
+
noSimulation: opts.noSimulation
|
|
52
|
+
});
|
|
53
|
+
if (txHash) {
|
|
54
|
+
this.txHashes.push(txHash);
|
|
55
|
+
}
|
|
56
|
+
this.logger.debug(`Deployed ${params.name} at ${address}`, {
|
|
57
|
+
args
|
|
58
|
+
});
|
|
59
|
+
if (this.createVerificationJson) {
|
|
60
|
+
// Encode constructor args for verification
|
|
61
|
+
let constructorArgsHex = '0x';
|
|
62
|
+
try {
|
|
63
|
+
const abiItem = params.contractAbi.find((x)=>x && x.type === 'constructor');
|
|
64
|
+
const inputDefs = abiItem && Array.isArray(abiItem.inputs) ? abiItem.inputs : [];
|
|
65
|
+
constructorArgsHex = inputDefs.length > 0 ? encodeAbiParameters(inputDefs, args ?? []) : '0x';
|
|
66
|
+
} catch {
|
|
67
|
+
constructorArgsHex = '0x';
|
|
68
|
+
}
|
|
69
|
+
this.verificationRecords.push({
|
|
70
|
+
name: params.name,
|
|
71
|
+
address: address.toString(),
|
|
72
|
+
constructorArgsHex,
|
|
73
|
+
libraries: deployedLibraries ?? []
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
address,
|
|
78
|
+
existed
|
|
79
|
+
};
|
|
80
|
+
} catch (error) {
|
|
81
|
+
throw new Error(`Failed to deploy ${params.name}`, {
|
|
82
|
+
cause: formatViemError(error)
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async waitForDeployments() {
|
|
87
|
+
if (this.acceleratedTestDeployments) {
|
|
88
|
+
this.logger.info('Accelerated test deployments - skipping waiting for deployments');
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (this.txHashes.length === 0) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
this.logger.verbose(`Waiting for ${this.txHashes.length} transactions to be mined`, {
|
|
95
|
+
txHashes: this.txHashes
|
|
96
|
+
});
|
|
97
|
+
const receipts = await Promise.all(this.txHashes.map((txHash)=>this.client.waitForTransactionReceipt({
|
|
98
|
+
hash: txHash
|
|
99
|
+
})));
|
|
100
|
+
const failed = receipts.filter((r)=>r.status !== 'success');
|
|
101
|
+
if (failed.length > 0) {
|
|
102
|
+
throw new Error(`Some deployment txs have failed: ${failed.map((f)=>f.transactionHash).join(', ')}`);
|
|
103
|
+
}
|
|
104
|
+
this.logger.info('All transactions mined successfully', {
|
|
105
|
+
txHashes: this.txHashes
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
sendTransaction(tx, options) {
|
|
109
|
+
return this.l1TxUtils.sendTransaction(tx, options).then(({ txHash, state })=>({
|
|
110
|
+
txHash,
|
|
111
|
+
gasLimit: state.gasLimit,
|
|
112
|
+
gasPrice: state.gasPrice
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Helper function to deploy ETH contracts.
|
|
118
|
+
* @param walletClient - A viem WalletClient.
|
|
119
|
+
* @param publicClient - A viem PublicClient.
|
|
120
|
+
* @param abi - The ETH contract's ABI (as abitype's Abi).
|
|
121
|
+
* @param bytecode - The ETH contract's bytecode.
|
|
122
|
+
* @param args - Constructor arguments for the contract.
|
|
123
|
+
* @param salt - Optional salt for CREATE2 deployment (does not wait for deployment tx to be mined if set, does not send tx if contract already exists).
|
|
124
|
+
* @returns The ETH address the contract was deployed to.
|
|
125
|
+
*/ export async function deployL1Contract(extendedClient, abi, bytecode, args = [], opts = {}) {
|
|
126
|
+
let txHash = undefined;
|
|
127
|
+
let resultingAddress = undefined;
|
|
128
|
+
const deployedLibraries = [];
|
|
129
|
+
const { salt: saltFromOpts, libraries, logger, gasLimit, acceleratedTestDeployments, noSimulation } = opts;
|
|
130
|
+
let { l1TxUtils } = opts;
|
|
131
|
+
if (!l1TxUtils) {
|
|
132
|
+
const config = getL1TxUtilsConfigEnvVars();
|
|
133
|
+
l1TxUtils = createL1TxUtilsFromViemWallet(extendedClient, {
|
|
134
|
+
logger
|
|
135
|
+
}, {
|
|
136
|
+
...config,
|
|
137
|
+
debugMaxGasLimit: acceleratedTestDeployments
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
if (libraries) {
|
|
141
|
+
// Note that this does NOT work well for linked libraries having linked libraries.
|
|
142
|
+
// Verify that all link references have corresponding code
|
|
143
|
+
for(const linkRef in libraries.linkReferences){
|
|
144
|
+
for(const contractName in libraries.linkReferences[linkRef]){
|
|
145
|
+
if (!libraries.libraryCode[contractName]) {
|
|
146
|
+
throw new Error(`Missing library code for ${contractName}`);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const replacements = {};
|
|
151
|
+
const libraryTxs = [];
|
|
152
|
+
for(const libraryName in libraries?.libraryCode){
|
|
153
|
+
const lib = libraries.libraryCode[libraryName];
|
|
154
|
+
const { libraries: _libraries, ...optsWithoutLibraries } = opts;
|
|
155
|
+
const { address, txHash } = await deployL1Contract(extendedClient, lib.contractAbi, lib.contractBytecode, [], optsWithoutLibraries);
|
|
156
|
+
// Log deployed library name and address for easier verification/triage
|
|
157
|
+
logger?.verbose(`Linked library deployed`, {
|
|
158
|
+
library: libraryName,
|
|
159
|
+
address: address.toString(),
|
|
160
|
+
txHash
|
|
161
|
+
});
|
|
162
|
+
if (txHash) {
|
|
163
|
+
libraryTxs.push(txHash);
|
|
164
|
+
}
|
|
165
|
+
// Try to find the source file for this library from linkReferences
|
|
166
|
+
let fileNameForLibrary = undefined;
|
|
167
|
+
for(const fileName in libraries.linkReferences){
|
|
168
|
+
if (libraries.linkReferences[fileName] && libraries.linkReferences[fileName][libraryName]) {
|
|
169
|
+
fileNameForLibrary = fileName;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (fileNameForLibrary) {
|
|
174
|
+
deployedLibraries.push({
|
|
175
|
+
file: fileNameForLibrary,
|
|
176
|
+
contract: libraryName,
|
|
177
|
+
address: address.toString()
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
for(const linkRef in libraries.linkReferences){
|
|
181
|
+
for(const contractName in libraries.linkReferences[linkRef]){
|
|
182
|
+
// If the library name matches the one we just deployed, we replace it.
|
|
183
|
+
if (contractName !== libraryName) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
// We read the first instance to figure out what we are to replace.
|
|
187
|
+
const start = 2 + 2 * libraries.linkReferences[linkRef][contractName][0].start;
|
|
188
|
+
const length = 2 * libraries.linkReferences[linkRef][contractName][0].length;
|
|
189
|
+
const toReplace = bytecode.slice(start, start + length);
|
|
190
|
+
replacements[toReplace] = address;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
const escapeRegExp = (s)=>{
|
|
195
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // Escape special characters
|
|
196
|
+
};
|
|
197
|
+
for(const toReplace in replacements){
|
|
198
|
+
const replacement = replacements[toReplace].toString().slice(2);
|
|
199
|
+
bytecode = bytecode.replace(new RegExp(escapeRegExp(toReplace), 'g'), replacement);
|
|
200
|
+
}
|
|
201
|
+
// Reth fails gas estimation if the deployed contract attempts to call a library that is not yet deployed,
|
|
202
|
+
// so we wait for all library deployments to be mined before deploying the contract.
|
|
203
|
+
// However, if we are in fast mode or using debugMaxGasLimit, we will skip simulation, so we can skip waiting.
|
|
204
|
+
if (libraryTxs.length > 0 && !acceleratedTestDeployments) {
|
|
205
|
+
logger?.verbose(`Awaiting for linked libraries to be deployed`);
|
|
206
|
+
await Promise.all(libraryTxs.map((txHash)=>extendedClient.waitForTransactionReceipt({
|
|
207
|
+
hash: txHash
|
|
208
|
+
})));
|
|
209
|
+
} else {
|
|
210
|
+
logger?.verbose(`Skipping waiting for linked libraries to be deployed ${acceleratedTestDeployments ? '(accelerated test deployments)' : ''}`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
let existed = false;
|
|
214
|
+
if (saltFromOpts) {
|
|
215
|
+
logger?.info(`Deploying contract with salt ${saltFromOpts}`);
|
|
216
|
+
const { address, paddedSalt: salt, calldata } = getExpectedAddress(abi, bytecode, args, saltFromOpts);
|
|
217
|
+
resultingAddress = address;
|
|
218
|
+
const existing = await extendedClient.getCode({
|
|
219
|
+
address: resultingAddress
|
|
220
|
+
});
|
|
221
|
+
if (existing === undefined || existing === '0x') {
|
|
222
|
+
if (!noSimulation) {
|
|
223
|
+
try {
|
|
224
|
+
await l1TxUtils.simulate({
|
|
225
|
+
to: DEPLOYER_ADDRESS,
|
|
226
|
+
data: concatHex([
|
|
227
|
+
salt,
|
|
228
|
+
calldata
|
|
229
|
+
]),
|
|
230
|
+
gas: gasLimit
|
|
231
|
+
});
|
|
232
|
+
} catch (err) {
|
|
233
|
+
logger?.error(`Failed to simulate deployment tx using universal deployer`, err);
|
|
234
|
+
await l1TxUtils.simulate({
|
|
235
|
+
to: null,
|
|
236
|
+
data: encodeDeployData({
|
|
237
|
+
abi,
|
|
238
|
+
bytecode,
|
|
239
|
+
args
|
|
240
|
+
}),
|
|
241
|
+
gas: gasLimit
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
const res = await l1TxUtils.sendTransaction({
|
|
246
|
+
to: DEPLOYER_ADDRESS,
|
|
247
|
+
data: concatHex([
|
|
248
|
+
salt,
|
|
249
|
+
calldata
|
|
250
|
+
])
|
|
251
|
+
}, {
|
|
252
|
+
gasLimit
|
|
253
|
+
});
|
|
254
|
+
txHash = res.txHash;
|
|
255
|
+
logger?.verbose(`Deployed contract with salt ${salt} to address ${resultingAddress} in tx ${txHash}.`);
|
|
256
|
+
} else {
|
|
257
|
+
logger?.verbose(`Skipping existing deployment of contract with salt ${salt} to address ${resultingAddress}`);
|
|
258
|
+
existed = true;
|
|
259
|
+
}
|
|
260
|
+
} else {
|
|
261
|
+
const deployData = encodeDeployData({
|
|
262
|
+
abi,
|
|
263
|
+
bytecode,
|
|
264
|
+
args
|
|
265
|
+
});
|
|
266
|
+
const { receipt } = await l1TxUtils.sendAndMonitorTransaction({
|
|
267
|
+
to: null,
|
|
268
|
+
data: deployData
|
|
269
|
+
}, {
|
|
270
|
+
gasLimit
|
|
271
|
+
});
|
|
272
|
+
txHash = receipt.transactionHash;
|
|
273
|
+
resultingAddress = receipt.contractAddress;
|
|
274
|
+
if (!resultingAddress) {
|
|
275
|
+
throw new Error(`No contract address found in receipt: ${JSON.stringify(receipt, (_, val)=>typeof val === 'bigint' ? String(val) : val)}`);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return {
|
|
279
|
+
address: EthAddress.fromString(resultingAddress),
|
|
280
|
+
txHash,
|
|
281
|
+
deployedLibraries,
|
|
282
|
+
existed
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
export function getExpectedAddress(abi, bytecode, args, salt) {
|
|
286
|
+
const paddedSalt = padHex(salt, {
|
|
287
|
+
size: 32
|
|
288
|
+
});
|
|
289
|
+
const calldata = encodeDeployData({
|
|
290
|
+
abi,
|
|
291
|
+
bytecode,
|
|
292
|
+
args
|
|
293
|
+
});
|
|
294
|
+
const address = getContractAddress({
|
|
295
|
+
from: DEPLOYER_ADDRESS,
|
|
296
|
+
salt: paddedSalt,
|
|
297
|
+
bytecode: calldata,
|
|
298
|
+
opcode: 'CREATE2'
|
|
299
|
+
});
|
|
300
|
+
return {
|
|
301
|
+
address,
|
|
302
|
+
paddedSalt,
|
|
303
|
+
calldata
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
export const deployUpgradePayload = async (deployer, addresses)=>{
|
|
307
|
+
const payloadAddress = (await deployer.deploy(RegisterNewRollupVersionPayloadArtifact, [
|
|
308
|
+
addresses.registryAddress.toString(),
|
|
309
|
+
addresses.rollupAddress.toString()
|
|
310
|
+
])).address;
|
|
311
|
+
return payloadAddress;
|
|
312
|
+
};
|
|
@@ -18,4 +18,4 @@ export interface EthSigner {
|
|
|
18
18
|
/** Sign a transaction */
|
|
19
19
|
signTransaction(transaction: TransactionSerializable): Promise<Signature>;
|
|
20
20
|
}
|
|
21
|
-
//# sourceMappingURL=
|
|
21
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXRoLXNpZ25lci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2V0aC1zaWduZXIvZXRoLXNpZ25lci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7R0FFRztBQUNILE9BQU8sS0FBSyxFQUFFLFFBQVEsRUFBRSxNQUFNLDBCQUEwQixDQUFDO0FBQ3pELE9BQU8sS0FBSyxFQUFFLFVBQVUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBQ2hFLE9BQU8sS0FBSyxFQUFFLFNBQVMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBRWpFLE9BQU8sS0FBSyxFQUFFLHVCQUF1QixFQUFFLG1CQUFtQixFQUFFLE1BQU0sTUFBTSxDQUFDO0FBRXpFOztHQUVHO0FBQ0gsTUFBTSxXQUFXLFNBQVM7SUFDeEIsMkNBQTJDO0lBQzNDLFFBQVEsQ0FBQyxPQUFPLEVBQUUsVUFBVSxDQUFDO0lBRTdCLG1FQUFtRTtJQUNuRSxXQUFXLENBQUMsT0FBTyxFQUFFLFFBQVEsR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUM7SUFFbkQsb0NBQW9DO0lBQ3BDLGFBQWEsQ0FBQyxTQUFTLEVBQUUsbUJBQW1CLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0lBRWxFLHlCQUF5QjtJQUN6QixlQUFlLENBQUMsV0FBVyxFQUFFLHVCQUF1QixHQUFHLE9BQU8sQ0FBQyxTQUFTLENBQUMsQ0FBQztDQUMzRSJ9
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from './eth-signer.js';
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ldGgtc2lnbmVyL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsaUJBQWlCLENBQUMifQ==
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
3
|
+
import type { ExtendedViemWalletClient } from './types.js';
|
|
4
|
+
export declare const FORWARDER_SOLIDITY_SOURCE = "\ncontract ForwarderProxy {\n function forward(address target, bytes calldata data) external payable returns (bytes memory) {\n (bool success, bytes memory result) = target.call{value: msg.value}(data);\n require(success, \"call failed\");\n return result;\n }\n}";
|
|
5
|
+
export declare const FORWARDER_ABI: readonly [{
|
|
6
|
+
readonly inputs: readonly [{
|
|
7
|
+
readonly internalType: "address";
|
|
8
|
+
readonly name: "target";
|
|
9
|
+
readonly type: "address";
|
|
10
|
+
}, {
|
|
11
|
+
readonly internalType: "bytes";
|
|
12
|
+
readonly name: "data";
|
|
13
|
+
readonly type: "bytes";
|
|
14
|
+
}];
|
|
15
|
+
readonly name: "forward";
|
|
16
|
+
readonly outputs: readonly [{
|
|
17
|
+
readonly internalType: "bytes";
|
|
18
|
+
readonly name: "";
|
|
19
|
+
readonly type: "bytes";
|
|
20
|
+
}];
|
|
21
|
+
readonly stateMutability: "payable";
|
|
22
|
+
readonly type: "function";
|
|
23
|
+
}];
|
|
24
|
+
export declare const FORWARDER_BYTECODE: `0x${string}`;
|
|
25
|
+
/**
|
|
26
|
+
* Deploys the forwarder proxy contract to L1.
|
|
27
|
+
* @param client - The L1 client to use for deployment
|
|
28
|
+
* @param logger - Optional logger
|
|
29
|
+
* @returns The deployed forwarder contract address
|
|
30
|
+
*/
|
|
31
|
+
export declare function deployForwarderProxy(client: ExtendedViemWalletClient, logger?: Logger): Promise<EthAddress>;
|
|
32
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9yd2FyZGVyX3Byb3h5LmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvZm9yd2FyZGVyX3Byb3h5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUMzRCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx1QkFBdUIsQ0FBQztBQVFwRCxPQUFPLEtBQUssRUFBRSx3QkFBd0IsRUFBRSxNQUFNLFlBQVksQ0FBQztBQUUzRCxlQUFPLE1BQU0seUJBQXlCLHVSQU9wQyxDQUFDO0FBRUgsZUFBTyxNQUFNLGFBQWE7Ozs7Ozs7Ozs7Ozs7Ozs7OztFQXlCaEIsQ0FBQztBQUVYLGVBQU8sTUFBTSxrQkFBa0IsZUFDbzZELENBQUM7QUFRcDhEOzs7OztHQUtHO0FBQ0gsd0JBQXNCLG9CQUFvQixDQUFDLE1BQU0sRUFBRSx3QkFBd0IsRUFBRSxNQUFNLENBQUMsRUFBRSxNQUFNLEdBQUcsT0FBTyxDQUFDLFVBQVUsQ0FBQyxDQVVqSCJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forwarder_proxy.d.ts","sourceRoot":"","sources":["../src/forwarder_proxy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAQpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAE3D,eAAO,MAAM,yBAAyB,uRAOpC,CAAC;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;EAyBhB,CAAC;AAEX,eAAO,MAAM,kBAAkB,eACo6D,CAAC;AAQp8D;;;;;GAKG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,wBAAwB,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAUjH"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/* eslint-disable no-console */ import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
3
|
+
import { extractChain } from 'viem';
|
|
4
|
+
import { anvil, mainnet, sepolia } from 'viem/chains';
|
|
5
|
+
import { L1Deployer } from './deploy_l1_contract.js';
|
|
6
|
+
export const FORWARDER_SOLIDITY_SOURCE = `
|
|
7
|
+
contract ForwarderProxy {
|
|
8
|
+
function forward(address target, bytes calldata data) external payable returns (bytes memory) {
|
|
9
|
+
(bool success, bytes memory result) = target.call{value: msg.value}(data);
|
|
10
|
+
require(success, "call failed");
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
}`;
|
|
14
|
+
export const FORWARDER_ABI = [
|
|
15
|
+
{
|
|
16
|
+
inputs: [
|
|
17
|
+
{
|
|
18
|
+
internalType: 'address',
|
|
19
|
+
name: 'target',
|
|
20
|
+
type: 'address'
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
internalType: 'bytes',
|
|
24
|
+
name: 'data',
|
|
25
|
+
type: 'bytes'
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
name: 'forward',
|
|
29
|
+
outputs: [
|
|
30
|
+
{
|
|
31
|
+
internalType: 'bytes',
|
|
32
|
+
name: '',
|
|
33
|
+
type: 'bytes'
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
stateMutability: 'payable',
|
|
37
|
+
type: 'function'
|
|
38
|
+
}
|
|
39
|
+
];
|
|
40
|
+
export const FORWARDER_BYTECODE = '0x6080604052348015600e575f5ffd5b506103bf8061001c5f395ff3fe60806040526004361061001d575f3560e01c80636fadcf7214610021575b5f5ffd5b61003b600480360381019061003691906101d0565b610051565b604051610048919061029d565b60405180910390f35b60605f5f8573ffffffffffffffffffffffffffffffffffffffff1634868660405161007d9291906102f9565b5f6040518083038185875af1925050503d805f81146100b7576040519150601f19603f3d011682016040523d82523d5f602084013e6100bc565b606091505b509150915081610101576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016100f89061036b565b60405180910390fd5b80925050509392505050565b5f5ffd5b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61013e82610115565b9050919050565b61014e81610134565b8114610158575f5ffd5b50565b5f8135905061016981610145565b92915050565b5f5ffd5b5f5ffd5b5f5ffd5b5f5f83601f8401126101905761018f61016f565b5b8235905067ffffffffffffffff8111156101ad576101ac610173565b5b6020830191508360018202830111156101c9576101c8610177565b5b9250929050565b5f5f5f604084860312156101e7576101e661010d565b5b5f6101f48682870161015b565b935050602084013567ffffffffffffffff81111561021557610214610111565b5b6102218682870161017b565b92509250509250925092565b5f81519050919050565b5f82825260208201905092915050565b8281835e5f83830152505050565b5f601f19601f8301169050919050565b5f61026f8261022d565b6102798185610237565b9350610289818560208601610247565b61029281610255565b840191505092915050565b5f6020820190508181035f8301526102b58184610265565b905092915050565b5f81905092915050565b828183375f83830152505050565b5f6102e083856102bd565b93506102ed8385846102c7565b82840190509392505050565b5f6103058284866102d5565b91508190509392505050565b5f82825260208201905092915050565b7f63616c6c206661696c65640000000000000000000000000000000000000000005f82015250565b5f610355600b83610311565b915061036082610321565b602082019050919050565b5f6020820190508181035f83015261038281610349565b905091905056fea26469706673582212209a1c8cf638cf1569450a731ef9457b862f9e153b0a46e5555429bcf4dffd999564736f6c634300081e0033';
|
|
41
|
+
const FORWARDER_ARTIFACT = {
|
|
42
|
+
name: 'Forwarder',
|
|
43
|
+
contractAbi: FORWARDER_ABI,
|
|
44
|
+
contractBytecode: FORWARDER_BYTECODE
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Deploys the forwarder proxy contract to L1.
|
|
48
|
+
* @param client - The L1 client to use for deployment
|
|
49
|
+
* @param logger - Optional logger
|
|
50
|
+
* @returns The deployed forwarder contract address
|
|
51
|
+
*/ export async function deployForwarderProxy(client, logger) {
|
|
52
|
+
const log = logger ?? createLogger('ethereum:forwarder');
|
|
53
|
+
const nonce = await client.getTransactionCount({
|
|
54
|
+
address: client.account.address
|
|
55
|
+
});
|
|
56
|
+
const deployer = new L1Deployer(client, nonce, new DateProvider(), false, log, undefined, false);
|
|
57
|
+
log.info('Deploying forwarder proxy contract');
|
|
58
|
+
const deployment = await deployer.deploy(FORWARDER_ARTIFACT, []);
|
|
59
|
+
log.info(`Forwarder proxy deployed at ${deployment.address.toString()}`);
|
|
60
|
+
return deployment.address;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Main function for deploying the forwarder proxy from command line.
|
|
64
|
+
* Usage: node forwarder_proxy.js <private_key> <rpc_url>
|
|
65
|
+
*/ async function main() {
|
|
66
|
+
const args = process.argv.slice(2);
|
|
67
|
+
if (args.length < 3) {
|
|
68
|
+
console.error('Usage: node forwarder_proxy.js <private_key> <rpc_url> <chain_id>');
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
const [privateKey, rpcUrl, chainId] = args;
|
|
72
|
+
// Dynamic import to avoid pulling in dependencies at module load time
|
|
73
|
+
const { createExtendedL1Client } = await import('./client.js');
|
|
74
|
+
const client = createExtendedL1Client([
|
|
75
|
+
rpcUrl
|
|
76
|
+
], privateKey.startsWith('0x') ? privateKey : `0x${privateKey}`, extractChain({
|
|
77
|
+
chains: [
|
|
78
|
+
mainnet,
|
|
79
|
+
sepolia,
|
|
80
|
+
anvil
|
|
81
|
+
],
|
|
82
|
+
id: parseInt(chainId)
|
|
83
|
+
}));
|
|
84
|
+
const address = await deployForwarderProxy(client);
|
|
85
|
+
console.log(`Forwarder proxy deployed at: ${address.toString()}`);
|
|
86
|
+
}
|
|
87
|
+
// Only run main if this is the entry point
|
|
88
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
89
|
+
main().catch((err)=>{
|
|
90
|
+
console.error('Failed to deploy forwarder proxy:', err);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
});
|
|
93
|
+
}
|