@ocap/tx-protocols 1.30.26 → 1.31.1

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 (122) hide show
  1. package/esm/execute.d.mts +11 -2
  2. package/esm/execute.mjs +724 -80
  3. package/esm/gas-security-guard.d.mts +375 -0
  4. package/esm/gas-security-guard.mjs +1103 -0
  5. package/esm/index.d.mts +36 -6
  6. package/esm/index.mjs +4 -2
  7. package/esm/pipes/ensure-cost.mjs +335 -59
  8. package/esm/protocols/account/delegate.mjs +64 -16
  9. package/esm/protocols/account/migrate.d.mts +3 -0
  10. package/esm/protocols/account/migrate.mjs +235 -35
  11. package/esm/protocols/account/revoke-delegate.d.mts +3 -3
  12. package/esm/protocols/account/revoke-delegate.mjs +70 -38
  13. package/esm/protocols/asset/acquire-v2.mjs +29 -12
  14. package/esm/protocols/asset/acquire-v3.mjs +78 -22
  15. package/esm/protocols/asset/calls/transfer-token.mjs +2 -1
  16. package/esm/protocols/asset/calls/transfer.mjs +1 -0
  17. package/esm/protocols/asset/consume.mjs +12 -4
  18. package/esm/protocols/asset/create.mjs +18 -5
  19. package/esm/protocols/asset/mint.mjs +23 -1
  20. package/esm/protocols/asset/pipes/exec-mint-hook.d.mts +21 -1
  21. package/esm/protocols/asset/pipes/exec-mint-hook.mjs +115 -1
  22. package/esm/protocols/asset/pipes/extract-factory-tokens.mjs +14 -8
  23. package/esm/protocols/asset/pipes/verify-itx-address.mjs +9 -0
  24. package/esm/protocols/asset/pipes/verify-itx-assets.mjs +21 -5
  25. package/esm/protocols/asset/update.d.mts +13 -2
  26. package/esm/protocols/asset/update.mjs +133 -14
  27. package/esm/protocols/factory/create.mjs +14 -6
  28. package/esm/protocols/governance/claim-stake.mjs +115 -11
  29. package/esm/protocols/governance/return-stake.mjs +44 -12
  30. package/esm/protocols/governance/revoke-ledger.d.mts +34 -0
  31. package/esm/protocols/governance/revoke-ledger.mjs +179 -0
  32. package/esm/protocols/governance/revoke-stake.mjs +25 -5
  33. package/esm/protocols/governance/slash-stake.mjs +72 -25
  34. package/esm/protocols/governance/stake.mjs +63 -13
  35. package/esm/protocols/rollup/claim-reward.mjs +39 -20
  36. package/esm/protocols/rollup/close.mjs +1 -1
  37. package/esm/protocols/rollup/create-block.mjs +8 -7
  38. package/esm/protocols/rollup/create.mjs +17 -6
  39. package/esm/protocols/rollup/join.mjs +3 -3
  40. package/esm/protocols/rollup/leave.mjs +1 -1
  41. package/esm/protocols/rollup/migrate.mjs +7 -4
  42. package/esm/protocols/rollup/pipes/verify-evidence.mjs +12 -4
  43. package/esm/protocols/rollup/update.mjs +6 -1
  44. package/esm/protocols/token/create.mjs +23 -12
  45. package/esm/protocols/token/deposit-v2.d.mts +5 -1
  46. package/esm/protocols/token/deposit-v2.mjs +81 -29
  47. package/esm/protocols/token/withdraw-v2.mjs +33 -16
  48. package/esm/protocols/token-factory/burn.mjs +43 -10
  49. package/esm/protocols/token-factory/create.mjs +23 -14
  50. package/esm/protocols/token-factory/mint.mjs +54 -21
  51. package/esm/protocols/token-factory/pipes/verify-icon.mjs +1 -1
  52. package/esm/protocols/token-factory/update.mjs +16 -6
  53. package/esm/protocols/trade/exchange-v2.d.mts +4 -0
  54. package/esm/protocols/trade/exchange-v2.mjs +78 -22
  55. package/esm/protocols/trade/transfer-v2.mjs +44 -13
  56. package/esm/protocols/trade/transfer-v3.mjs +72 -31
  57. package/esm/util.d.mts +3 -1
  58. package/esm/util.mjs +26 -17
  59. package/lib/execute.cjs +724 -76
  60. package/lib/execute.d.cts +11 -2
  61. package/lib/gas-security-guard.cjs +1142 -0
  62. package/lib/gas-security-guard.d.cts +375 -0
  63. package/lib/index.cjs +124 -1
  64. package/lib/index.d.cts +37 -7
  65. package/lib/pipes/ensure-cost.cjs +334 -58
  66. package/lib/protocols/account/delegate.cjs +64 -16
  67. package/lib/protocols/account/migrate.cjs +235 -35
  68. package/lib/protocols/account/migrate.d.cts +3 -0
  69. package/lib/protocols/account/revoke-delegate.cjs +71 -39
  70. package/lib/protocols/account/revoke-delegate.d.cts +3 -3
  71. package/lib/protocols/asset/acquire-v2.cjs +28 -11
  72. package/lib/protocols/asset/acquire-v3.cjs +77 -20
  73. package/lib/protocols/asset/calls/transfer-token.cjs +3 -2
  74. package/lib/protocols/asset/calls/transfer.cjs +1 -0
  75. package/lib/protocols/asset/consume.cjs +11 -3
  76. package/lib/protocols/asset/create.cjs +19 -6
  77. package/lib/protocols/asset/mint.cjs +23 -1
  78. package/lib/protocols/asset/pipes/exec-mint-hook.cjs +117 -1
  79. package/lib/protocols/asset/pipes/exec-mint-hook.d.cts +21 -1
  80. package/lib/protocols/asset/pipes/extract-factory-tokens.cjs +14 -9
  81. package/lib/protocols/asset/pipes/verify-itx-address.cjs +9 -0
  82. package/lib/protocols/asset/pipes/verify-itx-assets.cjs +21 -5
  83. package/lib/protocols/asset/update.cjs +131 -12
  84. package/lib/protocols/asset/update.d.cts +13 -2
  85. package/lib/protocols/factory/create.cjs +14 -6
  86. package/lib/protocols/governance/claim-stake.cjs +115 -10
  87. package/lib/protocols/governance/claim-stake.d.cts +1 -1
  88. package/lib/protocols/governance/return-stake.cjs +44 -11
  89. package/lib/protocols/governance/return-stake.d.cts +1 -1
  90. package/lib/protocols/governance/revoke-ledger.cjs +184 -0
  91. package/lib/protocols/governance/revoke-ledger.d.cts +34 -0
  92. package/lib/protocols/governance/revoke-stake.cjs +25 -5
  93. package/lib/protocols/governance/revoke-stake.d.cts +1 -1
  94. package/lib/protocols/governance/slash-stake.cjs +72 -24
  95. package/lib/protocols/governance/slash-stake.d.cts +1 -1
  96. package/lib/protocols/governance/stake.cjs +65 -14
  97. package/lib/protocols/rollup/claim-reward.cjs +39 -20
  98. package/lib/protocols/rollup/close.cjs +1 -1
  99. package/lib/protocols/rollup/create-block.cjs +9 -8
  100. package/lib/protocols/rollup/create-block.d.cts +1 -1
  101. package/lib/protocols/rollup/create.cjs +18 -7
  102. package/lib/protocols/rollup/join.cjs +3 -3
  103. package/lib/protocols/rollup/leave.cjs +1 -1
  104. package/lib/protocols/rollup/migrate.cjs +7 -4
  105. package/lib/protocols/rollup/pipes/verify-evidence.cjs +11 -3
  106. package/lib/protocols/rollup/update.cjs +6 -1
  107. package/lib/protocols/token/create.cjs +24 -13
  108. package/lib/protocols/token/deposit-v2.cjs +80 -28
  109. package/lib/protocols/token/deposit-v2.d.cts +5 -1
  110. package/lib/protocols/token/withdraw-v2.cjs +32 -15
  111. package/lib/protocols/token-factory/burn.cjs +42 -9
  112. package/lib/protocols/token-factory/create.cjs +24 -15
  113. package/lib/protocols/token-factory/mint.cjs +53 -20
  114. package/lib/protocols/token-factory/pipes/verify-icon.cjs +1 -1
  115. package/lib/protocols/token-factory/update.cjs +16 -6
  116. package/lib/protocols/trade/exchange-v2.cjs +76 -20
  117. package/lib/protocols/trade/exchange-v2.d.cts +4 -0
  118. package/lib/protocols/trade/transfer-v2.cjs +45 -14
  119. package/lib/protocols/trade/transfer-v3.cjs +72 -30
  120. package/lib/util.cjs +26 -17
  121. package/lib/util.d.cts +4 -2
  122. package/package.json +16 -16
