@aztec/ethereum 2.0.0-rc.23 → 2.0.0-rc.25
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/l1_tx_utils.d.ts +4 -2
- package/dest/l1_tx_utils.d.ts.map +1 -1
- package/dest/l1_tx_utils.js +21 -13
- package/dest/l1_tx_utils_with_blobs.d.ts +2 -1
- package/dest/l1_tx_utils_with_blobs.d.ts.map +1 -1
- package/dest/l1_tx_utils_with_blobs.js +7 -5
- package/dest/utils.d.ts.map +1 -1
- package/dest/utils.js +10 -161
- package/package.json +5 -5
- package/src/l1_tx_utils.ts +28 -9
- package/src/l1_tx_utils_with_blobs.ts +8 -2
- package/src/utils.ts +13 -185
package/dest/l1_tx_utils.d.ts
CHANGED
|
@@ -205,10 +205,11 @@ export declare class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
205
205
|
* Monitors a transaction until completion, handling speed-ups if needed
|
|
206
206
|
* @param request - Original transaction request (needed for speed-ups)
|
|
207
207
|
* @param initialTxHash - Hash of the initial transaction
|
|
208
|
+
* @param allVersions - Hashes of all transactions submitted under the same nonce (any of them could mine)
|
|
208
209
|
* @param params - Parameters used in the initial transaction
|
|
209
210
|
* @param gasConfig - Optional gas configuration
|
|
210
211
|
*/
|
|
211
|
-
monitorTransaction(request: L1TxRequest, initialTxHash: Hex, params: {
|
|
212
|
+
monitorTransaction(request: L1TxRequest, initialTxHash: Hex, allVersions: Set<Hex>, params: {
|
|
212
213
|
gasLimit: bigint;
|
|
213
214
|
}, _gasConfig?: Partial<L1TxUtilsConfig> & {
|
|
214
215
|
txTimeoutAt?: Date;
|
|
@@ -236,11 +237,12 @@ export declare class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
236
237
|
/**
|
|
237
238
|
* Attempts to cancel a transaction by sending a 0-value tx to self with same nonce but higher gas prices
|
|
238
239
|
* @param nonce - The nonce of the transaction to cancel
|
|
240
|
+
* @param allVersions - Hashes of all transactions submitted under the same nonce (any of them could mine)
|
|
239
241
|
* @param previousGasPrice - The gas price of the previous transaction
|
|
240
242
|
* @param attempts - The number of attempts to cancel the transaction
|
|
241
243
|
* @returns The hash of the cancellation transaction
|
|
242
244
|
*/
|
|
243
|
-
protected attemptTxCancellation(currentTxHash: Hex, nonce: number, isBlobTx?: boolean, previousGasPrice?: GasPrice, attempts?: number): Promise<`0x${string}`>;
|
|
245
|
+
protected attemptTxCancellation(currentTxHash: Hex, nonce: number, allVersions: Set<Hex>, isBlobTx?: boolean, previousGasPrice?: GasPrice, attempts?: number): Promise<`0x${string}`>;
|
|
244
246
|
}
|
|
245
247
|
export declare function createViemSigner(client: WalletClient): SigningCallback;
|
|
246
248
|
export declare function createL1TxUtilsFromViemWallet(client: ExtendedViemWalletClient, logger?: Logger, dateProvider?: DateProvider, config?: Partial<L1TxUtilsConfig>, debugMaxGasLimit?: boolean): L1TxUtils;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"l1_tx_utils.d.ts","sourceRoot":"","sources":["../src/l1_tx_utils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,kBAAkB,EAMxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAIvD,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OAAO,EACZ,KAAK,OAAO,EAEZ,KAAK,cAAc,EACnB,KAAK,8BAA8B,EAEnC,KAAK,GAAG,EAIR,KAAK,gCAAgC,EACrC,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EAQlB,MAAM,MAAM,CAAC;AAGd,OAAO,KAAK,EAAE,SAAS,E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
|
@@ -144,7 +144,7 @@ export class ReadOnlyL1TxUtils {
|
|
|
144
144
|
let blobBaseFee = 0n;
|
|
145
145
|
if (isBlobTx) {
|
|
146
146
|
try {
|
|
147
|
-
blobBaseFee = await this.client.getBlobBaseFee();
|
|
147
|
+
blobBaseFee = await retry(()=>this.client.getBlobBaseFee(), 'Getting L1 blob base fee', makeBackoff(times(2, ()=>1)), this.logger, true);
|
|
148
148
|
this.logger?.debug('L1 Blob base fee:', {
|
|
149
149
|
blobBaseFee: formatGwei(blobBaseFee)
|
|
150
150
|
});
|
|
@@ -526,9 +526,10 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
526
526
|
* Monitors a transaction until completion, handling speed-ups if needed
|
|
527
527
|
* @param request - Original transaction request (needed for speed-ups)
|
|
528
528
|
* @param initialTxHash - Hash of the initial transaction
|
|
529
|
+
* @param allVersions - Hashes of all transactions submitted under the same nonce (any of them could mine)
|
|
529
530
|
* @param params - Parameters used in the initial transaction
|
|
530
531
|
* @param gasConfig - Optional gas configuration
|
|
531
|
-
*/ async monitorTransaction(request, initialTxHash, params, _gasConfig, _blobInputs, isCancelTx = false) {
|
|
532
|
+
*/ async monitorTransaction(request, initialTxHash, allVersions, params, _gasConfig, _blobInputs, isCancelTx = false) {
|
|
532
533
|
const isBlobTx = !!_blobInputs;
|
|
533
534
|
const gasConfig = {
|
|
534
535
|
...this.config,
|
|
@@ -548,9 +549,7 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
548
549
|
throw new Error(`Failed to get L1 transaction ${initialTxHash} nonce`);
|
|
549
550
|
}
|
|
550
551
|
const nonce = tx.nonce;
|
|
551
|
-
|
|
552
|
-
initialTxHash
|
|
553
|
-
]);
|
|
552
|
+
allVersions.add(initialTxHash);
|
|
554
553
|
let currentTxHash = initialTxHash;
|
|
555
554
|
let attempts = 0;
|
|
556
555
|
let lastAttemptSent = this.dateProvider.now();
|
|
@@ -575,8 +574,9 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
575
574
|
const currentNonce = await this.client.getTransactionCount({
|
|
576
575
|
address: account
|
|
577
576
|
});
|
|
577
|
+
// If the current nonce on our account is greater than our transaction's nonce then a tx with the same nonce has been mined.
|
|
578
578
|
if (currentNonce > nonce) {
|
|
579
|
-
for (const hash of
|
|
579
|
+
for (const hash of allVersions){
|
|
580
580
|
try {
|
|
581
581
|
const receipt = await this.client.getTransactionReceipt({
|
|
582
582
|
hash
|
|
@@ -597,6 +597,10 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
597
597
|
}
|
|
598
598
|
}
|
|
599
599
|
}
|
|
600
|
+
// If we get here then we have checked all of our tx versions and not found anything.
|
|
601
|
+
// We should consider the nonce as MINED
|
|
602
|
+
this.state = 5;
|
|
603
|
+
throw new Error(`Nonce ${nonce} is MINED but not by one of our expected transactions`);
|
|
600
604
|
}
|
|
601
605
|
this.logger?.trace(`Tx timeout check for ${currentTxHash}: ${isTimedOut()}`, {
|
|
602
606
|
latestBlockTimestamp: Number(latestBlockTimestamp) * 1000,
|
|
@@ -645,6 +649,9 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
645
649
|
maxFeePerGas: newGasPrice.maxFeePerGas,
|
|
646
650
|
maxPriorityFeePerGas: newGasPrice.maxPriorityFeePerGas
|
|
647
651
|
};
|
|
652
|
+
if (isBlobTx && newGasPrice.maxFeePerBlobGas) {
|
|
653
|
+
txData.maxFeePerBlobGas = newGasPrice.maxFeePerBlobGas;
|
|
654
|
+
}
|
|
648
655
|
const signedRequest = await this.prepareSignedTransaction(txData);
|
|
649
656
|
const newHash = await this.client.sendRawTransaction({
|
|
650
657
|
serializedTransaction: signedRequest
|
|
@@ -663,7 +670,7 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
663
670
|
}
|
|
664
671
|
});
|
|
665
672
|
currentTxHash = newHash;
|
|
666
|
-
|
|
673
|
+
allVersions.add(currentTxHash);
|
|
667
674
|
lastAttemptSent = this.dateProvider.now();
|
|
668
675
|
}
|
|
669
676
|
await sleep(gasConfig.checkIntervalMs);
|
|
@@ -684,7 +691,7 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
684
691
|
this.state = 4;
|
|
685
692
|
} else if (gasConfig.cancelTxOnTimeout) {
|
|
686
693
|
// Fire cancellation without awaiting to avoid blocking the main thread
|
|
687
|
-
this.attemptTxCancellation(currentTxHash, nonce, isBlobTx, lastGasPrice, attempts).catch((err)=>{
|
|
694
|
+
this.attemptTxCancellation(currentTxHash, nonce, allVersions, isBlobTx, lastGasPrice, attempts).catch((err)=>{
|
|
688
695
|
const viemError = formatViemError(err);
|
|
689
696
|
this.logger?.error(`Failed to send cancellation for timed out tx ${currentTxHash}:`, viemError.message, {
|
|
690
697
|
metaMessages: viemError.metaMessages
|
|
@@ -710,7 +717,7 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
710
717
|
* @returns The receipt of the successful transaction
|
|
711
718
|
*/ async sendAndMonitorTransaction(request, gasConfig, blobInputs) {
|
|
712
719
|
const { txHash, gasLimit, gasPrice } = await this.sendTransaction(request, gasConfig, blobInputs);
|
|
713
|
-
const receipt = await this.monitorTransaction(request, txHash, {
|
|
720
|
+
const receipt = await this.monitorTransaction(request, txHash, new Set(), {
|
|
714
721
|
gasLimit
|
|
715
722
|
}, gasConfig, blobInputs);
|
|
716
723
|
return {
|
|
@@ -744,10 +751,11 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
744
751
|
/**
|
|
745
752
|
* Attempts to cancel a transaction by sending a 0-value tx to self with same nonce but higher gas prices
|
|
746
753
|
* @param nonce - The nonce of the transaction to cancel
|
|
754
|
+
* @param allVersions - Hashes of all transactions submitted under the same nonce (any of them could mine)
|
|
747
755
|
* @param previousGasPrice - The gas price of the previous transaction
|
|
748
756
|
* @param attempts - The number of attempts to cancel the transaction
|
|
749
757
|
* @returns The hash of the cancellation transaction
|
|
750
|
-
*/ async attemptTxCancellation(currentTxHash, nonce, isBlobTx = false, previousGasPrice, attempts = 0) {
|
|
758
|
+
*/ async attemptTxCancellation(currentTxHash, nonce, allVersions, isBlobTx = false, previousGasPrice, attempts = 0) {
|
|
751
759
|
if (isBlobTx) {
|
|
752
760
|
throw new Error('Cannot cancel blob transactions, please use L1TxUtilsWithBlobsClass');
|
|
753
761
|
}
|
|
@@ -757,7 +765,7 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
757
765
|
// Use high bump for cancellation to ensure it replaces the original tx
|
|
758
766
|
priorityFeeRetryBumpPercentage: 150
|
|
759
767
|
}, isBlobTx, attempts + 1, previousGasPrice);
|
|
760
|
-
this.logger?.
|
|
768
|
+
this.logger?.info(`Attempting to cancel L1 transaction ${currentTxHash} with nonce ${nonce}`, {
|
|
761
769
|
maxFeePerGas: formatGwei(cancelGasPrice.maxFeePerGas),
|
|
762
770
|
maxPriorityFeePerGas: formatGwei(cancelGasPrice.maxPriorityFeePerGas)
|
|
763
771
|
});
|
|
@@ -778,10 +786,10 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
778
786
|
serializedTransaction: signedRequest
|
|
779
787
|
});
|
|
780
788
|
this.state = 3;
|
|
781
|
-
this.logger?.
|
|
789
|
+
this.logger?.info(`Sent cancellation tx ${cancelTxHash} for timed out tx ${currentTxHash}`, {
|
|
782
790
|
nonce
|
|
783
791
|
});
|
|
784
|
-
const receipt = await this.monitorTransaction(request, cancelTxHash, {
|
|
792
|
+
const receipt = await this.monitorTransaction(request, cancelTxHash, allVersions, {
|
|
785
793
|
gasLimit: 21_000n
|
|
786
794
|
}, undefined, undefined, true);
|
|
787
795
|
return receipt.transactionHash;
|
|
@@ -8,11 +8,12 @@ export declare class L1TxUtilsWithBlobs extends L1TxUtils {
|
|
|
8
8
|
/**
|
|
9
9
|
* Attempts to cancel a transaction by sending a 0-value tx to self with same nonce but higher gas prices
|
|
10
10
|
* @param nonce - The nonce of the transaction to cancel
|
|
11
|
+
* @param allVersions - Hashes of all transactions submitted under the same nonce (any of them could mine)
|
|
11
12
|
* @param previousGasPrice - The gas price of the previous transaction
|
|
12
13
|
* @param attempts - The number of attempts to cancel the transaction
|
|
13
14
|
* @returns The hash of the cancellation transaction
|
|
14
15
|
*/
|
|
15
|
-
attemptTxCancellation(currentTxHash: Hex, nonce: number, isBlobTx?: boolean, previousGasPrice?: GasPrice, attempts?: number): Promise<`0x${string}`>;
|
|
16
|
+
attemptTxCancellation(currentTxHash: Hex, nonce: number, allVersions: Set<Hex>, isBlobTx?: boolean, previousGasPrice?: GasPrice, attempts?: number): Promise<`0x${string}`>;
|
|
16
17
|
}
|
|
17
18
|
export declare function createL1TxUtilsWithBlobsFromViemWallet(client: ExtendedViemWalletClient, logger?: Logger, dateProvider?: DateProvider, config?: Partial<L1TxUtilsConfig>, debugMaxGasLimit?: boolean): L1TxUtilsWithBlobs;
|
|
18
19
|
export declare function createL1TxUtilsWithBlobsFromEthSigner(client: ViemClient, signer: EthSigner, logger?: Logger, dateProvider?: DateProvider, config?: Partial<L1TxUtilsConfig>, debugMaxGasLimit?: boolean): L1TxUtilsWithBlobs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"l1_tx_utils_with_blobs.d.ts","sourceRoot":"","sources":["../src/l1_tx_utils_with_blobs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,KAAK,GAAG,EAA4C,MAAM,MAAM,CAAC;AAE1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EACL,KAAK,QAAQ,EACb,SAAS,EACT,KAAK,eAAe,EAGrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,wBAAwB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEvE,qBAAa,kBAAmB,SAAQ,SAAS;IAC/C
|
|
1
|
+
{"version":3,"file":"l1_tx_utils_with_blobs.d.ts","sourceRoot":"","sources":["../src/l1_tx_utils_with_blobs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,KAAK,GAAG,EAA4C,MAAM,MAAM,CAAC;AAE1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EACL,KAAK,QAAQ,EACb,SAAS,EACT,KAAK,eAAe,EAGrB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,wBAAwB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEvE,qBAAa,kBAAmB,SAAQ,SAAS;IAC/C;;;;;;;OAOG;IACY,qBAAqB,CAClC,aAAa,EAAE,GAAG,EAClB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,GAAG,CAAC,GAAG,CAAC,EACrB,QAAQ,UAAQ,EAChB,gBAAgB,CAAC,EAAE,QAAQ,EAC3B,QAAQ,SAAI;CAoFf;AAED,wBAAgB,sCAAsC,CACpD,MAAM,EAAE,wBAAwB,EAChC,MAAM,GAAE,MAAkC,EAC1C,YAAY,GAAE,YAAiC,EAC/C,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,EACjC,gBAAgB,GAAE,OAAe,sBAWlC;AAED,wBAAgB,qCAAqC,CACnD,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,SAAS,EACjB,MAAM,GAAE,MAAkC,EAC1C,YAAY,GAAE,YAAiC,EAC/C,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,EACjC,gBAAgB,GAAE,OAAe,sBAOlC"}
|
|
@@ -8,17 +8,18 @@ export class L1TxUtilsWithBlobs extends L1TxUtils {
|
|
|
8
8
|
/**
|
|
9
9
|
* Attempts to cancel a transaction by sending a 0-value tx to self with same nonce but higher gas prices
|
|
10
10
|
* @param nonce - The nonce of the transaction to cancel
|
|
11
|
+
* @param allVersions - Hashes of all transactions submitted under the same nonce (any of them could mine)
|
|
11
12
|
* @param previousGasPrice - The gas price of the previous transaction
|
|
12
13
|
* @param attempts - The number of attempts to cancel the transaction
|
|
13
14
|
* @returns The hash of the cancellation transaction
|
|
14
|
-
*/ async attemptTxCancellation(currentTxHash, nonce, isBlobTx = false, previousGasPrice, attempts = 0) {
|
|
15
|
+
*/ async attemptTxCancellation(currentTxHash, nonce, allVersions, isBlobTx = false, previousGasPrice, attempts = 0) {
|
|
15
16
|
// Get gas price with higher priority fee for cancellation
|
|
16
17
|
const cancelGasPrice = await this.getGasPrice({
|
|
17
18
|
...this.config,
|
|
18
19
|
// Use high bump for cancellation to ensure it replaces the original tx
|
|
19
20
|
priorityFeeRetryBumpPercentage: 150
|
|
20
21
|
}, isBlobTx, attempts + 1, previousGasPrice);
|
|
21
|
-
this.logger?.
|
|
22
|
+
this.logger?.info(`Attempting to cancel blob L1 transaction ${currentTxHash} with nonce ${nonce}`, {
|
|
22
23
|
maxFeePerGas: formatGwei(cancelGasPrice.maxFeePerGas),
|
|
23
24
|
maxPriorityFeePerGas: formatGwei(cancelGasPrice.maxPriorityFeePerGas),
|
|
24
25
|
maxFeePerBlobGas: cancelGasPrice.maxFeePerBlobGas === undefined ? undefined : formatGwei(cancelGasPrice.maxFeePerBlobGas)
|
|
@@ -40,7 +41,8 @@ export class L1TxUtilsWithBlobs extends L1TxUtils {
|
|
|
40
41
|
const cancelTxHash = await this.client.sendRawTransaction({
|
|
41
42
|
serializedTransaction: signedRequest
|
|
42
43
|
});
|
|
43
|
-
|
|
44
|
+
this.logger?.info(`Sent cancellation tx ${cancelTxHash} for timed out tx ${currentTxHash}`);
|
|
45
|
+
const receipt = await this.monitorTransaction(request, cancelTxHash, allVersions, {
|
|
44
46
|
gasLimit: 21_000n
|
|
45
47
|
}, undefined, undefined, true);
|
|
46
48
|
return receipt.transactionHash;
|
|
@@ -66,8 +68,8 @@ export class L1TxUtilsWithBlobs extends L1TxUtils {
|
|
|
66
68
|
const cancelTxHash = await this.client.sendRawTransaction({
|
|
67
69
|
serializedTransaction: signedRequest
|
|
68
70
|
});
|
|
69
|
-
this.logger?.
|
|
70
|
-
const receipt = await this.monitorTransaction(request, cancelTxHash, {
|
|
71
|
+
this.logger?.info(`Sent cancellation tx ${cancelTxHash} for timed out tx ${currentTxHash}`);
|
|
72
|
+
const receipt = await this.monitorTransaction(request, cancelTxHash, allVersions, {
|
|
71
73
|
gasLimit: 21_000n
|
|
72
74
|
}, undefined, blobInputs, true);
|
|
73
75
|
return receipt.transactionHash;
|
package/dest/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,EACL,KAAK,GAAG,EAER,KAAK,iBAAiB,EAEtB,KAAK,wBAAwB,EAC7B,KAAK,GAAG,EACR,KAAK,GAAG,EAGT,MAAM,MAAM,CAAC;AAEd,MAAM,WAAW,OAAO;IACtB,WAAW,EAAE,EAAE,CAAC;IAChB,WAAW,EAAE,EAAE,CAAC;IAChB,WAAW,EAAE,GAAG,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,CAAC,EAAE,GAAG,EAAE,CAAC;gBAET,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,GAAG,EAAE;CAKlD;AAED,wBAAgB,YAAY,CAC1B,KAAK,CAAC,IAAI,SAAS,GAAG,GAAG,SAAS,OAAO,EAAE,EAC3C,UAAU,SAAS,iBAAiB,CAAC,IAAI,CAAC,EAC1C,UAAU,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;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,GAAE,GAAe,GAAG,kBAAkB,CAwEpF;AAyBD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,GAAG,sBAa7C"}
|
package/dest/utils.js
CHANGED
|
@@ -118,34 +118,16 @@ function getNestedErrorData(error) {
|
|
|
118
118
|
if (error instanceof Error) {
|
|
119
119
|
return new FormattedViemError(error.message, error?.metaMessages);
|
|
120
120
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
//
|
|
125
|
-
if (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
// If we found a specific error detail, format it clearly
|
|
134
|
-
if (errorDetail) {
|
|
135
|
-
// Look for key sections of the formatted result to replace with highlighted error
|
|
136
|
-
let replaced = false;
|
|
137
|
-
// Try to find the Details: section
|
|
138
|
-
const detailsMatch = formattedRes.match(/Details: ([^\n]+)/);
|
|
139
|
-
if (detailsMatch) {
|
|
140
|
-
formattedRes = formattedRes.replace(detailsMatch[0], `Details: *${errorDetail}*`);
|
|
141
|
-
replaced = true;
|
|
142
|
-
}
|
|
143
|
-
// If we didn't find a Details section, add the error at the beginning
|
|
144
|
-
if (!replaced) {
|
|
145
|
-
formattedRes = `Error: *${errorDetail}*\n\n${formattedRes}`;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return new FormattedViemError(formattedRes.replace(/\\n/g, '\n'), error?.metaMessages);
|
|
121
|
+
const body = String(error);
|
|
122
|
+
const length = body.length;
|
|
123
|
+
// LogExplorer can only render up to 2500 characters in it's summary view. Try to keep the whole message below this number
|
|
124
|
+
// Limit the error to 2000 chacaters in order to allow code higher up to decorate this error with extra details (up to 500 characters)
|
|
125
|
+
if (length > 2000) {
|
|
126
|
+
const chunk = 950;
|
|
127
|
+
const truncated = length - 2 * chunk;
|
|
128
|
+
return new FormattedViemError(body.slice(0, chunk) + `...${truncated} characters truncated...` + body.slice(-1 * chunk));
|
|
129
|
+
}
|
|
130
|
+
return new FormattedViemError(body);
|
|
149
131
|
}
|
|
150
132
|
function stripAbis(obj) {
|
|
151
133
|
if (!obj || typeof obj !== 'object') {
|
|
@@ -166,139 +148,6 @@ function stripAbis(obj) {
|
|
|
166
148
|
}
|
|
167
149
|
});
|
|
168
150
|
}
|
|
169
|
-
function extractAndFormatRequestBody(message) {
|
|
170
|
-
// First check if message is extremely large and contains very large hex strings
|
|
171
|
-
if (message.length > 50000) {
|
|
172
|
-
message = replaceHexStrings(message, {
|
|
173
|
-
minLength: 10000,
|
|
174
|
-
truncateLength: 200
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
// Add a specific check for RPC calls with large params
|
|
178
|
-
if (message.includes('"method":"eth_sendRawTransaction"')) {
|
|
179
|
-
message = replaceHexStrings(message, {
|
|
180
|
-
pattern: /"params":\s*\[\s*"(0x[a-fA-F0-9]{1000,})"\s*\]/g,
|
|
181
|
-
transform: (hex)=>`"params":["${truncateHex(hex, 200)}"]`
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
// First handle Request body JSON
|
|
185
|
-
const requestBodyRegex = /Request body: ({[\s\S]*?})\n/g;
|
|
186
|
-
let result = message.replace(requestBodyRegex, (match, body)=>{
|
|
187
|
-
return `Request body: ${formatRequestBody(body)}\n`;
|
|
188
|
-
});
|
|
189
|
-
// Then handle Arguments section
|
|
190
|
-
const argsRegex = /((?:Request |Estimate Gas )?Arguments:[\s\S]*?(?=\n\n|$))/g;
|
|
191
|
-
result = result.replace(argsRegex, (section)=>{
|
|
192
|
-
const lines = section.split('\n');
|
|
193
|
-
const processedLines = lines.map((line)=>{
|
|
194
|
-
// Check if line contains a colon followed by content
|
|
195
|
-
const colonIndex = line.indexOf(':');
|
|
196
|
-
if (colonIndex !== -1) {
|
|
197
|
-
const [prefix, content] = [
|
|
198
|
-
line.slice(0, colonIndex + 1),
|
|
199
|
-
line.slice(colonIndex + 1).trim()
|
|
200
|
-
];
|
|
201
|
-
// If content contains a hex string, truncate it
|
|
202
|
-
if (content.includes('0x')) {
|
|
203
|
-
const processedContent = replaceHexStrings(content);
|
|
204
|
-
return `${prefix} ${processedContent}`;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return line;
|
|
208
|
-
});
|
|
209
|
-
return processedLines.join('\n');
|
|
210
|
-
});
|
|
211
|
-
// Finally, catch any remaining hex strings in the message
|
|
212
|
-
result = replaceHexStrings(result);
|
|
213
|
-
return result;
|
|
214
|
-
}
|
|
215
|
-
function truncateHex(hex, length = 100) {
|
|
216
|
-
if (!hex || typeof hex !== 'string') {
|
|
217
|
-
return hex;
|
|
218
|
-
}
|
|
219
|
-
if (!hex.startsWith('0x')) {
|
|
220
|
-
return hex;
|
|
221
|
-
}
|
|
222
|
-
if (hex.length <= length * 2) {
|
|
223
|
-
return hex;
|
|
224
|
-
}
|
|
225
|
-
// For extremely large hex strings, use more aggressive truncation
|
|
226
|
-
if (hex.length > 10000) {
|
|
227
|
-
return `${hex.slice(0, length)}...<${hex.length - length * 2} chars omitted>...${hex.slice(-length)}`;
|
|
228
|
-
}
|
|
229
|
-
return `${hex.slice(0, length)}...${hex.slice(-length)}`;
|
|
230
|
-
}
|
|
231
|
-
function replaceHexStrings(text, options = {}) {
|
|
232
|
-
const { minLength = 10, maxLength = Infinity, truncateLength = 100, pattern, transform = (hex)=>truncateHex(hex, truncateLength) } = options;
|
|
233
|
-
const hexRegex = pattern ?? new RegExp(`(0x[a-fA-F0-9]{${minLength},${maxLength}})`, 'g');
|
|
234
|
-
return text.replace(hexRegex, (match)=>transform(match));
|
|
235
|
-
}
|
|
236
|
-
function formatRequestBody(body) {
|
|
237
|
-
try {
|
|
238
|
-
// Special handling for eth_sendRawTransaction
|
|
239
|
-
if (body.includes('"method":"eth_sendRawTransaction"')) {
|
|
240
|
-
try {
|
|
241
|
-
const parsed = JSON.parse(body);
|
|
242
|
-
if (parsed.params && Array.isArray(parsed.params) && parsed.params.length > 0) {
|
|
243
|
-
// These are likely large transaction hex strings
|
|
244
|
-
parsed.params = parsed.params.map((param)=>{
|
|
245
|
-
if (typeof param === 'string' && param.startsWith('0x') && param.length > 1000) {
|
|
246
|
-
return truncateHex(param, 200);
|
|
247
|
-
}
|
|
248
|
-
return param;
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
return JSON.stringify(parsed, null, 2);
|
|
252
|
-
} catch {
|
|
253
|
-
// If specific parsing fails, fall back to regex-based truncation
|
|
254
|
-
return replaceHexStrings(body, {
|
|
255
|
-
pattern: /"params":\s*\[\s*"(0x[a-fA-F0-9]{1000,})"\s*\]/g,
|
|
256
|
-
transform: (hex)=>`"params":["${truncateHex(hex, 200)}"]`
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
// For extremely large request bodies, use simple truncation instead of parsing
|
|
261
|
-
if (body.length > 50000) {
|
|
262
|
-
const jsonStart = body.indexOf('{');
|
|
263
|
-
const jsonEnd = body.lastIndexOf('}');
|
|
264
|
-
if (jsonStart >= 0 && jsonEnd > jsonStart) {
|
|
265
|
-
return replaceHexStrings(body, {
|
|
266
|
-
minLength: 10000,
|
|
267
|
-
truncateLength: 200
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
const parsed = JSON.parse(body);
|
|
272
|
-
// Process the entire request body
|
|
273
|
-
const processed = processParams(parsed);
|
|
274
|
-
return JSON.stringify(processed, null, 2);
|
|
275
|
-
} catch {
|
|
276
|
-
// If JSON parsing fails, do a simple truncation of any large hex strings
|
|
277
|
-
return replaceHexStrings(body, {
|
|
278
|
-
minLength: 1000,
|
|
279
|
-
truncateLength: 150
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
// Recursively process all parameters that might contain hex strings
|
|
284
|
-
function processParams(obj) {
|
|
285
|
-
if (Array.isArray(obj)) {
|
|
286
|
-
return obj.map((item)=>processParams(item));
|
|
287
|
-
}
|
|
288
|
-
if (typeof obj === 'object' && obj !== null) {
|
|
289
|
-
const result = {};
|
|
290
|
-
for (const [key, value] of Object.entries(obj)){
|
|
291
|
-
result[key] = processParams(value);
|
|
292
|
-
}
|
|
293
|
-
return result;
|
|
294
|
-
}
|
|
295
|
-
if (typeof obj === 'string') {
|
|
296
|
-
if (obj.startsWith('0x')) {
|
|
297
|
-
return truncateHex(obj);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
return obj;
|
|
301
|
-
}
|
|
302
151
|
export function tryGetCustomErrorName(err) {
|
|
303
152
|
try {
|
|
304
153
|
// See https://viem.sh/docs/contract/simulateContract#handling-custom-errors
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/ethereum",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.25",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"../package.common.json"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@aztec/blob-lib": "2.0.0-rc.
|
|
35
|
-
"@aztec/constants": "2.0.0-rc.
|
|
36
|
-
"@aztec/foundation": "2.0.0-rc.
|
|
37
|
-
"@aztec/l1-artifacts": "2.0.0-rc.
|
|
34
|
+
"@aztec/blob-lib": "2.0.0-rc.25",
|
|
35
|
+
"@aztec/constants": "2.0.0-rc.25",
|
|
36
|
+
"@aztec/foundation": "2.0.0-rc.25",
|
|
37
|
+
"@aztec/l1-artifacts": "2.0.0-rc.25",
|
|
38
38
|
"@viem/anvil": "^0.0.10",
|
|
39
39
|
"dotenv": "^16.0.3",
|
|
40
40
|
"lodash.chunk": "^4.2.0",
|
package/src/l1_tx_utils.ts
CHANGED
|
@@ -279,7 +279,13 @@ export class ReadOnlyL1TxUtils {
|
|
|
279
279
|
let blobBaseFee = 0n;
|
|
280
280
|
if (isBlobTx) {
|
|
281
281
|
try {
|
|
282
|
-
blobBaseFee = await
|
|
282
|
+
blobBaseFee = await retry<bigint>(
|
|
283
|
+
() => this.client.getBlobBaseFee(),
|
|
284
|
+
'Getting L1 blob base fee',
|
|
285
|
+
makeBackoff(times(2, () => 1)),
|
|
286
|
+
this.logger,
|
|
287
|
+
true,
|
|
288
|
+
);
|
|
283
289
|
this.logger?.debug('L1 Blob base fee:', { blobBaseFee: formatGwei(blobBaseFee) });
|
|
284
290
|
} catch {
|
|
285
291
|
this.logger?.warn('Failed to get L1 blob base fee', attempt);
|
|
@@ -706,12 +712,14 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
706
712
|
* Monitors a transaction until completion, handling speed-ups if needed
|
|
707
713
|
* @param request - Original transaction request (needed for speed-ups)
|
|
708
714
|
* @param initialTxHash - Hash of the initial transaction
|
|
715
|
+
* @param allVersions - Hashes of all transactions submitted under the same nonce (any of them could mine)
|
|
709
716
|
* @param params - Parameters used in the initial transaction
|
|
710
717
|
* @param gasConfig - Optional gas configuration
|
|
711
718
|
*/
|
|
712
719
|
public async monitorTransaction(
|
|
713
720
|
request: L1TxRequest,
|
|
714
721
|
initialTxHash: Hex,
|
|
722
|
+
allVersions: Set<Hex>,
|
|
715
723
|
params: { gasLimit: bigint },
|
|
716
724
|
_gasConfig?: Partial<L1TxUtilsConfig> & { txTimeoutAt?: Date },
|
|
717
725
|
_blobInputs?: L1BlobInputs,
|
|
@@ -743,7 +751,7 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
743
751
|
}
|
|
744
752
|
const nonce = tx.nonce;
|
|
745
753
|
|
|
746
|
-
|
|
754
|
+
allVersions.add(initialTxHash);
|
|
747
755
|
let currentTxHash = initialTxHash;
|
|
748
756
|
let attempts = 0;
|
|
749
757
|
let lastAttemptSent = this.dateProvider.now();
|
|
@@ -776,8 +784,9 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
776
784
|
}));
|
|
777
785
|
|
|
778
786
|
const currentNonce = await this.client.getTransactionCount({ address: account });
|
|
787
|
+
// If the current nonce on our account is greater than our transaction's nonce then a tx with the same nonce has been mined.
|
|
779
788
|
if (currentNonce > nonce) {
|
|
780
|
-
for (const hash of
|
|
789
|
+
for (const hash of allVersions) {
|
|
781
790
|
try {
|
|
782
791
|
const receipt = await this.client.getTransactionReceipt({ hash });
|
|
783
792
|
if (receipt) {
|
|
@@ -796,6 +805,10 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
796
805
|
}
|
|
797
806
|
}
|
|
798
807
|
}
|
|
808
|
+
// If we get here then we have checked all of our tx versions and not found anything.
|
|
809
|
+
// We should consider the nonce as MINED
|
|
810
|
+
this.state = TxUtilsState.MINED;
|
|
811
|
+
throw new Error(`Nonce ${nonce} is MINED but not by one of our expected transactions`);
|
|
799
812
|
}
|
|
800
813
|
|
|
801
814
|
this.logger?.trace(`Tx timeout check for ${currentTxHash}: ${isTimedOut()}`, {
|
|
@@ -857,7 +870,7 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
857
870
|
},
|
|
858
871
|
);
|
|
859
872
|
|
|
860
|
-
const txData = {
|
|
873
|
+
const txData: PrepareTransactionRequestRequest = {
|
|
861
874
|
...request,
|
|
862
875
|
...blobInputs,
|
|
863
876
|
nonce,
|
|
@@ -865,6 +878,9 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
865
878
|
maxFeePerGas: newGasPrice.maxFeePerGas,
|
|
866
879
|
maxPriorityFeePerGas: newGasPrice.maxPriorityFeePerGas,
|
|
867
880
|
};
|
|
881
|
+
if (isBlobTx && newGasPrice.maxFeePerBlobGas) {
|
|
882
|
+
(txData as any).maxFeePerBlobGas = newGasPrice.maxFeePerBlobGas;
|
|
883
|
+
}
|
|
868
884
|
const signedRequest = await this.prepareSignedTransaction(txData);
|
|
869
885
|
const newHash = await this.client.sendRawTransaction({ serializedTransaction: signedRequest });
|
|
870
886
|
if (!isCancelTx) {
|
|
@@ -882,7 +898,7 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
882
898
|
|
|
883
899
|
currentTxHash = newHash;
|
|
884
900
|
|
|
885
|
-
|
|
901
|
+
allVersions.add(currentTxHash);
|
|
886
902
|
lastAttemptSent = this.dateProvider.now();
|
|
887
903
|
}
|
|
888
904
|
await sleep(gasConfig.checkIntervalMs!);
|
|
@@ -904,7 +920,7 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
904
920
|
this.state = TxUtilsState.NOT_MINED;
|
|
905
921
|
} else if (gasConfig.cancelTxOnTimeout) {
|
|
906
922
|
// Fire cancellation without awaiting to avoid blocking the main thread
|
|
907
|
-
this.attemptTxCancellation(currentTxHash, nonce, isBlobTx, lastGasPrice, attempts).catch(err => {
|
|
923
|
+
this.attemptTxCancellation(currentTxHash, nonce, allVersions, isBlobTx, lastGasPrice, attempts).catch(err => {
|
|
908
924
|
const viemError = formatViemError(err);
|
|
909
925
|
this.logger?.error(`Failed to send cancellation for timed out tx ${currentTxHash}:`, viemError.message, {
|
|
910
926
|
metaMessages: viemError.metaMessages,
|
|
@@ -938,7 +954,7 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
938
954
|
blobInputs?: L1BlobInputs,
|
|
939
955
|
): Promise<{ receipt: TransactionReceipt; gasPrice: GasPrice }> {
|
|
940
956
|
const { txHash, gasLimit, gasPrice } = await this.sendTransaction(request, gasConfig, blobInputs);
|
|
941
|
-
const receipt = await this.monitorTransaction(request, txHash, { gasLimit }, gasConfig, blobInputs);
|
|
957
|
+
const receipt = await this.monitorTransaction(request, txHash, new Set(), { gasLimit }, gasConfig, blobInputs);
|
|
942
958
|
return { receipt, gasPrice };
|
|
943
959
|
}
|
|
944
960
|
|
|
@@ -973,6 +989,7 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
973
989
|
/**
|
|
974
990
|
* Attempts to cancel a transaction by sending a 0-value tx to self with same nonce but higher gas prices
|
|
975
991
|
* @param nonce - The nonce of the transaction to cancel
|
|
992
|
+
* @param allVersions - Hashes of all transactions submitted under the same nonce (any of them could mine)
|
|
976
993
|
* @param previousGasPrice - The gas price of the previous transaction
|
|
977
994
|
* @param attempts - The number of attempts to cancel the transaction
|
|
978
995
|
* @returns The hash of the cancellation transaction
|
|
@@ -980,6 +997,7 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
980
997
|
protected async attemptTxCancellation(
|
|
981
998
|
currentTxHash: Hex,
|
|
982
999
|
nonce: number,
|
|
1000
|
+
allVersions: Set<Hex>,
|
|
983
1001
|
isBlobTx = false,
|
|
984
1002
|
previousGasPrice?: GasPrice,
|
|
985
1003
|
attempts = 0,
|
|
@@ -1000,7 +1018,7 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
1000
1018
|
previousGasPrice,
|
|
1001
1019
|
);
|
|
1002
1020
|
|
|
1003
|
-
this.logger?.
|
|
1021
|
+
this.logger?.info(`Attempting to cancel L1 transaction ${currentTxHash} with nonce ${nonce}`, {
|
|
1004
1022
|
maxFeePerGas: formatGwei(cancelGasPrice.maxFeePerGas),
|
|
1005
1023
|
maxPriorityFeePerGas: formatGwei(cancelGasPrice.maxPriorityFeePerGas),
|
|
1006
1024
|
});
|
|
@@ -1022,11 +1040,12 @@ export class L1TxUtils extends ReadOnlyL1TxUtils {
|
|
|
1022
1040
|
|
|
1023
1041
|
this.state = TxUtilsState.CANCELLED;
|
|
1024
1042
|
|
|
1025
|
-
this.logger?.
|
|
1043
|
+
this.logger?.info(`Sent cancellation tx ${cancelTxHash} for timed out tx ${currentTxHash}`, { nonce });
|
|
1026
1044
|
|
|
1027
1045
|
const receipt = await this.monitorTransaction(
|
|
1028
1046
|
request,
|
|
1029
1047
|
cancelTxHash,
|
|
1048
|
+
allVersions,
|
|
1030
1049
|
{ gasLimit: 21_000n },
|
|
1031
1050
|
undefined,
|
|
1032
1051
|
undefined,
|
|
@@ -19,6 +19,7 @@ export class L1TxUtilsWithBlobs extends L1TxUtils {
|
|
|
19
19
|
/**
|
|
20
20
|
* Attempts to cancel a transaction by sending a 0-value tx to self with same nonce but higher gas prices
|
|
21
21
|
* @param nonce - The nonce of the transaction to cancel
|
|
22
|
+
* @param allVersions - Hashes of all transactions submitted under the same nonce (any of them could mine)
|
|
22
23
|
* @param previousGasPrice - The gas price of the previous transaction
|
|
23
24
|
* @param attempts - The number of attempts to cancel the transaction
|
|
24
25
|
* @returns The hash of the cancellation transaction
|
|
@@ -26,6 +27,7 @@ export class L1TxUtilsWithBlobs extends L1TxUtils {
|
|
|
26
27
|
override async attemptTxCancellation(
|
|
27
28
|
currentTxHash: Hex,
|
|
28
29
|
nonce: number,
|
|
30
|
+
allVersions: Set<Hex>,
|
|
29
31
|
isBlobTx = false,
|
|
30
32
|
previousGasPrice?: GasPrice,
|
|
31
33
|
attempts = 0,
|
|
@@ -42,7 +44,7 @@ export class L1TxUtilsWithBlobs extends L1TxUtils {
|
|
|
42
44
|
previousGasPrice,
|
|
43
45
|
);
|
|
44
46
|
|
|
45
|
-
this.logger?.
|
|
47
|
+
this.logger?.info(`Attempting to cancel blob L1 transaction ${currentTxHash} with nonce ${nonce}`, {
|
|
46
48
|
maxFeePerGas: formatGwei(cancelGasPrice.maxFeePerGas),
|
|
47
49
|
maxPriorityFeePerGas: formatGwei(cancelGasPrice.maxPriorityFeePerGas),
|
|
48
50
|
maxFeePerBlobGas:
|
|
@@ -65,9 +67,12 @@ export class L1TxUtilsWithBlobs extends L1TxUtils {
|
|
|
65
67
|
const signedRequest = await this.prepareSignedTransaction(txData);
|
|
66
68
|
const cancelTxHash = await this.client.sendRawTransaction({ serializedTransaction: signedRequest });
|
|
67
69
|
|
|
70
|
+
this.logger?.info(`Sent cancellation tx ${cancelTxHash} for timed out tx ${currentTxHash}`);
|
|
71
|
+
|
|
68
72
|
const receipt = await this.monitorTransaction(
|
|
69
73
|
request,
|
|
70
74
|
cancelTxHash,
|
|
75
|
+
allVersions,
|
|
71
76
|
{ gasLimit: 21_000n },
|
|
72
77
|
undefined,
|
|
73
78
|
undefined,
|
|
@@ -94,11 +99,12 @@ export class L1TxUtilsWithBlobs extends L1TxUtils {
|
|
|
94
99
|
const signedRequest = await this.prepareSignedTransaction(txData);
|
|
95
100
|
const cancelTxHash = await this.client.sendRawTransaction({ serializedTransaction: signedRequest });
|
|
96
101
|
|
|
97
|
-
this.logger?.
|
|
102
|
+
this.logger?.info(`Sent cancellation tx ${cancelTxHash} for timed out tx ${currentTxHash}`);
|
|
98
103
|
|
|
99
104
|
const receipt = await this.monitorTransaction(
|
|
100
105
|
request,
|
|
101
106
|
cancelTxHash,
|
|
107
|
+
allVersions,
|
|
102
108
|
{ gasLimit: 21_000n },
|
|
103
109
|
undefined,
|
|
104
110
|
blobInputs,
|
package/src/utils.ts
CHANGED
|
@@ -181,41 +181,19 @@ export function formatViemError(error: any, abi: Abi = ErrorsAbi): FormattedViem
|
|
|
181
181
|
return new FormattedViemError(error.message, (error as any)?.metaMessages);
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// If we found a specific error detail, format it clearly
|
|
201
|
-
if (errorDetail) {
|
|
202
|
-
// Look for key sections of the formatted result to replace with highlighted error
|
|
203
|
-
let replaced = false;
|
|
204
|
-
|
|
205
|
-
// Try to find the Details: section
|
|
206
|
-
const detailsMatch = formattedRes.match(/Details: ([^\n]+)/);
|
|
207
|
-
if (detailsMatch) {
|
|
208
|
-
formattedRes = formattedRes.replace(detailsMatch[0], `Details: *${errorDetail}*`);
|
|
209
|
-
replaced = true;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// If we didn't find a Details section, add the error at the beginning
|
|
213
|
-
if (!replaced) {
|
|
214
|
-
formattedRes = `Error: *${errorDetail}*\n\n${formattedRes}`;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
return new FormattedViemError(formattedRes.replace(/\\n/g, '\n'), error?.metaMessages);
|
|
184
|
+
const body = String(error);
|
|
185
|
+
const length = body.length;
|
|
186
|
+
// LogExplorer can only render up to 2500 characters in it's summary view. Try to keep the whole message below this number
|
|
187
|
+
// Limit the error to 2000 chacaters in order to allow code higher up to decorate this error with extra details (up to 500 characters)
|
|
188
|
+
if (length > 2000) {
|
|
189
|
+
const chunk = 950;
|
|
190
|
+
const truncated = length - 2 * chunk;
|
|
191
|
+
return new FormattedViemError(
|
|
192
|
+
body.slice(0, chunk) + `...${truncated} characters truncated...` + body.slice(-1 * chunk),
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return new FormattedViemError(body);
|
|
219
197
|
}
|
|
220
198
|
|
|
221
199
|
function stripAbis(obj: any) {
|
|
@@ -241,156 +219,6 @@ function stripAbis(obj: any) {
|
|
|
241
219
|
});
|
|
242
220
|
}
|
|
243
221
|
|
|
244
|
-
function extractAndFormatRequestBody(message: string): string {
|
|
245
|
-
// First check if message is extremely large and contains very large hex strings
|
|
246
|
-
if (message.length > 50000) {
|
|
247
|
-
message = replaceHexStrings(message, { minLength: 10000, truncateLength: 200 });
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// Add a specific check for RPC calls with large params
|
|
251
|
-
if (message.includes('"method":"eth_sendRawTransaction"')) {
|
|
252
|
-
message = replaceHexStrings(message, {
|
|
253
|
-
pattern: /"params":\s*\[\s*"(0x[a-fA-F0-9]{1000,})"\s*\]/g,
|
|
254
|
-
transform: hex => `"params":["${truncateHex(hex, 200)}"]`,
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// First handle Request body JSON
|
|
259
|
-
const requestBodyRegex = /Request body: ({[\s\S]*?})\n/g;
|
|
260
|
-
let result = message.replace(requestBodyRegex, (match, body) => {
|
|
261
|
-
return `Request body: ${formatRequestBody(body)}\n`;
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
// Then handle Arguments section
|
|
265
|
-
const argsRegex = /((?:Request |Estimate Gas )?Arguments:[\s\S]*?(?=\n\n|$))/g;
|
|
266
|
-
result = result.replace(argsRegex, section => {
|
|
267
|
-
const lines = section.split('\n');
|
|
268
|
-
const processedLines = lines.map(line => {
|
|
269
|
-
// Check if line contains a colon followed by content
|
|
270
|
-
const colonIndex = line.indexOf(':');
|
|
271
|
-
if (colonIndex !== -1) {
|
|
272
|
-
const [prefix, content] = [line.slice(0, colonIndex + 1), line.slice(colonIndex + 1).trim()];
|
|
273
|
-
// If content contains a hex string, truncate it
|
|
274
|
-
if (content.includes('0x')) {
|
|
275
|
-
const processedContent = replaceHexStrings(content);
|
|
276
|
-
return `${prefix} ${processedContent}`;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
return line;
|
|
280
|
-
});
|
|
281
|
-
return processedLines.join('\n');
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
// Finally, catch any remaining hex strings in the message
|
|
285
|
-
result = replaceHexStrings(result);
|
|
286
|
-
|
|
287
|
-
return result;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function truncateHex(hex: string, length = 100) {
|
|
291
|
-
if (!hex || typeof hex !== 'string') {
|
|
292
|
-
return hex;
|
|
293
|
-
}
|
|
294
|
-
if (!hex.startsWith('0x')) {
|
|
295
|
-
return hex;
|
|
296
|
-
}
|
|
297
|
-
if (hex.length <= length * 2) {
|
|
298
|
-
return hex;
|
|
299
|
-
}
|
|
300
|
-
// For extremely large hex strings, use more aggressive truncation
|
|
301
|
-
if (hex.length > 10000) {
|
|
302
|
-
return `${hex.slice(0, length)}...<${hex.length - length * 2} chars omitted>...${hex.slice(-length)}`;
|
|
303
|
-
}
|
|
304
|
-
return `${hex.slice(0, length)}...${hex.slice(-length)}`;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
function replaceHexStrings(
|
|
308
|
-
text: string,
|
|
309
|
-
options: {
|
|
310
|
-
minLength?: number;
|
|
311
|
-
maxLength?: number;
|
|
312
|
-
truncateLength?: number;
|
|
313
|
-
pattern?: RegExp;
|
|
314
|
-
transform?: (hex: string) => string;
|
|
315
|
-
} = {},
|
|
316
|
-
): string {
|
|
317
|
-
const {
|
|
318
|
-
minLength = 10,
|
|
319
|
-
maxLength = Infinity,
|
|
320
|
-
truncateLength = 100,
|
|
321
|
-
pattern,
|
|
322
|
-
transform = hex => truncateHex(hex, truncateLength),
|
|
323
|
-
} = options;
|
|
324
|
-
|
|
325
|
-
const hexRegex = pattern ?? new RegExp(`(0x[a-fA-F0-9]{${minLength},${maxLength}})`, 'g');
|
|
326
|
-
return text.replace(hexRegex, match => transform(match));
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
function formatRequestBody(body: string) {
|
|
330
|
-
try {
|
|
331
|
-
// Special handling for eth_sendRawTransaction
|
|
332
|
-
if (body.includes('"method":"eth_sendRawTransaction"')) {
|
|
333
|
-
try {
|
|
334
|
-
const parsed = JSON.parse(body);
|
|
335
|
-
if (parsed.params && Array.isArray(parsed.params) && parsed.params.length > 0) {
|
|
336
|
-
// These are likely large transaction hex strings
|
|
337
|
-
parsed.params = parsed.params.map((param: any) => {
|
|
338
|
-
if (typeof param === 'string' && param.startsWith('0x') && param.length > 1000) {
|
|
339
|
-
return truncateHex(param, 200);
|
|
340
|
-
}
|
|
341
|
-
return param;
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
return JSON.stringify(parsed, null, 2);
|
|
345
|
-
} catch {
|
|
346
|
-
// If specific parsing fails, fall back to regex-based truncation
|
|
347
|
-
return replaceHexStrings(body, {
|
|
348
|
-
pattern: /"params":\s*\[\s*"(0x[a-fA-F0-9]{1000,})"\s*\]/g,
|
|
349
|
-
transform: hex => `"params":["${truncateHex(hex, 200)}"]`,
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
// For extremely large request bodies, use simple truncation instead of parsing
|
|
355
|
-
if (body.length > 50000) {
|
|
356
|
-
const jsonStart = body.indexOf('{');
|
|
357
|
-
const jsonEnd = body.lastIndexOf('}');
|
|
358
|
-
if (jsonStart >= 0 && jsonEnd > jsonStart) {
|
|
359
|
-
return replaceHexStrings(body, { minLength: 10000, truncateLength: 200 });
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
const parsed = JSON.parse(body);
|
|
364
|
-
|
|
365
|
-
// Process the entire request body
|
|
366
|
-
const processed = processParams(parsed);
|
|
367
|
-
return JSON.stringify(processed, null, 2);
|
|
368
|
-
} catch {
|
|
369
|
-
// If JSON parsing fails, do a simple truncation of any large hex strings
|
|
370
|
-
return replaceHexStrings(body, { minLength: 1000, truncateLength: 150 });
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
// Recursively process all parameters that might contain hex strings
|
|
375
|
-
function processParams(obj: any): any {
|
|
376
|
-
if (Array.isArray(obj)) {
|
|
377
|
-
return obj.map(item => processParams(item));
|
|
378
|
-
}
|
|
379
|
-
if (typeof obj === 'object' && obj !== null) {
|
|
380
|
-
const result: any = {};
|
|
381
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
382
|
-
result[key] = processParams(value);
|
|
383
|
-
}
|
|
384
|
-
return result;
|
|
385
|
-
}
|
|
386
|
-
if (typeof obj === 'string') {
|
|
387
|
-
if (obj.startsWith('0x')) {
|
|
388
|
-
return truncateHex(obj);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
return obj;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
222
|
export function tryGetCustomErrorName(err: any) {
|
|
395
223
|
try {
|
|
396
224
|
// See https://viem.sh/docs/contract/simulateContract#handling-custom-errors
|