@ocap/tx-protocols 1.31.0 → 1.31.2

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.
Files changed (164) hide show
  1. package/esm/bridge-release-crypto.d.mts +39 -0
  2. package/esm/bridge-release-crypto.mjs +88 -0
  3. package/esm/bridge-release-window.d.mts +47 -0
  4. package/esm/bridge-release-window.mjs +62 -0
  5. package/esm/bridge-reserve.d.mts +24 -0
  6. package/esm/bridge-reserve.mjs +41 -0
  7. package/esm/execute.d.mts +5 -3
  8. package/esm/execute.mjs +593 -21
  9. package/esm/gas-security-guard.d.mts +7 -2
  10. package/esm/gas-security-guard.mjs +25 -16
  11. package/esm/index.d.mts +38 -19
  12. package/esm/index.mjs +7 -3
  13. package/esm/pipes/ensure-cost.mjs +36 -10
  14. package/esm/pipes/write-ledger.d.mts +2 -2
  15. package/esm/pipes/write-ledger.mjs +6 -3
  16. package/esm/protocols/account/delegate.mjs +6 -4
  17. package/esm/protocols/account/migrate.mjs +5 -3
  18. package/esm/protocols/account/revoke-delegate.mjs +5 -3
  19. package/esm/protocols/asset/acquire-v2.mjs +3 -1
  20. package/esm/protocols/asset/acquire-v3.mjs +4 -2
  21. package/esm/protocols/asset/consume.mjs +3 -1
  22. package/esm/protocols/asset/create.mjs +4 -2
  23. package/esm/protocols/asset/mint.mjs +4 -2
  24. package/esm/protocols/asset/pipes/exec-mint-hook.mjs +1 -1
  25. package/esm/protocols/asset/pipes/verify-itx-address.mjs +1 -1
  26. package/esm/protocols/asset/pipes/verify-itx-assets.mjs +1 -1
  27. package/esm/protocols/asset/update.mjs +4 -2
  28. package/esm/protocols/bridge/release.d.mts +34 -0
  29. package/esm/protocols/bridge/release.mjs +385 -0
  30. package/esm/protocols/factory/create.mjs +4 -2
  31. package/esm/protocols/governance/claim-stake.mjs +35 -11
  32. package/esm/protocols/governance/return-stake.mjs +4 -2
  33. package/esm/protocols/governance/revoke-ledger.d.mts +34 -0
  34. package/esm/protocols/governance/revoke-ledger.mjs +179 -0
  35. package/esm/protocols/governance/revoke-stake.d.mts +7 -2
  36. package/esm/protocols/governance/revoke-stake.mjs +58 -29
  37. package/esm/protocols/governance/slash-stake.mjs +14 -4
  38. package/esm/protocols/governance/stake.mjs +6 -4
  39. package/esm/protocols/rollup/bridge-create.d.mts +13 -0
  40. package/esm/protocols/rollup/bridge-create.mjs +206 -0
  41. package/esm/protocols/rollup/bridge-membership.d.mts +10 -0
  42. package/esm/protocols/rollup/bridge-membership.mjs +154 -0
  43. package/esm/protocols/rollup/bridge-migrate.d.mts +10 -0
  44. package/esm/protocols/rollup/bridge-migrate.mjs +208 -0
  45. package/esm/protocols/rollup/bridge-v2.d.mts +113 -0
  46. package/esm/protocols/rollup/bridge-v2.mjs +219 -0
  47. package/esm/protocols/rollup/claim-reward.mjs +4 -2
  48. package/esm/protocols/rollup/close.d.mts +2 -1
  49. package/esm/protocols/rollup/close.mjs +59 -6
  50. package/esm/protocols/rollup/create-block.mjs +4 -2
  51. package/esm/protocols/rollup/create.d.mts +3 -0
  52. package/esm/protocols/rollup/create.mjs +45 -6
  53. package/esm/protocols/rollup/join.d.mts +2 -1
  54. package/esm/protocols/rollup/join.mjs +31 -23
  55. package/esm/protocols/rollup/leave.d.mts +2 -1
  56. package/esm/protocols/rollup/leave.mjs +32 -24
  57. package/esm/protocols/rollup/migrate.d.mts +2 -1
  58. package/esm/protocols/rollup/migrate.mjs +19 -10
  59. package/esm/protocols/rollup/pause.d.mts +4 -1
  60. package/esm/protocols/rollup/pause.mjs +50 -6
  61. package/esm/protocols/rollup/pipes/verify-evidence.mjs +2 -2
  62. package/esm/protocols/rollup/resume.d.mts +2 -1
  63. package/esm/protocols/rollup/resume.mjs +26 -6
  64. package/esm/protocols/rollup/update.d.mts +5 -1
  65. package/esm/protocols/rollup/update.mjs +56 -9
  66. package/esm/protocols/token/create.mjs +4 -2
  67. package/esm/protocols/token/deposit-v2.mjs +5 -3
  68. package/esm/protocols/token/withdraw-v2.mjs +5 -3
  69. package/esm/protocols/token-factory/burn.mjs +4 -2
  70. package/esm/protocols/token-factory/create.mjs +8 -4
  71. package/esm/protocols/token-factory/mint.mjs +4 -2
  72. package/esm/protocols/token-factory/update.mjs +20 -5
  73. package/esm/protocols/trade/exchange-v2.d.mts +5 -1
  74. package/esm/protocols/trade/exchange-v2.mjs +89 -4
  75. package/esm/protocols/trade/transfer-v2.mjs +15 -4
  76. package/esm/protocols/trade/transfer-v3.mjs +5 -3
  77. package/esm/stateless-prefix.d.mts +16 -0
  78. package/esm/stateless-prefix.mjs +82 -0
  79. package/esm/tx-timer.d.mts +1 -1
  80. package/esm/tx-timer.mjs +1 -1
  81. package/esm/util.mjs +2 -2
  82. package/lib/bridge-release-crypto.cjs +93 -0
  83. package/lib/bridge-release-crypto.d.cts +39 -0
  84. package/lib/bridge-release-window.cjs +69 -0
  85. package/lib/bridge-release-window.d.cts +47 -0
  86. package/lib/bridge-reserve.cjs +45 -0
  87. package/lib/bridge-reserve.d.cts +24 -0
  88. package/lib/execute.cjs +594 -19
  89. package/lib/execute.d.cts +4 -2
  90. package/lib/gas-security-guard.cjs +25 -16
  91. package/lib/gas-security-guard.d.cts +7 -2
  92. package/lib/index.cjs +10 -1
  93. package/lib/index.d.cts +37 -18
  94. package/lib/pipes/ensure-cost.cjs +37 -11
  95. package/lib/pipes/write-ledger.cjs +6 -3
  96. package/lib/pipes/write-ledger.d.cts +2 -2
  97. package/lib/protocols/account/delegate.cjs +6 -4
  98. package/lib/protocols/account/migrate.cjs +5 -3
  99. package/lib/protocols/account/revoke-delegate.cjs +5 -3
  100. package/lib/protocols/asset/acquire-v2.cjs +3 -1
  101. package/lib/protocols/asset/acquire-v3.cjs +4 -2
  102. package/lib/protocols/asset/consume.cjs +3 -1
  103. package/lib/protocols/asset/create.cjs +4 -2
  104. package/lib/protocols/asset/mint.cjs +4 -2
  105. package/lib/protocols/asset/pipes/exec-mint-hook.cjs +1 -1
  106. package/lib/protocols/asset/pipes/verify-itx-address.cjs +1 -1
  107. package/lib/protocols/asset/pipes/verify-itx-assets.cjs +1 -1
  108. package/lib/protocols/asset/update.cjs +4 -2
  109. package/lib/protocols/bridge/release.cjs +390 -0
  110. package/lib/protocols/bridge/release.d.cts +34 -0
  111. package/lib/protocols/factory/create.cjs +4 -2
  112. package/lib/protocols/governance/claim-stake.cjs +35 -11
  113. package/lib/protocols/governance/return-stake.cjs +4 -2
  114. package/lib/protocols/governance/revoke-ledger.cjs +184 -0
  115. package/lib/protocols/governance/revoke-ledger.d.cts +34 -0
  116. package/lib/protocols/governance/revoke-stake.cjs +58 -29
  117. package/lib/protocols/governance/revoke-stake.d.cts +7 -2
  118. package/lib/protocols/governance/slash-stake.cjs +14 -4
  119. package/lib/protocols/governance/stake.cjs +6 -4
  120. package/lib/protocols/rollup/bridge-create.cjs +209 -0
  121. package/lib/protocols/rollup/bridge-create.d.cts +13 -0
  122. package/lib/protocols/rollup/bridge-membership.cjs +157 -0
  123. package/lib/protocols/rollup/bridge-membership.d.cts +10 -0
  124. package/lib/protocols/rollup/bridge-migrate.cjs +212 -0
  125. package/lib/protocols/rollup/bridge-migrate.d.cts +10 -0
  126. package/lib/protocols/rollup/bridge-v2.cjs +244 -0
  127. package/lib/protocols/rollup/bridge-v2.d.cts +113 -0
  128. package/lib/protocols/rollup/claim-reward.cjs +4 -2
  129. package/lib/protocols/rollup/close.cjs +59 -6
  130. package/lib/protocols/rollup/close.d.cts +2 -1
  131. package/lib/protocols/rollup/create-block.cjs +4 -2
  132. package/lib/protocols/rollup/create.cjs +45 -6
  133. package/lib/protocols/rollup/create.d.cts +3 -0
  134. package/lib/protocols/rollup/join.cjs +31 -23
  135. package/lib/protocols/rollup/join.d.cts +2 -1
  136. package/lib/protocols/rollup/leave.cjs +32 -24
  137. package/lib/protocols/rollup/leave.d.cts +2 -1
  138. package/lib/protocols/rollup/migrate.cjs +19 -10
  139. package/lib/protocols/rollup/migrate.d.cts +2 -1
  140. package/lib/protocols/rollup/pause.cjs +50 -6
  141. package/lib/protocols/rollup/pause.d.cts +4 -1
  142. package/lib/protocols/rollup/pipes/verify-evidence.cjs +2 -2
  143. package/lib/protocols/rollup/resume.cjs +26 -6
  144. package/lib/protocols/rollup/resume.d.cts +2 -1
  145. package/lib/protocols/rollup/update.cjs +56 -9
  146. package/lib/protocols/rollup/update.d.cts +5 -1
  147. package/lib/protocols/token/create.cjs +4 -2
  148. package/lib/protocols/token/deposit-v2.cjs +5 -3
  149. package/lib/protocols/token/withdraw-v2.cjs +5 -3
  150. package/lib/protocols/token-factory/burn.cjs +4 -2
  151. package/lib/protocols/token-factory/create.cjs +8 -4
  152. package/lib/protocols/token-factory/mint.cjs +4 -2
  153. package/lib/protocols/token-factory/update.cjs +20 -5
  154. package/lib/protocols/trade/exchange-v2.cjs +90 -3
  155. package/lib/protocols/trade/exchange-v2.d.cts +5 -1
  156. package/lib/protocols/trade/transfer-v2.cjs +15 -4
  157. package/lib/protocols/trade/transfer-v3.cjs +5 -3
  158. package/lib/stateless-prefix.cjs +88 -0
  159. package/lib/stateless-prefix.d.cts +16 -0
  160. package/lib/tx-timer.cjs +1 -1
  161. package/lib/tx-timer.d.cts +1 -1
  162. package/lib/util.cjs +2 -2
  163. package/package.json +16 -16
  164. package/tools/fixtures.ts +9 -4