@@ -0,0 +1,1142 @@
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
+ let _ocap_mcrypto = require("@ocap/mcrypto");
5
+ let _ocap_state = require("@ocap/state");
6
+ let _ocap_tx_pipeline = require("@ocap/tx-pipeline");
7
+ let _ocap_util = require("@ocap/util");
8
+ let _ocap_util_lib_error = require("@ocap/util/lib/error");
9
+ let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
10
+ let lodash_cloneDeep = require("lodash/cloneDeep");
11
+ lodash_cloneDeep = require_rolldown_runtime.__toESM(lodash_cloneDeep);
12
+ let node_crypto = require("node:crypto");
13
+ let _ocap_wallet = require("@ocap/wallet");
14
+
15
+ //#region src/gas-security-guard.ts
16
+ const ZERO = new _ocap_util.BN(0);
17
+ const BPS_DENOMINATOR = new _ocap_util.BN(1e4);
18
+ const DEFAULT_MAX_FREE_GAS_TX_SIZE = 4096;
19
+ const DEFAULT_MAX_FREE_GAS_STATE_OPS = 6;
20
+ const DEFAULT_BURST_WINDOW_MS = 6e4;
21
+ const DEFAULT_BASE_BURST_ALLOWANCE = 10;
22
+ const DEFAULT_BURST_REJECT_MULTIPLE = 100;
23
+ const DEFAULT_DELEGATED_BURST_MULTIPLE = 20;
24
+ const DEFAULT_STRIKE_WINDOW_MS = 6e5;
25
+ const DEFAULT_WARNING_STRIKE_THRESHOLD = 2;
26
+ const DEFAULT_THROTTLE_STRIKE_THRESHOLD = 5;
27
+ const DEFAULT_SLASH_STRIKE_THRESHOLD = 10;
28
+ const DEFAULT_THROTTLE_COOLDOWN_MS = 15e3;
29
+ const DEFAULT_GAS_PASS_EPOCH_SECONDS = 60;
30
+ const DEFAULT_FISHERMAN_BOUNTY_BPS = 1e3;
31
+ const MAX_TRACKED_ACTORS = 1e4;
32
+ const MAX_NULLIFIERS_PER_STAKE = 5e3;
33
+ const MAX_FREE_VARIANTS = 2;
34
+ /**
35
+ * High-overhead creator, factory, token-issuance, rollup, and batch transaction types
36
+ * that ALWAYS require direct gas payment (`requiresDirectGas: true`) and cannot waive
37
+ * gas via self-staked `Stake-for-Gas` or Unlinkable Gas Pass.
38
+ */
39
+ const DIRECT_GAS_REQUIRED_TX_TYPES = new Set([
40
+ "create_token",
41
+ "create_token_factory",
42
+ "update_token_factory",
43
+ "create_factory",
44
+ "create_asset",
45
+ "mint_asset",
46
+ "update_asset",
47
+ "create_rollup",
48
+ "update_rollup",
49
+ "create_rollup_block",
50
+ "join_rollup",
51
+ "leave_rollup",
52
+ "pause_rollup",
53
+ "resume_rollup",
54
+ "close_rollup",
55
+ "migrate_rollup",
56
+ "claim_block_reward",
57
+ "slash_stake",
58
+ "return_stake",
59
+ "execute_transaction_block"
60
+ ]);
61
+ /**
62
+ * Everyday end-user transaction types eligible for `Stake-for-Gas` free gas waiver
63
+ * when within the 3D envelope (`txType` allowlist + `txSize <= 4096` + `stateOps <= 6`).
64
+ */
65
+ const FREE_GAS_ELIGIBLE_TX_TYPES = new Set([
66
+ "transfer",
67
+ "transfer_v2",
68
+ "transfer_v3",
69
+ "exchange",
70
+ "exchange_v2",
71
+ "declare",
72
+ "account_migrate",
73
+ "delegate",
74
+ "revoke_delegate",
75
+ "stake",
76
+ "revoke_stake",
77
+ "claim_stake",
78
+ "consume_asset",
79
+ "acquire_asset_v2",
80
+ "acquire_asset_v3",
81
+ "mint_token",
82
+ "burn_token",
83
+ "deposit_token_v2",
84
+ "withdraw_token_v2",
85
+ "poke"
86
+ ]);
87
+ const registryByStateDb = /* @__PURE__ */ new WeakMap();
88
+ let defaultGlobalRegistry = createEmptyRegistry();
89
+ function createEmptyRegistry() {
90
+ return {
91
+ actors: /* @__PURE__ */ new Map(),
92
+ consumedNullifiers: /* @__PURE__ */ new Map(),
93
+ txWarningsByHash: /* @__PURE__ */ new Map()
94
+ };
95
+ }
96
+ function getUnderlyingTarget(statedb) {
97
+ if (!statedb || typeof statedb !== "object") return null;
98
+ const raw = statedb._underlyingStateDb || statedb;
99
+ const accountTable = raw.account;
100
+ if (accountTable && typeof accountTable === "object") return accountTable;
101
+ return raw;
102
+ }
103
+ function getGasSecurityRegistry(statedb) {
104
+ const target = getUnderlyingTarget(statedb);
105
+ if (!target) return defaultGlobalRegistry;
106
+ let reg = registryByStateDb.get(target);
107
+ if (!reg) {
108
+ reg = createEmptyRegistry();
109
+ registryByStateDb.set(target, reg);
110
+ }
111
+ return reg;
112
+ }
113
+ function resetGasSecurityState(statedb) {
114
+ const target = getUnderlyingTarget(statedb);
115
+ if (target) registryByStateDb.set(target, createEmptyRegistry());
116
+ defaultGlobalRegistry = createEmptyRegistry();
117
+ }
118
+ function normalizeActorAddress(raw) {
119
+ if (typeof raw !== "string") return "";
120
+ const trimmed = raw.trim();
121
+ if (!trimmed) return "";
122
+ const stripped = trimmed.startsWith("did:abt:") ? (0, _ocap_util.toAddress)(trimmed) : trimmed;
123
+ if (/^0x[0-9a-fA-F]{40}$/.test(stripped)) return _ocap_state.account.ensureChecksumAddress(stripped.toLowerCase());
124
+ return _ocap_state.account.ensureChecksumAddress(stripped);
125
+ }
126
+ function normalizeShortTxType(txType) {
127
+ if (typeof txType !== "string" || !txType.trim()) return "";
128
+ const parts = txType.trim().split(":");
129
+ return parts[parts.length - 1] || "";
130
+ }
131
+ function resolveGasSecurityConfig(config) {
132
+ const txGas = config?.transaction?.txGas || {};
133
+ const sec = (config?.transaction)?.security || {};
134
+ const numOr = (val, fallback) => typeof val === "number" && Number.isFinite(val) && val > 0 ? val : fallback;
135
+ const boolOr = (val, fallback) => typeof val === "boolean" ? val : fallback;
136
+ return {
137
+ enabled: boolOr(sec.enabled, true),
138
+ throttle: boolOr(sec.throttle, true),
139
+ burstEscalation: boolOr(sec.burstEscalation, true),
140
+ autoSlash: boolOr(sec.autoSlash, false),
141
+ gasPassNullifierCheck: boolOr(sec.gasPassNullifierCheck, false),
142
+ burstRejectMultiple: numOr(sec.burstRejectMultiple, DEFAULT_BURST_REJECT_MULTIPLE),
143
+ exemptActors: Array.isArray(sec.exemptActors) ? sec.exemptActors.map((a) => normalizeActorAddress(a)).filter(Boolean) : [],
144
+ delegatedBurstMultiple: numOr(sec.delegatedBurstMultiple, DEFAULT_DELEGATED_BURST_MULTIPLE),
145
+ maxFreeGasTxSize: numOr(txGas.maxFreeGasTxSize, DEFAULT_MAX_FREE_GAS_TX_SIZE),
146
+ maxFreeGasStateOps: numOr(txGas.maxFreeGasStateOps, DEFAULT_MAX_FREE_GAS_STATE_OPS),
147
+ burstWindowMs: numOr(txGas.burstWindowMs, DEFAULT_BURST_WINDOW_MS),
148
+ baseBurstAllowance: numOr(txGas.baseBurstAllowance, DEFAULT_BASE_BURST_ALLOWANCE),
149
+ strikeWindowMs: numOr(sec.strikeWindowMs, DEFAULT_STRIKE_WINDOW_MS),
150
+ warningThreshold: numOr(sec.warningThreshold, DEFAULT_WARNING_STRIKE_THRESHOLD),
151
+ throttleThreshold: numOr(sec.throttleThreshold, DEFAULT_THROTTLE_STRIKE_THRESHOLD),
152
+ slashThreshold: numOr(sec.slashThreshold, DEFAULT_SLASH_STRIKE_THRESHOLD),
153
+ throttleCooldownMs: numOr(sec.throttleCooldownMs, DEFAULT_THROTTLE_COOLDOWN_MS),
154
+ gasPassEpochSeconds: numOr(sec.gasPassEpochSeconds, DEFAULT_GAS_PASS_EPOCH_SECONDS),
155
+ fishermanBountyBps: typeof sec.fishermanBountyBps === "number" && Number.isFinite(sec.fishermanBountyBps) && sec.fishermanBountyBps >= 0 && sec.fishermanBountyBps <= 5e3 ? Math.floor(sec.fishermanBountyBps) : DEFAULT_FISHERMAN_BOUNTY_BPS
156
+ };
157
+ }
158
+ /** Actor keys are addresses, or `signer>principal` pairs for delegated-tx burst windows. */
159
+ function normalizeActorKey(raw) {
160
+ return raw.includes(">") ? raw.split(">").map((part) => part === "*" ? part : normalizeActorAddress(part)).join(">") : normalizeActorAddress(raw);
161
+ }
162
+ function getOrCreateActorRecord(reg, rawActor, nowMs, cfg) {
163
+ const actor = normalizeActorKey(rawActor);
164
+ let rec = reg.actors.get(actor);
165
+ if (rec) {
166
+ reg.actors.delete(actor);
167
+ reg.actors.set(actor, rec);
168
+ } else {
169
+ if (reg.actors.size >= MAX_TRACKED_ACTORS) {
170
+ let victim;
171
+ for (const [key, candidate] of reg.actors) if (candidate.cooldownUntilMs <= nowMs) {
172
+ victim = key;
173
+ break;
174
+ }
175
+ victim = victim ?? reg.actors.keys().next().value;
176
+ if (victim) reg.actors.delete(victim);
177
+ }
178
+ rec = {
179
+ actor,
180
+ bursts: [],
181
+ strikes: [],
182
+ cooldownUntilMs: 0
183
+ };
184
+ reg.actors.set(actor, rec);
185
+ }
186
+ const burstCutoff = nowMs - cfg.burstWindowMs;
187
+ rec.bursts = rec.bursts.filter((b) => b.t > burstCutoff);
188
+ const strikeCutoff = nowMs - cfg.strikeWindowMs;
189
+ rec.strikes = rec.strikes.filter((s) => s.timestampMs > strikeCutoff);
190
+ return rec;
191
+ }
192
+ /**
193
+ * 3D `Stake-for-Gas` Eligibility Gate:
194
+ * 1. `txType` must be in `FREE_GAS_ELIGIBLE_TX_TYPES` (everyday user actions only).
195
+ * 2. `txSize` must be <= `maxFreeGasTxSize` (default 4096 bytes).
196
+ * 3. `stateOps` (`estimate.create + estimate.update`) must be <= `maxFreeGasStateOps` (default 6).
197
+ * 4. Failed transactions (`isFailedTxGasCharge === true`) NEVER waive gas.
198
+ */
199
+ function evaluateStakeForGasEligibility(params) {
200
+ const cfg = resolveGasSecurityConfig(params.config);
201
+ if (params.isFailedTxGasCharge) return {
202
+ eligible: false,
203
+ reason: "FAILED_TX_REQUIRES_DIRECT_GAS"
204
+ };
205
+ const shortType = normalizeShortTxType(params.txType);
206
+ const customAllowlist = (params.config?.transaction?.txGas)?.freeGasAllowedTxTypes;
207
+ if ((!params.isThirdPartySponsor || params.enforceSponsor3DEligibility === true) && shortType) {
208
+ if (Array.isArray(customAllowlist) && customAllowlist.length > 0) {
209
+ if (!customAllowlist.some((t) => normalizeShortTxType(t) === shortType || t === params.txType)) return {
210
+ eligible: false,
211
+ reason: "TX_TYPE_REQUIRES_DIRECT_GAS"
212
+ };
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 {
214
+ eligible: false,
215
+ reason: "TX_TYPE_REQUIRES_DIRECT_GAS"
216
+ };
217
+ }
218
+ if ((typeof params.txSize === "number" ? params.txSize : 0) > cfg.maxFreeGasTxSize) return {
219
+ eligible: false,
220
+ reason: "TX_SIZE_EXCEEDS_FREE_GAS_CEILING"
221
+ };
222
+ if ((params.gasEstimate?.create || 0) + (params.gasEstimate?.update || 0) > cfg.maxFreeGasStateOps) return {
223
+ eligible: false,
224
+ reason: "STATE_OPS_EXCEED_FREE_GAS_CEILING"
225
+ };
226
+ return { eligible: true };
227
+ }
228
+ const CREATION_TARGET_TX_TYPES = new Set([
229
+ "create_asset",
230
+ "acquire_asset",
231
+ "acquire_asset_v2",
232
+ "acquire_asset_v3",
233
+ "create_factory",
234
+ "create_token",
235
+ "create_token_factory"
236
+ ]);
237
+ /**
238
+ * Extracts all target DIDs referenced by a transaction (`itx.to`, `itx.factory`, `itx.tokenFactory`,
239
+ * `itx.address`, `itx.assets`, `itx.inputs`, `itx.outputs`, `itx.sender`, `itx.receiver`) for
240
+ * Paymaster `allowedTargets` scoping.
241
+ */
242
+ function extractTransactionTargets(tx, decodedItx, txType) {
243
+ if ((!tx || typeof tx !== "object") && (!decodedItx || typeof decodedItx !== "object")) return [];
244
+ const targets = /* @__PURE__ */ new Set();
245
+ const addTarget = (candidate) => {
246
+ const norm = normalizeActorAddress(candidate);
247
+ if (norm) targets.add(norm);
248
+ };
249
+ const shortType = normalizeShortTxType(txType || (tx?.itx)?.typeUrl);
250
+ const rawItx = decodedItx || tx?.itxJson || tx?.itx;
251
+ const itx = rawItx && typeof rawItx === "object" && !Buffer.isBuffer(rawItx) && typeof rawItx.value !== "string" ? rawItx : decodedItx;
252
+ if (itx && typeof itx === "object") {
253
+ const scalarFields = [
254
+ "to",
255
+ "factory",
256
+ "receiver",
257
+ "rollup",
258
+ "tokenAddress",
259
+ "factoryAddress",
260
+ "tokenFactory",
261
+ "owner",
262
+ "parent",
263
+ "issuer",
264
+ "validator",
265
+ "contract",
266
+ "delegatee"
267
+ ];
268
+ if (!CREATION_TARGET_TX_TYPES.has(shortType)) scalarFields.push("address");
269
+ for (const field of scalarFields) if (typeof itx[field] === "string" && itx[field]) addTarget(itx[field]);
270
+ const extractPartySubTargets = (party) => {
271
+ if (!party || typeof party !== "object") return;
272
+ const p = party;
273
+ addTarget(p.address);
274
+ addTarget(p.owner);
275
+ addTarget(p.to);
276
+ const pAssets = (0, _ocap_util_lib_get_list_field.getListField)(p, "assets");
277
+ if (Array.isArray(pAssets)) for (const a of pAssets) addTarget(a);
278
+ const pTokens = (0, _ocap_util_lib_get_list_field.getListField)(p, "tokens");
279
+ if (Array.isArray(pTokens)) {
280
+ for (const tok of pTokens) if (tok && typeof tok === "object") addTarget(tok.address);
281
+ }
282
+ };
283
+ if (itx.sender && typeof itx.sender === "object") extractPartySubTargets(itx.sender);
284
+ if (itx.receiver && typeof itx.receiver === "object") extractPartySubTargets(itx.receiver);
285
+ const assets = (0, _ocap_util_lib_get_list_field.getListField)(itx, "assets");
286
+ if (Array.isArray(assets)) for (const a of assets) addTarget(a);
287
+ const inputs = (0, _ocap_util_lib_get_list_field.getListField)(itx, "inputs");
288
+ if (Array.isArray(inputs)) for (const inp of inputs) extractPartySubTargets(inp);
289
+ const outputs = (0, _ocap_util_lib_get_list_field.getListField)(itx, "outputs");
290
+ if (Array.isArray(outputs)) for (const out of outputs) extractPartySubTargets(out);
291
+ }
292
+ return Array.from(targets);
293
+ }
294
+ /**
295
+ * Verifies Merchant / DApp Paymaster (`extra.gasStakeHeaders` JWT) scope constraints:
296
+ * - `allowedTxTypes`: if present, transaction type must be in `allowedTxTypes`.
297
+ * - `allowedTargets`: if present, transaction must touch at least one target and EVERY target
298
+ * touched by the transaction (excluding the sender `tx.from` itself in multi-input change)
299
+ * must be in `allowedTargets`.
300
+ * - `maxGasPerTx`: if present, `totalGas` must not exceed `maxGasPerTx`.
301
+ */
302
+ function verifyPaymasterConstraints(params) {
303
+ const { decoded, tx, itx, txType, totalGas } = params;
304
+ const isPaymasterDirectCharge = decoded.mode === "paymaster" || decoded.chargeSponsorBalance === true;
305
+ if (Array.isArray(decoded.allowedTxTypes)) {
306
+ if (decoded.allowedTxTypes.length === 0) return {
307
+ valid: false,
308
+ reason: "PAYMASTER_TX_TYPE_FORBIDDEN",
309
+ isPaymasterDirectCharge
310
+ };
311
+ const shortType = normalizeShortTxType(txType);
312
+ if (!decoded.allowedTxTypes.some((allowed) => allowed === txType || normalizeShortTxType(allowed) === shortType)) return {
313
+ valid: false,
314
+ reason: "PAYMASTER_TX_TYPE_FORBIDDEN",
315
+ isPaymasterDirectCharge
316
+ };
317
+ }
318
+ if (Array.isArray(decoded.allowedTargets)) {
319
+ const normalizedAllowed = decoded.allowedTargets.map((t) => normalizeActorAddress(t)).filter(Boolean);
320
+ if (normalizedAllowed.length === 0) return {
321
+ valid: false,
322
+ reason: "PAYMASTER_TARGET_FORBIDDEN",
323
+ isPaymasterDirectCharge
324
+ };
325
+ const txFrom = normalizeActorAddress(tx?.from);
326
+ const allTargets = extractTransactionTargets(tx, itx, txType).filter((t) => t !== txFrom);
327
+ if (allTargets.length === 0) return {
328
+ valid: false,
329
+ reason: "PAYMASTER_TARGET_FORBIDDEN",
330
+ isPaymasterDirectCharge
331
+ };
332
+ if (!allTargets.every((target) => normalizedAllowed.some((allowed) => (0, _ocap_util.isSameDid)(target, allowed) || target === allowed))) return {
333
+ valid: false,
334
+ reason: "PAYMASTER_TARGET_FORBIDDEN",
335
+ isPaymasterDirectCharge
336
+ };
337
+ }
338
+ if (decoded.maxGasPerTx !== void 0 && decoded.maxGasPerTx !== null && decoded.maxGasPerTx !== "") {
339
+ const capStr = String(decoded.maxGasPerTx).trim();
340
+ if (!/^(0|[1-9]\d*)$/.test(capStr)) return {
341
+ valid: false,
342
+ reason: "PAYMASTER_MAX_GAS_EXCEEDED",
343
+ isPaymasterDirectCharge
344
+ };
345
+ const capBN = new _ocap_util.BN(capStr, 10);
346
+ if ((totalGas ?? ZERO).gt(capBN)) return {
347
+ valid: false,
348
+ reason: "PAYMASTER_MAX_GAS_EXCEEDED",
349
+ isPaymasterDirectCharge
350
+ };
351
+ }
352
+ return {
353
+ valid: true,
354
+ isPaymasterDirectCharge
355
+ };
356
+ }
357
+ /**
358
+ * Computes the SHA-256 hash of a stake owner's secret for Unlinkable Gas Pass verification:
359
+ * `SHA256("ocap:gas-pass-secret:v1:" + passSecret)`
360
+ */
361
+ function computeUnlinkableGasPassSecretHash(passSecret) {
362
+ return (0, node_crypto.createHash)("sha256").update(`ocap:gas-pass-secret:v1:${passSecret}`).digest("hex").toLowerCase();
363
+ }
364
+ /**
365
+ * Computes the deterministic commitment for a Consumer Self-Use Unlinkable Gas Pass:
366
+ * `SHA256("ocap:gas-pass:v1:" + normalizeActorAddress(stakeId) + ":" + epoch + ":" + nullifier + ":" + txHash)`
367
+ */
368
+ function computeUnlinkableGasPassCommitment(params) {
369
+ const normStakeId = normalizeActorAddress(params.stakeId);
370
+ return (0, node_crypto.createHash)("sha256").update(`ocap:gas-pass:v1:${normStakeId}:${params.epoch}:${params.nullifier}:${params.txHash}`).digest("hex");
371
+ }
372
+ /**
373
+ * Verifies and consumes a Consumer Self-Use Unlinkable Gas Pass (`extra.gasPass`),
374
+ * allowing a user who staked ABT on their main DID to pay/waive gas from a fresh
375
+ * unlinked sub-DID without revealing their main DID on-chain in `tx.from`, while
376
+ * strictly enforcing cryptographic authorization (`passSecret` matching `stakeState.gasPassSecretHash`
377
+ * or `pk`+`signature` signed by `stakeState.sender`), `nullifier` single-use per epoch, and
378
+ * stake-proportional quota.
379
+ */
380
+ function verifyAndConsumeUnlinkableGasPass(params) {
381
+ const { gasPass, stakeState, txHash, config, statedb } = params;
382
+ if (!gasPass || typeof gasPass !== "object") return {
383
+ valid: false,
384
+ reason: "INVALID_GAS_PASS"
385
+ };
386
+ const stakeId = normalizeActorAddress(gasPass.stakeId);
387
+ const nullifier = typeof gasPass.nullifier === "string" ? gasPass.nullifier.trim() : "";
388
+ const commitment = typeof gasPass.commitment === "string" ? gasPass.commitment.trim().toLowerCase() : "";
389
+ const epoch = typeof gasPass.epoch === "number" && Number.isInteger(gasPass.epoch) ? gasPass.epoch : -1;
390
+ if (!stakeId || !nullifier || nullifier.length < 16 || nullifier.length > 256 || !commitment || epoch < 0) return {
391
+ valid: false,
392
+ reason: "INVALID_GAS_PASS_FORMAT"
393
+ };
394
+ if (!stakeState || normalizeActorAddress(stakeState.address) !== stakeId) return {
395
+ valid: false,
396
+ reason: "GAS_PASS_STAKE_NOT_FOUND"
397
+ };
398
+ const stakeSender = normalizeActorAddress(stakeState.sender);
399
+ const stakeReceiver = normalizeActorAddress(stakeState.receiver);
400
+ if (!stakeSender || stakeSender !== stakeReceiver || (0, _arcblock_did_util.toStakeAddress)(stakeSender, stakeSender) !== stakeId) return {
401
+ valid: false,
402
+ reason: "GAS_PASS_NOT_SELF_STAKE"
403
+ };
404
+ const minStakeUnit = (0, _ocap_util.fromTokenToUnit)(config.transaction.txGas.minStake, config.token.decimal);
405
+ if (new _ocap_util.BN(stakeState.tokens?.[config.token.address] || 0).lt(minStakeUnit)) return {
406
+ valid: false,
407
+ reason: "GAS_PASS_INSUFFICIENT_STAKE"
408
+ };
409
+ const cfg = resolveGasSecurityConfig(config);
410
+ const nowSec = Math.floor((params.nowMs ?? Date.now()) / 1e3);
411
+ const currentEpoch = Math.floor(nowSec / cfg.gasPassEpochSeconds);
412
+ if (Math.abs(epoch - currentEpoch) > 1) return {
413
+ valid: false,
414
+ reason: "GAS_PASS_EPOCH_EXPIRED"
415
+ };
416
+ const expectedCommitment = computeUnlinkableGasPassCommitment({
417
+ stakeId,
418
+ epoch,
419
+ nullifier,
420
+ txHash
421
+ }).toLowerCase();
422
+ if (commitment !== expectedCommitment) return {
423
+ valid: false,
424
+ reason: "GAS_PASS_COMMITMENT_MISMATCH"
425
+ };
426
+ const stakeRecord = stakeState;
427
+ const stakeData = stakeRecord.data;
428
+ const rawSecretHash = stakeRecord.gasPassSecretHash || stakeData?.gasPassSecretHash;
429
+ let isAuthorized = false;
430
+ if (typeof gasPass.passSecret === "string" && gasPass.passSecret.length > 0 && typeof rawSecretHash === "string" && rawSecretHash.length > 0) {
431
+ if (computeUnlinkableGasPassSecretHash(gasPass.passSecret) === rawSecretHash.trim().toLowerCase()) isAuthorized = true;
432
+ }
433
+ if (!isAuthorized && typeof gasPass.pk === "string" && gasPass.pk && typeof gasPass.signature === "string" && gasPass.signature) try {
434
+ const didType = (0, _arcblock_did.toTypeInfo)(stakeSender);
435
+ if (normalizeActorAddress((0, _ocap_wallet.fromPublicKey)(gasPass.pk, didType).address) === stakeSender || (0, _arcblock_did.isFromPublicKey)(stakeSender, gasPass.pk)) {
436
+ const signer = (0, _ocap_mcrypto.getSigner)(didType.pk);
437
+ const hashedMsg = (0, _ocap_mcrypto.getHasher)(didType.hash)(expectedCommitment, 1);
438
+ if (signer.verify(hashedMsg, gasPass.signature, gasPass.pk) || signer.verify(expectedCommitment, gasPass.signature, gasPass.pk)) isAuthorized = true;
439
+ }
440
+ } catch {
441
+ isAuthorized = false;
442
+ }
443
+ if (!isAuthorized) return {
444
+ valid: false,
445
+ reason: "GAS_PASS_UNAUTHORIZED"
446
+ };
447
+ if (!cfg.gasPassNullifierCheck) return {
448
+ valid: true,
449
+ stakeId
450
+ };
451
+ const reg = getGasSecurityRegistry(statedb);
452
+ let nullifierMap = reg.consumedNullifiers.get(stakeId);
453
+ if (!nullifierMap) {
454
+ nullifierMap = /* @__PURE__ */ new Map();
455
+ reg.consumedNullifiers.set(stakeId, nullifierMap);
456
+ }
457
+ for (const [k, entry] of nullifierMap.entries()) if (entry.epoch < currentEpoch - 2) nullifierMap.delete(k);
458
+ const existingNullifier = nullifierMap.get(nullifier);
459
+ if (existingNullifier) {
460
+ if (existingNullifier.txHash && txHash && existingNullifier.txHash === txHash) return {
461
+ valid: true,
462
+ stakeId
463
+ };
464
+ return {
465
+ valid: false,
466
+ reason: "GAS_PASS_NULLIFIER_ALREADY_SPENT"
467
+ };
468
+ }
469
+ if (params.consumeNullifier !== false) {
470
+ if (nullifierMap.size >= MAX_NULLIFIERS_PER_STAKE) {
471
+ const oldest = nullifierMap.keys().next().value;
472
+ if (oldest) nullifierMap.delete(oldest);
473
+ }
474
+ nullifierMap.set(nullifier, {
475
+ epoch,
476
+ txHash
477
+ });
478
+ }
479
+ return {
480
+ valid: true,
481
+ stakeId
482
+ };
483
+ }
484
+ function computeStakeMultiple(config, stakeState) {
485
+ const minStakeUnit = (0, _ocap_util.fromTokenToUnit)(config.transaction.txGas.minStake || 1, config.token.decimal);
486
+ const maxStakeUnit = (0, _ocap_util.fromTokenToUnit)(config.transaction.txGas.maxStake || 1e4, config.token.decimal);
487
+ const stakedUnit = new _ocap_util.BN(stakeState?.tokens?.[config.token.address] || 0);
488
+ if (minStakeUnit.gt(ZERO) && stakedUnit.gte(minStakeUnit)) {
489
+ const cappedStake = stakedUnit.gt(maxStakeUnit) && maxStakeUnit.gt(ZERO) ? maxStakeUnit : stakedUnit;
490
+ return Math.max(1, Math.min(1e4, cappedStake.div(minStakeUnit).toNumber()));
491
+ }
492
+ return 1;
493
+ }
494
+ /**
495
+ * Stake-scaled per-sender burst quota (`rho = n_burst / B_normal(S)`) with machine-readable telemetry.
496
+ *
497
+ * RELIABILITY CONTRACT: the counter is process-local, so it is used for ADMISSION only (reject before the
498
+ * single-writer queue). It never reprices gas, never changes a waiver and never touches receipts; the executed
499
+ * outcome of a tx is a pure function of (tx, on-chain state). A request is rejected only above
500
+ * `baseBurstAllowance * stakeMultiple * burstRejectMultiple` (`hardLimitExceeded`); between 1x and the hard limit
501
+ * it is admitted and only advisory telemetry is returned (`quotaExceeded`).
502
+ */
503
+ function evaluateBurstQuota(params) {
504
+ const { config, statedb } = params;
505
+ const baseGas = params.baseGas ?? ZERO;
506
+ const cfg = resolveGasSecurityConfig(config);
507
+ const nowMs = params.nowMs ?? Date.now();
508
+ const rec = getOrCreateActorRecord(getGasSecurityRegistry(statedb), normalizeActorKey(params.actor || "anonymous"), nowMs, cfg);
509
+ const normHash = params.txHash ? params.txHash.trim().toUpperCase() : void 0;
510
+ const variantHash = params.variantHash ? params.variantHash.trim().toUpperCase() : void 0;
511
+ const existing = normHash ? rec.bursts.find((b) => b.h === normHash) : void 0;
512
+ let alreadyCounted = false;
513
+ if (existing) {
514
+ if (!variantHash || (existing.variants || []).includes(variantHash)) alreadyCounted = true;
515
+ else if ((existing.variants || []).length < MAX_FREE_VARIANTS) {
516
+ alreadyCounted = true;
517
+ if (params.recordBurst !== false) existing.variants = [...existing.variants || [], variantHash];
518
+ }
519
+ }
520
+ const burstCount = Math.max(1, rec.bursts.length + (alreadyCounted ? 0 : 1));
521
+ const stakeMultiple = computeStakeMultiple(config, params.stakeState);
522
+ const minStakeUnit = (0, _ocap_util.fromTokenToUnit)(config.transaction.txGas.minStake || 1, config.token.decimal);
523
+ const normalAllowance = cfg.baseBurstAllowance * stakeMultiple;
524
+ const hardLimit = Math.ceil(normalAllowance * (params.rejectMultiple ?? cfg.burstRejectMultiple));
525
+ const rawRho = burstCount / normalAllowance;
526
+ const loadRatio = Number(rawRho.toFixed(4));
527
+ const quotaExceeded = rawRho > 1;
528
+ const hardLimitExceeded = burstCount > hardLimit;
529
+ if (params.recordBurst !== false && !alreadyCounted && !hardLimitExceeded) rec.bursts.push({
530
+ t: nowMs,
531
+ h: existing && variantHash ? `${normHash}#${variantHash}` : normHash,
532
+ variants: variantHash ? [variantHash] : void 0
533
+ });
534
+ const recommendedBackoffMs = rawRho <= 1 ? 0 : Math.min(cfg.burstWindowMs, Math.ceil((rawRho - 1) * (cfg.burstWindowMs / 2)));
535
+ const requiredMultiplesFor1x = Math.max(1, Math.ceil(burstCount / cfg.baseBurstAllowance));
536
+ return {
537
+ burstCount,
538
+ normalAllowance,
539
+ hardLimit,
540
+ loadRatio,
541
+ quotaExceeded,
542
+ hardLimitExceeded,
543
+ telemetry: {
544
+ loadRatio,
545
+ remainingNormalQuota: Math.max(0, normalAllowance - burstCount),
546
+ currentGasMultiplier: 1,
547
+ nextTxEstimatedGas: baseGas.toString(10),
548
+ recommendedBackoffMs,
549
+ stakeRequiredFor1x: minStakeUnit.mul(new _ocap_util.BN(requiredMultiplesFor1x)).toString(10)
550
+ }
551
+ };
552
+ }
553
+ function getStrikeWeight(category) {
554
+ switch (category) {
555
+ case "INVARIANT_VIOLATION": return 3;
556
+ case "WAF_REJECT":
557
+ case "PAYMASTER_VIOLATION": return 2;
558
+ case "BENIGN_REJECT":
559
+ case "QUOTA_EXCEEDED": return 0;
560
+ default: return 1;
561
+ }
562
+ }
563
+ const BENIGN_REJECT_CODES = new Set([
564
+ "INVALID_NONCE",
565
+ "DUPLICATE_TX",
566
+ "ACCOUNT_MIGRATED",
567
+ "INVALID_TX_TIME",
568
+ "EXPIRED",
569
+ "TX_EXPIRED",
570
+ "NOT_FOUND",
571
+ "STAKE_NOT_FOUND",
572
+ "INVALID_LOCK_STATUS",
573
+ "ACCOUNT_NOT_FOUND"
574
+ ]);
575
+ function classifyErrorStrikeCategory(err) {
576
+ const code = err?.code || "INTERNAL";
577
+ const msg = err?.message || "";
578
+ if (code.startsWith("WAF_") || /Pre-Flight WAF/i.test(msg)) return {
579
+ shouldRecordStrike: true,
580
+ category: "WAF_REJECT",
581
+ code
582
+ };
583
+ if (code.endsWith("_VIOLATION") || code === "STATE_DELETION_FORBIDDEN" || code === "RW_SET_CEILING_EXCEEDED" || /Post-Execution Invariant Gate/i.test(msg)) return {
584
+ shouldRecordStrike: true,
585
+ category: "INVARIANT_VIOLATION",
586
+ code
587
+ };
588
+ if (code.startsWith("PAYMASTER_") || code.startsWith("GAS_PASS_")) return {
589
+ shouldRecordStrike: true,
590
+ category: "PAYMASTER_VIOLATION",
591
+ code
592
+ };
593
+ if (code === "TOO_MANY_TXS" || code === "ABUSE_SLASH_TRIGGERED") return {
594
+ shouldRecordStrike: false,
595
+ category: "QUOTA_EXCEEDED",
596
+ code
597
+ };
598
+ if (code.startsWith("INSUFFICIENT_") || BENIGN_REJECT_CODES.has(code)) return {
599
+ shouldRecordStrike: false,
600
+ category: "BENIGN_REJECT",
601
+ code
602
+ };
603
+ return {
604
+ shouldRecordStrike: true,
605
+ category: "PROTOCOL_REJECT",
606
+ code
607
+ };
608
+ }
609
+ function computeActorTier(strikeCount, cfg) {
610
+ if (strikeCount >= cfg.slashThreshold) return "SLASH_TRIGGERED";
611
+ if (strikeCount >= cfg.throttleThreshold) return "THROTTLED";
612
+ if (strikeCount >= cfg.warningThreshold) return "WARNING";
613
+ return "NORMAL";
614
+ }
615
+ function getActorSecurityStatus(params) {
616
+ const cfg = resolveGasSecurityConfig(params.config);
617
+ const nowMs = params.nowMs ?? Date.now();
618
+ const reg = getGasSecurityRegistry(params.statedb);
619
+ const actor = normalizeActorAddress(params.actor);
620
+ if (!actor) return {
621
+ strikeCount: 0,
622
+ tier: "NORMAL",
623
+ cooldownUntilMs: 0
624
+ };
625
+ const rec = getOrCreateActorRecord(reg, actor, nowMs, cfg);
626
+ const strikeCount = rec.strikes.reduce((acc, s) => acc + s.weight, 0);
627
+ const tier = computeActorTier(strikeCount, cfg);
628
+ const defaultTelemetry = params.telemetry || {
629
+ loadRatio: 0,
630
+ remainingNormalQuota: cfg.baseBurstAllowance,
631
+ currentGasMultiplier: 1,
632
+ nextTxEstimatedGas: "0",
633
+ recommendedBackoffMs: 0,
634
+ stakeRequiredFor1x: "0"
635
+ };
636
+ let warning;
637
+ if (tier !== "NORMAL" || defaultTelemetry.loadRatio >= .8) {
638
+ warning = {
639
+ tier,
640
+ code: tier === "SLASH_TRIGGERED" ? "ABUSE_SLASH_TRIGGERED" : tier === "THROTTLED" ? "ACTOR_THROTTLED" : tier === "WARNING" ? "SECURITY_STRIKE_WARNING" : "GAS_QUOTA_ADVISORY",
641
+ message: tier === "SLASH_TRIGGERED" ? `Actor ${actor} reached slash threshold (${strikeCount}/${cfg.slashThreshold}); new submissions are rejected during the cooldown${cfg.autoSlash ? " and Stake-for-Gas is subject to automatic slashing" : ""}.` : tier === "THROTTLED" ? `Actor ${actor} is throttled (${strikeCount}/${cfg.throttleThreshold} strikes); new submissions are rejected during the cooldown.` : tier === "WARNING" ? `Actor ${actor} accumulated ${strikeCount} security strikes (throttle at ${cfg.throttleThreshold}, slash at ${cfg.slashThreshold}).` : `Actor ${actor} burst gas load ratio is ${defaultTelemetry.loadRatio} (remaining normal quota: ${defaultTelemetry.remainingNormalQuota}).`,
642
+ actor,
643
+ strikeCount,
644
+ warningThreshold: cfg.warningThreshold,
645
+ throttleThreshold: cfg.throttleThreshold,
646
+ slashThreshold: cfg.slashThreshold,
647
+ gasStakeQuotaRemaining: defaultTelemetry.remainingNormalQuota,
648
+ cooldownUntilMs: rec.cooldownUntilMs,
649
+ telemetry: defaultTelemetry
650
+ };
651
+ rec.lastWarning = warning;
652
+ }
653
+ return {
654
+ strikeCount,
655
+ tier,
656
+ cooldownUntilMs: rec.cooldownUntilMs,
657
+ lastSlashEvidence: rec.lastSlashEvidence,
658
+ warning
659
+ };
660
+ }
661
+ /**
662
+ * Resolves the list of cryptographically verified actor addresses that may be penalized
663
+ * with a security strike for a failed or rejected transaction:
664
+ * - Never attributes strikes to `tx.from` or `tx.delegator` unless `VerifySignature` has
665
+ * cryptographically verified the transaction signature (`CRITICAL-2` protection).
666
+ * - When `tx.delegator` is present, attributes strikes ONLY to `tx.delegator` (the verified signer / delegatee),
667
+ * never to the principal `tx.from`, whether or not the delegation verified.
668
+ * - Never attributes sender-induced strikes to a third-party `gasStake.owner` (`CRITICAL-3`).
669
+ */
670
+ async function resolveVerifiedStrikeActors(ctx) {
671
+ if (!ctx || typeof ctx !== "object") return [];
672
+ const tx = ctx.tx;
673
+ if (!tx || typeof tx !== "object") return [];
674
+ const signer = tx.delegator || tx.from;
675
+ if (!signer || !tx.pk || !tx.signature) return [];
676
+ let sigVerified = ctx.isSignatureVerified === true || ctx._preFlightVerified === true;
677
+ if (!sigVerified) try {
678
+ if (!(0, _arcblock_did.isFromPublicKey)(signer, tx.pk)) return [];
679
+ await new Promise((resolve, reject) => {
680
+ const verifyFn = _ocap_tx_pipeline.pipes.VerifySignature;
681
+ Promise.resolve(verifyFn(ctx, (err) => err ? reject(err) : resolve())).catch(reject);
682
+ });
683
+ ctx.isSignatureVerified = true;
684
+ sigVerified = true;
685
+ } catch {
686
+ return [];
687
+ }
688
+ if (!sigVerified) return [];
689
+ const normSigner = normalizeActorAddress(signer);
690
+ if (!normSigner) return [];
691
+ return [normSigner];
692
+ }
693
+ /**
694
+ * Records a weighted security strike against one or more verified actor addresses,
695
+ * updates their tier (`NORMAL` -> `WARNING` -> `THROTTLED` -> `SLASH_TRIGGERED`), and if `SLASH_TRIGGERED` is reached,
696
+ * executes automatic `Stake-for-Gas` slashing into `config.vaults.slashedStake` (with optional Fisherman bounty split
697
+ * and 0% token burn per Axiom #3).
698
+ */
699
+ async function recordActorSecurityStrike(params) {
700
+ const cfg = resolveGasSecurityConfig(params.config);
701
+ if (!cfg.enabled) return {};
702
+ const nowMs = params.nowMs ?? Date.now();
703
+ const reg = getGasSecurityRegistry(params.statedb);
704
+ const weight = getStrikeWeight(params.category);
705
+ if (weight <= 0) return {};
706
+ const normTxHash = params.txHash ? params.txHash.trim().toUpperCase() : void 0;
707
+ const uniqueActors = Array.from(new Set(params.actors.map((a) => normalizeActorAddress(a)).filter(Boolean))).filter((a) => !cfg.exemptActors.includes(a));
708
+ let primaryWarning;
709
+ let slashEvidence;
710
+ for (const actor of uniqueActors) {
711
+ const rec = getOrCreateActorRecord(reg, actor, nowMs, cfg);
712
+ const prevStrikes = rec.strikes.map((s) => ({ ...s }));
713
+ const prevCooldown = rec.cooldownUntilMs;
714
+ const prevSlashEvidence = rec.lastSlashEvidence;
715
+ const prevWarning = rec.lastWarning;
716
+ if (!(normTxHash ? rec.strikes.some((s) => s.txHash === normTxHash) : false)) rec.strikes.push({
717
+ timestampMs: nowMs,
718
+ weight,
719
+ code: params.reasonCode,
720
+ txHash: normTxHash
721
+ });
722
+ const strikeCount = rec.strikes.reduce((acc, s) => acc + s.weight, 0);
723
+ const tier = computeActorTier(strikeCount, cfg);
724
+ if (tier === "THROTTLED" || tier === "SLASH_TRIGGERED") rec.cooldownUntilMs = Math.max(rec.cooldownUntilMs, nowMs + cfg.throttleCooldownMs);
725
+ const status = getActorSecurityStatus({
726
+ actor,
727
+ config: params.config,
728
+ statedb: params.statedb,
729
+ nowMs,
730
+ telemetry: params.telemetry
731
+ });
732
+ if (status.warning && !primaryWarning) primaryWarning = status.warning;
733
+ if (tier === "SLASH_TRIGGERED" && cfg.autoSlash && params.txn) try {
734
+ const evidence = await executeAutoGasStakeSlash({
735
+ offender: actor,
736
+ strikeCount,
737
+ strikes: rec.strikes,
738
+ config: params.config,
739
+ statedb: params.statedb,
740
+ txn: params.txn,
741
+ fishermanAddress: params.fishermanAddress,
742
+ nowMs
743
+ });
744
+ if (evidence) {
745
+ slashEvidence = evidence;
746
+ rec.lastSlashEvidence = evidence;
747
+ rec.strikes = [];
748
+ }
749
+ } catch (slashErr) {
750
+ rec.strikes = prevStrikes;
751
+ rec.cooldownUntilMs = prevCooldown;
752
+ rec.lastSlashEvidence = prevSlashEvidence;
753
+ rec.lastWarning = prevWarning;
754
+ throw slashErr;
755
+ }
756
+ }
757
+ if (params.txHash && primaryWarning) setTxSecurityWarningForHash(params.txHash, primaryWarning, params.statedb);
758
+ return {
759
+ primaryWarning,
760
+ slashEvidence
761
+ };
762
+ }
763
+ function snapshotActorSecurityRecords(actors, statedb, txHash) {
764
+ const reg = getGasSecurityRegistry(statedb);
765
+ const map = /* @__PURE__ */ new Map();
766
+ for (const raw of actors) {
767
+ const actor = normalizeActorAddress(raw);
768
+ if (!actor) continue;
769
+ const existing = reg.actors.get(actor);
770
+ map.set(actor, existing ? (0, lodash_cloneDeep.default)(existing) : null);
771
+ }
772
+ const normHash = txHash ? txHash.trim().toUpperCase() : void 0;
773
+ return {
774
+ actors: map,
775
+ txWarningExisted: normHash ? reg.txWarningsByHash.has(normHash) : false,
776
+ prevTxWarning: normHash ? reg.txWarningsByHash.get(normHash) : void 0,
777
+ txHash: normHash
778
+ };
779
+ }
780
+ function restoreActorSecurityRecords(snapshot, statedb) {
781
+ const reg = getGasSecurityRegistry(statedb);
782
+ for (const [actor, record] of snapshot.actors.entries()) if (record) reg.actors.set(actor, (0, lodash_cloneDeep.default)(record));
783
+ else reg.actors.delete(actor);
784
+ if (snapshot.txHash) if (snapshot.txWarningExisted && snapshot.prevTxWarning) reg.txWarningsByHash.set(snapshot.txHash, snapshot.prevTxWarning);
785
+ else reg.txWarningsByHash.delete(snapshot.txHash);
786
+ }
787
+ /**
788
+ * Executes automatic `Stake-for-Gas` slashing when an actor crosses `slashThreshold` (opt-in via
789
+ * `transaction.security.autoSlash`; ONLY inside the enclosing queued tx's own write set, `params.txn` is required):
790
+ * - Transfers 100% of the offender's staked official tokens out of `toStakeAddress(offender, offender)`:
791
+ * - `fishermanBountyBps` (default 10%) to `fishermanAddress` (if provided and distinct from `offender`).
792
+ * - Remaining 90% (or 100% if no fisherman) to `config.vaults.slashedStake` (or `config.vaults.txGas[0]` / `config.vaults.txFee`).
793
+ * - ZERO official tokens are ever burned (Axiom #3).
794
+ * - Creates and persists a deterministic `IAbuseSlashEvidence` record in `statedb.evidence`.
795
+ */
796
+ async function executeAutoGasStakeSlash(params) {
797
+ if (!params.txn) return null;
798
+ const offender = normalizeActorAddress(params.offender);
799
+ const stakeAddress = (0, _arcblock_did_util.toStakeAddress)(offender, offender);
800
+ const cfg = resolveGasSecurityConfig(params.config);
801
+ const nowIso = new Date(params.nowMs ?? Date.now()).toISOString();
802
+ const officialToken = params.config?.token?.address || "";
803
+ const vaults = params.config?.vaults || {};
804
+ const txGasVaults = Array.isArray(vaults.txGas) ? vaults.txGas : [];
805
+ const configuredVault = normalizeActorAddress(vaults.slashedStake || txGasVaults[0] || vaults.txFee || "");
806
+ const fallbackVaultSink = (0, _arcblock_did_util.toStakeAddress)(officialToken || stakeAddress, "slashed-stake-vault");
807
+ const vaultDestination = configuredVault && configuredVault !== offender ? configuredVault : fallbackVaultSink;
808
+ const fisherman = normalizeActorAddress(params.fishermanAddress);
809
+ const validFisherman = fisherman && fisherman !== offender && fisherman !== vaultDestination ? fisherman : void 0;
810
+ const reasonCodes = Array.from(new Set(params.strikes.map((s) => s.code)));
811
+ const recentTxHashes = Array.from(new Set(params.strikes.map((s) => s.txHash).filter(Boolean))).slice(-10);
812
+ let fishermanBountyBN = ZERO;
813
+ let vaultAmountBN = ZERO;
814
+ const slashedTokens = {};
815
+ const rawDb = params.statedb?._underlyingStateDb || params.statedb;
816
+ const stakeTable = rawDb?.stake;
817
+ const accountTable = rawDb?.account;
818
+ const evidenceTable = rawDb?.evidence;
819
+ const stateCtx = {
820
+ txHash: recentTxHashes.find((h) => /^[0-9a-fA-F]{64}$/.test(h)) || "",
821
+ txTime: nowIso,
822
+ txn: params.txn
823
+ };
824
+ if (stakeTable && typeof stakeTable.get === "function" && typeof stakeTable.update === "function" && officialToken) {
825
+ const performSlashMutations = async (activeCtx) => {
826
+ const stakeState = await stakeTable.get(stakeAddress, activeCtx);
827
+ const currentStaked = new _ocap_util.BN(stakeState?.tokens?.[officialToken] || 0);
828
+ if (!stakeState || currentStaked.lte(ZERO)) return;
829
+ const originalStakeSnapshot = (0, lodash_cloneDeep.default)(stakeState);
830
+ const existingVaultSnapshot = accountTable && typeof accountTable.get === "function" ? (0, lodash_cloneDeep.default)(await accountTable.get(vaultDestination, activeCtx)) : null;
831
+ slashedTokens[officialToken] = currentStaked.toString(10);
832
+ if (validFisherman && cfg.fishermanBountyBps > 0) fishermanBountyBN = currentStaked.mul(new _ocap_util.BN(cfg.fishermanBountyBps)).div(BPS_DENOMINATOR);
833
+ vaultAmountBN = currentStaked.sub(fishermanBountyBN);
834
+ const updatedStakeTokens = {
835
+ ...stakeState.tokens || {},
836
+ [officialToken]: "0"
837
+ };
838
+ const defaultGenesisCtx = {
839
+ genesisTime: nowIso,
840
+ genesisTx: "",
841
+ renaissanceTime: nowIso,
842
+ renaissanceTx: ""
843
+ };
844
+ let updatedStake;
845
+ try {
846
+ updatedStake = _ocap_state.stake.update({
847
+ context: defaultGenesisCtx,
848
+ ...(0, lodash_cloneDeep.default)(stakeState)
849
+ }, {
850
+ tokens: updatedStakeTokens,
851
+ message: "auto-slashed:abuse-strike-threshold"
852
+ }, activeCtx);
853
+ } catch {
854
+ updatedStake = {
855
+ ...(0, lodash_cloneDeep.default)(stakeState),
856
+ tokens: updatedStakeTokens,
857
+ message: "auto-slashed:abuse-strike-threshold"
858
+ };
859
+ }
860
+ let stakeDebited = false;
861
+ let vaultCredited = false;
862
+ try {
863
+ await stakeTable.update(stakeAddress, updatedStake, activeCtx);
864
+ stakeDebited = true;
865
+ const creditAccount = async (targetAddr, deltaBN) => {
866
+ if (!targetAddr || deltaBN.lte(ZERO) || !accountTable || typeof accountTable.get !== "function") return;
867
+ const existing = await accountTable.get(targetAddr, activeCtx);
868
+ const prevBal = new _ocap_util.BN(existing?.tokens?.[officialToken] || 0);
869
+ const nextTokens = {
870
+ ...existing?.tokens || {},
871
+ [officialToken]: prevBal.add(deltaBN).toString(10)
872
+ };
873
+ if (existing && typeof accountTable.update === "function") {
874
+ let nextAcc;
875
+ try {
876
+ nextAcc = _ocap_state.account.update({
877
+ context: defaultGenesisCtx,
878
+ ...(0, lodash_cloneDeep.default)(existing)
879
+ }, { tokens: nextTokens }, activeCtx);
880
+ } catch {
881
+ nextAcc = {
882
+ ...(0, lodash_cloneDeep.default)(existing),
883
+ tokens: nextTokens
884
+ };
885
+ }
886
+ await accountTable.update(targetAddr, nextAcc, activeCtx);
887
+ } else if (typeof accountTable.updateOrCreate === "function") {
888
+ const nextAcc = _ocap_state.account.updateOrCreate(existing ?? null, {
889
+ address: targetAddr,
890
+ tokens: nextTokens
891
+ }, activeCtx);
892
+ await accountTable.updateOrCreate(existing ?? null, nextAcc, activeCtx);
893
+ } else if (typeof accountTable.create === "function") {
894
+ const nextAcc = _ocap_state.account.create({
895
+ address: targetAddr,
896
+ tokens: nextTokens
897
+ }, activeCtx);
898
+ await accountTable.create(targetAddr, nextAcc, activeCtx);
899
+ }
900
+ };
901
+ await creditAccount(vaultDestination, vaultAmountBN);
902
+ vaultCredited = true;
903
+ if (validFisherman && fishermanBountyBN.gt(ZERO)) await creditAccount(validFisherman, fishermanBountyBN);
904
+ } catch (slashWriteErr) {
905
+ delete slashedTokens[officialToken];
906
+ vaultAmountBN = ZERO;
907
+ fishermanBountyBN = ZERO;
908
+ if (stakeDebited) try {
909
+ await stakeTable.update(stakeAddress, originalStakeSnapshot, activeCtx);
910
+ } catch {}
911
+ if (vaultCredited && existingVaultSnapshot && accountTable && typeof accountTable.update === "function") try {
912
+ await accountTable.update(vaultDestination, existingVaultSnapshot, activeCtx);
913
+ } catch {}
914
+ throw slashWriteErr;
915
+ }
916
+ };
917
+ await performSlashMutations(stateCtx);
918
+ }
919
+ if (Object.keys(slashedTokens).length === 0) return null;
920
+ const evidencePayload = {
921
+ type: "AbuseSlashEvidence",
922
+ offender,
923
+ stakeAddress,
924
+ strikeCount: params.strikeCount,
925
+ reasonCodes,
926
+ recentTxHashes,
927
+ slashedTokens,
928
+ fishermanAddress: validFisherman,
929
+ fishermanBounty: fishermanBountyBN.toString(10),
930
+ vaultDestination,
931
+ vaultAmount: vaultAmountBN.toString(10),
932
+ timestamp: nowIso
933
+ };
934
+ const evidenceHash = (0, node_crypto.createHash)("sha256").update(`ocap:abuse-slash:v1:${JSON.stringify(evidencePayload)}`).digest("hex").toUpperCase();
935
+ const evidenceRecord = {
936
+ evidenceHash,
937
+ ...evidencePayload
938
+ };
939
+ if (evidenceTable && typeof evidenceTable.create === "function") try {
940
+ if (!(typeof evidenceTable.get === "function" ? await evidenceTable.get(evidenceHash, stateCtx) : null)) {
941
+ const evState = _ocap_state.evidence.create({
942
+ hash: evidenceHash,
943
+ data: JSON.stringify(evidenceRecord)
944
+ }, {
945
+ txHash: evidenceHash,
946
+ txTime: nowIso
947
+ });
948
+ await evidenceTable.create(evidenceHash, evState, stateCtx);
949
+ }
950
+ } catch {}
951
+ return evidenceRecord;
952
+ }
953
+ /**
954
+ * Pre-queue ADMISSION control. This is the only consumer of the process-local strike / burst counters:
955
+ * it decides whether a request is accepted into the single-writer queue at all. It never changes the gas,
956
+ * waiver or receipts of a tx that is admitted, so executed outcomes stay a pure function of (tx, chain state)
957
+ * and cannot diverge between the two OS processes on main or across restarts.
958
+ *
959
+ * - `throttle`: the verified signer (`tx.delegator || tx.from`, i.e. the delegatee for delegated txs) is rejected
960
+ * with `TOO_MANY_TXS` while its strike-driven cooldown is active. Cooldowns always expire; actors without any
961
+ * strikes (and actors without stake) are never locked.
962
+ * - `burstEscalation`: the per-sender sliding-window quota rejects with `TOO_MANY_TXS` only above
963
+ * `baseBurstAllowance * stakeMultiple * burstRejectMultiple`. Keyed by the sender, never by the gas sponsor, so a
964
+ * sponsoring app is not capped across all of its users.
965
+ */
966
+ async function assertTxAdmission(params) {
967
+ const cfg = resolveGasSecurityConfig(params.config);
968
+ if (!cfg.enabled) return {};
969
+ const nowMs = params.nowMs ?? Date.now();
970
+ const signer = normalizeActorAddress(params.tx?.delegator || params.tx?.from || "");
971
+ const principal = normalizeActorAddress(params.tx?.from || signer);
972
+ if (!signer || cfg.exemptActors.includes(signer)) return {};
973
+ const dbTx = params.statedb?.tx;
974
+ if (params.txHash && typeof dbTx?.get === "function") {
975
+ let committed = null;
976
+ try {
977
+ committed = await dbTx.get(params.txHash);
978
+ } catch {
979
+ committed = null;
980
+ }
981
+ if (committed) {
982
+ const dup = new _ocap_util_lib_error.CustomError("DUPLICATE_TX", "Can not execute duplicate transaction");
983
+ dup._strikeRecorded = true;
984
+ throw dup;
985
+ }
986
+ }
987
+ const dbAccount = params.statedb?.account;
988
+ if (!params.tx?.delegator && params.tx?.from && typeof dbAccount?.get === "function") try {
989
+ const senderState = await dbAccount.get(params.tx.from);
990
+ const incoming = (0, _ocap_state.parseNonceBn)(params.tx.nonce);
991
+ if (senderState && incoming && incoming.lte((0, _ocap_state.parseNonceBn)(senderState.nonce) ?? new _ocap_util.BN(0))) {
992
+ const stale = new _ocap_util_lib_error.CustomError("INVALID_NONCE", "nonce must be greater in newer transactions");
993
+ stale._strikeRecorded = true;
994
+ throw stale;
995
+ }
996
+ } catch (e) {
997
+ if (e?.code === "INVALID_NONCE") throw e;
998
+ }
999
+ const countedHash = params.unsignedTxHash || params.txHash;
1000
+ const burstKey = principal && principal !== signer ? `${signer}>${principal}` : signer;
1001
+ if (cfg.throttle) {
1002
+ const status = getActorSecurityStatus({
1003
+ actor: signer,
1004
+ config: params.config,
1005
+ statedb: params.statedb,
1006
+ nowMs
1007
+ });
1008
+ if (status.tier !== "NORMAL" && status.tier !== "WARNING" && status.cooldownUntilMs > nowMs) {
1009
+ const err = new _ocap_util_lib_error.CustomError("TOO_MANY_TXS", status.warning?.message || `Actor ${signer} is throttled; retry after ${status.cooldownUntilMs - nowMs}ms cooldown`);
1010
+ err.warning = status.warning;
1011
+ throw err;
1012
+ }
1013
+ }
1014
+ let telemetry;
1015
+ if (cfg.burstEscalation && params.config?.transaction?.txGas && params.config?.token) {
1016
+ const config = params.config;
1017
+ let stakeState = null;
1018
+ try {
1019
+ const stakeId = (0, _arcblock_did_util.toStakeAddress)(signer, signer);
1020
+ stakeState = await params.statedb?.stake?.get?.(stakeId) || null;
1021
+ } catch {
1022
+ stakeState = null;
1023
+ }
1024
+ if (burstKey !== signer) {
1025
+ const agg = evaluateBurstQuota({
1026
+ actor: `${signer}>*`,
1027
+ stakeState,
1028
+ config,
1029
+ statedb: params.statedb,
1030
+ nowMs,
1031
+ txHash: countedHash,
1032
+ variantHash: params.txHash,
1033
+ recordBurst: false,
1034
+ rejectMultiple: cfg.burstRejectMultiple * cfg.delegatedBurstMultiple
1035
+ });
1036
+ if (agg.hardLimitExceeded) throw new _ocap_util_lib_error.CustomError("TOO_MANY_TXS", `Delegatee ${signer} exceeded the aggregate delegated burst limit (${agg.burstCount} > ${agg.hardLimit} per ${cfg.burstWindowMs}ms)`);
1037
+ }
1038
+ const evalRes = evaluateBurstQuota({
1039
+ actor: burstKey,
1040
+ stakeState,
1041
+ config,
1042
+ statedb: params.statedb,
1043
+ nowMs,
1044
+ txHash: countedHash,
1045
+ variantHash: params.txHash,
1046
+ recordBurst: false
1047
+ });
1048
+ telemetry = evalRes.telemetry;
1049
+ if (evalRes.hardLimitExceeded) {
1050
+ const status = getActorSecurityStatus({
1051
+ actor: signer,
1052
+ config: params.config,
1053
+ statedb: params.statedb,
1054
+ nowMs,
1055
+ telemetry
1056
+ });
1057
+ const err = new _ocap_util_lib_error.CustomError("TOO_MANY_TXS", `Actor ${signer} exceeded the burst limit (${evalRes.burstCount} > ${evalRes.hardLimit} per ${cfg.burstWindowMs}ms); retry after ${telemetry.recommendedBackoffMs}ms or stake more for a larger quota`);
1058
+ err.warning = status.warning || {
1059
+ tier: "NORMAL",
1060
+ code: "GAS_QUOTA_ADVISORY",
1061
+ message: `Actor ${signer} burst gas load ratio is ${telemetry.loadRatio}`,
1062
+ actor: signer,
1063
+ strikeCount: 0,
1064
+ warningThreshold: cfg.warningThreshold,
1065
+ throttleThreshold: cfg.throttleThreshold,
1066
+ slashThreshold: cfg.slashThreshold,
1067
+ gasStakeQuotaRemaining: 0,
1068
+ cooldownUntilMs: 0,
1069
+ telemetry
1070
+ };
1071
+ throw err;
1072
+ }
1073
+ const record = (actor, rejectMultiple) => evaluateBurstQuota({
1074
+ actor,
1075
+ stakeState,
1076
+ config,
1077
+ statedb: params.statedb,
1078
+ nowMs,
1079
+ txHash: countedHash,
1080
+ variantHash: params.txHash,
1081
+ rejectMultiple
1082
+ });
1083
+ if (burstKey !== signer) record(`${signer}>*`, cfg.burstRejectMultiple * cfg.delegatedBurstMultiple);
1084
+ record(burstKey);
1085
+ }
1086
+ return { telemetry };
1087
+ }
1088
+ function getTxSecurityWarningByHash(txHash, statedb) {
1089
+ if (!txHash || typeof txHash !== "string") return void 0;
1090
+ return getGasSecurityRegistry(statedb).txWarningsByHash.get(txHash.trim().toUpperCase());
1091
+ }
1092
+ function setTxSecurityWarningForHash(txHash, warning, statedb) {
1093
+ if (!txHash || typeof txHash !== "string" || !warning) return;
1094
+ const normKey = txHash.trim().toUpperCase();
1095
+ if (!normKey) return;
1096
+ const reg = getGasSecurityRegistry(statedb);
1097
+ if (!reg.txWarningsByHash.has(normKey) && reg.txWarningsByHash.size >= MAX_TRACKED_ACTORS) {
1098
+ const oldest = reg.txWarningsByHash.keys().next().value;
1099
+ if (oldest) reg.txWarningsByHash.delete(oldest);
1100
+ }
1101
+ reg.txWarningsByHash.set(normKey, warning);
1102
+ }
1103
+
1104
+ //#endregion
1105
+ exports.DEFAULT_BASE_BURST_ALLOWANCE = DEFAULT_BASE_BURST_ALLOWANCE;
1106
+ exports.DEFAULT_BURST_REJECT_MULTIPLE = DEFAULT_BURST_REJECT_MULTIPLE;
1107
+ exports.DEFAULT_BURST_WINDOW_MS = DEFAULT_BURST_WINDOW_MS;
1108
+ exports.DEFAULT_DELEGATED_BURST_MULTIPLE = DEFAULT_DELEGATED_BURST_MULTIPLE;
1109
+ exports.DEFAULT_FISHERMAN_BOUNTY_BPS = DEFAULT_FISHERMAN_BOUNTY_BPS;
1110
+ exports.DEFAULT_GAS_PASS_EPOCH_SECONDS = DEFAULT_GAS_PASS_EPOCH_SECONDS;
1111
+ exports.DEFAULT_MAX_FREE_GAS_STATE_OPS = DEFAULT_MAX_FREE_GAS_STATE_OPS;
1112
+ exports.DEFAULT_MAX_FREE_GAS_TX_SIZE = DEFAULT_MAX_FREE_GAS_TX_SIZE;
1113
+ exports.DEFAULT_SLASH_STRIKE_THRESHOLD = DEFAULT_SLASH_STRIKE_THRESHOLD;
1114
+ exports.DEFAULT_STRIKE_WINDOW_MS = DEFAULT_STRIKE_WINDOW_MS;
1115
+ exports.DEFAULT_THROTTLE_COOLDOWN_MS = DEFAULT_THROTTLE_COOLDOWN_MS;
1116
+ exports.DEFAULT_THROTTLE_STRIKE_THRESHOLD = DEFAULT_THROTTLE_STRIKE_THRESHOLD;
1117
+ exports.DEFAULT_WARNING_STRIKE_THRESHOLD = DEFAULT_WARNING_STRIKE_THRESHOLD;
1118
+ exports.DIRECT_GAS_REQUIRED_TX_TYPES = DIRECT_GAS_REQUIRED_TX_TYPES;
1119
+ exports.FREE_GAS_ELIGIBLE_TX_TYPES = FREE_GAS_ELIGIBLE_TX_TYPES;
1120
+ exports.assertTxAdmission = assertTxAdmission;
1121
+ exports.classifyErrorStrikeCategory = classifyErrorStrikeCategory;
1122
+ exports.computeActorTier = computeActorTier;
1123
+ exports.computeUnlinkableGasPassCommitment = computeUnlinkableGasPassCommitment;
1124
+ exports.computeUnlinkableGasPassSecretHash = computeUnlinkableGasPassSecretHash;
1125
+ exports.evaluateBurstQuota = evaluateBurstQuota;
1126
+ exports.evaluateStakeForGasEligibility = evaluateStakeForGasEligibility;
1127
+ exports.executeAutoGasStakeSlash = executeAutoGasStakeSlash;
1128
+ exports.extractTransactionTargets = extractTransactionTargets;
1129
+ exports.getActorSecurityStatus = getActorSecurityStatus;
1130
+ exports.getGasSecurityRegistry = getGasSecurityRegistry;
1131
+ exports.getTxSecurityWarningByHash = getTxSecurityWarningByHash;
1132
+ exports.normalizeActorAddress = normalizeActorAddress;
1133
+ exports.normalizeShortTxType = normalizeShortTxType;
1134
+ exports.recordActorSecurityStrike = recordActorSecurityStrike;
1135
+ exports.resetGasSecurityState = resetGasSecurityState;
1136
+ exports.resolveGasSecurityConfig = resolveGasSecurityConfig;
1137
+ exports.resolveVerifiedStrikeActors = resolveVerifiedStrikeActors;
1138
+ exports.restoreActorSecurityRecords = restoreActorSecurityRecords;
1139
+ exports.setTxSecurityWarningForHash = setTxSecurityWarningForHash;
1140
+ exports.snapshotActorSecurityRecords = snapshotActorSecurityRecords;
1141
+ exports.verifyAndConsumeUnlinkableGasPass = verifyAndConsumeUnlinkableGasPass;
1142
+ exports.verifyPaymasterConstraints = verifyPaymasterConstraints;