@aztec/ethereum 0.0.0-test.1 → 0.0.1-commit.001888fc
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 +14 -4
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +27 -3
- package/dest/config.d.ts +70 -23
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +155 -34
- package/dest/constants.d.ts +1 -1
- package/dest/contracts/empire_base.d.ts +27 -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 +69 -0
- package/dest/contracts/empire_slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/empire_slashing_proposer.js +216 -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 +20 -0
- package/dest/contracts/fee_asset_handler.d.ts.map +1 -0
- package/dest/contracts/fee_asset_handler.js +59 -0
- package/dest/contracts/fee_asset_price_oracle.d.ts +101 -0
- package/dest/contracts/fee_asset_price_oracle.d.ts.map +1 -0
- package/dest/contracts/fee_asset_price_oracle.js +651 -0
- package/dest/contracts/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 +45 -32
- package/dest/contracts/governance.d.ts.map +1 -1
- package/dest/contracts/governance.js +98 -85
- package/dest/contracts/governance_proposer.d.ts +19 -13
- package/dest/contracts/governance_proposer.d.ts.map +1 -1
- package/dest/contracts/governance_proposer.js +441 -26
- 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 +47 -0
- package/dest/contracts/inbox.d.ts.map +1 -0
- package/dest/contracts/inbox.js +80 -0
- package/dest/contracts/index.d.ts +12 -3
- package/dest/contracts/index.d.ts.map +1 -1
- package/dest/contracts/index.js +11 -2
- 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 +21 -0
- package/dest/contracts/multicall.d.ts.map +1 -0
- package/dest/contracts/multicall.js +157 -0
- 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 +12 -5
- package/dest/contracts/registry.d.ts.map +1 -1
- package/dest/contracts/registry.js +74 -17
- package/dest/contracts/rollup.d.ts +311 -53
- package/dest/contracts/rollup.d.ts.map +1 -1
- package/dest/contracts/rollup.js +1180 -116
- 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 +140 -0
- package/dest/contracts/tally_slashing_proposer.d.ts.map +1 -0
- package/dest/contracts/tally_slashing_proposer.js +320 -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_aztec_l1_contracts.d.ts +259 -0
- package/dest/deploy_aztec_l1_contracts.d.ts.map +1 -0
- package/dest/deploy_aztec_l1_contracts.js +413 -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 +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/forwarder_proxy.d.ts +32 -0
- package/dest/forwarder_proxy.d.ts.map +1 -0
- package/dest/forwarder_proxy.js +93 -0
- 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 +81744 -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 +25 -21
- package/dest/l1_reader.d.ts +6 -2
- package/dest/l1_reader.d.ts.map +1 -1
- package/dest/l1_reader.js +20 -9
- package/dest/l1_tx_utils/config.d.ts +65 -0
- package/dest/l1_tx_utils/config.d.ts.map +1 -0
- package/dest/l1_tx_utils/config.js +109 -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 +32 -0
- package/dest/l1_tx_utils/factory.d.ts.map +1 -0
- package/dest/l1_tx_utils/factory.js +22 -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 +42 -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 +13 -0
- package/dest/l1_tx_utils/index.d.ts.map +1 -0
- package/dest/l1_tx_utils/index.js +13 -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 +105 -0
- package/dest/l1_tx_utils/l1_tx_utils.d.ts.map +1 -0
- package/dest/l1_tx_utils/l1_tx_utils.js +639 -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 +327 -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/tx_delayer.d.ts +56 -0
- package/dest/l1_tx_utils/tx_delayer.d.ts.map +1 -0
- package/dest/l1_tx_utils/tx_delayer.js +221 -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 +16 -0
- package/dest/publisher_manager.d.ts.map +1 -0
- package/dest/publisher_manager.js +88 -0
- package/dest/queries.d.ts +5 -3
- package/dest/queries.d.ts.map +1 -1
- package/dest/queries.js +61 -12
- package/dest/test/chain_monitor.d.ts +94 -0
- package/dest/test/chain_monitor.d.ts.map +1 -0
- package/dest/test/chain_monitor.js +244 -0
- package/dest/test/eth_cheat_codes.d.ts +229 -0
- package/dest/test/eth_cheat_codes.d.ts.map +1 -0
- package/dest/test/eth_cheat_codes.js +560 -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 -3
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +3 -2
- package/dest/test/rollup_cheat_codes.d.ts +90 -0
- package/dest/test/rollup_cheat_codes.d.ts.map +1 -0
- package/dest/test/rollup_cheat_codes.js +292 -0
- package/dest/test/start_anvil.d.ts +23 -2
- package/dest/test/start_anvil.d.ts.map +1 -1
- package/dest/test/start_anvil.js +133 -24
- 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 +62 -8
- package/dest/types.d.ts.map +1 -1
- package/dest/types.js +3 -1
- package/dest/utils.d.ts +17 -3
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +111 -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 +51 -25
- package/src/account.ts +5 -0
- package/src/client.ts +51 -5
- package/src/config.ts +222 -43
- package/src/contracts/README.md +157 -0
- package/src/contracts/empire_base.ts +79 -7
- package/src/contracts/empire_slashing_proposer.ts +265 -0
- package/src/contracts/errors.ts +13 -0
- package/src/contracts/fee_asset_handler.ts +66 -0
- package/src/contracts/fee_asset_price_oracle.ts +280 -0
- package/src/contracts/fee_juice.ts +29 -15
- package/src/contracts/governance.ts +90 -78
- package/src/contracts/governance_proposer.ts +81 -25
- package/src/contracts/gse.ts +88 -0
- package/src/contracts/inbox.ts +115 -0
- package/src/contracts/index.ts +11 -2
- package/src/contracts/log.ts +13 -0
- package/src/contracts/multicall.ts +158 -0
- package/src/contracts/outbox.ts +98 -0
- package/src/contracts/registry.ts +81 -26
- package/src/contracts/rollup.ts +940 -89
- package/src/contracts/slasher_contract.ts +89 -0
- package/src/contracts/tally_slashing_proposer.ts +322 -0
- package/src/contracts/utils.ts +14 -0
- package/src/deploy_aztec_l1_contracts.ts +650 -0
- package/src/deploy_l1_contract.ts +362 -0
- package/src/eth-signer/eth-signer.ts +25 -0
- package/src/eth-signer/index.ts +1 -0
- package/src/forwarder_proxy.ts +108 -0
- package/src/generated/l1-contracts-defaults.ts +32 -0
- package/src/l1_artifacts.ts +254 -0
- package/src/l1_contract_addresses.ts +49 -34
- package/src/l1_reader.ts +30 -10
- package/src/l1_tx_utils/README.md +177 -0
- package/src/l1_tx_utils/config.ts +181 -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 +108 -0
- package/src/l1_tx_utils/index-blobs.ts +2 -0
- package/src/l1_tx_utils/index.ts +15 -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 +766 -0
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +423 -0
- package/src/l1_tx_utils/signer.ts +28 -0
- package/src/l1_tx_utils/tx_delayer.ts +294 -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 +108 -0
- package/src/queries.ts +82 -16
- package/src/test/chain_monitor.ts +302 -0
- 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 -2
- package/src/test/rollup_cheat_codes.ts +330 -0
- package/src/test/start_anvil.ts +166 -22
- package/src/test/upgrade_utils.ts +30 -21
- package/src/types.ts +71 -7
- package/src/utils.ts +137 -93
- 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/deploy_l1_contracts.d.ts +0 -21210
- package/dest/deploy_l1_contracts.d.ts.map +0 -1
- package/dest/deploy_l1_contracts.js +0 -687
- 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/index.d.ts +0 -14
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -13
- 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/dest/test/delayed_tx_utils.d.ts +0 -8
- package/dest/test/delayed_tx_utils.d.ts.map +0 -1
- package/dest/test/delayed_tx_utils.js +0 -21
- package/dest/test/tx_delayer.d.ts +0 -25
- package/dest/test/tx_delayer.d.ts.map +0 -1
- package/dest/test/tx_delayer.js +0 -116
- package/src/contracts/forwarder.ts +0 -132
- package/src/contracts/slashing_proposer.ts +0 -51
- package/src/deploy_l1_contracts.ts +0 -948
- package/src/eth_cheat_codes.ts +0 -314
- package/src/index.ts +0 -13
- package/src/l1_tx_utils.ts +0 -847
- package/src/l1_tx_utils_with_blobs.ts +0 -86
- package/src/test/delayed_tx_utils.ts +0 -24
- package/src/test/tx_delayer.ts +0 -163
|
@@ -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,8 +0,0 @@
|
|
|
1
|
-
import { L1TxUtilsWithBlobs } from '../l1_tx_utils_with_blobs.js';
|
|
2
|
-
import { type Delayer } from './tx_delayer.js';
|
|
3
|
-
export declare class DelayedTxUtils extends L1TxUtilsWithBlobs {
|
|
4
|
-
delayer: Delayer | undefined;
|
|
5
|
-
static fromL1TxUtils(l1TxUtils: L1TxUtilsWithBlobs, ethereumSlotDuration: number): DelayedTxUtils;
|
|
6
|
-
enableDelayer(ethereumSlotDuration: number): void;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=delayed_tx_utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delayed_tx_utils.d.ts","sourceRoot":"","sources":["../../src/test/delayed_tx_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,KAAK,OAAO,EAAe,MAAM,iBAAiB,CAAC;AAE5D,qBAAa,cAAe,SAAQ,kBAAkB;IAC7C,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;WAEtB,aAAa,CAAC,SAAS,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM;IAUhF,aAAa,CAAC,oBAAoB,EAAE,MAAM;CAOlD"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { L1TxUtilsWithBlobs } from '../l1_tx_utils_with_blobs.js';
|
|
2
|
-
import { withDelayer } from './tx_delayer.js';
|
|
3
|
-
export class DelayedTxUtils extends L1TxUtilsWithBlobs {
|
|
4
|
-
delayer;
|
|
5
|
-
static fromL1TxUtils(l1TxUtils, ethereumSlotDuration) {
|
|
6
|
-
const { client, delayer } = withDelayer(l1TxUtils.walletClient, {
|
|
7
|
-
ethereumSlotDuration
|
|
8
|
-
});
|
|
9
|
-
const casted = l1TxUtils;
|
|
10
|
-
casted.delayer = delayer;
|
|
11
|
-
casted.walletClient = client;
|
|
12
|
-
return casted;
|
|
13
|
-
}
|
|
14
|
-
enableDelayer(ethereumSlotDuration) {
|
|
15
|
-
const { client, delayer } = withDelayer(this.walletClient, {
|
|
16
|
-
ethereumSlotDuration
|
|
17
|
-
});
|
|
18
|
-
this.delayer = delayer;
|
|
19
|
-
this.walletClient = client;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { type Logger } from '@aztec/foundation/log';
|
|
2
|
-
import { type Client, type Hex } from 'viem';
|
|
3
|
-
import type { ViemWalletClient } from '../types.js';
|
|
4
|
-
export declare function waitUntilBlock<T extends Client>(client: T, blockNumber: number | bigint, logger?: Logger): Promise<boolean>;
|
|
5
|
-
export declare function waitUntilL1Timestamp<T extends Client>(client: T, timestamp: number | bigint, logger?: Logger): Promise<boolean>;
|
|
6
|
-
export interface Delayer {
|
|
7
|
-
/** Returns the list of all txs (not just the delayed ones) sent through the attached client. */
|
|
8
|
-
getTxs(): Hex[];
|
|
9
|
-
/** Delays the next tx to be sent so it lands on the given L1 block number. */
|
|
10
|
-
pauseNextTxUntilBlock(l1BlockNumber: number | bigint | undefined): void;
|
|
11
|
-
/** Delays the next tx to be sent so it lands on the given timestamp. */
|
|
12
|
-
pauseNextTxUntilTimestamp(l1Timestamp: number | bigint | undefined): void;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Returns a new client (without modifying the one passed in) with an injected tx delayer.
|
|
16
|
-
* The delayer can be used to hold off the next tx to be sent until a given block number.
|
|
17
|
-
* TODO(#10824): This doesn't play along well with blob txs for some reason.
|
|
18
|
-
*/
|
|
19
|
-
export declare function withDelayer<T extends ViemWalletClient>(client: T, opts: {
|
|
20
|
-
ethereumSlotDuration: bigint | number;
|
|
21
|
-
}): {
|
|
22
|
-
client: T;
|
|
23
|
-
delayer: Delayer;
|
|
24
|
-
};
|
|
25
|
-
//# sourceMappingURL=tx_delayer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tx_delayer.d.ts","sourceRoot":"","sources":["../../src/test/tx_delayer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAIlE,OAAO,EACL,KAAK,MAAM,EACX,KAAK,GAAG,EAMT,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD,wBAAgB,cAAc,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,oBAgBxG;AAED,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,oBAuB5G;AAED,MAAM,WAAW,OAAO;IACtB,gGAAgG;IAChG,MAAM,IAAI,GAAG,EAAE,CAAC;IAChB,8EAA8E;IAC9E,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACxE,wEAAwE;IACxE,yBAAyB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;CAC3E;AAwBD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,gBAAgB,EACpD,MAAM,EAAE,CAAC,EACT,IAAI,EAAE;IAAE,oBAAoB,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAC9C;IAAE,MAAM,EAAE,CAAC,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CA+DjC"}
|
package/dest/test/tx_delayer.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { omit } from '@aztec/foundation/collection';
|
|
2
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { retryUntil } from '@aztec/foundation/retry';
|
|
4
|
-
import { inspect } from 'util';
|
|
5
|
-
import { keccak256, parseTransaction, publicActions, walletActions } from 'viem';
|
|
6
|
-
export function waitUntilBlock(client, blockNumber, logger) {
|
|
7
|
-
const publicClient = 'getBlockNumber' in client && typeof client.getBlockNumber === 'function' ? client : client.extend(publicActions);
|
|
8
|
-
return retryUntil(async ()=>{
|
|
9
|
-
const currentBlockNumber = await publicClient.getBlockNumber({
|
|
10
|
-
cacheTime: 0
|
|
11
|
-
});
|
|
12
|
-
logger?.debug(`Block number is ${currentBlockNumber} (waiting until ${blockNumber})`);
|
|
13
|
-
return currentBlockNumber >= BigInt(blockNumber);
|
|
14
|
-
}, `Wait until L1 block ${blockNumber}`, 120, 0.1);
|
|
15
|
-
}
|
|
16
|
-
export function waitUntilL1Timestamp(client, timestamp, logger) {
|
|
17
|
-
const publicClient = 'getBlockNumber' in client && typeof client.getBlockNumber === 'function' ? client : client.extend(publicActions);
|
|
18
|
-
let lastBlock = undefined;
|
|
19
|
-
return retryUntil(async ()=>{
|
|
20
|
-
const currentBlockNumber = await publicClient.getBlockNumber({
|
|
21
|
-
cacheTime: 0
|
|
22
|
-
});
|
|
23
|
-
if (currentBlockNumber === lastBlock) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
lastBlock = currentBlockNumber;
|
|
27
|
-
const currentBlock = await publicClient.getBlock({
|
|
28
|
-
includeTransactions: false,
|
|
29
|
-
blockNumber: currentBlockNumber
|
|
30
|
-
});
|
|
31
|
-
const currentTs = currentBlock.timestamp;
|
|
32
|
-
logger?.debug(`Block timstamp is ${currentTs} (waiting until ${timestamp})`);
|
|
33
|
-
return currentTs >= BigInt(timestamp);
|
|
34
|
-
}, `Wait until L1 timestamp ${timestamp}`, 120, 0.1);
|
|
35
|
-
}
|
|
36
|
-
class DelayerImpl {
|
|
37
|
-
constructor(opts){
|
|
38
|
-
this.ethereumSlotDuration = BigInt(opts.ethereumSlotDuration);
|
|
39
|
-
}
|
|
40
|
-
ethereumSlotDuration;
|
|
41
|
-
nextWait = undefined;
|
|
42
|
-
txs = [];
|
|
43
|
-
getTxs() {
|
|
44
|
-
return this.txs;
|
|
45
|
-
}
|
|
46
|
-
pauseNextTxUntilBlock(l1BlockNumber) {
|
|
47
|
-
this.nextWait = {
|
|
48
|
-
l1BlockNumber: BigInt(l1BlockNumber)
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
pauseNextTxUntilTimestamp(l1Timestamp) {
|
|
52
|
-
this.nextWait = {
|
|
53
|
-
l1Timestamp: BigInt(l1Timestamp)
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Returns a new client (without modifying the one passed in) with an injected tx delayer.
|
|
59
|
-
* The delayer can be used to hold off the next tx to be sent until a given block number.
|
|
60
|
-
* TODO(#10824): This doesn't play along well with blob txs for some reason.
|
|
61
|
-
*/ export function withDelayer(client, opts) {
|
|
62
|
-
const logger = createLogger('ethereum:tx_delayer');
|
|
63
|
-
const delayer = new DelayerImpl(opts);
|
|
64
|
-
const extended = client// Tweak sendRawTransaction so it uses the delay defined in the delayer.
|
|
65
|
-
// Note that this will only work with local accounts (ie accounts for which we have the private key).
|
|
66
|
-
// Transactions signed by the node will not be delayed since they use sendTransaction directly,
|
|
67
|
-
// but we do not use them in our codebase at all.
|
|
68
|
-
.extend((client)=>({
|
|
69
|
-
async sendRawTransaction (...args) {
|
|
70
|
-
if (delayer.nextWait !== undefined) {
|
|
71
|
-
const waitUntil = delayer.nextWait;
|
|
72
|
-
delayer.nextWait = undefined;
|
|
73
|
-
const publicClient = client;
|
|
74
|
-
const wait = 'l1BlockNumber' in waitUntil ? waitUntilBlock(publicClient, waitUntil.l1BlockNumber - 1n, logger) : waitUntilL1Timestamp(publicClient, waitUntil.l1Timestamp - delayer.ethereumSlotDuration, logger);
|
|
75
|
-
// Compute the tx hash manually so we emulate sendRawTransaction response
|
|
76
|
-
const { serializedTransaction } = args[0];
|
|
77
|
-
const txHash = keccak256(serializedTransaction);
|
|
78
|
-
logger.info(`Delaying tx ${txHash} until ${inspect(waitUntil)}`, {
|
|
79
|
-
argsLen: args.length,
|
|
80
|
-
...omit(parseTransaction(serializedTransaction), 'data', 'sidecars')
|
|
81
|
-
});
|
|
82
|
-
// Do not await here so we can return the tx hash immediately as if it had been sent on the spot.
|
|
83
|
-
// Instead, delay it so it lands on the desired block number or timestamp, assuming anvil will
|
|
84
|
-
// mine it immediately.
|
|
85
|
-
void wait.then(async ()=>{
|
|
86
|
-
const clientTxHash = await client.sendRawTransaction(...args);
|
|
87
|
-
if (clientTxHash !== txHash) {
|
|
88
|
-
logger.error(`Tx hash returned by the client does not match computed one`, {
|
|
89
|
-
clientTxHash,
|
|
90
|
-
computedTxHash: txHash
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
logger.info(`Sent previously delayed tx ${clientTxHash} to land on ${inspect(waitUntil)}`);
|
|
94
|
-
delayer.txs.push(clientTxHash);
|
|
95
|
-
}).catch((err)=>logger.error(`Error sending tx after delay`, err));
|
|
96
|
-
return Promise.resolve(txHash);
|
|
97
|
-
} else {
|
|
98
|
-
const txHash = await client.sendRawTransaction(...args);
|
|
99
|
-
logger.verbose(`Sent tx immediately ${txHash}`);
|
|
100
|
-
delayer.txs.push(txHash);
|
|
101
|
-
return txHash;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}))// Re-extend with sendTransaction so it uses the modified sendRawTransaction.
|
|
105
|
-
.extend((client)=>({
|
|
106
|
-
sendTransaction: walletActions(client).sendTransaction
|
|
107
|
-
}))// And with the actions that depend on the modified sendTransaction
|
|
108
|
-
.extend((client)=>({
|
|
109
|
-
writeContract: walletActions(client).writeContract,
|
|
110
|
-
deployContract: walletActions(client).deployContract
|
|
111
|
-
}));
|
|
112
|
-
return {
|
|
113
|
-
client: extended,
|
|
114
|
-
delayer
|
|
115
|
-
};
|
|
116
|
-
}
|
|
@@ -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
|
-
}
|