@aztec/ethereum 0.0.0-test.1 → 0.0.1-commit.21caa21
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 +2 -0
- package/dest/account.d.ts.map +1 -0
- package/dest/account.js +4 -0
- package/dest/chain.d.ts +1 -1
- package/dest/client.d.ts +6 -4
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +16 -2
- package/dest/config.d.ts +111 -17
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +462 -22
- package/dest/constants.d.ts +1 -1
- package/dest/contracts/empire_base.d.ts +24 -8
- package/dest/contracts/empire_base.d.ts.map +1 -1
- package/dest/contracts/empire_base.js +75 -2
- package/dest/contracts/empire_slashing_proposer.d.ts +66 -0
- package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/empire_slashing_proposer.js +200 -0
- package/dest/contracts/errors.d.ts +7 -0
- package/dest/contracts/errors.d.ts.map +1 -0
- package/dest/contracts/errors.js +12 -0
- package/dest/contracts/fee_asset_handler.d.ts +19 -0
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -0
- package/dest/contracts/fee_asset_handler.js +57 -0
- package/dest/contracts/fee_juice.d.ts +6 -7
- package/dest/contracts/fee_juice.d.ts.map +1 -1
- package/dest/contracts/fee_juice.js +27 -20
- package/dest/contracts/governance.d.ts +43 -32
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +87 -84
- package/dest/contracts/governance_proposer.d.ts +16 -13
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +37 -17
- package/dest/contracts/gse.d.ts +32 -0
- package/dest/contracts/gse.d.ts.map +1 -0
- package/dest/contracts/gse.js +72 -0
- package/dest/contracts/inbox.d.ts +26 -0
- package/dest/contracts/inbox.d.ts.map +1 -0
- package/dest/contracts/inbox.js +45 -0
- package/dest/contracts/index.d.ts +9 -3
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +8 -2
- package/dest/contracts/multicall.d.ts +21 -0
- package/dest/contracts/multicall.d.ts.map +1 -0
- package/dest/contracts/multicall.js +156 -0
- package/dest/contracts/registry.d.ts +10 -5
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/registry.js +44 -16
- package/dest/contracts/rollup.d.ts +204 -40
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +529 -79
- package/dest/contracts/slasher_contract.d.ts +44 -0
- package/dest/contracts/slasher_contract.d.ts.map +1 -0
- package/dest/contracts/slasher_contract.js +75 -0
- package/dest/contracts/tally_slashing_proposer.d.ts +139 -0
- package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/tally_slashing_proposer.js +313 -0
- package/dest/contracts/utils.d.ts +3 -0
- package/dest/contracts/utils.d.ts.map +1 -0
- package/dest/contracts/utils.js +11 -0
- package/dest/deploy_l1_contracts.d.ts +577 -21114
- package/dest/deploy_l1_contracts.d.ts.map +1 -1
- package/dest/deploy_l1_contracts.js +1225 -421
- package/dest/eth-signer/eth-signer.d.ts +21 -0
- package/dest/eth-signer/eth-signer.d.ts.map +1 -0
- package/dest/eth-signer/eth-signer.js +5 -0
- package/dest/eth-signer/index.d.ts +2 -0
- package/dest/eth-signer/index.d.ts.map +1 -0
- package/dest/eth-signer/index.js +1 -0
- package/dest/index.d.ts +7 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +6 -2
- package/dest/l1_artifacts.d.ts +77344 -0
- package/dest/l1_artifacts.d.ts.map +1 -0
- package/dest/l1_artifacts.js +166 -0
- package/dest/l1_contract_addresses.d.ts +24 -4
- package/dest/l1_contract_addresses.d.ts.map +1 -1
- package/dest/l1_contract_addresses.js +22 -18
- package/dest/l1_reader.d.ts +2 -2
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +8 -8
- 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 +82 -0
- package/dest/l1_tx_utils/constants.d.ts +6 -0
- package/dest/l1_tx_utils/constants.d.ts.map +1 -0
- package/dest/l1_tx_utils/constants.js +14 -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/index.d.ts +10 -0
- package/dest/l1_tx_utils/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/index.js +10 -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_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 +610 -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 +94 -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 +430 -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 +6 -0
- package/dest/l1_types.d.ts.map +1 -0
- package/dest/l1_types.js +1 -0
- package/dest/publisher_manager.d.ts +15 -0
- package/dest/publisher_manager.d.ts.map +1 -0
- package/dest/publisher_manager.js +88 -0
- package/dest/queries.d.ts +4 -2
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +53 -12
- package/dest/test/chain_monitor.d.ts +73 -0
- package/dest/test/chain_monitor.d.ts.map +1 -0
- package/dest/test/chain_monitor.js +215 -0
- package/dest/test/delayed_tx_utils.d.ts +8 -3
- package/dest/test/delayed_tx_utils.d.ts.map +1 -1
- package/dest/test/delayed_tx_utils.js +13 -6
- package/dest/test/eth_cheat_codes.d.ts +217 -0
- package/dest/test/eth_cheat_codes.d.ts.map +1 -0
- package/dest/test/eth_cheat_codes.js +558 -0
- package/dest/test/eth_cheat_codes_with_state.d.ts +2 -2
- package/dest/test/eth_cheat_codes_with_state.d.ts.map +1 -1
- package/dest/test/eth_cheat_codes_with_state.js +1 -1
- package/dest/test/index.d.ts +4 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +3 -0
- package/dest/test/rollup_cheat_codes.d.ts +87 -0
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
- package/dest/test/rollup_cheat_codes.js +266 -0
- package/dest/test/start_anvil.d.ts +7 -1
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +16 -7
- package/dest/test/tx_delayer.d.ts +18 -7
- package/dest/test/tx_delayer.d.ts.map +1 -1
- package/dest/test/tx_delayer.js +95 -19
- package/dest/test/upgrade_utils.d.ts +6 -5
- package/dest/test/upgrade_utils.d.ts.map +1 -1
- package/dest/test/upgrade_utils.js +23 -16
- package/dest/types.d.ts +7 -8
- package/dest/types.d.ts.map +1 -1
- package/dest/types.js +3 -1
- package/dest/utils.d.ts +2 -1
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +43 -88
- package/dest/zkPassportVerifierAddress.d.ts +15 -0
- package/dest/zkPassportVerifierAddress.d.ts.map +1 -0
- package/dest/zkPassportVerifierAddress.js +11 -0
- package/package.json +28 -19
- package/src/account.ts +5 -0
- package/src/client.ts +42 -4
- package/src/config.ts +592 -31
- package/src/contracts/empire_base.ts +77 -7
- package/src/contracts/empire_slashing_proposer.ts +265 -0
- package/src/contracts/errors.ts +13 -0
- package/src/contracts/fee_asset_handler.ts +63 -0
- package/src/contracts/fee_juice.ts +29 -15
- package/src/contracts/governance.ts +80 -77
- package/src/contracts/governance_proposer.ts +66 -24
- package/src/contracts/gse.ts +88 -0
- package/src/contracts/inbox.ts +63 -0
- package/src/contracts/index.ts +8 -2
- package/src/contracts/multicall.ts +155 -0
- package/src/contracts/registry.ts +51 -26
- package/src/contracts/rollup.ts +596 -74
- package/src/contracts/slasher_contract.ts +89 -0
- package/src/contracts/tally_slashing_proposer.ts +316 -0
- package/src/contracts/utils.ts +14 -0
- package/src/deploy_l1_contracts.ts +1459 -538
- package/src/eth-signer/eth-signer.ts +25 -0
- package/src/eth-signer/index.ts +1 -0
- package/src/index.ts +6 -2
- package/src/l1_artifacts.ts +254 -0
- package/src/l1_contract_addresses.ts +32 -19
- package/src/l1_reader.ts +9 -9
- package/src/l1_tx_utils/README.md +177 -0
- package/src/l1_tx_utils/config.ts +143 -0
- package/src/l1_tx_utils/constants.ts +18 -0
- package/src/l1_tx_utils/factory.ts +64 -0
- package/src/l1_tx_utils/index.ts +12 -0
- package/src/l1_tx_utils/interfaces.ts +86 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +718 -0
- package/src/l1_tx_utils/l1_tx_utils_with_blobs.ts +77 -0
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +558 -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/l1_types.ts +6 -0
- package/src/publisher_manager.ts +106 -0
- package/src/queries.ts +73 -15
- package/src/test/chain_monitor.ts +243 -0
- package/src/test/delayed_tx_utils.ts +34 -6
- package/src/test/eth_cheat_codes.ts +588 -0
- package/src/test/eth_cheat_codes_with_state.ts +1 -1
- package/src/test/index.ts +3 -0
- package/src/test/rollup_cheat_codes.ts +307 -0
- package/src/test/start_anvil.ts +22 -5
- package/src/test/tx_delayer.ts +127 -26
- package/src/test/upgrade_utils.ts +30 -21
- package/src/types.ts +10 -8
- package/src/utils.ts +49 -90
- package/src/zkPassportVerifierAddress.ts +15 -0
- package/dest/contracts/forwarder.d.ts +0 -24
- package/dest/contracts/forwarder.d.ts.map +0 -1
- package/dest/contracts/forwarder.js +0 -101
- package/dest/contracts/slashing_proposer.d.ts +0 -21
- package/dest/contracts/slashing_proposer.d.ts.map +0 -1
- package/dest/contracts/slashing_proposer.js +0 -47
- package/dest/eth_cheat_codes.d.ts +0 -147
- package/dest/eth_cheat_codes.d.ts.map +0 -1
- package/dest/eth_cheat_codes.js +0 -303
- package/dest/l1_tx_utils.d.ts +0 -192
- package/dest/l1_tx_utils.d.ts.map +0 -1
- package/dest/l1_tx_utils.js +0 -641
- package/dest/l1_tx_utils_with_blobs.d.ts +0 -12
- package/dest/l1_tx_utils_with_blobs.d.ts.map +0 -1
- package/dest/l1_tx_utils_with_blobs.js +0 -64
- package/src/contracts/forwarder.ts +0 -132
- package/src/contracts/slashing_proposer.ts +0 -51
- package/src/eth_cheat_codes.ts +0 -314
- package/src/l1_tx_utils.ts +0 -847
- package/src/l1_tx_utils_with_blobs.ts +0 -86
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Blob } from '@aztec/blob-lib';
|
|
2
|
-
import { formatGwei } from 'viem';
|
|
3
|
-
import { L1TxUtils } from './l1_tx_utils.js';
|
|
4
|
-
export class L1TxUtilsWithBlobs extends L1TxUtils {
|
|
5
|
-
/**
|
|
6
|
-
* Attempts to cancel a transaction by sending a 0-value tx to self with same nonce but higher gas prices
|
|
7
|
-
* @param nonce - The nonce of the transaction to cancel
|
|
8
|
-
* @param previousGasPrice - The gas price of the previous transaction
|
|
9
|
-
* @param attempts - The number of attempts to cancel the transaction
|
|
10
|
-
* @returns The hash of the cancellation transaction
|
|
11
|
-
*/ async attemptTxCancellation(nonce, isBlobTx = false, previousGasPrice, attempts = 0) {
|
|
12
|
-
const account = this.walletClient.account;
|
|
13
|
-
// Get gas price with higher priority fee for cancellation
|
|
14
|
-
const cancelGasPrice = await this.getGasPrice({
|
|
15
|
-
...this.config,
|
|
16
|
-
// Use high bump for cancellation to ensure it replaces the original tx
|
|
17
|
-
priorityFeeRetryBumpPercentage: 150
|
|
18
|
-
}, isBlobTx, attempts + 1, previousGasPrice);
|
|
19
|
-
this.logger?.debug(`Attempting to cancel transaction with nonce ${nonce}`, {
|
|
20
|
-
maxFeePerGas: formatGwei(cancelGasPrice.maxFeePerGas),
|
|
21
|
-
maxPriorityFeePerGas: formatGwei(cancelGasPrice.maxPriorityFeePerGas)
|
|
22
|
-
});
|
|
23
|
-
const request = {
|
|
24
|
-
to: account.address,
|
|
25
|
-
value: 0n
|
|
26
|
-
};
|
|
27
|
-
// Send 0-value tx to self with higher gas price
|
|
28
|
-
if (!isBlobTx) {
|
|
29
|
-
const cancelTxHash = await this.walletClient.sendTransaction({
|
|
30
|
-
...request,
|
|
31
|
-
nonce,
|
|
32
|
-
gas: 21_000n,
|
|
33
|
-
maxFeePerGas: cancelGasPrice.maxFeePerGas,
|
|
34
|
-
maxPriorityFeePerGas: cancelGasPrice.maxPriorityFeePerGas
|
|
35
|
-
});
|
|
36
|
-
const receipt = await this.monitorTransaction(request, cancelTxHash, {
|
|
37
|
-
gasLimit: 21_000n
|
|
38
|
-
}, undefined, undefined, true);
|
|
39
|
-
return receipt.transactionHash;
|
|
40
|
-
} else {
|
|
41
|
-
const blobData = new Uint8Array(131072).fill(0);
|
|
42
|
-
const kzg = Blob.getViemKzgInstance();
|
|
43
|
-
const blobInputs = {
|
|
44
|
-
blobs: [
|
|
45
|
-
blobData
|
|
46
|
-
],
|
|
47
|
-
kzg,
|
|
48
|
-
maxFeePerBlobGas: cancelGasPrice.maxFeePerBlobGas
|
|
49
|
-
};
|
|
50
|
-
const cancelTxHash = await this.walletClient.sendTransaction({
|
|
51
|
-
...request,
|
|
52
|
-
...blobInputs,
|
|
53
|
-
nonce,
|
|
54
|
-
gas: 21_000n,
|
|
55
|
-
maxFeePerGas: cancelGasPrice.maxFeePerGas,
|
|
56
|
-
maxPriorityFeePerGas: cancelGasPrice.maxPriorityFeePerGas
|
|
57
|
-
});
|
|
58
|
-
const receipt = await this.monitorTransaction(request, cancelTxHash, {
|
|
59
|
-
gasLimit: 21_000n
|
|
60
|
-
}, undefined, blobInputs, true);
|
|
61
|
-
return receipt.transactionHash;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { toHex } from '@aztec/foundation/bigint-buffer';
|
|
2
|
-
import type { Logger } from '@aztec/foundation/log';
|
|
3
|
-
import { ForwarderAbi, ForwarderBytecode } from '@aztec/l1-artifacts';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
type EncodeFunctionDataParameters,
|
|
7
|
-
type GetContractReturnType,
|
|
8
|
-
type Hex,
|
|
9
|
-
encodeFunctionData,
|
|
10
|
-
getContract,
|
|
11
|
-
} from 'viem';
|
|
12
|
-
|
|
13
|
-
import { deployL1Contract } from '../deploy_l1_contracts.js';
|
|
14
|
-
import type { L1BlobInputs, L1GasConfig, L1TxRequest, L1TxUtils } from '../l1_tx_utils.js';
|
|
15
|
-
import type { L1Clients, ViemPublicClient, ViemWalletClient } from '../types.js';
|
|
16
|
-
import { RollupContract } from './rollup.js';
|
|
17
|
-
|
|
18
|
-
export class ForwarderContract {
|
|
19
|
-
private readonly forwarder: GetContractReturnType<typeof ForwarderAbi, ViemPublicClient>;
|
|
20
|
-
|
|
21
|
-
constructor(public readonly client: L1Clients['publicClient'], address: Hex, public readonly rollupAddress: Hex) {
|
|
22
|
-
this.forwarder = getContract({ address, abi: ForwarderAbi, client });
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
static async create(
|
|
26
|
-
owner: Hex,
|
|
27
|
-
walletClient: ViemWalletClient,
|
|
28
|
-
publicClient: ViemPublicClient,
|
|
29
|
-
logger: Logger,
|
|
30
|
-
rollupAddress: Hex,
|
|
31
|
-
) {
|
|
32
|
-
logger.info('Deploying forwarder contract');
|
|
33
|
-
|
|
34
|
-
const { address, txHash } = await deployL1Contract(
|
|
35
|
-
walletClient,
|
|
36
|
-
publicClient,
|
|
37
|
-
ForwarderAbi,
|
|
38
|
-
ForwarderBytecode,
|
|
39
|
-
[owner],
|
|
40
|
-
owner,
|
|
41
|
-
undefined,
|
|
42
|
-
logger,
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
if (txHash) {
|
|
46
|
-
await publicClient.waitForTransactionReceipt({ hash: txHash });
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
logger.info(`Forwarder contract deployed at ${address} with owner ${owner}`);
|
|
50
|
-
|
|
51
|
-
return new ForwarderContract(publicClient, address.toString(), rollupAddress);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
public getAddress() {
|
|
55
|
-
return this.forwarder.address;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
public async forward(
|
|
59
|
-
requests: L1TxRequest[],
|
|
60
|
-
l1TxUtils: L1TxUtils,
|
|
61
|
-
gasConfig: L1GasConfig | undefined,
|
|
62
|
-
blobConfig: L1BlobInputs | undefined,
|
|
63
|
-
logger: Logger,
|
|
64
|
-
) {
|
|
65
|
-
requests = requests.filter(request => request.to !== null);
|
|
66
|
-
const toArgs = requests.map(request => request.to!);
|
|
67
|
-
const dataArgs = requests.map(request => request.data!);
|
|
68
|
-
const forwarderFunctionData: EncodeFunctionDataParameters<typeof ForwarderAbi, 'forward'> = {
|
|
69
|
-
abi: ForwarderAbi,
|
|
70
|
-
functionName: 'forward',
|
|
71
|
-
args: [toArgs, dataArgs],
|
|
72
|
-
};
|
|
73
|
-
const encodedForwarderData = encodeFunctionData(forwarderFunctionData);
|
|
74
|
-
|
|
75
|
-
const { receipt, gasPrice } = await l1TxUtils.sendAndMonitorTransaction(
|
|
76
|
-
{
|
|
77
|
-
to: this.forwarder.address,
|
|
78
|
-
data: encodedForwarderData,
|
|
79
|
-
},
|
|
80
|
-
gasConfig,
|
|
81
|
-
blobConfig,
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
if (receipt.status === 'success') {
|
|
85
|
-
const stats = await l1TxUtils.getTransactionStats(receipt.transactionHash);
|
|
86
|
-
return { receipt, gasPrice, stats };
|
|
87
|
-
} else {
|
|
88
|
-
logger.error('Forwarder transaction failed', undefined, { receipt });
|
|
89
|
-
|
|
90
|
-
const args = {
|
|
91
|
-
...forwarderFunctionData,
|
|
92
|
-
address: this.forwarder.address,
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
let errorMsg: string | undefined;
|
|
96
|
-
|
|
97
|
-
if (blobConfig) {
|
|
98
|
-
const maxFeePerBlobGas = blobConfig.maxFeePerBlobGas ?? gasPrice.maxFeePerBlobGas;
|
|
99
|
-
if (maxFeePerBlobGas === undefined) {
|
|
100
|
-
errorMsg = 'maxFeePerBlobGas is required to get the error message';
|
|
101
|
-
} else {
|
|
102
|
-
logger.debug('Trying to get error from reverted tx with blob config');
|
|
103
|
-
errorMsg = await l1TxUtils.tryGetErrorFromRevertedTx(
|
|
104
|
-
encodedForwarderData,
|
|
105
|
-
args,
|
|
106
|
-
{
|
|
107
|
-
blobs: blobConfig.blobs,
|
|
108
|
-
kzg: blobConfig.kzg,
|
|
109
|
-
maxFeePerBlobGas,
|
|
110
|
-
},
|
|
111
|
-
[
|
|
112
|
-
{
|
|
113
|
-
address: this.rollupAddress,
|
|
114
|
-
stateDiff: [
|
|
115
|
-
{
|
|
116
|
-
slot: toHex(RollupContract.checkBlobStorageSlot, true),
|
|
117
|
-
value: toHex(0n, true),
|
|
118
|
-
},
|
|
119
|
-
],
|
|
120
|
-
},
|
|
121
|
-
],
|
|
122
|
-
);
|
|
123
|
-
}
|
|
124
|
-
} else {
|
|
125
|
-
logger.debug('Trying to get error from reverted tx without blob config');
|
|
126
|
-
errorMsg = await l1TxUtils.tryGetErrorFromRevertedTx(encodedForwarderData, args, undefined, []);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return { receipt, gasPrice, errorMsg };
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
-
import { SlashingProposerAbi } from '@aztec/l1-artifacts';
|
|
3
|
-
|
|
4
|
-
import { type GetContractReturnType, type Hex, getContract } from 'viem';
|
|
5
|
-
|
|
6
|
-
import type { L1TxRequest } from '../l1_tx_utils.js';
|
|
7
|
-
import type { ViemPublicClient } from '../types.js';
|
|
8
|
-
import { type IEmpireBase, encodeVote } from './empire_base.js';
|
|
9
|
-
|
|
10
|
-
export class SlashingProposerContract implements IEmpireBase {
|
|
11
|
-
private readonly proposer: GetContractReturnType<typeof SlashingProposerAbi, ViemPublicClient>;
|
|
12
|
-
|
|
13
|
-
constructor(public readonly client: ViemPublicClient, address: Hex) {
|
|
14
|
-
this.proposer = getContract({ address, abi: SlashingProposerAbi, client });
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
public get address() {
|
|
18
|
-
return EthAddress.fromString(this.proposer.address);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
public getQuorumSize() {
|
|
22
|
-
return this.proposer.read.N();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public getRoundSize() {
|
|
26
|
-
return this.proposer.read.M();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public computeRound(slot: bigint): Promise<bigint> {
|
|
30
|
-
return this.proposer.read.computeRound([slot]);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
public async getRoundInfo(
|
|
34
|
-
rollupAddress: Hex,
|
|
35
|
-
round: bigint,
|
|
36
|
-
): Promise<{ lastVote: bigint; leader: Hex; executed: boolean }> {
|
|
37
|
-
const roundInfo = await this.proposer.read.rounds([rollupAddress, round]);
|
|
38
|
-
return {
|
|
39
|
-
lastVote: roundInfo[0],
|
|
40
|
-
leader: roundInfo[1],
|
|
41
|
-
executed: roundInfo[2],
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public createVoteRequest(payload: Hex): L1TxRequest {
|
|
46
|
-
return {
|
|
47
|
-
to: this.address.toString(),
|
|
48
|
-
data: encodeVote(payload),
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
}
|
package/src/eth_cheat_codes.ts
DELETED
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
import { toBigIntBE, toHex } from '@aztec/foundation/bigint-buffer';
|
|
2
|
-
import { keccak256 } from '@aztec/foundation/crypto';
|
|
3
|
-
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
-
|
|
6
|
-
import { type Hex, createPublicClient, fallback, http } from 'viem';
|
|
7
|
-
|
|
8
|
-
import type { ViemPublicClient } from './types.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A class that provides utility functions for interacting with ethereum (L1).
|
|
12
|
-
*/
|
|
13
|
-
export class EthCheatCodes {
|
|
14
|
-
private publicClient: ViemPublicClient;
|
|
15
|
-
constructor(
|
|
16
|
-
/**
|
|
17
|
-
* The RPC URL to use for interacting with the chain
|
|
18
|
-
*/
|
|
19
|
-
public rpcUrls: string[],
|
|
20
|
-
/**
|
|
21
|
-
* The logger to use for the eth cheatcodes
|
|
22
|
-
*/
|
|
23
|
-
public logger = createLogger('ethereum:cheat_codes'),
|
|
24
|
-
) {
|
|
25
|
-
this.publicClient = createPublicClient({
|
|
26
|
-
transport: fallback(this.rpcUrls.map(url => http(url))),
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async rpcCall(method: string, params: any[]) {
|
|
31
|
-
const paramsString = JSON.stringify(params);
|
|
32
|
-
this.logger.info(`Calling ${method} with params: ${paramsString} on ${this.rpcUrls.join(', ')}`);
|
|
33
|
-
return (await this.publicClient.transport.request({
|
|
34
|
-
method,
|
|
35
|
-
params,
|
|
36
|
-
})) as any;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Get the auto mine status of the underlying chain
|
|
41
|
-
* @returns True if automine is on, false otherwise
|
|
42
|
-
*/
|
|
43
|
-
public async isAutoMining(): Promise<boolean> {
|
|
44
|
-
try {
|
|
45
|
-
const res = await this.rpcCall('anvil_getAutomine', []);
|
|
46
|
-
return res;
|
|
47
|
-
} catch (err) {
|
|
48
|
-
this.logger.error(`Calling "anvil_getAutomine" failed with:`, err);
|
|
49
|
-
}
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Get the current blocknumber
|
|
55
|
-
* @returns The current block number
|
|
56
|
-
*/
|
|
57
|
-
public async blockNumber(): Promise<number> {
|
|
58
|
-
const res = await this.rpcCall('eth_blockNumber', []);
|
|
59
|
-
return parseInt(res, 16);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Get the current chainId
|
|
64
|
-
* @returns The current chainId
|
|
65
|
-
*/
|
|
66
|
-
public async chainId(): Promise<number> {
|
|
67
|
-
const res = await this.rpcCall('eth_chainId', []);
|
|
68
|
-
return parseInt(res, 16);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Get the current timestamp
|
|
73
|
-
* @returns The current timestamp
|
|
74
|
-
*/
|
|
75
|
-
public async timestamp(): Promise<number> {
|
|
76
|
-
const res = await this.rpcCall('eth_getBlockByNumber', ['latest', true]);
|
|
77
|
-
return parseInt(res.timestamp, 16);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Advance the chain by a number of blocks
|
|
82
|
-
* @param numberOfBlocks - The number of blocks to mine
|
|
83
|
-
*/
|
|
84
|
-
public async mine(numberOfBlocks = 1): Promise<void> {
|
|
85
|
-
await this.doMine(numberOfBlocks);
|
|
86
|
-
this.logger.warn(`Mined ${numberOfBlocks} L1 blocks`);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
private async doMine(numberOfBlocks = 1): Promise<void> {
|
|
90
|
-
try {
|
|
91
|
-
await this.rpcCall('hardhat_mine', [numberOfBlocks]);
|
|
92
|
-
} catch (err) {
|
|
93
|
-
throw new Error(`Error mining: ${err}`);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Mines a single block with evm_mine
|
|
99
|
-
*/
|
|
100
|
-
public async evmMine(): Promise<void> {
|
|
101
|
-
try {
|
|
102
|
-
await this.rpcCall('evm_mine', []);
|
|
103
|
-
} catch (err) {
|
|
104
|
-
throw new Error(`Error mining: ${err}`);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Set the balance of an account
|
|
110
|
-
* @param account - The account to set the balance for
|
|
111
|
-
* @param balance - The balance to set
|
|
112
|
-
*/
|
|
113
|
-
public async setBalance(account: EthAddress, balance: bigint): Promise<void> {
|
|
114
|
-
try {
|
|
115
|
-
await this.rpcCall('anvil_setBalance', [account.toString(), toHex(balance)]);
|
|
116
|
-
} catch (err) {
|
|
117
|
-
throw new Error(`Error setting balance for ${account}: ${err}`);
|
|
118
|
-
}
|
|
119
|
-
this.logger.warn(`Set balance for ${account} to ${balance}`);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Set the interval between blocks (block time)
|
|
124
|
-
* @param interval - The interval to use between blocks
|
|
125
|
-
*/
|
|
126
|
-
public async setBlockInterval(interval: number): Promise<void> {
|
|
127
|
-
try {
|
|
128
|
-
await this.rpcCall('anvil_setBlockTimestampInterval', [interval]);
|
|
129
|
-
} catch (err) {
|
|
130
|
-
throw new Error(`Error setting block interval: ${err}`);
|
|
131
|
-
}
|
|
132
|
-
this.logger.warn(`Set L1 block interval to ${interval}`);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Set the next block base fee per gas
|
|
137
|
-
* @param baseFee - The base fee to set
|
|
138
|
-
*/
|
|
139
|
-
public async setNextBlockBaseFeePerGas(baseFee: bigint | number): Promise<void> {
|
|
140
|
-
try {
|
|
141
|
-
await this.rpcCall('anvil_setNextBlockBaseFeePerGas', [baseFee.toString()]);
|
|
142
|
-
} catch (err) {
|
|
143
|
-
throw new Error(`Error setting next block base fee per gas: ${err}`);
|
|
144
|
-
}
|
|
145
|
-
this.logger.warn(`Set L1 next block base fee per gas to ${baseFee}`);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Set the interval between blocks (block time)
|
|
150
|
-
* @param seconds - The interval to use between blocks
|
|
151
|
-
*/
|
|
152
|
-
public async setIntervalMining(seconds: number): Promise<void> {
|
|
153
|
-
try {
|
|
154
|
-
await this.rpcCall('anvil_setIntervalMining', [seconds]);
|
|
155
|
-
} catch (err) {
|
|
156
|
-
throw new Error(`Error setting interval mining: ${err}`);
|
|
157
|
-
}
|
|
158
|
-
this.logger.warn(`Set L1 interval mining to ${seconds} seconds`);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Set the automine status of the underlying anvil chain
|
|
163
|
-
* @param automine - The automine status to set
|
|
164
|
-
*/
|
|
165
|
-
public async setAutomine(automine: boolean): Promise<void> {
|
|
166
|
-
try {
|
|
167
|
-
await this.rpcCall('anvil_setAutomine', [automine]);
|
|
168
|
-
} catch (err) {
|
|
169
|
-
throw new Error(`Error setting automine: ${err}`);
|
|
170
|
-
}
|
|
171
|
-
this.logger.warn(`Set L1 automine to ${automine}`);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Drop a transaction from the mempool
|
|
176
|
-
* @param txHash - The transaction hash
|
|
177
|
-
*/
|
|
178
|
-
public async dropTransaction(txHash: Hex): Promise<void> {
|
|
179
|
-
try {
|
|
180
|
-
await this.rpcCall('anvil_dropTransaction', [txHash]);
|
|
181
|
-
} catch (err) {
|
|
182
|
-
throw new Error(`Error dropping transaction: ${err}`);
|
|
183
|
-
}
|
|
184
|
-
this.logger.warn(`Dropped transaction ${txHash}`);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Set the next block timestamp
|
|
189
|
-
* @param timestamp - The timestamp to set the next block to
|
|
190
|
-
*/
|
|
191
|
-
public async setNextBlockTimestamp(timestamp: number): Promise<void> {
|
|
192
|
-
try {
|
|
193
|
-
await this.rpcCall('evm_setNextBlockTimestamp', [timestamp]);
|
|
194
|
-
} catch (err: any) {
|
|
195
|
-
throw new Error(`Error setting next block timestamp: ${err.message}`);
|
|
196
|
-
}
|
|
197
|
-
this.logger.warn(`Set L1 next block timestamp to ${timestamp}`);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Set the next block timestamp and mines the block
|
|
202
|
-
* @param timestamp - The timestamp to set the next block to
|
|
203
|
-
*/
|
|
204
|
-
public async warp(timestamp: number | bigint, silent = false): Promise<void> {
|
|
205
|
-
try {
|
|
206
|
-
await this.rpcCall('evm_setNextBlockTimestamp', [Number(timestamp)]);
|
|
207
|
-
} catch (err) {
|
|
208
|
-
throw new Error(`Error warping: ${err}`);
|
|
209
|
-
}
|
|
210
|
-
await this.doMine();
|
|
211
|
-
if (!silent) {
|
|
212
|
-
this.logger.warn(`Warped L1 timestamp to ${timestamp}`);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Load the value at a storage slot of a contract address on eth
|
|
218
|
-
* @param contract - The contract address
|
|
219
|
-
* @param slot - The storage slot
|
|
220
|
-
* @returns - The value at the storage slot
|
|
221
|
-
*/
|
|
222
|
-
public async load(contract: EthAddress, slot: bigint): Promise<bigint> {
|
|
223
|
-
const res = await this.rpcCall('eth_getStorageAt', [contract.toString(), toHex(slot), 'latest']);
|
|
224
|
-
return BigInt(res);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/**
|
|
228
|
-
* Set the value at a storage slot of a contract address on eth
|
|
229
|
-
* @param contract - The contract address
|
|
230
|
-
* @param slot - The storage slot
|
|
231
|
-
* @param value - The value to set the storage slot to
|
|
232
|
-
*/
|
|
233
|
-
public async store(contract: EthAddress, slot: bigint, value: bigint): Promise<void> {
|
|
234
|
-
// for the rpc call, we need to change value to be a 32 byte hex string.
|
|
235
|
-
try {
|
|
236
|
-
await this.rpcCall('hardhat_setStorageAt', [contract.toString(), toHex(slot), toHex(value, true)]);
|
|
237
|
-
} catch (err) {
|
|
238
|
-
throw new Error(`Error setting storage for contract ${contract} at ${slot}: ${err}`);
|
|
239
|
-
}
|
|
240
|
-
this.logger.warn(`Set L1 storage for contract ${contract} at ${slot} to ${value}`);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Computes the slot value for a given map and key.
|
|
245
|
-
* @param baseSlot - The base slot of the map (specified in Aztec.nr contract)
|
|
246
|
-
* @param key - The key to lookup in the map
|
|
247
|
-
* @returns The storage slot of the value in the map
|
|
248
|
-
*/
|
|
249
|
-
public keccak256(baseSlot: bigint, key: bigint): bigint {
|
|
250
|
-
// abi encode (removing the 0x) - concat key and baseSlot (both padded to 32 bytes)
|
|
251
|
-
const abiEncoded = toHex(key, true).substring(2) + toHex(baseSlot, true).substring(2);
|
|
252
|
-
return toBigIntBE(keccak256(Buffer.from(abiEncoded, 'hex')));
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* Send transactions impersonating an externally owned account or contract.
|
|
257
|
-
* @param who - The address to impersonate
|
|
258
|
-
*/
|
|
259
|
-
public async startImpersonating(who: EthAddress | Hex): Promise<void> {
|
|
260
|
-
try {
|
|
261
|
-
await this.rpcCall('hardhat_impersonateAccount', [who.toString()]);
|
|
262
|
-
} catch (err) {
|
|
263
|
-
throw new Error(`Error impersonating ${who}: ${err}`);
|
|
264
|
-
}
|
|
265
|
-
this.logger.warn(`Impersonating ${who}`);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Stop impersonating an account that you are currently impersonating.
|
|
270
|
-
* @param who - The address to stop impersonating
|
|
271
|
-
*/
|
|
272
|
-
public async stopImpersonating(who: EthAddress | Hex): Promise<void> {
|
|
273
|
-
try {
|
|
274
|
-
await this.rpcCall('hardhat_stopImpersonatingAccount', [who.toString()]);
|
|
275
|
-
} catch (err) {
|
|
276
|
-
throw new Error(`Error when stopping the impersonation of ${who}: ${err}`);
|
|
277
|
-
}
|
|
278
|
-
this.logger.warn(`Stopped impersonating ${who}`);
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Set the bytecode for a contract
|
|
283
|
-
* @param contract - The contract address
|
|
284
|
-
* @param bytecode - The bytecode to set
|
|
285
|
-
*/
|
|
286
|
-
public async etch(contract: EthAddress, bytecode: `0x${string}`): Promise<void> {
|
|
287
|
-
try {
|
|
288
|
-
await this.rpcCall('hardhat_setCode', [contract.toString(), bytecode]);
|
|
289
|
-
} catch (err) {
|
|
290
|
-
throw new Error(`Error setting bytecode for ${contract}: ${err}`);
|
|
291
|
-
}
|
|
292
|
-
this.logger.warn(`Set bytecode for ${contract} to ${bytecode}`);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Get the bytecode for a contract
|
|
297
|
-
* @param contract - The contract address
|
|
298
|
-
* @returns The bytecode for the contract
|
|
299
|
-
*/
|
|
300
|
-
public async getBytecode(contract: EthAddress): Promise<`0x${string}`> {
|
|
301
|
-
const res = await this.rpcCall('eth_getCode', [contract.toString(), 'latest']);
|
|
302
|
-
return res;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Get the raw transaction object for a given transaction hash
|
|
307
|
-
* @param txHash - The transaction hash
|
|
308
|
-
* @returns The raw transaction
|
|
309
|
-
*/
|
|
310
|
-
public async getRawTransaction(txHash: Hex): Promise<`0x${string}`> {
|
|
311
|
-
const res = await this.rpcCall('debug_getRawTransaction', [txHash]);
|
|
312
|
-
return res;
|
|
313
|
-
}
|
|
314
|
-
}
|