@aztec/ethereum 5.2.0-nightly.20260813 → 5.2.0-nightly.20260814
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/client.d.ts +3 -1
- package/dest/client.d.ts.map +1 -1
- package/dest/client.js +4 -1
- package/dest/l1_tx_utils/l1_tx_utils.js +4 -4
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils/readonly_l1_tx_utils.js +47 -18
- package/package.json +5 -5
- package/src/client.ts +6 -0
- package/src/l1_tx_utils/l1_tx_utils.ts +4 -4
- package/src/l1_tx_utils/readonly_l1_tx_utils.ts +47 -12
package/dest/client.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ export declare function makeL1HttpTransport(rpcUrls: string[], opts?: {
|
|
|
24
24
|
export declare function getL1RpcHttpStatus(err: unknown): number | undefined;
|
|
25
25
|
/** Returns true when an L1 RPC error's cause chain contains the given HTTP status. */
|
|
26
26
|
export declare function isL1RpcHttpStatus(err: unknown, status: number): boolean;
|
|
27
|
+
/** Returns the JSON-RPC error code reported by the L1 node, if the error's cause chain carries one. */
|
|
28
|
+
export declare function getL1RpcErrorCode(err: unknown): number | undefined;
|
|
27
29
|
/**
|
|
28
30
|
* Returns the individual RPC URLs underlying a viem public client that was constructed with a
|
|
29
31
|
* fallback HTTP transport (see {@link makeL1HttpTransport}). Returns an empty array if the
|
|
@@ -37,4 +39,4 @@ export declare function waitForPublicClient(config: Config, logger?: Logger): Pr
|
|
|
37
39
|
export declare function createExtendedL1Client(rpcUrls: string[], mnemonicOrPrivateKeyOrHdAccount: string | HDAccount | PrivateKeyAccount | LocalAccount, chain?: Chain, pollingIntervalMS?: number, addressIndex?: number, opts?: {
|
|
38
40
|
httpTimeoutMS?: number;
|
|
39
41
|
}): ExtendedViemWalletClient;
|
|
40
|
-
//# sourceMappingURL=data:application/json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BTSxDQUFBO0NBQUUsR0FDaEMsd0JBQXdCLENBZ0IxQiJ9
|
package/dest/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAIpD,OAAO,EACL,KAAK,KAAK,EACV,KAAK,iBAAiB,EACtB,KAAK,SAAS,EAEd,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAIpD,OAAO,EACL,KAAK,KAAK,EACV,KAAK,iBAAiB,EACtB,KAAK,SAAS,EAEd,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EAOvB,MAAM,MAAM,CAAC;AAKd,OAAO,KAAK,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE7E,KAAK,MAAM,GAAG;IACZ,0FAA0F;IAC1F,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,0DAA0D;IAC1D,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,YAAY,EAAE,MAAM,IAAI,oBAAoB,EAAE,CAAC;AAE/C,yFAAyF;AACzF,qBAAa,UAAW,SAAQ,KAAK;IACnC,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,EAGlD;CACF;AAED,wEAAwE;AACxE,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,sCAEjF;AAED,uFAAuF;AACvF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAEnE;AAED,sFAAsF;AACtF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAEvE;AAED,uGAAuG;AACvG,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAElE;AAkBD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,EAAE,CAWvE;AAID,wDAAwD;AACxD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAOhE;AAED,0FAA0F;AAC1F,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAIpG;AAyBD,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EAAE,EACjB,+BAA+B,EAAE,MAAM,GAAG,SAAS,GAAG,iBAAiB,GAAG,YAAY,EACtF,KAAK,GAAE,KAAe,EACtB,iBAAiB,CAAC,EAAE,MAAM,EAC1B,YAAY,CAAC,EAAE,MAAM,EACrB,IAAI,CAAC,EAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,GAChC,wBAAwB,CAgB1B"}
|
package/dest/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
2
2
|
import { getErrorCause } from '@aztec/foundation/types';
|
|
3
|
-
import { HttpRequestError, createPublicClient, createWalletClient, fallback, http, publicActions } from 'viem';
|
|
3
|
+
import { HttpRequestError, RpcRequestError, createPublicClient, createWalletClient, fallback, http, publicActions } from 'viem';
|
|
4
4
|
import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
|
|
5
5
|
import { foundry } from 'viem/chains';
|
|
6
6
|
import { createEthereumChain } from './chain.js';
|
|
@@ -22,6 +22,9 @@ import { createEthereumChain } from './chain.js';
|
|
|
22
22
|
/** Returns true when an L1 RPC error's cause chain contains the given HTTP status. */ export function isL1RpcHttpStatus(err, status) {
|
|
23
23
|
return getL1RpcHttpStatus(err) === status;
|
|
24
24
|
}
|
|
25
|
+
/** Returns the JSON-RPC error code reported by the L1 node, if the error's cause chain carries one. */ export function getL1RpcErrorCode(err) {
|
|
26
|
+
return getErrorCause(err, RpcRequestError)?.code;
|
|
27
|
+
}
|
|
25
28
|
function wrapL1RpcTransport(transport) {
|
|
26
29
|
const wrappedTransport = (parameters)=>{
|
|
27
30
|
const fallbackTransport = transport(parameters);
|
|
@@ -570,20 +570,20 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
570
570
|
..._blockOverrides
|
|
571
571
|
};
|
|
572
572
|
const gasConfig = merge(this.config, _gasConfig);
|
|
573
|
-
|
|
573
|
+
// Fee fields are deliberately omitted. Supplying them makes the node apply the EIP-1559 upfront funds
|
|
574
|
+
// check (sender balance >= gas * maxFeePerGas) against the worst-case gas cap below, which rejects the
|
|
575
|
+
// whole simulation request before any execution. Omitted fee fields default to a zero gas price.
|
|
574
576
|
const call = {
|
|
575
577
|
to: request.to,
|
|
576
578
|
data: request.data,
|
|
577
579
|
from: request.from ?? this.getSenderAddress().toString(),
|
|
578
|
-
maxFeePerGas: gasPrice.maxFeePerGas,
|
|
579
|
-
maxPriorityFeePerGas: gasPrice.maxPriorityFeePerGas,
|
|
580
580
|
gas: request.gas ?? MAX_L1_TX_LIMIT
|
|
581
581
|
};
|
|
582
582
|
if (!request.gas && !gasConfig.ignoreBlockGasLimit) {
|
|
583
583
|
// MAX_L1_TX_LIMIT is set as call.gas, ensure block gasLimit is sufficient
|
|
584
584
|
blockOverrides.gasLimit = MAX_L1_TX_LIMIT;
|
|
585
585
|
}
|
|
586
|
-
return this._simulate(call, blockOverrides, stateOverrides, gasConfig, abi);
|
|
586
|
+
return await this._simulate(call, blockOverrides, stateOverrides, gasConfig, abi);
|
|
587
587
|
}
|
|
588
588
|
/**
|
|
589
589
|
* Attempts to cancel a transaction by sending a 0-value tx to self with same nonce but higher gas prices
|
|
@@ -80,4 +80,4 @@ export declare class ReadOnlyL1TxUtils {
|
|
|
80
80
|
}>;
|
|
81
81
|
bumpGasLimit(gasLimit: bigint, _gasConfig?: L1TxUtilsConfig): bigint;
|
|
82
82
|
}
|
|
83
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
83
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVhZG9ubHlfbDFfdHhfdXRpbHMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9sMV90eF91dGlscy9yZWFkb25seV9sMV90eF91dGlscy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUNoRSxPQUFPLEVBQUUsS0FBSyxNQUFNLEVBQWdCLE1BQU0sdUJBQXVCLENBQUM7QUFFbEUsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBS3ZELE9BQU8sRUFDTCxLQUFLLEdBQUcsRUFDUixLQUFLLE9BQU8sRUFFWixLQUFLLGNBQWMsRUFFbkIsS0FBSyxpQkFBaUIsRUFDdEIsS0FBSyxHQUFHLEVBSVIsS0FBSyxhQUFhLEVBS25CLE1BQU0sTUFBTSxDQUFDO0FBR2QsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sYUFBYSxDQUFDO0FBQzlDLE9BQU8sRUFBRSxLQUFLLGVBQWUsRUFBbUQsTUFBTSxhQUFhLENBQUM7QUFTcEcsT0FBTyxLQUFLLEVBQUUsUUFBUSxFQUFFLFlBQVksRUFBRSxXQUFX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yxDQVVyRDtJQUVELFVBQWdCLFNBQVMsQ0FDdkIsSUFBSSxFQUFFLEdBQUcsRUFDVCxjQUFjLDRDQUFxQyxFQUNuRCxjQUFjLDJCQUFvQixFQUNsQyxTQUFTLEVBQUUsZUFBZSxHQUFHO1FBQUUsbUJBQW1CLENBQUMsRUFBRSxNQUFNLENBQUE7S0FBRSxFQUM3RCxHQUFHLEVBQUUsR0FBRzs7O09Bb0RUO0lBRU0sWUFBWSxDQUFDLFFBQVEsRUFBRSxNQUFNLEVBQUUsVUFBVSxDQUFDLEVBQUUsZUFBZSxHQUFHLE1BQU0sQ0FXMUU7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readonly_l1_tx_utils.d.ts","sourceRoot":"","sources":["../../src/l1_tx_utils/readonly_l1_tx_utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKvD,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OAAO,EAEZ,KAAK,cAAc,EAEnB,KAAK,iBAAiB,EACtB,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"readonly_l1_tx_utils.d.ts","sourceRoot":"","sources":["../../src/l1_tx_utils/readonly_l1_tx_utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAElE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKvD,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OAAO,EAEZ,KAAK,cAAc,EAEnB,KAAK,iBAAiB,EACtB,KAAK,GAAG,EAIR,KAAK,aAAa,EAKnB,MAAM,MAAM,CAAC;AAGd,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AgB,GAAG,SAAS,CAAC,CAY/E;IAEY,yBAAyB,CACpC,IAAI,EAAE,GAAG,EACT,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS,GAAG,EAAE,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB,GAAG,EAAE,GAAG,CAAC;QACT,OAAO,EAAE,GAAG,CAAC;KACd,EACD,UAAU,EAAE,CAAC,YAAY,GAAG;QAAE,gBAAgB,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,SAAS,EACrE,aAAa,GAAE,aAAkB,+BAgDlC;IAEY,QAAQ,CACnB,OAAO,EAAE,WAAW,GAAG;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,GAAG,CAAA;KAAE,EACnD,cAAc,GAAE,cAAc,CAAC,MAAM,EAAE,MAAM,CAAM,EACnD,cAAc,GAAE,aAAkB,EAClC,GAAG,GAAE,GAAe,EACpB,UAAU,CAAC,EAAE,eAAe,GAAG;QAAE,mBAAmB,CAAC,EAAE,MAAM,CAAA;KAAE,GAC9D,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,KAAK,MAAM,EAAE,CAAA;KAAE,CAAC,CAUrD;IAED,UAAgB,SAAS,CACvB,IAAI,EAAE,GAAG,EACT,cAAc,4CAAqC,EACnD,cAAc,2BAAoB,EAClC,SAAS,EAAE,eAAe,GAAG;QAAE,mBAAmB,CAAC,EAAE,MAAM,CAAA;KAAE,EAC7D,GAAG,EAAE,GAAG;;;OAoDT;IAEM,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,eAAe,GAAG,MAAM,CAW1E;CACF"}
|
|
@@ -4,13 +4,30 @@ import { makeBackoff, retry } from '@aztec/foundation/retry';
|
|
|
4
4
|
import { getErrorCause } from '@aztec/foundation/types';
|
|
5
5
|
import { RollupAbi } from '@aztec/l1-artifacts/RollupAbi';
|
|
6
6
|
import pickBy from 'lodash.pickby';
|
|
7
|
-
import { MethodNotFoundRpcError, MethodNotSupportedRpcError, decodeErrorResult, formatGwei, getContractError, hexToBytes } from 'viem';
|
|
7
|
+
import { MethodNotFoundRpcError, MethodNotSupportedRpcError, RpcRequestError, decodeErrorResult, formatGwei, getContractError, hexToBytes } from 'viem';
|
|
8
|
+
import { getL1RpcErrorCode } from '../client.js';
|
|
8
9
|
import { defaultL1TxUtilsConfig, l1TxUtilsConfigMappings } from './config.js';
|
|
9
10
|
import { BLOCK_TIME_MS, MAX_L1_TX_LIMIT, MIN_BLOB_REPLACEMENT_BUMP_PERCENTAGE, MIN_REPLACEMENT_BUMP_PERCENTAGE, WEI_CONST } from './constants.js';
|
|
10
11
|
import { P75AllTxsPriorityFeeStrategy } from './fee-strategies/index.js';
|
|
11
12
|
import { getCalldataGasUsage, tryGetCustomErrorNameContractFunction } from './utils.js';
|
|
12
13
|
// Change this to the current strategy we want to use
|
|
13
14
|
const CurrentStrategy = P75AllTxsPriorityFeeStrategy;
|
|
15
|
+
/** Error code returned by eth_simulateV1 for `insufficient funds for gas * price + value`. */ const INSUFFICIENT_FUNDS_RPC_ERROR_CODE = -38014;
|
|
16
|
+
/**
|
|
17
|
+
* Returns true when an RPC transport error reports the node's upfront funds check
|
|
18
|
+
* (sender balance >= gasLimit * maxFeePerGas) rejecting the request. Matches on the message as well as on the
|
|
19
|
+
* error code, since RPC gateways differ in how they wrap node errors. Apply this only to transport errors: an
|
|
20
|
+
* execution revert string can mention insufficient funds without being this kind of rejection.
|
|
21
|
+
*/ function isInsufficientFundsRpcError(err) {
|
|
22
|
+
if (getL1RpcErrorCode(err) === INSUFFICIENT_FUNDS_RPC_ERROR_CODE) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
const messages = [
|
|
26
|
+
err,
|
|
27
|
+
getErrorCause(err, RpcRequestError)
|
|
28
|
+
].map((e)=>e instanceof Error ? e.message : '').join(' ');
|
|
29
|
+
return /insufficient funds/i.test(messages);
|
|
30
|
+
}
|
|
14
31
|
export class ReadOnlyL1TxUtils {
|
|
15
32
|
client;
|
|
16
33
|
logger;
|
|
@@ -269,8 +286,7 @@ export class ReadOnlyL1TxUtils {
|
|
|
269
286
|
return await this._simulate(call, blockOverrides, stateOverrides, gasConfig, abi);
|
|
270
287
|
}
|
|
271
288
|
async _simulate(call, blockOverrides = {}, stateOverrides = [], gasConfig, abi) {
|
|
272
|
-
|
|
273
|
-
const result = await this.client.simulateBlocks({
|
|
289
|
+
const simulateBlocks = ()=>this.client.simulateBlocks({
|
|
274
290
|
validation: false,
|
|
275
291
|
blocks: [
|
|
276
292
|
{
|
|
@@ -282,21 +298,11 @@ export class ReadOnlyL1TxUtils {
|
|
|
282
298
|
}
|
|
283
299
|
]
|
|
284
300
|
});
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
});
|
|
291
|
-
throw new Error(`L1 transaction simulation failed with error ${decodedError.errorName}(${decodedError.args?.join(',')})`);
|
|
292
|
-
}
|
|
293
|
-
this.logger?.debug(`L1 transaction simulation succeeded`, {
|
|
294
|
-
...result[0].calls[0]
|
|
295
|
-
});
|
|
296
|
-
return {
|
|
297
|
-
gasUsed: result[0].gasUsed,
|
|
298
|
-
result: result[0].calls[0].data
|
|
299
|
-
};
|
|
301
|
+
// Only the request itself is wrapped, so that transport-level rejections are never confused with an
|
|
302
|
+
// execution revert (whose decoded revert string could well mention insufficient funds too).
|
|
303
|
+
let result;
|
|
304
|
+
try {
|
|
305
|
+
result = await simulateBlocks();
|
|
300
306
|
} catch (err) {
|
|
301
307
|
if (getErrorCause(err, MethodNotFoundRpcError) || getErrorCause(err, MethodNotSupportedRpcError)) {
|
|
302
308
|
if (gasConfig.fallbackGasEstimate) {
|
|
@@ -308,8 +314,31 @@ export class ReadOnlyL1TxUtils {
|
|
|
308
314
|
}
|
|
309
315
|
this.logger?.error('Node does not support eth_simulateV1 API');
|
|
310
316
|
}
|
|
317
|
+
if (isInsufficientFundsRpcError(err)) {
|
|
318
|
+
const rpcError = getErrorCause(err, RpcRequestError);
|
|
319
|
+
const providerMessage = rpcError?.details ?? (err instanceof Error ? err.message : String(err));
|
|
320
|
+
const gas = call?.gas !== undefined ? `, gas ${call.gas}` : '';
|
|
321
|
+
throw new Error(`L1 node rejected the eth_simulateV1 request with an insufficient funds error before executing it ` + `(sender ${call?.from ?? 'unknown'}${gas}): ${providerMessage}`, {
|
|
322
|
+
cause: err
|
|
323
|
+
});
|
|
324
|
+
}
|
|
311
325
|
throw err;
|
|
312
326
|
}
|
|
327
|
+
if (result[0].calls[0].status === 'failure') {
|
|
328
|
+
this.logger?.error('L1 transaction simulation failed', result[0].calls[0].error);
|
|
329
|
+
const decodedError = decodeErrorResult({
|
|
330
|
+
abi,
|
|
331
|
+
data: result[0].calls[0].data
|
|
332
|
+
});
|
|
333
|
+
throw new Error(`L1 transaction simulation failed with error ${decodedError.errorName}(${decodedError.args?.join(',')})`);
|
|
334
|
+
}
|
|
335
|
+
this.logger?.debug(`L1 transaction simulation succeeded`, {
|
|
336
|
+
...result[0].calls[0]
|
|
337
|
+
});
|
|
338
|
+
return {
|
|
339
|
+
gasUsed: result[0].gasUsed,
|
|
340
|
+
result: result[0].calls[0].data
|
|
341
|
+
};
|
|
313
342
|
}
|
|
314
343
|
bumpGasLimit(gasLimit, _gasConfig) {
|
|
315
344
|
const gasConfig = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/ethereum",
|
|
3
|
-
"version": "5.2.0-nightly.
|
|
3
|
+
"version": "5.2.0-nightly.20260814",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./account": "./dest/account.js",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"../package.common.json"
|
|
51
51
|
],
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@aztec/blob-lib": "5.2.0-nightly.
|
|
54
|
-
"@aztec/constants": "5.2.0-nightly.
|
|
55
|
-
"@aztec/foundation": "5.2.0-nightly.
|
|
56
|
-
"@aztec/l1-artifacts": "5.2.0-nightly.
|
|
53
|
+
"@aztec/blob-lib": "5.2.0-nightly.20260814",
|
|
54
|
+
"@aztec/constants": "5.2.0-nightly.20260814",
|
|
55
|
+
"@aztec/foundation": "5.2.0-nightly.20260814",
|
|
56
|
+
"@aztec/l1-artifacts": "5.2.0-nightly.20260814",
|
|
57
57
|
"dotenv": "^16.0.3",
|
|
58
58
|
"lodash.chunk": "^4.2.0",
|
|
59
59
|
"lodash.pickby": "^4.5.0",
|
package/src/client.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
type HttpTransport,
|
|
11
11
|
type LocalAccount,
|
|
12
12
|
type PrivateKeyAccount,
|
|
13
|
+
RpcRequestError,
|
|
13
14
|
createPublicClient,
|
|
14
15
|
createWalletClient,
|
|
15
16
|
fallback,
|
|
@@ -58,6 +59,11 @@ export function isL1RpcHttpStatus(err: unknown, status: number): boolean {
|
|
|
58
59
|
return getL1RpcHttpStatus(err) === status;
|
|
59
60
|
}
|
|
60
61
|
|
|
62
|
+
/** Returns the JSON-RPC error code reported by the L1 node, if the error's cause chain carries one. */
|
|
63
|
+
export function getL1RpcErrorCode(err: unknown): number | undefined {
|
|
64
|
+
return getErrorCause(err, RpcRequestError)?.code;
|
|
65
|
+
}
|
|
66
|
+
|
|
61
67
|
function wrapL1RpcTransport(transport: FallbackTransport<HttpTransport[]>): FallbackTransport<HttpTransport[]> {
|
|
62
68
|
const wrappedTransport: FallbackTransport<HttpTransport[]> = parameters => {
|
|
63
69
|
const fallbackTransport = transport(parameters);
|
|
@@ -685,14 +685,14 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
685
685
|
): Promise<{ gasUsed: bigint; result: `0x${string}` }> {
|
|
686
686
|
const blockOverrides = { ..._blockOverrides };
|
|
687
687
|
const gasConfig = merge(this.config, _gasConfig);
|
|
688
|
-
const gasPrice = await this.getGasPrice(gasConfig, false);
|
|
689
688
|
|
|
689
|
+
// Fee fields are deliberately omitted. Supplying them makes the node apply the EIP-1559 upfront funds
|
|
690
|
+
// check (sender balance >= gas * maxFeePerGas) against the worst-case gas cap below, which rejects the
|
|
691
|
+
// whole simulation request before any execution. Omitted fee fields default to a zero gas price.
|
|
690
692
|
const call: any = {
|
|
691
693
|
to: request.to!,
|
|
692
694
|
data: request.data,
|
|
693
695
|
from: request.from ?? this.getSenderAddress().toString(),
|
|
694
|
-
maxFeePerGas: gasPrice.maxFeePerGas,
|
|
695
|
-
maxPriorityFeePerGas: gasPrice.maxPriorityFeePerGas,
|
|
696
696
|
gas: request.gas ?? MAX_L1_TX_LIMIT,
|
|
697
697
|
};
|
|
698
698
|
|
|
@@ -701,7 +701,7 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
701
701
|
blockOverrides.gasLimit = MAX_L1_TX_LIMIT;
|
|
702
702
|
}
|
|
703
703
|
|
|
704
|
-
return this._simulate(call, blockOverrides, stateOverrides, gasConfig, abi);
|
|
704
|
+
return await this._simulate(call, blockOverrides, stateOverrides, gasConfig, abi);
|
|
705
705
|
}
|
|
706
706
|
|
|
707
707
|
/**
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
type Hex,
|
|
18
18
|
MethodNotFoundRpcError,
|
|
19
19
|
MethodNotSupportedRpcError,
|
|
20
|
+
RpcRequestError,
|
|
20
21
|
type StateOverride,
|
|
21
22
|
decodeErrorResult,
|
|
22
23
|
formatGwei,
|
|
@@ -24,6 +25,7 @@ import {
|
|
|
24
25
|
hexToBytes,
|
|
25
26
|
} from 'viem';
|
|
26
27
|
|
|
28
|
+
import { getL1RpcErrorCode } from '../client.js';
|
|
27
29
|
import type { ViemClient } from '../types.js';
|
|
28
30
|
import { type L1TxUtilsConfig, defaultL1TxUtilsConfig, l1TxUtilsConfigMappings } from './config.js';
|
|
29
31
|
import {
|
|
@@ -40,6 +42,23 @@ import { getCalldataGasUsage, tryGetCustomErrorNameContractFunction } from './ut
|
|
|
40
42
|
// Change this to the current strategy we want to use
|
|
41
43
|
const CurrentStrategy: PriorityFeeStrategy = P75AllTxsPriorityFeeStrategy;
|
|
42
44
|
|
|
45
|
+
/** Error code returned by eth_simulateV1 for `insufficient funds for gas * price + value`. */
|
|
46
|
+
const INSUFFICIENT_FUNDS_RPC_ERROR_CODE = -38014;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Returns true when an RPC transport error reports the node's upfront funds check
|
|
50
|
+
* (sender balance >= gasLimit * maxFeePerGas) rejecting the request. Matches on the message as well as on the
|
|
51
|
+
* error code, since RPC gateways differ in how they wrap node errors. Apply this only to transport errors: an
|
|
52
|
+
* execution revert string can mention insufficient funds without being this kind of rejection.
|
|
53
|
+
*/
|
|
54
|
+
function isInsufficientFundsRpcError(err: unknown): boolean {
|
|
55
|
+
if (getL1RpcErrorCode(err) === INSUFFICIENT_FUNDS_RPC_ERROR_CODE) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
const messages = [err, getErrorCause(err, RpcRequestError)].map(e => (e instanceof Error ? e.message : '')).join(' ');
|
|
59
|
+
return /insufficient funds/i.test(messages);
|
|
60
|
+
}
|
|
61
|
+
|
|
43
62
|
export class ReadOnlyL1TxUtils {
|
|
44
63
|
public config: Required<L1TxUtilsConfig>;
|
|
45
64
|
protected interrupted = false;
|
|
@@ -373,8 +392,8 @@ export class ReadOnlyL1TxUtils {
|
|
|
373
392
|
gasConfig: L1TxUtilsConfig & { fallbackGasEstimate?: bigint },
|
|
374
393
|
abi: Abi,
|
|
375
394
|
) {
|
|
376
|
-
|
|
377
|
-
|
|
395
|
+
const simulateBlocks = () =>
|
|
396
|
+
this.client.simulateBlocks({
|
|
378
397
|
validation: false,
|
|
379
398
|
blocks: [
|
|
380
399
|
{
|
|
@@ -385,16 +404,11 @@ export class ReadOnlyL1TxUtils {
|
|
|
385
404
|
],
|
|
386
405
|
});
|
|
387
406
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
`L1 transaction simulation failed with error ${decodedError.errorName}(${decodedError.args?.join(',')})`,
|
|
394
|
-
);
|
|
395
|
-
}
|
|
396
|
-
this.logger?.debug(`L1 transaction simulation succeeded`, { ...result[0].calls[0] });
|
|
397
|
-
return { gasUsed: result[0].gasUsed, result: result[0].calls[0].data as `0x${string}` };
|
|
407
|
+
// Only the request itself is wrapped, so that transport-level rejections are never confused with an
|
|
408
|
+
// execution revert (whose decoded revert string could well mention insufficient funds too).
|
|
409
|
+
let result: Awaited<ReturnType<typeof simulateBlocks>>;
|
|
410
|
+
try {
|
|
411
|
+
result = await simulateBlocks();
|
|
398
412
|
} catch (err) {
|
|
399
413
|
if (getErrorCause(err, MethodNotFoundRpcError) || getErrorCause(err, MethodNotSupportedRpcError)) {
|
|
400
414
|
if (gasConfig.fallbackGasEstimate) {
|
|
@@ -405,8 +419,29 @@ export class ReadOnlyL1TxUtils {
|
|
|
405
419
|
}
|
|
406
420
|
this.logger?.error('Node does not support eth_simulateV1 API');
|
|
407
421
|
}
|
|
422
|
+
if (isInsufficientFundsRpcError(err)) {
|
|
423
|
+
const rpcError = getErrorCause(err, RpcRequestError);
|
|
424
|
+
const providerMessage = rpcError?.details ?? (err instanceof Error ? err.message : String(err));
|
|
425
|
+
const gas = call?.gas !== undefined ? `, gas ${call.gas}` : '';
|
|
426
|
+
throw new Error(
|
|
427
|
+
`L1 node rejected the eth_simulateV1 request with an insufficient funds error before executing it ` +
|
|
428
|
+
`(sender ${call?.from ?? 'unknown'}${gas}): ${providerMessage}`,
|
|
429
|
+
{ cause: err },
|
|
430
|
+
);
|
|
431
|
+
}
|
|
408
432
|
throw err;
|
|
409
433
|
}
|
|
434
|
+
|
|
435
|
+
if (result[0].calls[0].status === 'failure') {
|
|
436
|
+
this.logger?.error('L1 transaction simulation failed', result[0].calls[0].error);
|
|
437
|
+
const decodedError = decodeErrorResult({ abi, data: result[0].calls[0].data });
|
|
438
|
+
|
|
439
|
+
throw new Error(
|
|
440
|
+
`L1 transaction simulation failed with error ${decodedError.errorName}(${decodedError.args?.join(',')})`,
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
this.logger?.debug(`L1 transaction simulation succeeded`, { ...result[0].calls[0] });
|
|
444
|
+
return { gasUsed: result[0].gasUsed, result: result[0].calls[0].data as `0x${string}` };
|
|
410
445
|
}
|
|
411
446
|
|
|
412
447
|
public bumpGasLimit(gasLimit: bigint, _gasConfig?: L1TxUtilsConfig): bigint {
|