package/lib/execute.d.cts CHANGED
@@ -1,10 +1,12 @@
1
1
  import { ITxGasQuotaTelemetry, ITxSecurityWarning } from "./gas-security-guard.cjs";
2
2
  import { TxTimer } from "./tx-timer.cjs";
3
3
  import { Blacklist } from "@ocap/state";
4
- import { IAccountState, IGasContext } from "@ocap/types";
4
+ import { IAccountState, IBaseContext, IGasContext } from "@ocap/types";
5
5
  import { CustomError } from "@ocap/util/lib/error";
6
6
 
7
7
  //#region src/execute.d.ts
8
+ declare const PREFLIGHT_VERIFIED_SNAPSHOT_SYMBOL: symbol;
9
+ declare const tryApplyPreFlightVerifiedSnapshot: (context: IBaseContext) => boolean;
8
10
  /** State helpers interface */
9
11
  interface IStateHelpers {
10
12
  tx: {
@@ -69,4 +71,4 @@ declare const createExecute: ({
69
71
  runAsLambda
70
72
  }: IExecuteOptions) => ExecuteFn;
71
73
  //#endregion
72
- export { UNSIGNED_TX_EVIDENCE_DATA_PREFIX, createExecute as default, toUnsignedEvidenceKey };
74
+ export { PREFLIGHT_VERIFIED_SNAPSHOT_SYMBOL, UNSIGNED_TX_EVIDENCE_DATA_PREFIX, createExecute as default, toUnsignedEvidenceKey, tryApplyPreFlightVerifiedSnapshot };
@@ -1,12 +1,12 @@
1
1
  const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
- let _arcblock_did = require("@arcblock/did");
3
- let _arcblock_did_util = require("@arcblock/did-util");
4
2
  let _ocap_mcrypto = require("@ocap/mcrypto");
5
- let _ocap_state = require("@ocap/state");
6
3
  let _ocap_tx_pipeline = require("@ocap/tx-pipeline");
7
- let _ocap_util = require("@ocap/util");
8
4
  let _ocap_util_lib_error = require("@ocap/util/lib/error");
9
5
  let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
6
+ let _arcblock_did = require("@arcblock/did");
7
+ let _arcblock_did_util = require("@arcblock/did-util");
8
+ let _ocap_state = require("@ocap/state");
9
+ let _ocap_util = require("@ocap/util");
10
10
  let lodash_cloneDeep = require("lodash/cloneDeep");
11
11
  lodash_cloneDeep = require_rolldown_runtime.__toESM(lodash_cloneDeep);
12
12
  let node_crypto = require("node:crypto");
@@ -34,7 +34,7 @@ const MAX_FREE_VARIANTS = 2;
34
34
  /**
35
35
  * High-overhead creator, factory, token-issuance, rollup, and batch transaction types
36
36
  * that ALWAYS require direct gas payment (`requiresDirectGas: true`) and cannot waive
37
- * gas via self-staked `Stake-for-Gas` or Unlinkable Gas Pass.
37
+ * gas via self-staked `Stake-for-Gas`, Unlinkable Gas Pass or a third-party sponsor's stake (#1420).
38
38
  */
39
39
  const DIRECT_GAS_REQUIRED_TX_TYPES = new Set([
40
40
  "create_token",
@@ -191,7 +191,11 @@ function getOrCreateActorRecord(reg, rawActor, nowMs, cfg) {
191
191
  }
192
192
  /**
193
193
  * 3D `Stake-for-Gas` Eligibility Gate:
194
- * 1. `txType` must be in `FREE_GAS_ELIGIBLE_TX_TYPES` (everyday user actions only).
194
+ * 0. `txType` must not be in `DIRECT_GAS_REQUIRED_TX_TYPES`. This holds for every stake-based waiver: self
195
+ * stake, gas pass and third-party sponsor stake (#1420). Only an operator-configured
196
+ * `txGas.freeGasAllowedTxTypes` entry can lift it.
197
+ * 1. `txType` must be in `FREE_GAS_ELIGIBLE_TX_TYPES` (everyday user actions only). Third-party sponsors are
198
+ * exempt from this allowlist unless `enforceSponsor3DEligibility` is on.
195
199
  * 2. `txSize` must be <= `maxFreeGasTxSize` (default 4096 bytes).
196
200
  * 3. `stateOps` (`estimate.create + estimate.update`) must be <= `maxFreeGasStateOps` (default 6).
197
201
  * 4. Failed transactions (`isFailedTxGasCharge === true`) NEVER waive gas.
@@ -204,13 +208,15 @@ function evaluateStakeForGasEligibility(params) {
204
208
  };
205
209
  const shortType = normalizeShortTxType(params.txType);
206
210
  const customAllowlist = (params.config?.transaction?.txGas)?.freeGasAllowedTxTypes;
207
- if ((!params.isThirdPartySponsor || params.enforceSponsor3DEligibility === true) && shortType) {
211
+ const enforceAllowlist = !params.isThirdPartySponsor || params.enforceSponsor3DEligibility === true;
212
+ if (shortType) {
213
+ const requiresDirectGas = DIRECT_GAS_REQUIRED_TX_TYPES.has(shortType);
208
214
  if (Array.isArray(customAllowlist) && customAllowlist.length > 0) {
209
- if (!customAllowlist.some((t) => normalizeShortTxType(t) === shortType || t === params.txType)) return {
215
+ if (!customAllowlist.some((t) => normalizeShortTxType(t) === shortType || t === params.txType) && (enforceAllowlist || requiresDirectGas)) return {
210
216
  eligible: false,
211
217
  reason: "TX_TYPE_REQUIRES_DIRECT_GAS"
212
218
  };
213
- } else if (DIRECT_GAS_REQUIRED_TX_TYPES.has(shortType) || typeof params.txType === "string" && params.txType.startsWith("fg:t:") && !FREE_GAS_ELIGIBLE_TX_TYPES.has(shortType)) return {
219
+ } else if (requiresDirectGas || enforceAllowlist && typeof params.txType === "string" && params.txType.startsWith("fg:t:") && !FREE_GAS_ELIGIBLE_TX_TYPES.has(shortType)) return {
214
220
  eligible: false,
215
221
  reason: "TX_TYPE_REQUIRES_DIRECT_GAS"
216
222
  };
@@ -466,14 +472,16 @@ function verifyAndConsumeUnlinkableGasPass(params) {
466
472
  reason: "GAS_PASS_NULLIFIER_ALREADY_SPENT"
467
473
  };
468
474
  }
469
- if (nullifierMap.size >= MAX_NULLIFIERS_PER_STAKE) {
470
- const oldest = nullifierMap.keys().next().value;
471
- if (oldest) nullifierMap.delete(oldest);
475
+ if (params.consumeNullifier !== false) {
476
+ if (nullifierMap.size >= MAX_NULLIFIERS_PER_STAKE) {
477
+ const oldest = nullifierMap.keys().next().value;
478
+ if (oldest) nullifierMap.delete(oldest);
479
+ }
480
+ nullifierMap.set(nullifier, {
481
+ epoch,
482
+ txHash
483
+ });
472
484
  }
473
- nullifierMap.set(nullifier, {
474
- epoch,
475
- txHash
476
- });
477
485
  return {
478
486
  valid: true,
479
487
  stakeId
@@ -565,6 +573,7 @@ const BENIGN_REJECT_CODES = new Set([
565
573
  "INVALID_TX_TIME",
566
574
  "EXPIRED",
567
575
  "TX_EXPIRED",
576
+ "EXPIRED_TX",
568
577
  "NOT_FOUND",
569
578
  "STAKE_NOT_FOUND",
570
579
  "INVALID_LOCK_STATUS",
@@ -18,7 +18,7 @@ declare const DEFAULT_FISHERMAN_BOUNTY_BPS = 1000;
18
18
  /**
19
19
  * High-overhead creator, factory, token-issuance, rollup, and batch transaction types
20
20
  * that ALWAYS require direct gas payment (`requiresDirectGas: true`) and cannot waive
21
- * gas via self-staked `Stake-for-Gas` or Unlinkable Gas Pass.
21
+ * gas via self-staked `Stake-for-Gas`, Unlinkable Gas Pass or a third-party sponsor's stake (#1420).
22
22
  */
23
23
  declare const DIRECT_GAS_REQUIRED_TX_TYPES: ReadonlySet<string>;
24
24
  /**
@@ -150,7 +150,11 @@ interface IStakeForGasEligibilityResult {
150
150
  }
151
151
  /**
152
152
  * 3D `Stake-for-Gas` Eligibility Gate:
153
- * 1. `txType` must be in `FREE_GAS_ELIGIBLE_TX_TYPES` (everyday user actions only).
153
+ * 0. `txType` must not be in `DIRECT_GAS_REQUIRED_TX_TYPES`. This holds for every stake-based waiver: self
154
+ * stake, gas pass and third-party sponsor stake (#1420). Only an operator-configured
155
+ * `txGas.freeGasAllowedTxTypes` entry can lift it.
156
+ * 1. `txType` must be in `FREE_GAS_ELIGIBLE_TX_TYPES` (everyday user actions only). Third-party sponsors are
157
+ * exempt from this allowlist unless `enforceSponsor3DEligibility` is on.
154
158
  * 2. `txSize` must be <= `maxFreeGasTxSize` (default 4096 bytes).
155
159
  * 3. `stateOps` (`estimate.create + estimate.update`) must be <= `maxFreeGasStateOps` (default 6).
156
160
  * 4. Failed transactions (`isFailedTxGasCharge === true`) NEVER waive gas.
@@ -222,6 +226,7 @@ declare function verifyAndConsumeUnlinkableGasPass(params: {
222
226
  nowMs?: number;
223
227
  config: IChainConfig;
224
228
  statedb?: unknown;
229
+ consumeNullifier?: boolean;
225
230
  }): {
226
231
  valid: boolean;
227
232
  reason?: string;
package/lib/index.cjs CHANGED
@@ -2,6 +2,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
2
2
  const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
3
3
  const require_gas_security_guard = require('./gas-security-guard.cjs');
4
4
  const require_pipes_write_ledger = require('./pipes/write-ledger.cjs');
5
+ const require_stateless_prefix = require('./stateless-prefix.cjs');
5
6
  const require_tx_timer = require('./tx-timer.cjs');
6
7
  const require_execute = require('./execute.cjs');
7
8
  const require_protocols_account_delegate = require('./protocols/account/delegate.cjs');
@@ -13,6 +14,7 @@ const require_protocols_asset_consume = require('./protocols/asset/consume.cjs')
13
14
  const require_protocols_asset_create = require('./protocols/asset/create.cjs');
14
15
  const require_protocols_asset_mint = require('./protocols/asset/mint.cjs');
15
16
  const require_protocols_asset_update = require('./protocols/asset/update.cjs');
17
+ const require_protocols_bridge_release = require('./protocols/bridge/release.cjs');
16
18
  const require_protocols_factory_create = require('./protocols/factory/create.cjs');
17
19
  const require_protocols_governance_claim_stake = require('./protocols/governance/claim-stake.cjs');
18
20
  const require_protocols_governance_return_stake = require('./protocols/governance/return-stake.cjs');
@@ -39,9 +41,9 @@ const require_protocols_token_withdraw_v2 = require('./protocols/token/withdraw-
39
41
  const require_protocols_trade_exchange_v2 = require('./protocols/trade/exchange-v2.cjs');
40
42
  const require_protocols_trade_transfer_v2 = require('./protocols/trade/transfer-v2.cjs');
41
43
  const require_protocols_trade_transfer_v3 = require('./protocols/trade/transfer-v3.cjs');
44
+ let _ocap_tx_pipeline = require("@ocap/tx-pipeline");
42
45
  let _ocap_state = require("@ocap/state");
43
46
  _ocap_state = require_rolldown_runtime.__toESM(_ocap_state);
44
- let _ocap_tx_pipeline = require("@ocap/tx-pipeline");
45
47
 
46
48
  //#region src/index.ts
47
49
  const createExecutor = ({ filter, runAsLambda }) => {
@@ -67,6 +69,7 @@ const createExecutor = ({ filter, runAsLambda }) => {
67
69
  updateTokenFactory: require_protocols_token_factory_update.default,
68
70
  mintToken: require_protocols_token_factory_mint.default,
69
71
  burnToken: require_protocols_token_factory_burn.default,
72
+ releaseBridgeToken: require_protocols_bridge_release.default,
70
73
  stake: require_protocols_governance_stake.default,
71
74
  revokeStake: require_protocols_governance_revoke_stake.default,
72
75
  claimStake: require_protocols_governance_claim_stake.default,
@@ -83,6 +86,7 @@ const createExecutor = ({ filter, runAsLambda }) => {
83
86
  claimBlockReward: require_protocols_rollup_claim_reward.default,
84
87
  migrateRollup: require_protocols_rollup_migrate.default
85
88
  };
89
+ require_stateless_prefix.setDefaultStatelessProtocols(protocols);
86
90
  const execute$1 = require_execute.default({
87
91
  filter,
88
92
  runAsLambda
@@ -137,6 +141,7 @@ Object.defineProperty(exports, 'MAX_PREFLIGHT_JSON_KEYS', {
137
141
  return _ocap_tx_pipeline.MAX_PREFLIGHT_JSON_KEYS;
138
142
  }
139
143
  });
144
+ exports.PREFLIGHT_VERIFIED_SNAPSHOT_SYMBOL = require_execute.PREFLIGHT_VERIFIED_SNAPSHOT_SYMBOL;
140
145
  Object.defineProperty(exports, 'PostExecutionInvariantGate', {
141
146
  enumerable: true,
142
147
  get: function () {
@@ -171,6 +176,7 @@ Object.defineProperty(exports, 'assertRawWireEnvelope', {
171
176
  return _ocap_tx_pipeline.assertRawWireEnvelope;
172
177
  }
173
178
  });
179
+ exports.assertStatelessTxRules = require_stateless_prefix.assertStatelessTxRules;
174
180
  exports.assertTxAdmission = require_gas_security_guard.assertTxAdmission;
175
181
  exports.classifyErrorStrikeCategory = require_gas_security_guard.classifyErrorStrikeCategory;
176
182
  exports.computeActorTier = require_gas_security_guard.computeActorTier;
@@ -185,6 +191,7 @@ exports.executeAutoGasStakeSlash = require_gas_security_guard.executeAutoGasStak
185
191
  exports.extractTransactionTargets = require_gas_security_guard.extractTransactionTargets;
186
192
  exports.getActorSecurityStatus = require_gas_security_guard.getActorSecurityStatus;
187
193
  exports.getGasSecurityRegistry = require_gas_security_guard.getGasSecurityRegistry;
194
+ exports.getStatelessPrefixLength = require_stateless_prefix.getStatelessPrefixLength;
188
195
  exports.getTxSecurityWarningByHash = require_gas_security_guard.getTxSecurityWarningByHash;
189
196
  Object.defineProperty(exports, 'inspectPostExecutionInvariants', {
190
197
  enumerable: true,
@@ -204,6 +211,7 @@ Object.defineProperty(exports, 'installStateWriteInterceptor', {
204
211
  return _ocap_tx_pipeline.installStateWriteInterceptor;
205
212
  }
206
213
  });
214
+ exports.markStatelessPrefix = require_stateless_prefix.markStatelessPrefix;
207
215
  exports.normalizeActorAddress = require_gas_security_guard.normalizeActorAddress;
208
216
  Object.defineProperty(exports, 'normalizeEntityKey', {
209
217
  enumerable: true,
@@ -230,5 +238,6 @@ Object.defineProperty(exports, 'scanItxPayloadAnomalies', {
230
238
  });
231
239
  exports.setTxSecurityWarningForHash = require_gas_security_guard.setTxSecurityWarningForHash;
232
240
  exports.toUnsignedEvidenceKey = require_execute.toUnsignedEvidenceKey;
241
+ exports.tryApplyPreFlightVerifiedSnapshot = require_execute.tryApplyPreFlightVerifiedSnapshot;
233
242
  exports.verifyAndConsumeUnlinkableGasPass = require_gas_security_guard.verifyAndConsumeUnlinkableGasPass;
234
243
  exports.verifyPaymasterConstraints = require_gas_security_guard.verifyPaymasterConstraints;
package/lib/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { DEFAULT_BASE_BURST_ALLOWANCE, DEFAULT_BURST_REJECT_MULTIPLE, DEFAULT_BURST_WINDOW_MS, DEFAULT_FISHERMAN_BOUNTY_BPS, DEFAULT_GAS_PASS_EPOCH_SECONDS, DEFAULT_MAX_FREE_GAS_STATE_OPS, DEFAULT_MAX_FREE_GAS_TX_SIZE, DEFAULT_SLASH_STRIKE_THRESHOLD, DEFAULT_STRIKE_WINDOW_MS, DEFAULT_THROTTLE_COOLDOWN_MS, DEFAULT_THROTTLE_STRIKE_THRESHOLD, DEFAULT_WARNING_STRIKE_THRESHOLD, DIRECT_GAS_REQUIRED_TX_TYPES, FREE_GAS_ELIGIBLE_TX_TYPES, IAbuseSlashEvidence, IGasSecurityConfig, IPaymasterDecodedClaims, IStakeForGasEligibilityResult, ITxGasQuotaTelemetry, ITxSecurityWarning, IUnlinkableGasPass, SecurityStrikeTier, StrikeReasonCategory, assertTxAdmission, classifyErrorStrikeCategory, computeActorTier, computeUnlinkableGasPassCommitment, computeUnlinkableGasPassSecretHash, evaluateBurstQuota, evaluateStakeForGasEligibility, executeAutoGasStakeSlash, extractTransactionTargets, getActorSecurityStatus, getGasSecurityRegistry, getTxSecurityWarningByHash, normalizeActorAddress, normalizeShortTxType, recordActorSecurityStrike, resetGasSecurityState, resolveGasSecurityConfig, resolveVerifiedStrikeActors, setTxSecurityWarningForHash, verifyAndConsumeUnlinkableGasPass, verifyPaymasterConstraints } from "./gas-security-guard.cjs";
2
2
  import { COUNTER_NAMES, CounterName, QueueState, STAGE_LABELS, StageLabel, TxMeta, TxStatus, TxTimer, TxTimerSummaryV2 } from "./tx-timer.cjs";
3
- import { UNSIGNED_TX_EVIDENCE_DATA_PREFIX, toUnsignedEvidenceKey } from "./execute.cjs";
3
+ import { PREFLIGHT_VERIFIED_SNAPSHOT_SYMBOL, UNSIGNED_TX_EVIDENCE_DATA_PREFIX, toUnsignedEvidenceKey, tryApplyPreFlightVerifiedSnapshot } from "./execute.cjs";
4
4
  import { TokenInput } from "./protocols/trade/transfer-v2.cjs";
5
5
  import { MultiInput } from "./protocols/trade/transfer-v3.cjs";
6
6
  import { TokenInput as TokenInput$1 } from "./protocols/trade/exchange-v2.cjs";
@@ -12,14 +12,17 @@ import { TokenInput as TokenInput$4 } from "./protocols/token/withdraw-v2.cjs";
12
12
  import { TokenInfoForVerification } from "./protocols/token-factory/update.cjs";
13
13
  import { MultiInput as MultiInput$2 } from "./protocols/token-factory/mint.cjs";
14
14
  import { MultiInput as MultiInput$3 } from "./protocols/token-factory/burn.cjs";
15
+ import { Context } from "./protocols/bridge/release.cjs";
15
16
  import { MultiInput as MultiInput$4 } from "./protocols/governance/stake.cjs";
16
17
  import { MultiOutput, TokenCondition } from "./protocols/governance/revoke-stake.cjs";
17
18
  import { MultiOutput as MultiOutput$1, TokenCondition as TokenCondition$1, TokenInput as TokenInput$5 } from "./protocols/governance/claim-stake.cjs";
18
19
  import { MultiOutput as MultiOutput$2 } from "./protocols/governance/slash-stake.cjs";
19
20
  import { MultiInput as MultiInput$5, TokenCondition as TokenCondition$2 } from "./protocols/governance/return-stake.cjs";
21
+ import { BridgeCtxMixin } from "./protocols/rollup/bridge-v2.cjs";
20
22
  import { TokenChange as TokenChange$1 } from "./protocols/rollup/create-block.cjs";
21
23
  import { TokenChange as TokenChange$2 } from "./protocols/rollup/claim-reward.cjs";
22
24
  import { WriteLedger } from "./pipes/write-ledger.cjs";
25
+ import { assertStatelessTxRules, getStatelessPrefixLength, markStatelessPrefix } from "./stateless-prefix.cjs";
23
26
  import * as states from "@ocap/state";
24
27
  import * as _ocap_types0 from "@ocap/types";
25
28
  import * as _ocap_util0 from "@ocap/util";
@@ -300,6 +303,7 @@ declare const createExecutor: ({
300
303
  delta: string;
301
304
  }[];
302
305
  }>;
306
+ releaseBridgeToken: _ocap_tx_pipeline0.Runner<Context>;
303
307
  stake: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TStakeTx> & Partial<_ocap_types0.IWithSender> & Partial<_ocap_types0.IWithSigners> & Partial<_ocap_types0.IWithReceiver> & Partial<_ocap_types0.IWithStake> & Partial<_ocap_types0.IWithTokens> & Partial<_ocap_types0.IWithAssets> & {
304
308
  inputs?: MultiInput$4[];
305
309
  senders?: string[];
@@ -310,7 +314,8 @@ declare const createExecutor: ({
310
314
  revokeWaitingPeriod?: number;
311
315
  slashers?: string[];
312
316
  }>;
313
- revokeStake: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TRevokeStakeTx> & _ocap_types0.IWithSender & _ocap_types0.IWithStake & Partial<_ocap_types0.IWithReceivers> & Partial<_ocap_types0.IWithTokens> & Partial<_ocap_types0.IWithAssets> & {
317
+ revokeStake: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TRevokeStakeTx> & _ocap_types0.IWithSender & _ocap_types0.IWithStake & Partial<_ocap_types0.IWithReceivers> & Partial<_ocap_types0.IWithTokens> & Partial<_ocap_types0.IWithAssets> & Partial<Pick<_ocap_types0.IWithToken, "tokenState">> & Partial<_ocap_types0.IWithTokenFactory> & {
318
+ tokenStakeRelease?: "retire" | "retired";
314
319
  outputs?: MultiOutput[];
315
320
  receivers?: string[];
316
321
  tokens?: string[];
@@ -357,23 +362,29 @@ declare const createExecutor: ({
357
362
  tokenState?: _ocap_types0.ITokenState;
358
363
  rollupState?: _ocap_types0.IRollupState | null;
359
364
  isDelegationChanged?: boolean;
365
+ isBridgeV2?: boolean;
366
+ bridgeInput?: unknown;
360
367
  }>;
361
- updateRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TUpdateRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners>;
362
- joinRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TJoinRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & _ocap_types0.IWithStake & {
368
+ updateRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TUpdateRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & BridgeCtxMixin & {
369
+ bridgePlan?: states.rollup.BridgePatchPlan;
370
+ }>;
371
+ joinRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TJoinRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & _ocap_types0.IWithStake & BridgeCtxMixin & {
363
372
  evidenceState?: _ocap_types0.IEvidenceState | null;
364
373
  newValidator?: _ocap_types0.IRollupValidator;
365
374
  validatorsHash?: string;
366
375
  }>;
367
- leaveRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TLeaveRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & _ocap_types0.IWithStake & {
376
+ leaveRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TLeaveRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & _ocap_types0.IWithStake & BridgeCtxMixin & {
368
377
  validatorsHash?: string;
369
378
  evidenceState?: _ocap_types0.IEvidenceState | null;
370
379
  }>;
371
- pauseRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TPauseRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners>;
372
- closeRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TCloseRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & {
380
+ pauseRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TPauseRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & BridgeCtxMixin & {
381
+ pauseKind?: "quorum" | "lone";
382
+ }>;
383
+ closeRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TCloseRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & BridgeCtxMixin & {
373
384
  stakeAddresses?: string[];
374
385
  stakeStates?: _ocap_types0.IStakeState[];
375
386
  }>;
376
- resumeRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TResumeRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners>;
387
+ resumeRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TResumeRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & BridgeCtxMixin>;
377
388
  createRollupBlock: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TCreateRollupBlockTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & _ocap_types0.IWithStakes & {
378
389
  formattedItx?: Record<string, unknown>;
379
390
  previousBlock?: _ocap_types0.IRollupBlock | null;
@@ -422,7 +433,7 @@ declare const createExecutor: ({
422
433
  missingAccountStates?: _ocap_types0.IAccountState[];
423
434
  stakeStates?: _ocap_types0.IStakeState[];
424
435
  }>;
425
- migrateRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TMigrateRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners>;
436
+ migrateRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TMigrateRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & BridgeCtxMixin>;
426
437
  };
427
438
  declare const defaultExecutor: {
428
439
  execute: (context: unknown, done?: (err: Error | null, res?: unknown) => void) => any;
@@ -684,6 +695,7 @@ declare const defaultExecutor: {
684
695
  delta: string;
685
696
  }[];
686
697
  }>;
698
+ releaseBridgeToken: _ocap_tx_pipeline0.Runner<Context>;
687
699
  stake: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TStakeTx> & Partial<_ocap_types0.IWithSender> & Partial<_ocap_types0.IWithSigners> & Partial<_ocap_types0.IWithReceiver> & Partial<_ocap_types0.IWithStake> & Partial<_ocap_types0.IWithTokens> & Partial<_ocap_types0.IWithAssets> & {
688
700
  inputs?: MultiInput$4[];
689
701
  senders?: string[];
@@ -694,7 +706,8 @@ declare const defaultExecutor: {
694
706
  revokeWaitingPeriod?: number;
695
707
  slashers?: string[];
696
708
  }>;
697
- revokeStake: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TRevokeStakeTx> & _ocap_types0.IWithSender & _ocap_types0.IWithStake & Partial<_ocap_types0.IWithReceivers> & Partial<_ocap_types0.IWithTokens> & Partial<_ocap_types0.IWithAssets> & {
709
+ revokeStake: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TRevokeStakeTx> & _ocap_types0.IWithSender & _ocap_types0.IWithStake & Partial<_ocap_types0.IWithReceivers> & Partial<_ocap_types0.IWithTokens> & Partial<_ocap_types0.IWithAssets> & Partial<Pick<_ocap_types0.IWithToken, "tokenState">> & Partial<_ocap_types0.IWithTokenFactory> & {
710
+ tokenStakeRelease?: "retire" | "retired";
698
711
  outputs?: MultiOutput[];
699
712
  receivers?: string[];
700
713
  tokens?: string[];
@@ -741,23 +754,29 @@ declare const defaultExecutor: {
741
754
  tokenState?: _ocap_types0.ITokenState;
742
755
  rollupState?: _ocap_types0.IRollupState | null;
743
756
  isDelegationChanged?: boolean;
757
+ isBridgeV2?: boolean;
758
+ bridgeInput?: unknown;
744
759
  }>;
745
- updateRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TUpdateRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners>;
746
- joinRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TJoinRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & _ocap_types0.IWithStake & {
760
+ updateRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TUpdateRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & BridgeCtxMixin & {
761
+ bridgePlan?: states.rollup.BridgePatchPlan;
762
+ }>;
763
+ joinRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TJoinRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & _ocap_types0.IWithStake & BridgeCtxMixin & {
747
764
  evidenceState?: _ocap_types0.IEvidenceState | null;
748
765
  newValidator?: _ocap_types0.IRollupValidator;
749
766
  validatorsHash?: string;
750
767
  }>;
751
- leaveRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TLeaveRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & _ocap_types0.IWithStake & {
768
+ leaveRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TLeaveRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & _ocap_types0.IWithStake & BridgeCtxMixin & {
752
769
  validatorsHash?: string;
753
770
  evidenceState?: _ocap_types0.IEvidenceState | null;
754
771
  }>;
755
- pauseRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TPauseRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners>;
756
- closeRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TCloseRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & {
772
+ pauseRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TPauseRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & BridgeCtxMixin & {
773
+ pauseKind?: "quorum" | "lone";
774
+ }>;
775
+ closeRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TCloseRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & BridgeCtxMixin & {
757
776
  stakeAddresses?: string[];
758
777
  stakeStates?: _ocap_types0.IStakeState[];
759
778
  }>;
760
- resumeRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TResumeRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners>;
779
+ resumeRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TResumeRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & BridgeCtxMixin>;
761
780
  createRollupBlock: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TCreateRollupBlockTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & _ocap_types0.IWithStakes & {
762
781
  formattedItx?: Record<string, unknown>;
763
782
  previousBlock?: _ocap_types0.IRollupBlock | null;
@@ -806,8 +825,8 @@ declare const defaultExecutor: {
806
825
  missingAccountStates?: _ocap_types0.IAccountState[];
807
826
  stakeStates?: _ocap_types0.IStakeState[];
808
827
  }>;
809
- migrateRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TMigrateRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners>;
828
+ migrateRollup: _ocap_tx_pipeline0.Runner<_ocap_types0.IReadyContext<_ocap_types0.TMigrateRollupTx> & _ocap_types0.IWithRollup & _ocap_types0.IWithSender & _ocap_types0.IWithSigners & BridgeCtxMixin>;
810
829
  };
811
830
  declare const execute: (context: unknown, done?: (err: Error | null, res?: unknown) => void) => any;
812
831
  //#endregion
813
- export { COUNTER_NAMES, type CounterName, DEFAULT_BASE_BURST_ALLOWANCE, DEFAULT_BURST_REJECT_MULTIPLE, DEFAULT_BURST_WINDOW_MS, DEFAULT_FISHERMAN_BOUNTY_BPS, DEFAULT_GAS_PASS_EPOCH_SECONDS, DEFAULT_MAX_FREE_GAS_STATE_OPS, DEFAULT_MAX_FREE_GAS_TX_SIZE, DEFAULT_SLASH_STRIKE_THRESHOLD, DEFAULT_STRIKE_WINDOW_MS, DEFAULT_THROTTLE_COOLDOWN_MS, DEFAULT_THROTTLE_STRIKE_THRESHOLD, DEFAULT_WARNING_STRIKE_THRESHOLD, DIRECT_GAS_REQUIRED_TX_TYPES, FREE_GAS_ELIGIBLE_TX_TYPES, type IAbuseSlashEvidence, type IGasSecurityConfig, type IPaymasterDecodedClaims, type IStakeForGasEligibilityResult, type ITxGasQuotaTelemetry, type ITxSecurityWarning, type IUnlinkableGasPass, MAX_POST_EXECUTION_WRITE_SET_ENTRIES, MAX_PREFLIGHT_JSON_DEPTH, MAX_PREFLIGHT_JSON_KEYS, PostExecutionInvariantGate, PreFlightWaf, type QueueState, STAGE_LABELS, type SecurityStrikeTier, type StageLabel, type StrikeReasonCategory, TRACKED_STATE_TABLES, type TxMeta, type TxStatus, TxTimer, type TxTimerSummaryV2, UNSIGNED_TX_EVIDENCE_DATA_PREFIX, WriteLedger, assertKnownItxFields, assertRawWireEnvelope, assertTxAdmission, classifyErrorStrikeCategory, computeActorTier, computeUnlinkableGasPassCommitment, computeUnlinkableGasPassSecretHash, createExecutor, defaultExecutor as default, evaluateBurstQuota, evaluateStakeForGasEligibility, execute, executeAutoGasStakeSlash, extractTransactionTargets, getActorSecurityStatus, getGasSecurityRegistry, getTxSecurityWarningByHash, inspectPostExecutionInvariants, inspectTransactionPreFlight, installStateWriteInterceptor, normalizeActorAddress, normalizeEntityKey, normalizeShortTxType, recordActorSecurityStrike, resetGasSecurityState, resolveGasSecurityConfig, resolveVerifiedStrikeActors, rollbackTrackedStateWrites, scanItxPayloadAnomalies, setTxSecurityWarningForHash, toUnsignedEvidenceKey, verifyAndConsumeUnlinkableGasPass, verifyPaymasterConstraints };
832
+ export { COUNTER_NAMES, type CounterName, DEFAULT_BASE_BURST_ALLOWANCE, DEFAULT_BURST_REJECT_MULTIPLE, DEFAULT_BURST_WINDOW_MS, DEFAULT_FISHERMAN_BOUNTY_BPS, DEFAULT_GAS_PASS_EPOCH_SECONDS, DEFAULT_MAX_FREE_GAS_STATE_OPS, DEFAULT_MAX_FREE_GAS_TX_SIZE, DEFAULT_SLASH_STRIKE_THRESHOLD, DEFAULT_STRIKE_WINDOW_MS, DEFAULT_THROTTLE_COOLDOWN_MS, DEFAULT_THROTTLE_STRIKE_THRESHOLD, DEFAULT_WARNING_STRIKE_THRESHOLD, DIRECT_GAS_REQUIRED_TX_TYPES, FREE_GAS_ELIGIBLE_TX_TYPES, type IAbuseSlashEvidence, type IGasSecurityConfig, type IPaymasterDecodedClaims, type IStakeForGasEligibilityResult, type ITxGasQuotaTelemetry, type ITxSecurityWarning, type IUnlinkableGasPass, MAX_POST_EXECUTION_WRITE_SET_ENTRIES, MAX_PREFLIGHT_JSON_DEPTH, MAX_PREFLIGHT_JSON_KEYS, PREFLIGHT_VERIFIED_SNAPSHOT_SYMBOL, PostExecutionInvariantGate, PreFlightWaf, type QueueState, STAGE_LABELS, type SecurityStrikeTier, type StageLabel, type StrikeReasonCategory, TRACKED_STATE_TABLES, type TxMeta, type TxStatus, TxTimer, type TxTimerSummaryV2, UNSIGNED_TX_EVIDENCE_DATA_PREFIX, WriteLedger, assertKnownItxFields, assertRawWireEnvelope, assertStatelessTxRules, assertTxAdmission, classifyErrorStrikeCategory, computeActorTier, computeUnlinkableGasPassCommitment, computeUnlinkableGasPassSecretHash, createExecutor, defaultExecutor as default, evaluateBurstQuota, evaluateStakeForGasEligibility, execute, executeAutoGasStakeSlash, extractTransactionTargets, getActorSecurityStatus, getGasSecurityRegistry, getStatelessPrefixLength, getTxSecurityWarningByHash, inspectPostExecutionInvariants, inspectTransactionPreFlight, installStateWriteInterceptor, markStatelessPrefix, normalizeActorAddress, normalizeEntityKey, normalizeShortTxType, recordActorSecurityStrike, resetGasSecurityState, resolveGasSecurityConfig, resolveVerifiedStrikeActors, rollbackTrackedStateWrites, scanItxPayloadAnomalies, setTxSecurityWarningForHash, toUnsignedEvidenceKey, tryApplyPreFlightVerifiedSnapshot, verifyAndConsumeUnlinkableGasPass, verifyPaymasterConstraints };
@@ -1,15 +1,16 @@
1
1
  Object.defineProperty(exports, '__esModule', { value: true });
2
2
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
3
+ const require_bridge_reserve = require('../bridge-reserve.cjs');
3
4
  const require_gas_security_guard = require('../gas-security-guard.cjs');
4
5
  const require_util = require('../util.cjs');
6
+ let _ocap_util_lib_error = require("@ocap/util/lib/error");
5
7
  let _arcblock_did = require("@arcblock/did");
6
8
  let _arcblock_did_util = require("@arcblock/did-util");
9
+ let _arcblock_jwt = require("@arcblock/jwt");
10
+ _arcblock_jwt = require_rolldown_runtime.__toESM(_arcblock_jwt);
7
11
  let _ocap_state = require("@ocap/state");
8
12
  let _ocap_util = require("@ocap/util");
9
- let _ocap_util_lib_error = require("@ocap/util/lib/error");
10
13
  let _ocap_util_lib_get_related_addr = require("@ocap/util/lib/get-related-addr");
11
- let _arcblock_jwt = require("@arcblock/jwt");
12
- _arcblock_jwt = require_rolldown_runtime.__toESM(_arcblock_jwt);
13
14
  let lodash_noop = require("lodash/noop");
14
15
  lodash_noop = require_rolldown_runtime.__toESM(lodash_noop);
15
16
  let debug = require("debug");
@@ -32,6 +33,8 @@ function isMatchingAccountPublicKey(onChainPk, headerPk) {
32
33
  const { config } = context;
33
34
  const { tx, extra = {}, txHash = "", txTime } = context;
34
35
  const isFailedTxGasCharge = Boolean(context.isFailedTxGasCharge);
36
+ const canChargeSenderDirectly = Boolean(senderState);
37
+ const txSize = context._baseTxSize ?? context.txSize;
35
38
  const nowMs = txTime ? +new Date(txTime) : Date.now();
36
39
  const { token, pk } = extra.gasStakeHeaders || {};
37
40
  const rawGasPass = extra.gasPass || extra.txExtra?.gasPass;
@@ -70,7 +73,7 @@ function isMatchingAccountPublicKey(onChainPk, headerPk) {
70
73
  };
71
74
  };
72
75
  let isThirdPartyGasPass = false;
73
- if (!isFailedTxGasCharge && rawGasPass) {
76
+ if ((!isFailedTxGasCharge || !canChargeSenderDirectly) && rawGasPass) {
74
77
  const passStakeState = rawGasPass.stakeId ? await statedb.stake?.get?.(rawGasPass.stakeId, context) : null;
75
78
  const passResult = require_gas_security_guard.verifyAndConsumeUnlinkableGasPass({
76
79
  gasPass: rawGasPass,
@@ -88,7 +91,16 @@ function isMatchingAccountPublicKey(onChainPk, headerPk) {
88
91
  const passOwner = passStakeState?.sender || rawGasPass.stakeId;
89
92
  isThirdPartyGasPass = Boolean(passOwner && (!tx?.from || !(0, _ocap_util.isSameDid)(passOwner, tx.from)) && (!tx?.delegator || !(0, _ocap_util.isSameDid)(passOwner, tx.delegator)));
90
93
  const selfStakeInfo = isThirdPartyGasPass ? await resolveSignerSelfGasStake() : null;
91
- if (selfStakeInfo?.valid) {
94
+ const selfStakeEligible = Boolean(selfStakeInfo?.valid) && require_gas_security_guard.evaluateStakeForGasEligibility({
95
+ txType,
96
+ txSize,
97
+ gasEstimate,
98
+ isFailedTxGasCharge: isFailedTxGasCharge && canChargeSenderDirectly,
99
+ isThirdPartySponsor: false,
100
+ enforceSponsor3DEligibility: false,
101
+ config
102
+ }).eligible;
103
+ if (selfStakeInfo?.valid && selfStakeEligible) {
92
104
  gasStake.owner = selfStakeInfo.owner;
93
105
  gasStake.stakeId = selfStakeInfo.stakeId;
94
106
  gasStake.state = selfStakeInfo.state;
@@ -98,7 +110,7 @@ function isMatchingAccountPublicKey(onChainPk, headerPk) {
98
110
  gasStake.stakeId = passResult.stakeId;
99
111
  gasStake.state = passStakeState;
100
112
  }
101
- } else if (!isFailedTxGasCharge && token && pk) {
113
+ } else if ((!isFailedTxGasCharge || !canChargeSenderDirectly) && token && pk) {
102
114
  const decoded = _arcblock_jwt.decode(token) || {};
103
115
  const sponsorAddress = (0, _arcblock_did.toAddress)(decoded.iss || "");
104
116
  if (!sponsorAddress || !(0, _arcblock_did.isFromPublicKey)(sponsorAddress, pk)) {
@@ -106,6 +118,11 @@ function isMatchingAccountPublicKey(onChainPk, headerPk) {
106
118
  hdrErr._unauthenticatedExtraFailure = true;
107
119
  return next(hdrErr);
108
120
  }
121
+ try {
122
+ require_bridge_reserve.assertBridgeReserveNotSponsor(sponsorAddress);
123
+ } catch (err) {
124
+ return next(err);
125
+ }
109
126
  if (await _arcblock_jwt.verify(token, pk, {
110
127
  enforceTimestamp: !txTime,
111
128
  tolerance: 5
@@ -143,7 +160,7 @@ function isMatchingAccountPublicKey(onChainPk, headerPk) {
143
160
  }
144
161
  if (!isSponsorMigrated && !isSponsorBlocked) {
145
162
  const sponsorStakeId = (0, _arcblock_did_util.toStakeAddress)(sponsorAddress, sponsorAddress);
146
- const isDirectMode = decoded.mode === "paymaster";
163
+ const isDirectMode = decoded.mode === "paymaster" || decoded.chargeSponsorBalance === true;
147
164
  const sponsorStakeState = !isDirectMode ? await statedb.stake?.get?.(sponsorStakeId, context) : null;
148
165
  const officialTok = config.token?.address || "";
149
166
  const sponsorIsBacked = isDirectMode ? Boolean(sponsorState && officialTok && new _ocap_util.BN(sponsorState.tokens?.[officialTok] || 0).gte((totalGas ?? ZERO).gt(ZERO) ? totalGas ?? ZERO : new _ocap_util.BN(1))) : require_util.isGasStakeValid(sponsorStakeState, config);
@@ -178,7 +195,16 @@ function isMatchingAccountPublicKey(onChainPk, headerPk) {
178
195
  }
179
196
  }
180
197
  const selfStakeInfo = await resolveSignerSelfGasStake();
181
- if (selfStakeInfo.valid) {
198
+ const selfStakeEligible = Boolean(selfStakeInfo.valid) && require_gas_security_guard.evaluateStakeForGasEligibility({
199
+ txType,
200
+ txSize,
201
+ gasEstimate,
202
+ isFailedTxGasCharge: isFailedTxGasCharge && canChargeSenderDirectly,
203
+ isThirdPartySponsor: false,
204
+ enforceSponsor3DEligibility: false,
205
+ config
206
+ }).eligible;
207
+ if (selfStakeInfo.valid && selfStakeEligible) {
182
208
  gasStake.owner = selfStakeInfo.owner;
183
209
  gasStake.stakeId = selfStakeInfo.stakeId;
184
210
  gasStake.state = selfStakeInfo.state;
@@ -204,9 +230,9 @@ function isMatchingAccountPublicKey(onChainPk, headerPk) {
204
230
  if (!gasStake.state && gasStake.stakeId) gasStake.state = await statedb.stake.get(gasStake.stakeId, context);
205
231
  const eligibility = require_gas_security_guard.evaluateStakeForGasEligibility({
206
232
  txType,
207
- txSize: context._baseTxSize ?? context.txSize,
233
+ txSize,
208
234
  gasEstimate,
209
- isFailedTxGasCharge,
235
+ isFailedTxGasCharge: isFailedTxGasCharge && canChargeSenderDirectly,
210
236
  isThirdPartySponsor,
211
237
  enforceSponsor3DEligibility,
212
238
  config
@@ -251,7 +277,7 @@ function isMatchingAccountPublicKey(onChainPk, headerPk) {
251
277
  value: totalGasBN.toString(10)
252
278
  };
253
279
  context.gasVaultChange = changes.gas;
254
- if (isPaymasterDirectCharge && !isFailedTxGasCharge) sponsorGasCost = totalGasBN;
280
+ if (isPaymasterDirectCharge && (!isFailedTxGasCharge || !canChargeSenderDirectly)) sponsorGasCost = totalGasBN;
255
281
  else txCost = txCost.add(totalGasBN);
256
282
  }
257
283
  if (changes.fee) if (config.vaults.txFees?.length) {
@@ -9,7 +9,10 @@ let _ocap_message = require("@ocap/message");
9
9
  * WriteLedger Pipe
10
10
  *
11
11
  * Writes verified transactions to the Ledger append-only log.
12
- * Must be placed AFTER VerifySignature to ensure only authenticated txs are recorded.
12
+ * Must run AFTER VerifySignature to ensure only authenticated txs are recorded, and (#1419) only at the point
13
+ * where the tx state is written: after the protocol accepted the tx, or after a failed tx was charged
14
+ * failed-tx gas. It still runs before `statedb.tx.create` and the statedb commit. See `appendLedgerEntry` in
15
+ * `execute.ts`.
13
16
  *
14
17
  * The ledger provides:
15
18
  * - Append-only immutable transaction log
@@ -35,8 +38,8 @@ const LEDGER_ERRORS = {
35
38
  * ```typescript
36
39
  * import { WriteLedger } from '@ocap/tx-protocols/pipes/write-ledger';
37
40
  *
38
- * // In pipeline setup (after VerifySignature):
39
- * runner.use(WriteLedger);
41
+ * // After the protocol runner, right before the tx state is written:
42
+ * await runSinglePipe(WriteLedger, context);
40
43
  * ```
41
44
  */
42
45
  const WriteLedger = async (context, next) => {
@@ -68,8 +68,8 @@ declare const LEDGER_ERRORS: {
68
68
  * ```typescript
69
69
  * import { WriteLedger } from '@ocap/tx-protocols/pipes/write-ledger';
70
70
  *
71
- * // In pipeline setup (after VerifySignature):
72
- * runner.use(WriteLedger);
71
+ * // After the protocol runner, right before the tx state is written:
72
+ * await runSinglePipe(WriteLedger, context);
73
73
  * ```
74
74
  */
75
75
  declare const WriteLedger: PipeFunction<IWriteLedgerContext>;
@@ -2,14 +2,15 @@ Object.defineProperty(exports, '__esModule', { value: true });
2
2
  const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
3
3
  const require_pipes_ensure_cost = require('../../pipes/ensure-cost.cjs');
4
4
  const require_pipes_ensure_gas = require('../../pipes/ensure-gas.cjs');
5
- let _arcblock_did = require("@arcblock/did");
6
- let _arcblock_did_util = require("@arcblock/did-util");
5
+ const require_stateless_prefix = require('../../stateless-prefix.cjs');
7
6
  let _ocap_mcrypto = require("@ocap/mcrypto");
8
- let _ocap_state = require("@ocap/state");
9
7
  let _ocap_tx_pipeline = require("@ocap/tx-pipeline");
10
- let _ocap_util = require("@ocap/util");
11
8
  let _ocap_util_lib_error = require("@ocap/util/lib/error");
12
9
  let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
10
+ let _arcblock_did = require("@arcblock/did");
11
+ let _arcblock_did_util = require("@arcblock/did-util");
12
+ let _ocap_state = require("@ocap/state");
13
+ let _ocap_util = require("@ocap/util");
13
14
  let lodash_cloneDeep = require("lodash/cloneDeep");
14
15
  lodash_cloneDeep = require_rolldown_runtime.__toESM(lodash_cloneDeep);
15
16
  let lodash_get = require("lodash/get");
@@ -122,6 +123,7 @@ runner.use(_ocap_tx_pipeline.pipes.VerifyInfo([{
122
123
  return (context.formattedItx?.ops || []).every((op) => (0, _ocap_util.scopeMatchAny)(op.typeUrl, allowed));
123
124
  }
124
125
  }]));
126
+ require_stateless_prefix.markStatelessPrefix(runner);
125
127
  runner.use(_ocap_tx_pipeline.pipes.ExtractState({
126
128
  from: "tx.from",
127
129
  to: "senderState",
@@ -3,13 +3,14 @@ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
3
3
  const require_util = require('../../util.cjs');
4
4
  const require_pipes_ensure_cost = require('../../pipes/ensure-cost.cjs');
5
5
  const require_pipes_ensure_gas = require('../../pipes/ensure-gas.cjs');
6
- let _arcblock_did = require("@arcblock/did");
6
+ const require_stateless_prefix = require('../../stateless-prefix.cjs');
7
7
  let _ocap_mcrypto = require("@ocap/mcrypto");
8
- let _ocap_state = require("@ocap/state");
9
8
  let _ocap_tx_pipeline = require("@ocap/tx-pipeline");
10
- let _ocap_util = require("@ocap/util");
11
9
  let _ocap_util_lib_error = require("@ocap/util/lib/error");
12
10
  let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
11
+ let _arcblock_did = require("@arcblock/did");
12
+ let _ocap_state = require("@ocap/state");
13
+ let _ocap_util = require("@ocap/util");
13
14
  let _ocap_util_lib_get_related_addr = require("@ocap/util/lib/get-related-addr");
14
15
  let debug = require("debug");
15
16
  debug = require_rolldown_runtime.__toESM(debug);
@@ -71,6 +72,7 @@ runner.use(_ocap_tx_pipeline.pipes.VerifyInfo([{
71
72
  return (0, _arcblock_did.isSameEntity)((0, _arcblock_did.fromPublicKey)(typeof context.itx.pk === "string" ? `0x${pkHex}` : context.itx.pk, (0, _arcblock_did.toTypeInfo)(context.itx.address)), context.itx.address) && !(0, _arcblock_did.isSameEntity)(context.itx.address, context.tx.from);
72
73
  }
73
74
  }]));
75
+ require_stateless_prefix.markStatelessPrefix(runner);
74
76
  runner.use(_ocap_tx_pipeline.pipes.ExtractState({
75
77
  from: "tx.from",
76
78
  to: "senderState",
@@ -2,12 +2,13 @@ Object.defineProperty(exports, '__esModule', { value: true });
2
2
  const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
3
3
  const require_pipes_ensure_cost = require('../../pipes/ensure-cost.cjs');
4
4
  const require_pipes_ensure_gas = require('../../pipes/ensure-gas.cjs');
5
- let _arcblock_did_util = require("@arcblock/did-util");
6
- let _ocap_state = require("@ocap/state");
5
+ const require_stateless_prefix = require('../../stateless-prefix.cjs');
7
6
  let _ocap_tx_pipeline = require("@ocap/tx-pipeline");
8
- let _ocap_util = require("@ocap/util");
9
7
  let _ocap_util_lib_error = require("@ocap/util/lib/error");
10
8
  let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
9
+ let _arcblock_did_util = require("@arcblock/did-util");
10
+ let _ocap_state = require("@ocap/state");
11
+ let _ocap_util = require("@ocap/util");
11
12
  let _ocap_util_lib_get_related_addr = require("@ocap/util/lib/get-related-addr");
12
13
  let lodash_cloneDeep = require("lodash/cloneDeep");
13
14
  lodash_cloneDeep = require_rolldown_runtime.__toESM(lodash_cloneDeep);
@@ -40,6 +41,7 @@ runner.use((context, next) => {
40
41
  if (error) return next(new _ocap_util_lib_error.CustomError("INVALID_TX", `Invalid itx: ${error.message}`));
41
42
  return next();
42
43
  });
44
+ require_stateless_prefix.markStatelessPrefix(runner);
43
45
  runner.use(_ocap_tx_pipeline.pipes.ExtractState({
44
46
  from: "itx.to",
45
47
  to: "receiverState",