@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,77 @@
|
|
|
1
|
+
import { Blob } from '@aztec/blob-lib';
|
|
2
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
import type { Logger } from '@aztec/foundation/log';
|
|
4
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
5
|
+
|
|
6
|
+
import type { TransactionSerializable } from 'viem';
|
|
7
|
+
|
|
8
|
+
import type { EthSigner } from '../eth-signer/eth-signer.js';
|
|
9
|
+
import type { ExtendedViemWalletClient, ViemClient } from '../types.js';
|
|
10
|
+
import type { L1TxUtilsConfig } from './config.js';
|
|
11
|
+
import type { IL1TxMetrics, IL1TxStore } from './interfaces.js';
|
|
12
|
+
import { L1TxUtils } from './l1_tx_utils.js';
|
|
13
|
+
import { createViemSigner } from './signer.js';
|
|
14
|
+
import type { L1BlobInputs, SigningCallback } from './types.js';
|
|
15
|
+
|
|
16
|
+
/** Extends L1TxUtils with the capability to cancel blobs. This needs to be a separate class so we don't require a dependency on blob-lib unnecessarily. */
|
|
17
|
+
export class L1TxUtilsWithBlobs extends L1TxUtils {
|
|
18
|
+
/** Makes empty blob inputs for the cancellation tx. */
|
|
19
|
+
protected override makeEmptyBlobInputs(maxFeePerBlobGas: bigint): Required<L1BlobInputs> {
|
|
20
|
+
const blobData = new Uint8Array(131072).fill(0);
|
|
21
|
+
const kzg = Blob.getViemKzgInstance();
|
|
22
|
+
return { blobs: [blobData], kzg, maxFeePerBlobGas };
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function createL1TxUtilsWithBlobsFromViemWallet(
|
|
27
|
+
client: ExtendedViemWalletClient,
|
|
28
|
+
deps: {
|
|
29
|
+
logger?: Logger;
|
|
30
|
+
dateProvider?: DateProvider;
|
|
31
|
+
store?: IL1TxStore;
|
|
32
|
+
metrics?: IL1TxMetrics;
|
|
33
|
+
} = {},
|
|
34
|
+
config: Partial<L1TxUtilsConfig> = {},
|
|
35
|
+
debugMaxGasLimit: boolean = false,
|
|
36
|
+
) {
|
|
37
|
+
return new L1TxUtilsWithBlobs(
|
|
38
|
+
client,
|
|
39
|
+
EthAddress.fromString(client.account.address),
|
|
40
|
+
createViemSigner(client),
|
|
41
|
+
deps.logger,
|
|
42
|
+
deps.dateProvider,
|
|
43
|
+
config,
|
|
44
|
+
debugMaxGasLimit,
|
|
45
|
+
deps.store,
|
|
46
|
+
deps.metrics,
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function createL1TxUtilsWithBlobsFromEthSigner(
|
|
51
|
+
client: ViemClient,
|
|
52
|
+
signer: EthSigner,
|
|
53
|
+
deps: {
|
|
54
|
+
logger?: Logger;
|
|
55
|
+
dateProvider?: DateProvider;
|
|
56
|
+
store?: IL1TxStore;
|
|
57
|
+
metrics?: IL1TxMetrics;
|
|
58
|
+
} = {},
|
|
59
|
+
config: Partial<L1TxUtilsConfig> = {},
|
|
60
|
+
debugMaxGasLimit: boolean = false,
|
|
61
|
+
) {
|
|
62
|
+
const callback: SigningCallback = async (transaction: TransactionSerializable, _signingAddress) => {
|
|
63
|
+
return (await signer.signTransaction(transaction)).toViemTransactionSignature();
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
return new L1TxUtilsWithBlobs(
|
|
67
|
+
client,
|
|
68
|
+
signer.address,
|
|
69
|
+
callback,
|
|
70
|
+
deps.logger,
|
|
71
|
+
deps.dateProvider,
|
|
72
|
+
config,
|
|
73
|
+
debugMaxGasLimit,
|
|
74
|
+
deps.store,
|
|
75
|
+
deps.metrics,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
import { getKeys, merge, pick, times } from '@aztec/foundation/collection';
|
|
2
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
5
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
6
|
+
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
7
|
+
|
|
8
|
+
import pickBy from 'lodash.pickby';
|
|
9
|
+
import {
|
|
10
|
+
type Abi,
|
|
11
|
+
type Account,
|
|
12
|
+
type BaseError,
|
|
13
|
+
type BlockOverrides,
|
|
14
|
+
type ContractFunctionExecutionError,
|
|
15
|
+
type GetCodeReturnType,
|
|
16
|
+
type Hex,
|
|
17
|
+
MethodNotFoundRpcError,
|
|
18
|
+
MethodNotSupportedRpcError,
|
|
19
|
+
type StateOverride,
|
|
20
|
+
decodeErrorResult,
|
|
21
|
+
formatGwei,
|
|
22
|
+
getContractError,
|
|
23
|
+
hexToBytes,
|
|
24
|
+
} from 'viem';
|
|
25
|
+
|
|
26
|
+
import type { ViemClient } from '../types.js';
|
|
27
|
+
import { type L1TxUtilsConfig, defaultL1TxUtilsConfig, l1TxUtilsConfigMappings } from './config.js';
|
|
28
|
+
import {
|
|
29
|
+
BLOCK_TIME_MS,
|
|
30
|
+
LARGE_GAS_LIMIT,
|
|
31
|
+
MIN_BLOB_REPLACEMENT_BUMP_PERCENTAGE,
|
|
32
|
+
MIN_REPLACEMENT_BUMP_PERCENTAGE,
|
|
33
|
+
WEI_CONST,
|
|
34
|
+
} from './constants.js';
|
|
35
|
+
import { P75AllTxsPriorityFeeStrategy, type PriorityFeeStrategy } from './fee-strategies/index.js';
|
|
36
|
+
import type { GasPrice, L1BlobInputs, L1TxRequest, TransactionStats } from './types.js';
|
|
37
|
+
import { getCalldataGasUsage, tryGetCustomErrorNameContractFunction } from './utils.js';
|
|
38
|
+
|
|
39
|
+
// Change this to the current strategy we want to use
|
|
40
|
+
const CurrentStrategy: PriorityFeeStrategy = P75AllTxsPriorityFeeStrategy;
|
|
41
|
+
|
|
42
|
+
export class ReadOnlyL1TxUtils {
|
|
43
|
+
public config: Required<L1TxUtilsConfig>;
|
|
44
|
+
protected interrupted = false;
|
|
45
|
+
|
|
46
|
+
constructor(
|
|
47
|
+
public client: ViemClient,
|
|
48
|
+
protected logger: Logger = createLogger('ethereum:readonly-l1-utils'),
|
|
49
|
+
public readonly dateProvider: DateProvider,
|
|
50
|
+
config?: Partial<L1TxUtilsConfig>,
|
|
51
|
+
protected debugMaxGasLimit: boolean = false,
|
|
52
|
+
) {
|
|
53
|
+
this.config = merge(defaultL1TxUtilsConfig, pick(config || {}, ...getKeys(l1TxUtilsConfigMappings)));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public interrupt() {
|
|
57
|
+
this.interrupted = true;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public restart() {
|
|
61
|
+
this.interrupted = false;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public getBlock() {
|
|
65
|
+
return this.client.getBlock();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public getBlockNumber() {
|
|
69
|
+
return this.client.getBlockNumber();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public getCode(address: EthAddress): Promise<GetCodeReturnType> {
|
|
73
|
+
return this.client.getCode({ address: address.toString() });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Gets the current gas price with bounds checking
|
|
78
|
+
*/
|
|
79
|
+
public async getGasPrice(
|
|
80
|
+
gasConfigOverrides?: L1TxUtilsConfig,
|
|
81
|
+
isBlobTx: boolean = false,
|
|
82
|
+
attempt: number = 0,
|
|
83
|
+
previousGasPrice?: typeof attempt extends 0 ? never : GasPrice,
|
|
84
|
+
): Promise<GasPrice> {
|
|
85
|
+
const gasConfig = merge(this.config, gasConfigOverrides);
|
|
86
|
+
|
|
87
|
+
// Execute strategy - it handles all RPC calls internally and returns everything we need
|
|
88
|
+
const strategyResult = await retry(
|
|
89
|
+
() =>
|
|
90
|
+
CurrentStrategy.execute(this.client, {
|
|
91
|
+
gasConfig,
|
|
92
|
+
isBlobTx,
|
|
93
|
+
logger: this.logger,
|
|
94
|
+
}),
|
|
95
|
+
'Executing priority fee strategy',
|
|
96
|
+
makeBackoff(times(2, () => 0)),
|
|
97
|
+
this.logger,
|
|
98
|
+
true,
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const { latestBlock, blobBaseFee, priorityFee: strategyPriorityFee } = strategyResult;
|
|
102
|
+
|
|
103
|
+
// Extract base fee from latest block
|
|
104
|
+
const baseFee = latestBlock.baseFeePerGas ?? 0n;
|
|
105
|
+
|
|
106
|
+
// Handle blob base fee
|
|
107
|
+
if (isBlobTx && blobBaseFee === undefined) {
|
|
108
|
+
this.logger?.warn('Failed to get L1 blob base fee', attempt);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
let priorityFee = strategyPriorityFee;
|
|
112
|
+
|
|
113
|
+
// Apply minimum priority fee floor if configured
|
|
114
|
+
if (gasConfig.minimumPriorityFeePerGas) {
|
|
115
|
+
const minimumPriorityFee = BigInt(Math.trunc(gasConfig.minimumPriorityFeePerGas * Number(WEI_CONST)));
|
|
116
|
+
if (priorityFee < minimumPriorityFee) {
|
|
117
|
+
this.logger?.debug('Applying minimum priority fee floor', {
|
|
118
|
+
calculatedPriorityFee: formatGwei(priorityFee),
|
|
119
|
+
minimumPriorityFeePerGas: gasConfig.minimumPriorityFeePerGas,
|
|
120
|
+
appliedFee: formatGwei(minimumPriorityFee),
|
|
121
|
+
});
|
|
122
|
+
priorityFee = minimumPriorityFee;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
let maxFeePerGas = baseFee;
|
|
126
|
+
|
|
127
|
+
let maxFeePerBlobGas = blobBaseFee ?? 0n;
|
|
128
|
+
|
|
129
|
+
// Bump base fee so it's valid for next blocks if it stalls
|
|
130
|
+
const numBlocks = Math.ceil(gasConfig.stallTimeMs! / BLOCK_TIME_MS);
|
|
131
|
+
for (let i = 0; i < numBlocks; i++) {
|
|
132
|
+
// each block can go up 12.5% from previous baseFee
|
|
133
|
+
maxFeePerGas = (maxFeePerGas * (1_000n + 125n)) / 1_000n;
|
|
134
|
+
// same for blob gas fee
|
|
135
|
+
maxFeePerBlobGas = (maxFeePerBlobGas * (1_000n + 125n)) / 1_000n;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (attempt > 0) {
|
|
139
|
+
const configBump =
|
|
140
|
+
gasConfig.priorityFeeRetryBumpPercentage ?? defaultL1TxUtilsConfig.priorityFeeRetryBumpPercentage!;
|
|
141
|
+
|
|
142
|
+
// if this is a blob tx, we have to use the blob bump percentage
|
|
143
|
+
const minBumpPercentage = isBlobTx ? MIN_BLOB_REPLACEMENT_BUMP_PERCENTAGE : MIN_REPLACEMENT_BUMP_PERCENTAGE;
|
|
144
|
+
|
|
145
|
+
const bumpPercentage = configBump > minBumpPercentage ? configBump : minBumpPercentage;
|
|
146
|
+
// Calculate minimum required fees based on previous attempt
|
|
147
|
+
// multiply by 100 & divide by 100 to maintain some precision
|
|
148
|
+
const minPriorityFee =
|
|
149
|
+
(previousGasPrice!.maxPriorityFeePerGas * (100_00n + BigInt(bumpPercentage * 1_00))) / 100_00n;
|
|
150
|
+
const minMaxFee = (previousGasPrice!.maxFeePerGas * (100_00n + BigInt(bumpPercentage * 1_00))) / 100_00n;
|
|
151
|
+
|
|
152
|
+
// Apply bump percentage to competitive fee
|
|
153
|
+
const competitivePriorityFee = (priorityFee * (100_00n + BigInt(configBump * 1_00))) / 100_00n;
|
|
154
|
+
|
|
155
|
+
this.logger?.debug(`Speed-up attempt ${attempt}: using competitive fee strategy`, {
|
|
156
|
+
networkEstimate: formatGwei(priorityFee),
|
|
157
|
+
competitiveFee: formatGwei(competitivePriorityFee),
|
|
158
|
+
minRequired: formatGwei(minPriorityFee),
|
|
159
|
+
bumpPercentage: configBump,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// Use maximum between competitive fee and minimum required bump
|
|
163
|
+
const finalPriorityFee = competitivePriorityFee > minPriorityFee ? competitivePriorityFee : minPriorityFee;
|
|
164
|
+
const feeSource = finalPriorityFee === competitivePriorityFee ? 'competitive' : 'minimum-bump';
|
|
165
|
+
|
|
166
|
+
priorityFee = finalPriorityFee;
|
|
167
|
+
// Add the final priority fee to maxFeePerGas
|
|
168
|
+
maxFeePerGas += finalPriorityFee;
|
|
169
|
+
maxFeePerGas = maxFeePerGas > minMaxFee ? maxFeePerGas : minMaxFee;
|
|
170
|
+
|
|
171
|
+
this.logger?.debug(`Speed-up fee decision: using ${feeSource} fee`, {
|
|
172
|
+
finalPriorityFee: formatGwei(finalPriorityFee),
|
|
173
|
+
});
|
|
174
|
+
} else {
|
|
175
|
+
// First attempt: apply configured bump percentage to competitive fee
|
|
176
|
+
// multiply by 100 & divide by 100 to maintain some precision
|
|
177
|
+
priorityFee = (priorityFee * (100_00n + BigInt((gasConfig.priorityFeeBumpPercentage || 0) * 1_00))) / 100_00n;
|
|
178
|
+
this.logger?.debug('Initial transaction: using competitive fee from market analysis', {
|
|
179
|
+
networkEstimate: formatGwei(priorityFee),
|
|
180
|
+
});
|
|
181
|
+
maxFeePerGas += priorityFee;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// maxGwei and maxBlobGwei are hard limits
|
|
185
|
+
const effectiveMaxGwei = BigInt(Math.trunc(gasConfig.maxGwei! * Number(WEI_CONST)));
|
|
186
|
+
const effectiveMaxBlobGwei = BigInt(Math.trunc(gasConfig.maxBlobGwei! * Number(WEI_CONST)));
|
|
187
|
+
|
|
188
|
+
// Ensure we don't exceed maxGwei
|
|
189
|
+
if (effectiveMaxGwei > 0n) {
|
|
190
|
+
maxFeePerGas = maxFeePerGas > effectiveMaxGwei ? effectiveMaxGwei : maxFeePerGas;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Ensure we don't exceed maxBlobGwei
|
|
194
|
+
if (maxFeePerBlobGas && effectiveMaxBlobGwei > 0n) {
|
|
195
|
+
maxFeePerBlobGas = maxFeePerBlobGas > effectiveMaxBlobGwei ? effectiveMaxBlobGwei : maxFeePerBlobGas;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Ensure priority fee doesn't exceed max fee
|
|
199
|
+
const maxPriorityFeePerGas = priorityFee > maxFeePerGas ? maxFeePerGas : priorityFee;
|
|
200
|
+
|
|
201
|
+
if (attempt > 0 && previousGasPrice?.maxFeePerBlobGas) {
|
|
202
|
+
const bumpPercentage =
|
|
203
|
+
gasConfig.priorityFeeRetryBumpPercentage! > MIN_BLOB_REPLACEMENT_BUMP_PERCENTAGE
|
|
204
|
+
? gasConfig.priorityFeeRetryBumpPercentage!
|
|
205
|
+
: MIN_BLOB_REPLACEMENT_BUMP_PERCENTAGE;
|
|
206
|
+
|
|
207
|
+
// calculate min blob fee based on previous attempt
|
|
208
|
+
const minBlobFee = (previousGasPrice.maxFeePerBlobGas * (100_00n + BigInt(bumpPercentage * 1_00))) / 100_00n;
|
|
209
|
+
|
|
210
|
+
// use max between current network values and min required values
|
|
211
|
+
maxFeePerBlobGas = maxFeePerBlobGas > minBlobFee ? maxFeePerBlobGas : minBlobFee;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
this.logger?.trace(
|
|
215
|
+
`Computed L1 gas price max fee ${formatGwei(maxFeePerGas)} and max priority fee ${formatGwei(maxPriorityFeePerGas)}`,
|
|
216
|
+
{
|
|
217
|
+
attempt,
|
|
218
|
+
baseFee: formatGwei(baseFee),
|
|
219
|
+
maxFeePerGas: formatGwei(maxFeePerGas),
|
|
220
|
+
maxPriorityFeePerGas: formatGwei(maxPriorityFeePerGas),
|
|
221
|
+
blobBaseFee: formatGwei(blobBaseFee ?? 0n),
|
|
222
|
+
maxFeePerBlobGas: formatGwei(maxFeePerBlobGas),
|
|
223
|
+
},
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
return {
|
|
227
|
+
maxFeePerGas,
|
|
228
|
+
maxPriorityFeePerGas,
|
|
229
|
+
...(maxFeePerBlobGas && { maxFeePerBlobGas: maxFeePerBlobGas }),
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Estimates gas and adds buffer
|
|
235
|
+
*/
|
|
236
|
+
public async estimateGas(
|
|
237
|
+
account: Account | Hex,
|
|
238
|
+
request: L1TxRequest,
|
|
239
|
+
_gasConfig?: L1TxUtilsConfig,
|
|
240
|
+
_blobInputs?: L1BlobInputs,
|
|
241
|
+
): Promise<bigint> {
|
|
242
|
+
const gasConfig = { ...this.config, ..._gasConfig };
|
|
243
|
+
let initialEstimate = 0n;
|
|
244
|
+
if (_blobInputs) {
|
|
245
|
+
// @note requests with blobs also require maxFeePerBlobGas to be set
|
|
246
|
+
const gasPrice = await this.getGasPrice(gasConfig, true, 0);
|
|
247
|
+
initialEstimate = await this.client.estimateGas({
|
|
248
|
+
account,
|
|
249
|
+
...request,
|
|
250
|
+
..._blobInputs,
|
|
251
|
+
maxFeePerBlobGas: gasPrice.maxFeePerBlobGas!,
|
|
252
|
+
gas: LARGE_GAS_LIMIT,
|
|
253
|
+
blockTag: 'latest',
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
this.logger?.trace(`Estimated gas for blob tx: ${initialEstimate}`);
|
|
257
|
+
} else {
|
|
258
|
+
initialEstimate = await this.client.estimateGas({
|
|
259
|
+
account,
|
|
260
|
+
...request,
|
|
261
|
+
gas: LARGE_GAS_LIMIT,
|
|
262
|
+
blockTag: 'latest',
|
|
263
|
+
});
|
|
264
|
+
this.logger?.trace(`Estimated gas for non-blob tx: ${initialEstimate}`);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
// Add buffer based on either fixed amount or percentage
|
|
268
|
+
const withBuffer = this.bumpGasLimit(initialEstimate, gasConfig);
|
|
269
|
+
|
|
270
|
+
return withBuffer;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
async getTransactionStats(txHash: string): Promise<TransactionStats | undefined> {
|
|
274
|
+
const tx = await this.client.getTransaction({ hash: txHash as Hex });
|
|
275
|
+
if (!tx) {
|
|
276
|
+
return undefined;
|
|
277
|
+
}
|
|
278
|
+
const calldata = hexToBytes(tx.input);
|
|
279
|
+
return {
|
|
280
|
+
sender: tx.from.toString(),
|
|
281
|
+
transactionHash: tx.hash,
|
|
282
|
+
calldataSize: calldata.length,
|
|
283
|
+
calldataGas: getCalldataGasUsage(calldata),
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
public async tryGetErrorFromRevertedTx(
|
|
288
|
+
data: Hex,
|
|
289
|
+
args: {
|
|
290
|
+
args: readonly any[];
|
|
291
|
+
functionName: string;
|
|
292
|
+
abi: Abi;
|
|
293
|
+
address: Hex;
|
|
294
|
+
},
|
|
295
|
+
blobInputs: (L1BlobInputs & { maxFeePerBlobGas: bigint }) | undefined,
|
|
296
|
+
stateOverride: StateOverride = [],
|
|
297
|
+
) {
|
|
298
|
+
try {
|
|
299
|
+
await this.client.simulateContract({
|
|
300
|
+
...args,
|
|
301
|
+
account: this.client.account,
|
|
302
|
+
stateOverride,
|
|
303
|
+
});
|
|
304
|
+
this.logger?.trace('Simulated blob tx', { blobInputs });
|
|
305
|
+
// If the above passes, we have a blob error. We cannot simulate blob txs, and failed txs no longer throw errors.
|
|
306
|
+
// Strangely, the only way to throw the revert reason as an error and provide blobs is prepareTransactionRequest.
|
|
307
|
+
// See: https://github.com/wevm/viem/issues/2075
|
|
308
|
+
// This throws a EstimateGasExecutionError with the custom error information:
|
|
309
|
+
const request = blobInputs
|
|
310
|
+
? {
|
|
311
|
+
account: this.client.account,
|
|
312
|
+
to: args.address,
|
|
313
|
+
data,
|
|
314
|
+
blobs: blobInputs.blobs,
|
|
315
|
+
kzg: blobInputs.kzg,
|
|
316
|
+
maxFeePerBlobGas: blobInputs.maxFeePerBlobGas,
|
|
317
|
+
}
|
|
318
|
+
: {
|
|
319
|
+
account: this.client.account,
|
|
320
|
+
to: args.address,
|
|
321
|
+
data,
|
|
322
|
+
};
|
|
323
|
+
this.logger?.trace('Preparing tx', { request });
|
|
324
|
+
await this.client.prepareTransactionRequest(request);
|
|
325
|
+
this.logger?.trace('Prepared tx');
|
|
326
|
+
return undefined;
|
|
327
|
+
} catch (simulationErr: any) {
|
|
328
|
+
// If we don't have a ContractFunctionExecutionError, we have a blob related error => use getContractError to get the error msg.
|
|
329
|
+
const contractErr =
|
|
330
|
+
simulationErr.name === 'ContractFunctionExecutionError'
|
|
331
|
+
? simulationErr
|
|
332
|
+
: getContractError(simulationErr as BaseError, {
|
|
333
|
+
args: [],
|
|
334
|
+
abi: args.abi,
|
|
335
|
+
functionName: args.functionName,
|
|
336
|
+
address: args.address,
|
|
337
|
+
});
|
|
338
|
+
if (contractErr.name === 'ContractFunctionExecutionError') {
|
|
339
|
+
const execErr = contractErr as ContractFunctionExecutionError;
|
|
340
|
+
return tryGetCustomErrorNameContractFunction(execErr);
|
|
341
|
+
}
|
|
342
|
+
this.logger?.error(`Error getting error from simulation`, simulationErr);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
public async simulate(
|
|
347
|
+
request: L1TxRequest & { gas?: bigint; from?: Hex },
|
|
348
|
+
blockOverrides: BlockOverrides<bigint, number> = {},
|
|
349
|
+
stateOverrides: StateOverride = [],
|
|
350
|
+
abi: Abi = RollupAbi,
|
|
351
|
+
_gasConfig?: L1TxUtilsConfig & { fallbackGasEstimate?: bigint },
|
|
352
|
+
): Promise<{ gasUsed: bigint; result: `0x${string}` }> {
|
|
353
|
+
const gasConfig = { ...this.config, ..._gasConfig };
|
|
354
|
+
|
|
355
|
+
const call: any = {
|
|
356
|
+
to: request.to!,
|
|
357
|
+
data: request.data,
|
|
358
|
+
...(request.from && { from: request.from }),
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
return await this._simulate(call, blockOverrides, stateOverrides, gasConfig, abi);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
protected async _simulate(
|
|
365
|
+
call: any,
|
|
366
|
+
blockOverrides: BlockOverrides<bigint, number> = {},
|
|
367
|
+
stateOverrides: StateOverride = [],
|
|
368
|
+
gasConfig: L1TxUtilsConfig & { fallbackGasEstimate?: bigint },
|
|
369
|
+
abi: Abi,
|
|
370
|
+
) {
|
|
371
|
+
try {
|
|
372
|
+
const result = await this.client.simulateBlocks({
|
|
373
|
+
validation: false,
|
|
374
|
+
blocks: [
|
|
375
|
+
{
|
|
376
|
+
blockOverrides,
|
|
377
|
+
stateOverrides,
|
|
378
|
+
calls: [call],
|
|
379
|
+
},
|
|
380
|
+
],
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
if (result[0].calls[0].status === 'failure') {
|
|
384
|
+
this.logger?.error('L1 transaction simulation failed', result[0].calls[0].error);
|
|
385
|
+
const decodedError = decodeErrorResult({ abi, data: result[0].calls[0].data });
|
|
386
|
+
|
|
387
|
+
throw new Error(
|
|
388
|
+
`L1 transaction simulation failed with error ${decodedError.errorName}(${decodedError.args?.join(',')})`,
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
this.logger?.debug(`L1 transaction simulation succeeded`, { ...result[0].calls[0] });
|
|
392
|
+
return { gasUsed: result[0].gasUsed, result: result[0].calls[0].data as `0x${string}` };
|
|
393
|
+
} catch (err) {
|
|
394
|
+
if (err instanceof MethodNotFoundRpcError || err instanceof MethodNotSupportedRpcError) {
|
|
395
|
+
if (gasConfig.fallbackGasEstimate) {
|
|
396
|
+
this.logger?.warn(
|
|
397
|
+
`Node does not support eth_simulateV1 API. Using fallback gas estimate: ${gasConfig.fallbackGasEstimate}`,
|
|
398
|
+
);
|
|
399
|
+
return { gasUsed: gasConfig.fallbackGasEstimate, result: '0x' as `0x${string}` };
|
|
400
|
+
}
|
|
401
|
+
this.logger?.error('Node does not support eth_simulateV1 API');
|
|
402
|
+
}
|
|
403
|
+
throw err;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
public bumpGasLimit(gasLimit: bigint, _gasConfig?: L1TxUtilsConfig): bigint {
|
|
408
|
+
const gasConfig = { ...this.config, ..._gasConfig };
|
|
409
|
+
const bumpedGasLimit = gasLimit + (gasLimit * BigInt((gasConfig?.gasLimitBufferPercentage || 0) * 1_00)) / 100_00n;
|
|
410
|
+
|
|
411
|
+
const cleanGasConfig = pickBy(gasConfig, (_, key) => key in l1TxUtilsConfigMappings);
|
|
412
|
+
this.logger?.trace(`Bumping gas limit from ${gasLimit} to ${bumpedGasLimit}`, {
|
|
413
|
+
gasLimit,
|
|
414
|
+
gasConfig: cleanGasConfig,
|
|
415
|
+
bumpedGasLimit,
|
|
416
|
+
});
|
|
417
|
+
return bumpedGasLimit;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
+
import type { ViemTransactionSignature } from '@aztec/foundation/eth-signature';
|
|
3
|
+
|
|
4
|
+
import { type TransactionSerializable, type WalletClient, parseTransaction } from 'viem';
|
|
5
|
+
|
|
6
|
+
import type { SigningCallback } from './types.js';
|
|
7
|
+
|
|
8
|
+
export function createViemSigner(client: WalletClient) {
|
|
9
|
+
const signer: SigningCallback = async (
|
|
10
|
+
tx: TransactionSerializable,
|
|
11
|
+
_address: EthAddress,
|
|
12
|
+
): Promise<ViemTransactionSignature> => {
|
|
13
|
+
const signedTx = await client.signTransaction(tx as any);
|
|
14
|
+
|
|
15
|
+
const parsed = parseTransaction(signedTx);
|
|
16
|
+
|
|
17
|
+
if (!parsed.r || !parsed.s || (parsed.yParity !== 0 && parsed.yParity !== 1)) {
|
|
18
|
+
throw new Error('Failed to extract signature from viem signed transaction');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
r: parsed.r,
|
|
23
|
+
s: parsed.s,
|
|
24
|
+
yParity: parsed.yParity,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
return signer;
|
|
28
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { BlobKzgInstance } from '@aztec/blob-lib/types';
|
|
2
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
import type { ViemTransactionSignature } from '@aztec/foundation/eth-signature';
|
|
4
|
+
|
|
5
|
+
import type { Abi, Address, Hex, TransactionReceipt, TransactionSerializable } from 'viem';
|
|
6
|
+
|
|
7
|
+
import type { L1TxUtilsConfig } from './config.js';
|
|
8
|
+
|
|
9
|
+
export interface L1TxRequest {
|
|
10
|
+
to: Address | null;
|
|
11
|
+
data?: Hex;
|
|
12
|
+
value?: bigint;
|
|
13
|
+
abi?: Abi;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type L1TxConfig = Partial<L1TxUtilsConfig> & { gasLimit?: bigint; txTimeoutAt?: Date };
|
|
17
|
+
|
|
18
|
+
export interface L1BlobInputs {
|
|
19
|
+
blobs: Uint8Array[];
|
|
20
|
+
kzg: BlobKzgInstance;
|
|
21
|
+
maxFeePerBlobGas?: bigint;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface GasPrice {
|
|
25
|
+
maxFeePerGas: bigint;
|
|
26
|
+
maxPriorityFeePerGas: bigint;
|
|
27
|
+
maxFeePerBlobGas?: bigint;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type TransactionStats = {
|
|
31
|
+
/** Address of the sender. */
|
|
32
|
+
sender: string;
|
|
33
|
+
/** Hash of the transaction. */
|
|
34
|
+
transactionHash: string;
|
|
35
|
+
/** Size in bytes of the tx calldata */
|
|
36
|
+
calldataSize: number;
|
|
37
|
+
/** Gas required to pay for the calldata inclusion (depends on size and number of zeros) */
|
|
38
|
+
calldataGas: number;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export enum TxUtilsState {
|
|
42
|
+
IDLE,
|
|
43
|
+
SENT,
|
|
44
|
+
SPEED_UP,
|
|
45
|
+
CANCELLED,
|
|
46
|
+
NOT_MINED,
|
|
47
|
+
MINED,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const TerminalTxUtilsState = [TxUtilsState.IDLE, TxUtilsState.MINED, TxUtilsState.NOT_MINED];
|
|
51
|
+
|
|
52
|
+
export type L1TxState = {
|
|
53
|
+
id: number;
|
|
54
|
+
txHashes: Hex[];
|
|
55
|
+
cancelTxHashes: Hex[];
|
|
56
|
+
gasLimit: bigint;
|
|
57
|
+
gasPrice: GasPrice;
|
|
58
|
+
txConfigOverrides: L1TxConfig;
|
|
59
|
+
request: L1TxRequest;
|
|
60
|
+
status: TxUtilsState;
|
|
61
|
+
nonce: number;
|
|
62
|
+
sentAtL1Ts: Date;
|
|
63
|
+
lastSentAtL1Ts: Date;
|
|
64
|
+
receipt?: TransactionReceipt;
|
|
65
|
+
blobInputs: L1BlobInputs | undefined;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export type SigningCallback = (
|
|
69
|
+
transaction: TransactionSerializable,
|
|
70
|
+
signingAddress: EthAddress,
|
|
71
|
+
) => Promise<ViemTransactionSignature>;
|
|
72
|
+
|
|
73
|
+
export class UnknownMinedTxError extends Error {
|
|
74
|
+
constructor(nonce: number, account: string) {
|
|
75
|
+
super(`Nonce ${nonce} from account ${account} is MINED but not by one of our expected transactions`);
|
|
76
|
+
this.name = 'UnknownMinedTxError';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export class DroppedTransactionError extends Error {
|
|
81
|
+
constructor(nonce: number, account: string) {
|
|
82
|
+
super(`Transaction with nonce ${nonce} from account ${account} was dropped from the mempool`);
|
|
83
|
+
this.name = 'DroppedTransactionError';
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { compactArray } from '@aztec/foundation/collection';
|
|
2
|
+
|
|
3
|
+
import type { ContractFunctionExecutionError } from 'viem';
|
|
4
|
+
|
|
5
|
+
export function tryGetCustomErrorNameContractFunction(err: ContractFunctionExecutionError) {
|
|
6
|
+
return compactArray([err.shortMessage, ...(err.metaMessages ?? []).slice(0, 2).map(s => s.trim())]).join(' ');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* Returns cost of calldata usage in Ethereum.
|
|
11
|
+
* @param data - Calldata.
|
|
12
|
+
* @returns 4 for each zero byte, 16 for each nonzero.
|
|
13
|
+
*/
|
|
14
|
+
export function getCalldataGasUsage(data: Uint8Array) {
|
|
15
|
+
return data.filter(byte => byte === 0).length * 4 + data.filter(byte => byte !== 0).length * 16;
|
|
16
|
+
}
|