@kohaku-eth/tornado-cash 0.0.2-alpha.17 → 0.0.2-alpha.18

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/dist/index.d.ts CHANGED
@@ -502,6 +502,12 @@ interface IPaymasterWithdrawParams extends IWithdrawBaseParams {
502
502
  mode: 'paymaster';
503
503
  delegation?: DelegationConfig;
504
504
  tailCalls?: (address: AccountId) => Promise<TxData[]>;
505
+ /**
506
+ * Optional baseline for the execution-phase gas of user `tailCalls` (not
507
+ * including per-note direct withdraws). Used when bundler estimation fails;
508
+ * when estimation succeeds the bundler estimate still wins.
509
+ */
510
+ tailCallsGasEstimate?: bigint;
505
511
  }
506
512
  type IWithdrawapOperationParams = IRelayerWithdrawParams | IPaymasterWithdrawParams;
507
513
  interface IGetNotesParams extends IBaseOperationParams {
@@ -567,6 +573,13 @@ interface TCRelayerUnshieldOptions extends UnshieldOptions {
567
573
  interface TCPaymasterUnshieldOptions extends UnshieldOptions {
568
574
  mode: 'paymaster';
569
575
  delegation?: DelegationConfig;
576
+ /**
577
+ * Optional baseline for the execution-phase gas of user `tailCalls` (not
578
+ * including per-note direct withdraws). Used as the batch execution-tail
579
+ * baseline when bundler estimation fails; when estimation succeeds the
580
+ * bundler estimate still wins. Defaults to the SDK's static callGasLimit.
581
+ */
582
+ tailCallsGasEstimate?: bigint;
570
583
  }
571
584
  type TCPrepareUnshieldOptions = TCRelayerUnshieldOptions | TCPaymasterUnshieldOptions;
572
585
  interface TCPrepareShieldOptions {
package/dist/index.js CHANGED
@@ -592,7 +592,8 @@ var TornadoCashProtocol = class {
592
592
  ...baseParams,
593
593
  mode: "paymaster",
594
594
  delegation: options.delegation,
595
- tailCalls: options.tailCalls
595
+ tailCalls: options.tailCalls,
596
+ tailCallsGasEstimate: options.tailCallsGasEstimate
596
597
  });
597
598
  } else {
598
599
  withdrawals = await stateManager.getWithdrawalPayloads({
@@ -22386,11 +22386,11 @@ var PER_DIRECT_WITHDRAW_GAS = 400000n;
22386
22386
  var PER_DIRECT_WITHDRAW_GAS_ERC20 = 500000n;
22387
22387
  var FORWARD_GAS = 60000n;
22388
22388
  var baseGasUnits = {
22389
- preVerificationGas: 80000n,
22389
+ preVerificationGas: 85000n,
22390
22390
  verificationGasLimit: 50000n,
22391
22391
  callGasLimit: 300000n,
22392
22392
  paymasterVerificationGasLimit: 350000n,
22393
- paymasterPostOpGasLimit: 10000n
22393
+ paymasterPostOpGasLimit: 50000n
22394
22394
  };
22395
22395
  function reasonableGasUnits(isERC20) {
22396
22396
  if (!isERC20) return baseGasUnits;
@@ -22399,10 +22399,10 @@ function reasonableGasUnits(isERC20) {
22399
22399
  paymasterVerificationGasLimit: baseGasUnits.paymasterVerificationGasLimit + ERC20_TRANSFER_GAS
22400
22400
  };
22401
22401
  }
22402
- function reasonableGasUnitsForBatch(isERC20, extraWithdrawals, hasUserTailCalls) {
22402
+ function reasonableGasUnitsForBatch(isERC20, extraWithdrawals, hasUserTailCalls, tailCallsGasEstimate) {
22403
22403
  const base = reasonableGasUnits(isERC20);
22404
22404
  const perWithdraw = isERC20 ? PER_DIRECT_WITHDRAW_GAS_ERC20 : PER_DIRECT_WITHDRAW_GAS;
22405
- const executionTail = hasUserTailCalls ? base.callGasLimit : FORWARD_GAS;
22405
+ const executionTail = hasUserTailCalls ? tailCallsGasEstimate ?? base.callGasLimit : FORWARD_GAS;
22406
22406
  return {
22407
22407
  ...base,
22408
22408
  callGasLimit: BigInt(extraWithdrawals) * perWithdraw + executionTail
@@ -24224,6 +24224,7 @@ var paymasterWithdrawThunk = createAsyncThunk("withdraw/executePaymasterWithdraw
24224
24224
  },
24225
24225
  secretManager,
24226
24226
  tailCalls,
24227
+ tailCallsGasEstimate,
24227
24228
  ...rest
24228
24229
  }, { getState, dispatch }) => {
24229
24230
  const state = getState();
@@ -24369,7 +24370,12 @@ var paymasterWithdrawThunk = createAsyncThunk("withdraw/executePaymasterWithdraw
24369
24370
  tailCalls: composeTailCalls(fee2),
24370
24371
  nonce: 0n
24371
24372
  });
24372
- const baselineGas = reasonableGasUnitsForBatch(poolInfo.isERC20, directDeposits.length, tailCalls != null);
24373
+ const baselineGas = reasonableGasUnitsForBatch(
24374
+ poolInfo.isERC20,
24375
+ directDeposits.length,
24376
+ tailCalls != null,
24377
+ tailCallsGasEstimate
24378
+ );
24373
24379
  let fee = await quoteFee(computeMinimumViableFee(baselineGas, maxFeePerGas));
24374
24380
  let gas = baselineGas;
24375
24381
  let sponsoringProof = await prove(sponsoringDeposit, senderAddress, relayerAddress, fee);
@@ -24685,7 +24691,8 @@ var storeStateManager = async ({
24685
24691
  delegation: params.delegation
24686
24692
  },
24687
24693
  secretManager,
24688
- tailCalls: params.tailCalls
24694
+ tailCalls: params.tailCalls,
24695
+ tailCallsGasEstimate: params.tailCallsGasEstimate
24689
24696
  })
24690
24697
  )
24691
24698
  );
@@ -21612,11 +21612,11 @@ var PER_DIRECT_WITHDRAW_GAS = 400000n;
21612
21612
  var PER_DIRECT_WITHDRAW_GAS_ERC20 = 500000n;
21613
21613
  var FORWARD_GAS = 60000n;
21614
21614
  var baseGasUnits = {
21615
- preVerificationGas: 80000n,
21615
+ preVerificationGas: 85000n,
21616
21616
  verificationGasLimit: 50000n,
21617
21617
  callGasLimit: 300000n,
21618
21618
  paymasterVerificationGasLimit: 350000n,
21619
- paymasterPostOpGasLimit: 10000n
21619
+ paymasterPostOpGasLimit: 50000n
21620
21620
  };
21621
21621
  function reasonableGasUnits(isERC20) {
21622
21622
  if (!isERC20) return baseGasUnits;
@@ -21625,10 +21625,10 @@ function reasonableGasUnits(isERC20) {
21625
21625
  paymasterVerificationGasLimit: baseGasUnits.paymasterVerificationGasLimit + ERC20_TRANSFER_GAS
21626
21626
  };
21627
21627
  }
21628
- function reasonableGasUnitsForBatch(isERC20, extraWithdrawals, hasUserTailCalls) {
21628
+ function reasonableGasUnitsForBatch(isERC20, extraWithdrawals, hasUserTailCalls, tailCallsGasEstimate) {
21629
21629
  const base = reasonableGasUnits(isERC20);
21630
21630
  const perWithdraw = isERC20 ? PER_DIRECT_WITHDRAW_GAS_ERC20 : PER_DIRECT_WITHDRAW_GAS;
21631
- const executionTail = hasUserTailCalls ? base.callGasLimit : FORWARD_GAS;
21631
+ const executionTail = hasUserTailCalls ? tailCallsGasEstimate ?? base.callGasLimit : FORWARD_GAS;
21632
21632
  return {
21633
21633
  ...base,
21634
21634
  callGasLimit: BigInt(extraWithdrawals) * perWithdraw + executionTail
@@ -23450,6 +23450,7 @@ var paymasterWithdrawThunk = createAsyncThunk("withdraw/executePaymasterWithdraw
23450
23450
  },
23451
23451
  secretManager,
23452
23452
  tailCalls,
23453
+ tailCallsGasEstimate,
23453
23454
  ...rest
23454
23455
  }, { getState, dispatch }) => {
23455
23456
  const state = getState();
@@ -23595,7 +23596,12 @@ var paymasterWithdrawThunk = createAsyncThunk("withdraw/executePaymasterWithdraw
23595
23596
  tailCalls: composeTailCalls(fee2),
23596
23597
  nonce: 0n
23597
23598
  });
23598
- const baselineGas = reasonableGasUnitsForBatch(poolInfo.isERC20, directDeposits.length, tailCalls != null);
23599
+ const baselineGas = reasonableGasUnitsForBatch(
23600
+ poolInfo.isERC20,
23601
+ directDeposits.length,
23602
+ tailCalls != null,
23603
+ tailCallsGasEstimate
23604
+ );
23599
23605
  let fee = await quoteFee(computeMinimumViableFee(baselineGas, maxFeePerGas));
23600
23606
  let gas = baselineGas;
23601
23607
  let sponsoringProof = await prove(sponsoringDeposit, senderAddress, relayerAddress, fee);
@@ -23911,7 +23917,8 @@ var storeStateManager = async ({
23911
23917
  delegation: params.delegation
23912
23918
  },
23913
23919
  secretManager,
23914
- tailCalls: params.tailCalls
23920
+ tailCalls: params.tailCalls,
23921
+ tailCallsGasEstimate: params.tailCallsGasEstimate
23915
23922
  })
23916
23923
  )
23917
23924
  );
