@ocap/tx-pipeline 1.31.5 → 1.31.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/bridge-release-keys.d.mts +17 -1
- package/esm/bridge-release-keys.mjs +35 -20
- package/esm/bridge-reserves.d.mts +48 -9
- package/esm/bridge-reserves.mjs +66 -16
- package/esm/helpers/bridge-withdraw.d.mts +22 -38
- package/esm/helpers/bridge-withdraw.mjs +57 -77
- package/esm/helpers/replay-guard.d.mts +29 -12
- package/esm/helpers/replay-guard.mjs +68 -22
- package/esm/index.d.mts +3 -3
- package/esm/index.mjs +3 -3
- package/esm/legacy-protocol-sunset.d.mts +35 -21
- package/esm/legacy-protocol-sunset.mjs +124 -70
- package/esm/legacy-rollup-archive.d.mts +44 -7
- package/esm/legacy-rollup-archive.mjs +78 -13
- package/esm/library.d.mts +3 -3
- package/esm/library.mjs +3 -3
- package/esm/pipes/bridge-release-gate.d.mts +3 -2
- package/esm/pipes/bridge-release-gate.mjs +90 -35
- package/esm/pipes/bridge-reserve-v2-gate.d.mts +2 -0
- package/esm/pipes/bridge-reserve-v2-gate.mjs +31 -13
- package/esm/pipes/decode-tx.mjs +1 -1
- package/esm/pipes/post-execution-invariant-gate.mjs +5 -4
- package/esm/pipes/pre-flight-waf.mjs +6 -3
- package/esm/pipes/verify-multisig-v2.mjs +1 -1
- package/esm/pipes/verify-multisig.mjs +1 -1
- package/esm/pipes/verify-tx-size.mjs +8 -2
- package/esm/pipes/verify-tx.mjs +1 -1
- package/esm/transaction-block.mjs +11 -0
- package/lib/bridge-release-keys.cjs +35 -18
- package/lib/bridge-release-keys.d.cts +17 -1
- package/lib/bridge-reserves.cjs +73 -18
- package/lib/bridge-reserves.d.cts +48 -9
- package/lib/helpers/bridge-withdraw.cjs +60 -80
- package/lib/helpers/bridge-withdraw.d.cts +22 -38
- package/lib/helpers/replay-guard.cjs +64 -17
- package/lib/helpers/replay-guard.d.cts +29 -12
- package/lib/index.cjs +2 -2
- package/lib/index.d.cts +3 -3
- package/lib/legacy-protocol-sunset.cjs +122 -69
- package/lib/legacy-protocol-sunset.d.cts +35 -21
- package/lib/legacy-rollup-archive.cjs +82 -14
- package/lib/legacy-rollup-archive.d.cts +44 -7
- package/lib/library.cjs +1 -2
- package/lib/library.d.cts +3 -3
- package/lib/pipes/bridge-release-gate.cjs +89 -33
- package/lib/pipes/bridge-release-gate.d.cts +3 -2
- package/lib/pipes/bridge-reserve-v2-gate.cjs +30 -12
- package/lib/pipes/bridge-reserve-v2-gate.d.cts +2 -0
- package/lib/pipes/decode-tx.cjs +1 -1
- package/lib/pipes/post-execution-invariant-gate.cjs +3 -2
- package/lib/pipes/pre-flight-waf.cjs +6 -3
- package/lib/pipes/verify-multisig-v2.cjs +1 -1
- package/lib/pipes/verify-multisig.cjs +1 -1
- package/lib/pipes/verify-tx-size.cjs +8 -2
- package/lib/pipes/verify-tx.cjs +1 -1
- package/lib/transaction-block.cjs +11 -0
- package/package.json +10 -10
|
@@ -13,11 +13,13 @@ lodash_isEqual = require_rolldown_runtime.__toESM(lodash_isEqual);
|
|
|
13
13
|
* bridge a reserve belongs to comes from the `reserve -> bridge` index, resolved once per transaction by
|
|
14
14
|
* `prepareBridgeReserveGate` before this synchronous check runs (`bridge-reserves.ts`); the address is never trusted.
|
|
15
15
|
*
|
|
16
|
-
* - R1 debits:
|
|
17
|
-
*
|
|
18
|
-
* `transaction.bridge.enabled` must be on for a
|
|
19
|
-
*
|
|
20
|
-
*
|
|
16
|
+
* - R1 debits: a release of THAT bridge (the reserve of `itx.rollup`, or of its `migratedTo` chain for a REFUND): a
|
|
17
|
+
* `deposit_token_v2` with `kind ∈ {1,2,3}` (`isBridgeRelease`, #1692); a v1 deposit (`kind == 0`) never debits a reserve. Also `migrate_rollup`,
|
|
18
|
+
* and the reconcile hook (a named, empty list today). The master switch `transaction.bridge.enabled` must be on for a
|
|
19
|
+
* release.
|
|
20
|
+
* - R2 credits: the bridge branch of `withdraw_token_v2` (the withdraw, #1691) into the reserve of the live, unpaused,
|
|
21
|
+
* not-closing v2 bridge `itx.rollup` names and no other, with the master switch on, in the bridge token only;
|
|
22
|
+
* `create_rollup` funding the reserve of the bridge it creates;
|
|
21
23
|
* `migrate_rollup` filling the successor's reserve. A role-25 address that maps to no bridge accepts nothing.
|
|
22
24
|
* - R3: a reserve account is only materialised by `create_rollup`, only token balances ever change, nothing writes the
|
|
23
25
|
* `balance` table directly, and no record of another table gains a reference to a reserve.
|
|
@@ -40,13 +42,25 @@ const migratedToOf = (row) => {
|
|
|
40
42
|
* `assertBridgeReservesV2Protected`.
|
|
41
43
|
*/
|
|
42
44
|
const LEGACY_BALANCE_FIELDS = new Set(["balance", "balanceNum"]);
|
|
43
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Account columns whose stored default is zero (statedb/sqlite 001-genesis). Since #1640 the sqlite statedb returns
|
|
47
|
+
* the whole stored row from create / update, so every new account carries them; at zero they are "not set", the same
|
|
48
|
+
* as an account row that does not have them at all (memory statedb). Any other value is state and still counts (#1647).
|
|
49
|
+
*/
|
|
50
|
+
const ZERO_DEFAULT_FIELDS = new Set([
|
|
51
|
+
"gasBalance",
|
|
52
|
+
"numTxs",
|
|
53
|
+
"numAssets"
|
|
54
|
+
]);
|
|
55
|
+
const isZeroDefault = (k, v) => ZERO_DEFAULT_FIELDS.has(k) && (v === 0 || v === "0");
|
|
56
|
+
/** Account fields other than balances; empty values, zero column defaults and the context are ignored. */
|
|
44
57
|
const stableFields = (account) => {
|
|
45
58
|
const out = {};
|
|
46
59
|
for (const [k, v] of Object.entries(account || {})) {
|
|
47
60
|
if (LEGACY_BALANCE_FIELDS.has(k)) continue;
|
|
48
61
|
if (k === "tokens" || k === "context" || k === "meta" || k === "$loki" || k.startsWith("_")) continue;
|
|
49
62
|
if (v === void 0 || v === null || v === "" || Array.isArray(v) && v.length === 0) continue;
|
|
63
|
+
if (isZeroDefault(k, v)) continue;
|
|
50
64
|
out[k] = v;
|
|
51
65
|
}
|
|
52
66
|
return out;
|
|
@@ -164,12 +178,15 @@ function assertBridgeReservesV2Protected(input) {
|
|
|
164
178
|
const afterRollups = after.get("rollup") ?? /* @__PURE__ */ new Map();
|
|
165
179
|
const beforeRollups = before.get("rollup") ?? /* @__PURE__ */ new Map();
|
|
166
180
|
const reserveOfBridge = (bridge) => norm((0, _arcblock_did_util.toBridgeReserveAddress)(bridge));
|
|
181
|
+
const isRelease = require_bridge_reserves.isNamedBridgeRelease(txType, input.itx);
|
|
182
|
+
const mayDebit = require_bridge_reserves.BRIDGE_RESERVE_DEBIT_TX_TYPES.includes(txType) || isRelease;
|
|
183
|
+
const debitTypes = `${require_bridge_reserves.BRIDGE_RESERVE_DEBIT_TX_TYPES.join(", ")}, deposit_token_v2 (bridge kinds)`;
|
|
167
184
|
for (const c of changes) {
|
|
168
|
-
if (c.debits.length > 0 && !
|
|
185
|
+
if (c.debits.length > 0 && !mayDebit) throw createGateError("BRIDGE_RESERVE_DEBIT_FORBIDDEN", `Post-Execution Invariant Gate: bridge reserve ${c.key} was debited in a ${txType || "unknown"} tx (allowed: ${debitTypes})`);
|
|
169
186
|
if (c.credits.length > 0 && !require_bridge_reserves.BRIDGE_RESERVE_CREDIT_TX_TYPES.includes(txType)) throw createGateError("BRIDGE_RESERVE_CREDIT_FORBIDDEN", `Post-Execution Invariant Gate: bridge reserve ${c.key} was credited in a ${txType || "unknown"} tx (allowed: ${require_bridge_reserves.BRIDGE_RESERVE_CREDIT_TX_TYPES.join(", ")})`);
|
|
170
187
|
if (!c.before && txType !== "create_rollup") throw createGateError("BRIDGE_RESERVE_STATE_VIOLATION", `Post-Execution Invariant Gate: bridge reserve ${c.key} can only be materialised by create_rollup, not by a ${txType || "unknown"} tx`);
|
|
171
188
|
if (c.before && !(0, lodash_isEqual.default)(stableFields(c.before), stableFields(c.after))) throw createGateError("BRIDGE_RESERVE_STATE_VIOLATION", `Post-Execution Invariant Gate: bridge reserve ${c.key} may only change token balances`);
|
|
172
|
-
if (!
|
|
189
|
+
if (!mayDebit && !require_bridge_reserves.BRIDGE_RESERVE_CREDIT_TX_TYPES.includes(txType)) throw createGateError("BRIDGE_RESERVE_STATE_VIOLATION", `Post-Execution Invariant Gate: bridge reserve ${c.key} can not be written by a ${txType || "unknown"} tx`);
|
|
173
190
|
}
|
|
174
191
|
const legacy = (rec, field) => {
|
|
175
192
|
const v = rec?.[field];
|
|
@@ -179,19 +196,21 @@ function assertBridgeReservesV2Protected(input) {
|
|
|
179
196
|
const resolution = input.resolution ?? null;
|
|
180
197
|
const bridgeOf = (key) => resolution?.reserves.get(require_bridge_reserves.bareAddress(key)) ?? null;
|
|
181
198
|
if (txType !== "create_rollup" && txType !== "migrate_rollup") {
|
|
182
|
-
const ledgerRows =
|
|
199
|
+
const ledgerRows = isRelease && Number(input.releaseKind) === 2 ? new Set([...input.resolution?.release?.debitable.values() ?? []].map((b) => require_bridge_reserves.bareAddress(b.address))) : /* @__PURE__ */ new Set();
|
|
183
200
|
for (const [key, row] of afterRollups.entries()) {
|
|
184
201
|
const prior = beforeRollups.get(key) ?? null;
|
|
185
202
|
if (ledgerRows.has(require_bridge_reserves.bareAddress(key))) continue;
|
|
186
203
|
if (isBridgeV2Row(row) && !(0, lodash_isEqual.default)(prior, row)) throw createGateError("BRIDGE_RESERVE_STATE_VIOLATION", `Post-Execution Invariant Gate: a ${txType || "unknown"} tx can not move a bridge reserve and write the bridge ${key} in the same tx`);
|
|
187
204
|
}
|
|
188
205
|
}
|
|
189
|
-
if (txType === require_bridge_reserves.
|
|
206
|
+
if (txType === require_bridge_reserves.BRIDGE_WITHDRAW_V2_TX_TYPE) {
|
|
190
207
|
for (const c of changes) {
|
|
191
208
|
if (c.debits.length > 0 || c.credits.length === 0) throw createGateError("BRIDGE_RESERVE_DEBIT_FORBIDDEN", `Post-Execution Invariant Gate: a withdraw only credits a bridge reserve (${c.key})`);
|
|
192
209
|
if (!input.enabled) throw createGateError("BRIDGE_RESERVE_CREDIT_FORBIDDEN", `Post-Execution Invariant Gate: bridge reserve ${c.key} can not be credited while transaction.bridge.enabled is off`);
|
|
193
210
|
const bridge = bridgeOf(c.key);
|
|
194
211
|
if (!bridge) throw createGateError("BRIDGE_RESERVE_CREDIT_FORBIDDEN", `Post-Execution Invariant Gate: ${c.key} has the bridge reserve role but is not the reserve of any v2 bridge`);
|
|
212
|
+
const named = resolution?.withdraw ?? null;
|
|
213
|
+
if (!named || require_bridge_reserves.bareAddress(named.address) !== require_bridge_reserves.bareAddress(bridge.address)) throw createGateError("BRIDGE_RESERVE_CREDIT_FORBIDDEN", `Post-Execution Invariant Gate: a withdraw_token_v2 of ${named?.address ?? "(no v2 bridge)"} can not credit reserve ${c.key}, which belongs to bridge ${bridge.address}`);
|
|
195
214
|
if (!bridge.acceptingWithdraws) throw createGateError("BRIDGE_RESERVE_CREDIT_FORBIDDEN", `Post-Execution Invariant Gate: bridge ${bridge.address} does not accept withdraws (paused: ${bridge.paused}, closing: ${bridge.closing}, final: ${bridge.final}, migrated: ${bridge.migrated})`);
|
|
196
215
|
const token = norm(bridge.token);
|
|
197
216
|
for (const tok of c.credits) if (!token || tok !== token) throw createGateError("BRIDGE_RESERVE_CREDIT_FORBIDDEN", `Post-Execution Invariant Gate: bridge reserve ${c.key} can only be credited with the bridge token ${token}, not ${tok}`);
|
|
@@ -203,8 +222,7 @@ function assertBridgeReservesV2Protected(input) {
|
|
|
203
222
|
}
|
|
204
223
|
return;
|
|
205
224
|
}
|
|
206
|
-
if (
|
|
207
|
-
const isRelease = txType === require_bridge_reserves.BRIDGE_RELEASE_TX_TYPE;
|
|
225
|
+
if (isRelease || require_bridge_reserves.BRIDGE_RECONCILE_TX_TYPES.includes(txType)) {
|
|
208
226
|
if (changes.some((c) => c.credits.length > 0 || c.debits.length === 0)) throw createGateError("BRIDGE_RESERVE_CREDIT_FORBIDDEN", `Post-Execution Invariant Gate: a ${txType} tx only debits a bridge reserve`);
|
|
209
227
|
if (isRelease && !input.enabled) throw createGateError("BRIDGE_RESERVE_DEBIT_FORBIDDEN", "Post-Execution Invariant Gate: a bridge reserve can not be debited while transaction.bridge.enabled is off");
|
|
210
228
|
if (isRelease && changes.length !== 1) throw createGateError("BRIDGE_RESERVE_DEBIT_FORBIDDEN", `Post-Execution Invariant Gate: a release debits exactly one bridge reserve, got ${changes.length}`);
|
|
@@ -33,6 +33,8 @@ interface BridgeReserveV2GateInput {
|
|
|
33
33
|
resolution?: BridgeReserveResolution | null;
|
|
34
34
|
/** `itx.kind` of a release (2 = REFUND may follow the `migratedTo` chain) */
|
|
35
35
|
releaseKind?: unknown;
|
|
36
|
+
/** the itx: a `deposit_token_v2` is a release only with `kind ∈ {1,2,3}` (`isBridgeRelease`) */
|
|
37
|
+
itx?: Rec | null;
|
|
36
38
|
/**
|
|
37
39
|
* Defence in depth for R2 (#1465): validates the transaction as a withdraw into `bridge` (shape, range, recipient) and
|
|
38
40
|
* returns a message when it is not, or when the reserve grew by anything other than the withdrawn amount.
|
package/lib/pipes/decode-tx.cjs
CHANGED
|
@@ -6,8 +6,8 @@ const require_pipes_pre_flight_waf = require('./pre-flight-waf.cjs');
|
|
|
6
6
|
let _ocap_mcrypto = require("@ocap/mcrypto");
|
|
7
7
|
let _ocap_util = require("@ocap/util");
|
|
8
8
|
let _ocap_util_lib_error = require("@ocap/util/lib/error");
|
|
9
|
-
let _ocap_message = require("@ocap/message");
|
|
10
9
|
let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
|
|
10
|
+
let _ocap_message = require("@ocap/message");
|
|
11
11
|
let _ocap_message_cbor = require("@ocap/message/cbor");
|
|
12
12
|
let _ocap_message_protobuf = require("@ocap/message/protobuf");
|
|
13
13
|
let lodash_cloneDeep = require("lodash/cloneDeep");
|
|
@@ -534,8 +534,9 @@ function inspectPostExecutionInvariants(context) {
|
|
|
534
534
|
enabled: !!(context.config?.transaction)?.bridge?.enabled,
|
|
535
535
|
resolution: context._bridgeReserveGate ?? null,
|
|
536
536
|
releaseKind: context.itx?.kind,
|
|
537
|
+
itx: context.itx ?? null,
|
|
537
538
|
checkWithdraw: (bridge, credited) => {
|
|
538
|
-
const withdraw = require_helpers_bridge_withdraw.
|
|
539
|
+
const withdraw = require_helpers_bridge_withdraw.checkBridgeWithdrawV2(context, bridge);
|
|
539
540
|
if (require_helpers_bridge_withdraw.isBridgeWithdrawFailure(withdraw)) return `${withdraw.code}: ${withdraw.message}`;
|
|
540
541
|
if (!credited.eq(new _ocap_util.BN(withdraw.amount))) return `the reserve grew by ${credited.toString(10)}, not by the withdrawn amount ${withdraw.amount}`;
|
|
541
542
|
return null;
|
|
@@ -813,7 +814,7 @@ function inspectPostExecutionInvariants(context) {
|
|
|
813
814
|
const isCloseRollupTx = txType === "fg:t:close_rollup" || txType === "close_rollup";
|
|
814
815
|
const isLeaveRollupTx = txType === "fg:t:leave_rollup" || txType === "leave_rollup";
|
|
815
816
|
const isSlashStakeTx = txType === "fg:t:slash_stake" || txType === "slash_stake";
|
|
816
|
-
const isRollupDepositTx = txType === "fg:t:deposit_token_v2" || txType === "deposit_token_v2";
|
|
817
|
+
const isRollupDepositTx = (txType === "fg:t:deposit_token_v2" || txType === "deposit_token_v2") && !require_bridge_reserves.isBridgeRelease(txType, context.itx) && context.isBridgeV2 !== true;
|
|
817
818
|
const isClaimBlockRewardTx = txType === "fg:t:claim_block_reward" || txType === "claim_block_reward";
|
|
818
819
|
const isStakeOfRetiredToken = (stakeRec) => {
|
|
819
820
|
for (const afterFac of afterFactories.values()) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
3
|
+
const require_bridge_reserves = require('../bridge-reserves.cjs');
|
|
3
4
|
const require_encrypted_nft_envelope = require('../encrypted-nft-envelope.cjs');
|
|
4
5
|
const require_pipes_decode_itx = require('./decode-itx.cjs');
|
|
5
6
|
const require_runner = require('../runner.cjs');
|
|
@@ -10,10 +11,10 @@ const require_pipes_verify_tx = require('./verify-tx.cjs');
|
|
|
10
11
|
const require_pipes_verify_tx_size = require('./verify-tx-size.cjs');
|
|
11
12
|
const require_pipes_decode_tx = require('./decode-tx.cjs');
|
|
12
13
|
let _ocap_util_lib_error = require("@ocap/util/lib/error");
|
|
13
|
-
let _ocap_message = require("@ocap/message");
|
|
14
14
|
let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
|
|
15
15
|
let lodash_get = require("lodash/get");
|
|
16
16
|
lodash_get = require_rolldown_runtime.__toESM(lodash_get);
|
|
17
|
+
let _ocap_message = require("@ocap/message");
|
|
17
18
|
let lodash_cloneDeep = require("lodash/cloneDeep");
|
|
18
19
|
lodash_cloneDeep = require_rolldown_runtime.__toESM(lodash_cloneDeep);
|
|
19
20
|
|
|
@@ -522,6 +523,8 @@ function scanItxPayloadAnomalies(itx, txType, config, rawTxItx, txSignatures) {
|
|
|
522
523
|
if (totalNestedAssets > maxListSize * 2) throw new _ocap_util_lib_error.CustomError("INVALID_TX_SIZE", `Total nested asset entries (${totalNestedAssets}) exceeds safe envelope`);
|
|
523
524
|
const itxSignatures = (0, _ocap_util_lib_get_list_field.getListField)(itxObj, "signatures");
|
|
524
525
|
if (Array.isArray(itxSignatures) && itxSignatures.length > maxMultisig) throw new _ocap_util_lib_error.CustomError("INVALID_TX", `Too many signatures in itx: maximum allowed is ${maxMultisig}`);
|
|
526
|
+
const itxValidatorSignatures = (0, _ocap_util_lib_get_list_field.getListField)(itxObj, "validatorSignatures");
|
|
527
|
+
if (Array.isArray(itxValidatorSignatures) && itxValidatorSignatures.length > maxMultisig) throw new _ocap_util_lib_error.CustomError("INVALID_TX", `Too many signatures in itx: maximum allowed is ${maxMultisig}`);
|
|
525
528
|
const txsList = (0, _ocap_util_lib_get_list_field.getListField)(itxObj, "txs");
|
|
526
529
|
const maxTxsLimit = Math.max(maxListSize, MAX_ROLLUP_TXS_LIST_SIZE);
|
|
527
530
|
if (Array.isArray(txsList) && txsList.length > maxTxsLimit) throw new _ocap_util_lib_error.CustomError("INVALID_TX_SIZE", `Size of txs can not exceeded ${maxTxsLimit} items`);
|
|
@@ -606,7 +609,7 @@ function tryApplyPreFlightVerifiedSnapshot(context) {
|
|
|
606
609
|
]) : void 0) || snap.maxTxSizeForType !== (snap.txType ? (0, lodash_get.default)(config, [
|
|
607
610
|
"transaction",
|
|
608
611
|
"maxTxSize",
|
|
609
|
-
snap.txType
|
|
612
|
+
require_bridge_reserves.txResourceKey(snap.txType, snap.itx)
|
|
610
613
|
], defaultSizeLimit) : defaultSizeLimit) || snap.maxExtraSize !== (0, lodash_get.default)(config, "transaction.maxExtraSize") || snap.maxMultisig !== (0, lodash_get.default)(config, "transaction.maxMultisig") || snap.maxListSize !== (0, lodash_get.default)(config, "transaction.maxListSize") || snap.maxAssetSize !== (0, lodash_get.default)(config, "transaction.maxAssetSize") || snap.isSupportedTx !== Boolean(Array.isArray(supportedTxs) && supportedTxs.includes(snap.txType)) || snap.isMultiSignV2Tx !== Boolean(Array.isArray(multiSignV2Txs) && multiSignV2Txs.includes(snap.txType))) return false;
|
|
611
614
|
const extra = context.extra;
|
|
612
615
|
if (snap.txExtraSerialized !== serializeExtraField(extra?.txExtra) || snap.gasStakeHeadersSerialized !== serializeExtraField(extra?.gasStakeHeaders) || snap.coSignatureSerialized !== serializeExtraField(extra?.coSignature)) return false;
|
|
@@ -762,7 +765,7 @@ async function inspectTransactionPreFlight(context) {
|
|
|
762
765
|
maxTxSizeForType: (0, lodash_get.default)(config, [
|
|
763
766
|
"transaction",
|
|
764
767
|
"maxTxSize",
|
|
765
|
-
preFlightCtx.txType
|
|
768
|
+
require_bridge_reserves.txResourceKey(preFlightCtx.txType, preFlightCtx.itx)
|
|
766
769
|
], defaultSizeLimit),
|
|
767
770
|
maxExtraSize: (0, lodash_get.default)(config, "transaction.maxExtraSize"),
|
|
768
771
|
maxMultisig: (0, lodash_get.default)(config, "transaction.maxMultisig"),
|
|
@@ -7,10 +7,10 @@ const require_helpers_encode_tx_by_context = require('../helpers/encode-tx-by-co
|
|
|
7
7
|
let _ocap_mcrypto = require("@ocap/mcrypto");
|
|
8
8
|
let _ocap_util_lib_error = require("@ocap/util/lib/error");
|
|
9
9
|
let _arcblock_did = require("@arcblock/did");
|
|
10
|
-
let _ocap_message = require("@ocap/message");
|
|
11
10
|
let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
|
|
12
11
|
let lodash_get = require("lodash/get");
|
|
13
12
|
lodash_get = require_rolldown_runtime.__toESM(lodash_get);
|
|
13
|
+
let _ocap_message = require("@ocap/message");
|
|
14
14
|
let lodash_cloneDeep = require("lodash/cloneDeep");
|
|
15
15
|
lodash_cloneDeep = require_rolldown_runtime.__toESM(lodash_cloneDeep);
|
|
16
16
|
let lodash_omit = require("lodash/omit");
|
|
@@ -6,10 +6,10 @@ const require_helpers_encode_tx_by_context = require('../helpers/encode-tx-by-co
|
|
|
6
6
|
let _ocap_mcrypto = require("@ocap/mcrypto");
|
|
7
7
|
let _ocap_util_lib_error = require("@ocap/util/lib/error");
|
|
8
8
|
let _arcblock_did = require("@arcblock/did");
|
|
9
|
-
let _ocap_message = require("@ocap/message");
|
|
10
9
|
let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
|
|
11
10
|
let lodash_get = require("lodash/get");
|
|
12
11
|
lodash_get = require_rolldown_runtime.__toESM(lodash_get);
|
|
12
|
+
let _ocap_message = require("@ocap/message");
|
|
13
13
|
let lodash_cloneDeep = require("lodash/cloneDeep");
|
|
14
14
|
lodash_cloneDeep = require_rolldown_runtime.__toESM(lodash_cloneDeep);
|
|
15
15
|
let _ocap_wallet = require("@ocap/wallet");
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
3
|
+
const require_bridge_reserves = require('../bridge-reserves.cjs');
|
|
3
4
|
let _ocap_util_lib_error = require("@ocap/util/lib/error");
|
|
4
|
-
let _ocap_message = require("@ocap/message");
|
|
5
5
|
let lodash_get = require("lodash/get");
|
|
6
6
|
lodash_get = require_rolldown_runtime.__toESM(lodash_get);
|
|
7
|
+
let _ocap_message = require("@ocap/message");
|
|
7
8
|
|
|
8
9
|
//#region src/pipes/verify-tx-size.ts
|
|
9
10
|
const DEFAULT_MAX_EXTRA_SIZE = 8 * 1024;
|
|
@@ -39,7 +40,12 @@ function VerifyTxSize(context, next) {
|
|
|
39
40
|
context._baseTxSize = baseTxSize;
|
|
40
41
|
const defaultSizeLimit = (0, lodash_get.default)(config, "transaction.maxTxSize.default");
|
|
41
42
|
const rawItx = tx.itx;
|
|
42
|
-
const
|
|
43
|
+
const typeKey = txType || rawItx?.typeUrl || (rawItx?.type ? (0, _ocap_message.toTypeUrl)(rawItx.type) : void 0);
|
|
44
|
+
const sizeLimit = (0, lodash_get.default)(config, [
|
|
45
|
+
"transaction",
|
|
46
|
+
"maxTxSize",
|
|
47
|
+
typeKey ? require_bridge_reserves.txResourceKey(typeKey, context.itx) : typeKey
|
|
48
|
+
], defaultSizeLimit);
|
|
43
49
|
if (baseTxSize > sizeLimit) return next(new _ocap_util_lib_error.CustomError("INVALID_TX_SIZE", `Transaction size too large for ${txType}: expect ${sizeLimit}, got ${baseTxSize}`));
|
|
44
50
|
const maxExtraSize = (0, lodash_get.default)(config, "transaction.maxExtraSize", DEFAULT_MAX_EXTRA_SIZE);
|
|
45
51
|
if (totalExtraBytes > maxExtraSize || gasStakeHeadersBytes > MAX_GAS_STAKE_HEADERS_SIZE || coSignatureBytes > MAX_CO_SIGNATURE_SIZE) {
|
package/lib/pipes/verify-tx.cjs
CHANGED
|
@@ -6,10 +6,10 @@ let _ocap_util = require("@ocap/util");
|
|
|
6
6
|
let _ocap_util_lib_error = require("@ocap/util/lib/error");
|
|
7
7
|
let _arcblock_did = require("@arcblock/did");
|
|
8
8
|
let _ocap_state = require("@ocap/state");
|
|
9
|
-
let _ocap_message = require("@ocap/message");
|
|
10
9
|
let _ocap_util_lib_get_list_field = require("@ocap/util/lib/get-list-field");
|
|
11
10
|
let lodash_get = require("lodash/get");
|
|
12
11
|
lodash_get = require_rolldown_runtime.__toESM(lodash_get);
|
|
12
|
+
let _ocap_message = require("@ocap/message");
|
|
13
13
|
let lodash_isEmpty = require("lodash/isEmpty");
|
|
14
14
|
lodash_isEmpty = require_rolldown_runtime.__toESM(lodash_isEmpty);
|
|
15
15
|
|
|
@@ -2025,6 +2025,17 @@ async function executeCrossChainPurchaseBlock(input, options) {
|
|
|
2025
2025
|
if (input.enforceZeroSum === false) throw new _ocap_util_lib_error.CustomError("INVALID_CROSS_CHAIN_PURCHASE", "Zero-sum conservation cannot be disabled in cross-chain purchase blocks");
|
|
2026
2026
|
const proposer = deposit.proposer || input.relayer;
|
|
2027
2027
|
assertSafeKey(proposer, "deposit.proposer");
|
|
2028
|
+
let depositRollupRow;
|
|
2029
|
+
try {
|
|
2030
|
+
const rollupTable = options.statedb?.rollup;
|
|
2031
|
+
if (typeof rollupTable?.get !== "function") throw new Error("the statedb has no rollup table");
|
|
2032
|
+
const canonical = String(deposit.rollup).trim().replace(/^did:abt:/, "");
|
|
2033
|
+
const rows = await Promise.all([...new Set([deposit.rollup, canonical])].map((key) => rollupTable.get(key)));
|
|
2034
|
+
depositRollupRow = rows.find((row) => row?.data?.value?.version === 2) ?? rows[0];
|
|
2035
|
+
} catch (err) {
|
|
2036
|
+
throw new _ocap_util_lib_error.CustomError("INVALID_CROSS_CHAIN_PURCHASE", `Can not read deposit.rollup ${deposit.rollup}: ${String(err?.message || err)}`);
|
|
2037
|
+
}
|
|
2038
|
+
if (depositRollupRow?.data?.value?.version === 2) throw new _ocap_util_lib_error.CustomError("FORBIDDEN", `deposit.rollup ${deposit.rollup} is a v2 bridge: a bridge deposit can not be a step of a cross-chain purchase block`);
|
|
2028
2039
|
const combinedOfacList = /* @__PURE__ */ new Set();
|
|
2029
2040
|
if (Array.isArray(input.ofacBlocklist)) for (const addr of input.ofacBlocklist) combinedOfacList.add(addr);
|
|
2030
2041
|
if (options.ofacBlocklist) for (const addr of options.ofacBlocklist) combinedOfacList.add(addr);
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.31.
|
|
6
|
+
"version": "1.31.7",
|
|
7
7
|
"description": "Pipeline runner and common pipelines to process transactions",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./lib/index.cjs",
|
|
@@ -49,15 +49,15 @@
|
|
|
49
49
|
"elliptic": "6.5.3"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@arcblock/did": "1.31.
|
|
53
|
-
"@arcblock/did-util": "1.31.
|
|
54
|
-
"@ocap/client": "1.31.
|
|
55
|
-
"@ocap/mcrypto": "1.31.
|
|
56
|
-
"@ocap/message": "1.31.
|
|
57
|
-
"@ocap/state": "1.31.
|
|
58
|
-
"@ocap/types": "1.31.
|
|
59
|
-
"@ocap/util": "1.31.
|
|
60
|
-
"@ocap/wallet": "1.31.
|
|
52
|
+
"@arcblock/did": "1.31.7",
|
|
53
|
+
"@arcblock/did-util": "1.31.7",
|
|
54
|
+
"@ocap/client": "1.31.7",
|
|
55
|
+
"@ocap/mcrypto": "1.31.7",
|
|
56
|
+
"@ocap/message": "1.31.7",
|
|
57
|
+
"@ocap/state": "1.31.7",
|
|
58
|
+
"@ocap/types": "1.31.7",
|
|
59
|
+
"@ocap/util": "1.31.7",
|
|
60
|
+
"@ocap/wallet": "1.31.7",
|
|
61
61
|
"elliptic": "6.6.1",
|
|
62
62
|
"debug": "^4.4.3",
|
|
63
63
|
"lodash": "^4.17.23"
|