@@ -211,6 +211,12 @@ interface IPaymasterWithdrawParams extends IWithdrawBaseParams {
211
211
  mode: 'paymaster';
212
212
  delegation?: DelegationConfig;
213
213
  tailCalls?: (address: AccountId) => Promise<TxData[]>;
214
+ /**
215
+ * Optional baseline for the execution-phase gas of user `tailCalls` (not
216
+ * including per-note direct withdraws). Used when bundler estimation fails;
217
+ * when estimation succeeds the bundler estimate still wins.
218
+ */
219
+ tailCallsGasEstimate?: bigint;
214
220
  }
215
221
  type IWithdrawapOperationParams = IRelayerWithdrawParams | IPaymasterWithdrawParams;
216
222
  interface IGetNotesParams extends IBaseOperationParams {
@@ -212,6 +212,12 @@ interface IPaymasterWithdrawParams extends IWithdrawBaseParams {
212
212
  mode: 'paymaster';
213
213
  delegation?: DelegationConfig;
214
214
  tailCalls?: (address: AccountId) => Promise<TxData[]>;
215
+ /**
216
+ * Optional baseline for the execution-phase gas of user `tailCalls` (not
217
+ * including per-note direct withdraws). Used when bundler estimation fails;
218
+ * when estimation succeeds the bundler estimate still wins.
219
+ */
220
+ tailCallsGasEstimate?: bigint;
215
221
  }
216
222
  type IWithdrawapOperationParams = IRelayerWithdrawParams | IPaymasterWithdrawParams;
217
223
  interface IGetNotesParams extends IBaseOperationParams {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kohaku-eth/tornado-cash",
3
- "version": "0.0.2-alpha.17",
3
+ "version": "0.0.2-alpha.18",
4
4
  "description": "Tornado Cash Shielded Pool Kohaku Plugin",
5
5
  "type": "module",
6
6
  "private": false,
@@ -75,8 +75,8 @@
75
75
  "ox": "^0.12.0",
76
76
  "viem": "^2.51.3",
77
77
  "@kohaku-eth/plugins": "0.0.1-alpha.11",
78
- "@kohaku-eth/mimc-tree": "0.0.3",
79
- "@kohaku-eth/provider": "0.1.0-alpha.8"
78
+ "@kohaku-eth/provider": "0.1.0-alpha.8",
79
+ "@kohaku-eth/mimc-tree": "0.0.3"
80
80
  },
81
81
  "devDependencies": {
82
82
  "@types/node": "^24.12.2",