@ocap/tx-protocols 1.31.9 → 1.32.0

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 (37) hide show
  1. package/esm/execute.d.mts +6 -1
  2. package/esm/execute.mjs +151 -9
  3. package/esm/gas-security-guard.d.mts +19 -1
  4. package/esm/gas-security-guard.mjs +44 -1
  5. package/esm/index.d.mts +8 -2
  6. package/esm/index.mjs +2 -2
  7. package/esm/pipes/ensure-cost.mjs +39 -2
  8. package/esm/pipes/write-ledger.mjs +18 -3
  9. package/esm/protocols/rollup/bridge-create.mjs +8 -3
  10. package/esm/protocols/rollup/bridge-governance-tx-binding.d.mts +7 -0
  11. package/esm/protocols/rollup/bridge-governance-tx-binding.mjs +212 -0
  12. package/esm/protocols/rollup/bridge-governance-vote.d.mts +49 -0
  13. package/esm/protocols/rollup/bridge-governance-vote.mjs +564 -0
  14. package/esm/protocols/rollup/bridge-migrate.mjs +6 -3
  15. package/esm/protocols/rollup/bridge-v2.d.mts +6 -0
  16. package/esm/protocols/rollup/bridge-v2.mjs +5 -0
  17. package/esm/protocols/rollup/update.d.mts +2 -0
  18. package/esm/protocols/rollup/update.mjs +28 -6
  19. package/lib/execute.cjs +151 -9
  20. package/lib/execute.d.cts +6 -1
  21. package/lib/gas-security-guard.cjs +44 -0
  22. package/lib/gas-security-guard.d.cts +19 -1
  23. package/lib/index.cjs +1 -0
  24. package/lib/index.d.cts +8 -2
  25. package/lib/pipes/ensure-cost.cjs +39 -2
  26. package/lib/pipes/write-ledger.cjs +18 -3
  27. package/lib/protocols/rollup/bridge-create.cjs +8 -3
  28. package/lib/protocols/rollup/bridge-governance-tx-binding.cjs +213 -0
  29. package/lib/protocols/rollup/bridge-governance-tx-binding.d.cts +7 -0
  30. package/lib/protocols/rollup/bridge-governance-vote.cjs +573 -0
  31. package/lib/protocols/rollup/bridge-governance-vote.d.cts +49 -0
  32. package/lib/protocols/rollup/bridge-migrate.cjs +6 -3
  33. package/lib/protocols/rollup/bridge-v2.cjs +5 -0
  34. package/lib/protocols/rollup/bridge-v2.d.cts +6 -0
  35. package/lib/protocols/rollup/update.cjs +28 -6
  36. package/lib/protocols/rollup/update.d.cts +2 -0
  37. package/package.json +16 -16
@@ -0,0 +1,573 @@
1
+ const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
2
+ const require_protocols_rollup_bridge_v2 = require('./bridge-v2.cjs');
3
+ const require_protocols_rollup_bridge_governance_tx_binding = require('./bridge-governance-tx-binding.cjs');
4
+ let _ocap_mcrypto = require("@ocap/mcrypto");
5
+ let _ocap_util_lib_error = require("@ocap/util/lib/error");
6
+ let _ocap_state = require("@ocap/state");
7
+ let _ocap_util = require("@ocap/util");
8
+ let _ocap_tx_pipeline = require("@ocap/tx-pipeline");
9
+
10
+ //#region src/protocols/rollup/bridge-governance-vote.ts
11
+ /**
12
+ * On-chain dual-plane governance proposal & co-signing ledger (`update_rollup` `govProposalVote` branch, #1880 / #1839).
13
+ *
14
+ * Persists proposals and signatures exclusively in the 66-character self-identifying `gi:<63hex>` / `gd:<63hex>`
15
+ * `statedb.evidence` namespace without mutating `BridgeBodyV2` or `bridge.owner`'s OCAP `nonce`.
16
+ */
17
+ const MAX_ACTIVE_DRAFTS_PER_PROPOSER = 2;
18
+ const MAX_SINGLE_SIG_PROPOSALS_PER_PROPOSER = 2;
19
+ const MAX_GOV_INDEX_RING_CAP = 100;
20
+ const MAX_GOV_PROPOSAL_TTL_SEC = 45 * 86400;
21
+ const MAX_GOV_CREATED_AT_SKEW_SEC = 300;
22
+ const GOV_VOTE_PAYLOAD_KEYS = new Set([
23
+ "plane",
24
+ "proposalId",
25
+ "title",
26
+ "rationaleUrl",
27
+ "proposal",
28
+ "vote"
29
+ ]);
30
+ const VOTE_INPUT_KEYS = new Set([
31
+ "signer",
32
+ "role",
33
+ "signature",
34
+ "envelope"
35
+ ]);
36
+ function parseStoredEvidenceObject(row) {
37
+ const raw = row?.data;
38
+ if (typeof raw === "string") try {
39
+ const parsed = JSON.parse(raw);
40
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : void 0;
41
+ } catch {
42
+ return;
43
+ }
44
+ const val = raw?.value;
45
+ return val && typeof val === "object" && !Array.isArray(val) ? val : void 0;
46
+ }
47
+ function isGovProposalVotePayload(rawData) {
48
+ return Object.prototype.hasOwnProperty.call(rawData, "govProposalVote");
49
+ }
50
+ function invalidTx(msg) {
51
+ throw new _ocap_util_lib_error.CustomError("INVALID_TX", msg);
52
+ }
53
+ function invalidSig(msg) {
54
+ throw new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", msg);
55
+ }
56
+ function sortVotes(votes) {
57
+ return [...votes].sort((a, b) => {
58
+ const da = BigInt(a.signer);
59
+ const db = BigInt(b.signer);
60
+ return da < db ? -1 : da > db ? 1 : 0;
61
+ });
62
+ }
63
+ async function verifyAndScoreOcapVote(context, proposal, voteRec, envelope, existingVotes, isNewDoc, txSec) {
64
+ const bridgeBody = context.bridgeBody;
65
+ const rollupState = context.rollupState;
66
+ if (bridgeBody.migratedTo !== null) invalidTx("The reserve has migrated: the bridge is frozen");
67
+ const { action } = proposal;
68
+ const allowedWhenClosed = action.kind === "migrate_rollup" && action.migrateKind === "reserve" || action.kind === "update_rollup" && (action.patch.proposeOwner !== void 0 || action.patch.cancelOwnerProposal === true);
69
+ if (bridgeBody.closingAt !== null && !allowedWhenClosed) invalidTx("A closed bridge is frozen for this OCAP governance action");
70
+ const owner = (0, _ocap_mcrypto.checkedNonZeroAddress)(bridgeBody.owner, "bridgeBody.owner");
71
+ let quorumBody = bridgeBody;
72
+ if (action.kind === "migrate_rollup" && action.migrateKind === "reserve") if (action.step === "cancel") {
73
+ if (!bridgeBody.pendingMigration) invalidTx("There is no pending reserve migration to cancel");
74
+ } else {
75
+ if (!_ocap_state.rollup.isBridgeFinalAt(bridgeBody, txSec)) invalidTx("The source bridge is not final yet");
76
+ if (action.step === "announce" && bridgeBody.pendingMigration) invalidTx("A reserve migration is already pending");
77
+ if (action.step === "execute") {
78
+ const p = bridgeBody.pendingMigration;
79
+ if (!p) invalidTx("No reserve migration was announced");
80
+ if (_ocap_state.rollup.lc(p.to) !== _ocap_state.rollup.lc(action.targetBridge)) invalidTx("The target differs from the announced migration");
81
+ }
82
+ const targetRow = await context.statedb.rollup.get(action.targetBridge, context);
83
+ if (!targetRow || !_ocap_state.rollup.isBridgeV2(targetRow)) invalidTx("The migration target must be a v2 bridge");
84
+ if (_ocap_state.rollup.sameAddress(targetRow.address, rollupState.address)) invalidTx("Can not migrate a reserve to its own bridge");
85
+ const tbody = _ocap_state.rollup.getBridgeBody(targetRow);
86
+ if (targetRow.closed || tbody.closingAt !== null) invalidTx("The migration target is closed");
87
+ if (targetRow.tokenAddress !== rollupState.tokenAddress) invalidTx("The migration target bridges a different OCAP token");
88
+ if (tbody.ethChainId !== bridgeBody.ethChainId || _ocap_state.rollup.bareEthAddress(targetRow.contractAddress) !== _ocap_state.rollup.bareEthAddress(rollupState.contractAddress)) invalidTx("The migration target bridges a different ethereum token");
89
+ if (_ocap_state.rollup.toSeconds(targetRow.context?.genesisTime) < bridgeBody.finalAt) invalidTx("The migration target must be created after the source bridge is final");
90
+ quorumBody = tbody;
91
+ }
92
+ const activeEpoch = _ocap_state.rollup.activeEpochAt(quorumBody, txSec);
93
+ if (!activeEpoch) invalidTx("The bridge has no active epoch yet");
94
+ const activeValidators = new Set(activeEpoch.validators.map((v) => (0, _ocap_mcrypto.checkedNonZeroAddress)(v, "validator")));
95
+ let signer = "";
96
+ let signature = "";
97
+ let signedDigest = "";
98
+ let publicKeyHex;
99
+ let role = "";
100
+ if (action.kind === "join_rollup" || action.kind === "leave_rollup") {
101
+ if (envelope !== "eip712") invalidTx("BridgeMembership proposals require eip712 envelope");
102
+ const lastEpoch = bridgeBody.epochs[bridgeBody.epochs.length - 1];
103
+ if (!lastEpoch || action.epoch !== BigInt(lastEpoch.epoch + 1)) invalidTx(`${action.kind}.epoch must equal ${lastEpoch ? lastEpoch.epoch + 1 : 2}`);
104
+ signedDigest = (0, _ocap_mcrypto.toHexDigest)((0, _ocap_mcrypto.computeBridgeMembershipDigest)((0, _ocap_mcrypto.membershipFromOcapProposal)(proposal)));
105
+ const tombstoneKey = require_protocols_rollup_bridge_v2.membershipTombstoneKey(rollupState.address, Number(action.epoch), signedDigest);
106
+ const tombstoneRow = await context.statedb.evidence.get(tombstoneKey, context);
107
+ if (tombstoneRow && !(0, _ocap_tx_pipeline.isV1EvidenceRow)(tombstoneRow)) invalidTx("This membership approval was already used on this chain");
108
+ try {
109
+ const rec = (0, _ocap_mcrypto.recoverOcapMembershipProposalSigner)(proposal, String(voteRec.signature ?? ""));
110
+ signer = rec.signer;
111
+ signature = rec.signature;
112
+ } catch (err) {
113
+ invalidSig(`Invalid BridgeMembership signature: ${err.message}`);
114
+ }
115
+ const isJoiner = action.kind === "join_rollup" && signer === action.validator;
116
+ const isOwner = signer === owner;
117
+ const isVal = activeValidators.has(signer);
118
+ if (!isJoiner && !isOwner && !isVal) invalidSig(`Signer ${signer} is not an authorized membership co-signer on this bridge`);
119
+ if (isNewDoc && isJoiner && !isOwner && !isVal) invalidSig("Only the bridge owner or an active validator may open a join_rollup proposal; the candidate validator may only co-sign an existing proposal");
120
+ role = isJoiner ? "joiner" : isOwner ? "owner" : "validator";
121
+ } else {
122
+ await require_protocols_rollup_bridge_governance_tx_binding.verifyOcapProposalTxBinding(context, proposal);
123
+ signedDigest = action.challenge;
124
+ const rawExpectedSigner = voteRec.signer !== void 0 ? voteRec.signer : !("signerRoster" in action) && action.txFrom?.startsWith("0x") ? action.txFrom : void 0;
125
+ if (rawExpectedSigner === void 0) invalidTx("govProposalVote.vote.signer is required for ArcBlockTransaction vote");
126
+ const expectedSigner = (0, _ocap_mcrypto.checkedNonZeroAddress)(rawExpectedSigner, "vote.signer");
127
+ try {
128
+ const rec = (0, _ocap_mcrypto.recoverArcBlockTxEnvelopeSigner)({
129
+ chainId: proposal.ocapChainId,
130
+ action: action.kind,
131
+ from: expectedSigner,
132
+ nonce: action.frozenNonce.toString(10),
133
+ challenge: signedDigest
134
+ }, String(voteRec.signature ?? ""), envelope);
135
+ signer = rec.signer;
136
+ signature = rec.signature;
137
+ publicKeyHex = rec.publicKeyHex;
138
+ } catch (err) {
139
+ invalidSig(`Invalid ArcBlockTransaction signature: ${err.message}`);
140
+ }
141
+ if (signer !== expectedSigner) invalidSig(`Recovered signer ${signer} does not match vote.signer ${expectedSigner}`);
142
+ if ("signerRoster" in action && !action.signerRoster.some((e) => e.signer === signer && e.pk === publicKeyHex)) invalidSig(`Signer ${signer} (pk ${publicKeyHex}) is not in proposal signerRoster`);
143
+ if (!("signerRoster" in action) && signer !== action.txFrom) invalidSig(`Single-signer OCAP proposal vote.signer (${signer}) must match proposal.action.txFrom`);
144
+ if (action.kind === "pause_rollup" && action.mode === "lone") {
145
+ if (!bridgeBody.pausers.some((p) => _ocap_state.rollup.sameAddress(p, signer))) invalidSig(`Signer ${signer} is not an authorized bridge pauser`);
146
+ if (signer !== owner && !activeValidators.has(signer)) invalidSig("Pauser-only key cannot submit govProposalVote; submit PauseRollupTx directly");
147
+ role = "pauser";
148
+ } else if (action.kind === "migrate_rollup" && action.migrateKind === "reserve" && action.step === "cancel") {
149
+ const isOfficial = !!context.config?.token?.address && (0, _ocap_util.isSameDid)(rollupState.tokenAddress, context.config.token.address);
150
+ const tokenState = isOfficial ? null : await context.statedb.token.get(rollupState.tokenAddress, context);
151
+ const authority = isOfficial ? context.config?.moderator?.address : tokenState?.issuer;
152
+ if (!authority || !_ocap_state.rollup.sameAddress(authority, signer)) invalidSig(`Signer ${signer} is not the token authority`);
153
+ role = "authority";
154
+ } else if (action.kind === "update_rollup" && action.patch.cancelOwnerProposal === true) {
155
+ if (signer !== owner) invalidSig("Only the current bridge owner may co-sign cancelOwnerProposal");
156
+ role = "owner";
157
+ } else {
158
+ if (signer !== owner && !activeValidators.has(signer)) invalidSig(`Signer ${signer} is neither the bridge owner nor an active validator`);
159
+ role = signer === owner ? "owner" : "validator";
160
+ }
161
+ }
162
+ if (voteRec.signer !== void 0 && (0, _ocap_mcrypto.checkedNonZeroAddress)(voteRec.signer, "vote.signer") !== signer) invalidSig("vote.signer does not match recovered signature signer");
163
+ if (voteRec.role !== void 0 && voteRec.role !== role) invalidTx(`vote.role must be "${role}" for signer ${signer}`);
164
+ const signerLc = signer.toLowerCase();
165
+ const prev = existingVotes.find((v) => v.signer.toLowerCase() === signerLc);
166
+ const entry = {
167
+ signer,
168
+ role,
169
+ signature,
170
+ envelope,
171
+ isSeed: signer === owner,
172
+ votedAt: prev && prev.signature === signature ? prev.votedAt : txSec,
173
+ ...publicKeyHex ? { publicKeyHex } : {}
174
+ };
175
+ const nextVotes = sortVotes([...existingVotes.filter((v) => v.signer.toLowerCase() !== signerLc), entry]);
176
+ const votedAddrs = new Set(nextVotes.map((v) => v.signer));
177
+ const valCount = [...votedAddrs].filter((a) => activeValidators.has(a)).length;
178
+ let quorumReached = false;
179
+ if (action.kind === "pause_rollup" && action.mode === "lone" || action.kind === "migrate_rollup" && action.migrateKind === "reserve" && action.step === "cancel") quorumReached = nextVotes.length >= 1;
180
+ else if (action.kind === "update_rollup" && action.patch.cancelOwnerProposal === true) quorumReached = votedAddrs.has(owner);
181
+ else if (action.kind === "update_rollup" && action.patch.proposeOwner !== void 0) quorumReached = valCount >= Math.ceil(2 * activeEpoch.validators.length / 3);
182
+ else if (action.kind === "join_rollup") quorumReached = votedAddrs.has(owner) && votedAddrs.has(action.validator) && valCount >= activeEpoch.threshold;
183
+ else quorumReached = votedAddrs.has(owner) && valCount >= activeEpoch.threshold;
184
+ return {
185
+ signer,
186
+ role,
187
+ signature,
188
+ signedDigest,
189
+ publicKeyHex,
190
+ nextVotes,
191
+ quorumReached
192
+ };
193
+ }
194
+ async function planBridgeGovProposalVote(context, rawData) {
195
+ if (Object.keys(rawData).length !== 1) invalidTx("govProposalVote cannot be combined with any rollup patch keys");
196
+ const txSec = context.txSec;
197
+ const bridge = context.itx.rollup;
198
+ const chainId = context.config.chainId;
199
+ const bridgeBody = context.bridgeBody;
200
+ const rollupState = context.rollupState;
201
+ let payload;
202
+ let voteRec;
203
+ let optionalTitle;
204
+ let optionalRationaleUrl;
205
+ try {
206
+ payload = (0, _ocap_mcrypto.assertPlainObject)(rawData.govProposalVote, "govProposalVote");
207
+ (0, _ocap_mcrypto.assertAllowedKeys)(payload, GOV_VOTE_PAYLOAD_KEYS, "govProposalVote");
208
+ voteRec = (0, _ocap_mcrypto.assertPlainObject)(payload.vote, "govProposalVote.vote");
209
+ (0, _ocap_mcrypto.assertAllowedKeys)(voteRec, VOTE_INPUT_KEYS, "govProposalVote.vote");
210
+ if (payload.title !== void 0) optionalTitle = (0, _ocap_mcrypto.assertValidProposalTitle)(payload.title, "govProposalVote.title");
211
+ if (payload.rationaleUrl !== void 0) optionalRationaleUrl = (0, _ocap_mcrypto.assertValidRationaleUrl)(payload.rationaleUrl, "govProposalVote.rationaleUrl");
212
+ } catch (err) {
213
+ invalidTx(err.message);
214
+ }
215
+ const rawProposal = (() => {
216
+ try {
217
+ return (0, _ocap_mcrypto.assertPlainObject)(payload.proposal, "govProposalVote.proposal");
218
+ } catch (err) {
219
+ invalidTx(err.message);
220
+ }
221
+ })();
222
+ const plane = payload.plane ?? rawProposal.plane;
223
+ if (plane !== "ethereum" && plane !== "ocap") invalidTx("govProposalVote.plane must be 'ethereum' or 'ocap'");
224
+ if (rawProposal.plane !== plane) invalidTx("govProposalVote.plane does not match proposal.plane");
225
+ const envelopeRaw = voteRec.envelope ?? "eip712";
226
+ if (envelopeRaw !== "eip712" && envelopeRaw !== "eip191") invalidTx("govProposalVote.vote.envelope must be 'eip712' or 'eip191'");
227
+ const envelope = envelopeRaw;
228
+ let proposalId = "";
229
+ let canonicalProposalStr = "";
230
+ let canonicalProposalObj;
231
+ let actionKind = "";
232
+ let summary = "";
233
+ let expiresAt = 0n;
234
+ let certJson;
235
+ if (plane === "ethereum") {
236
+ if (envelope !== "eip712") invalidTx("Ethereum GovernanceCert votes require eip712 envelope");
237
+ if (bridgeBody.closingAt !== null || rollupState.closed) invalidTx("Ethereum governance proposals cannot be voted on a closed bridge");
238
+ const evmGov = bridgeBody.evmGovernance ?? null;
239
+ if (!evmGov) invalidTx("Bridge has no configured evmGovernance roster");
240
+ const proposal = (() => {
241
+ try {
242
+ return (0, _ocap_mcrypto.coerceEvmProposal)(rawProposal);
243
+ } catch (err) {
244
+ invalidTx(err.message);
245
+ }
246
+ })();
247
+ if (proposal.ocapChainId !== chainId) invalidTx("proposal.ocapChainId does not match this OCAP chain");
248
+ if (proposal.ocapBridge !== bridge) invalidTx("proposal.ocapBridge does not match itx.rollup");
249
+ if (proposal.deployment.chainId !== BigInt(bridgeBody.ethChainId)) invalidTx("proposal.deployment.chainId does not match bridge ethChainId");
250
+ if (proposal.deployment.gateway.toLowerCase() !== bridgeBody.gateway.toLowerCase()) invalidTx("proposal.deployment.gateway does not match bridge gateway");
251
+ const expectedToken = _ocap_state.rollup.bareEthAddress(rollupState.contractAddress);
252
+ if (expectedToken && !/^0x0{40}$/.test(expectedToken)) {
253
+ if (proposal.deployment.token === void 0 || proposal.deployment.token.toLowerCase() !== expectedToken) invalidTx("proposal.deployment.token must match bridge contractAddress");
254
+ }
255
+ const expectedVault = _ocap_state.rollup.bareEthAddress(rollupState.vaultAddress);
256
+ if (expectedVault && !/^0x0{40}$/.test(expectedVault)) {
257
+ if (proposal.deployment.vault === void 0 || proposal.deployment.vault.toLowerCase() !== expectedVault) invalidTx("proposal.deployment.vault must match bridge vaultAddress");
258
+ }
259
+ if (proposal.deployment.signerManager !== evmGov.signerManager.address) invalidTx("proposal.deployment.signerManager does not match bridge evmGovernance.signerManager.address");
260
+ if (evmGov.vaultSignerManager === null) {
261
+ if (proposal.deployment.vaultSignerManager !== void 0) invalidTx("proposal.deployment.vaultSignerManager must be omitted when bridge vaultSignerManager is null");
262
+ } else if (proposal.deployment.vaultSignerManager !== evmGov.vaultSignerManager.address) invalidTx("proposal.deployment.vaultSignerManager must match bridge evmGovernance.vaultSignerManager.address");
263
+ const valSetLc = proposal.deployment.validatorSet.toLowerCase();
264
+ for (const [label, addr] of [
265
+ ["gateway", proposal.deployment.gateway],
266
+ ["token", proposal.deployment.token],
267
+ ["vault", proposal.deployment.vault],
268
+ ["signerManager", proposal.deployment.signerManager],
269
+ ["vaultSignerManager", proposal.deployment.vaultSignerManager]
270
+ ]) if (addr && valSetLc === addr.toLowerCase()) invalidTx(`proposal.deployment.validatorSet collides with ${label}`);
271
+ const cert = (() => {
272
+ try {
273
+ canonicalProposalStr = (0, _ocap_mcrypto.serializeEvmProposal)(proposal);
274
+ return (0, _ocap_mcrypto.buildCertFromProposal)(proposal);
275
+ } catch (err) {
276
+ invalidTx(err.message);
277
+ }
278
+ })();
279
+ proposalId = cert.proposalHash;
280
+ canonicalProposalObj = (0, _ocap_mcrypto.toJsonSafeValue)(proposal);
281
+ certJson = (0, _ocap_mcrypto.toJsonSafeValue)(cert);
282
+ actionKind = proposal.action.kind;
283
+ summary = proposal.summary;
284
+ expiresAt = proposal.expiresAt;
285
+ if (BigInt(txSec) >= expiresAt) invalidTx("Governance proposal has expired");
286
+ if (payload.proposalId !== void 0) {
287
+ let supplied = "";
288
+ try {
289
+ supplied = (0, _ocap_mcrypto.checkedBytes32)(payload.proposalId, "proposalId");
290
+ } catch (err) {
291
+ invalidTx(err.message);
292
+ }
293
+ if (supplied !== proposalId) invalidTx("govProposalVote.proposalId does not match recomputed proposalHash");
294
+ }
295
+ const indexKey$1 = (0, _ocap_mcrypto.bridgeGovIndexKey)(bridge);
296
+ const docKey$1 = (0, _ocap_mcrypto.bridgeGovDocKey)(bridge, proposalId);
297
+ const [existingDocRow$1, existingIndexRow$1] = await Promise.all([context.statedb.evidence.get(docKey$1, context), context.statedb.evidence.get(indexKey$1, context)]);
298
+ const existingDoc$1 = parseStoredEvidenceObject(existingDocRow$1);
299
+ const existingVotes$1 = Array.isArray(existingDoc$1?.votes) ? existingDoc$1.votes : [];
300
+ let signer = "";
301
+ let signature = "";
302
+ try {
303
+ const rec = (0, _ocap_mcrypto.recoverGovernanceCertSigner)(proposal.deployment, cert, String(voteRec.signature ?? ""));
304
+ signer = rec.signer;
305
+ signature = rec.signature;
306
+ } catch (err) {
307
+ invalidSig(`Invalid GovernanceCert signature: ${err.message}`);
308
+ }
309
+ if (voteRec.signer !== void 0 && (0, _ocap_mcrypto.checkedNonZeroAddress)(voteRec.signer, "vote.signer") !== signer) invalidSig("vote.signer does not match recovered GovernanceCert signer");
310
+ const governingSm = (0, _ocap_mcrypto.signerManagerFor)(proposal.deployment, proposal.target);
311
+ const isVaultSm = evmGov.vaultSignerManager !== null && governingSm === evmGov.vaultSignerManager.address && governingSm !== evmGov.signerManager.address;
312
+ const role = isVaultSm ? "vaultSignerManager" : "signerManager";
313
+ const roster = isVaultSm ? evmGov.vaultSignerManager : evmGov.signerManager;
314
+ if (voteRec.role !== void 0 && voteRec.role !== role) invalidTx(`vote.role must be "${role}"`);
315
+ if (!roster.signers.includes(signer)) invalidSig(`Signer ${signer} is not an active member of ${role}`);
316
+ const signerLc = signer.toLowerCase();
317
+ const prev = existingVotes$1.find((v) => v.signer.toLowerCase() === signerLc);
318
+ const voteEntry = {
319
+ signer,
320
+ role,
321
+ signature,
322
+ envelope,
323
+ isSeed: roster.seeds.includes(signer),
324
+ votedAt: prev && prev.signature === signature ? prev.votedAt : txSec
325
+ };
326
+ const nextVotes = sortVotes([...existingVotes$1.filter((v) => v.signer.toLowerCase() !== signerLc), voteEntry]);
327
+ const activeSet = new Set(nextVotes.filter((v) => v.role === role && roster.signers.includes(v.signer)).map((v) => v.signer));
328
+ const seedCount = roster.seeds.filter((s) => activeSet.has(s)).length;
329
+ const quorumReached = activeSet.size >= roster.threshold && seedCount >= roster.seedThreshold;
330
+ const signedDigest = (0, _ocap_mcrypto.toHexDigest)((0, _ocap_mcrypto.computeGovernanceCertDigest)(proposal.deployment, cert));
331
+ return finalizeGovVotePlan({
332
+ bridge,
333
+ proposalId,
334
+ signedDigest,
335
+ plane: "ethereum",
336
+ actionKind,
337
+ summary,
338
+ proposalCreatedAt: proposal.createdAt,
339
+ expiresAt,
340
+ optionalTitle,
341
+ optionalRationaleUrl,
342
+ canonicalProposalStr,
343
+ canonicalProposalObj,
344
+ certJson,
345
+ signer,
346
+ nextVotes,
347
+ quorumReached,
348
+ txSec,
349
+ indexKey: indexKey$1,
350
+ docKey: docKey$1,
351
+ existingDocRow: existingDocRow$1,
352
+ existingIndexRow: existingIndexRow$1
353
+ });
354
+ }
355
+ const ocapProposal = (() => {
356
+ try {
357
+ const p = (0, _ocap_mcrypto.coerceOcapProposal)(rawProposal);
358
+ canonicalProposalStr = (0, _ocap_mcrypto.serializeOcapProposal)(p);
359
+ proposalId = (0, _ocap_mcrypto.computeOcapProposalId)(p);
360
+ return p;
361
+ } catch (err) {
362
+ invalidTx(err.message);
363
+ }
364
+ })();
365
+ if (ocapProposal.ocapChainId !== chainId) invalidTx("proposal.ocapChainId does not match this OCAP chain");
366
+ if (ocapProposal.ocapBridge !== bridge) invalidTx("proposal.ocapBridge does not match itx.rollup");
367
+ canonicalProposalObj = (0, _ocap_mcrypto.toJsonSafeValue)(ocapProposal);
368
+ actionKind = ocapProposal.action.kind;
369
+ summary = ocapProposal.summary;
370
+ expiresAt = ocapProposal.expiresAt;
371
+ if (BigInt(txSec) >= expiresAt) invalidTx("Governance proposal has expired");
372
+ if (payload.proposalId !== void 0) {
373
+ let supplied = "";
374
+ try {
375
+ supplied = (0, _ocap_mcrypto.checkedBytes32)(payload.proposalId, "proposalId");
376
+ } catch (err) {
377
+ invalidTx(err.message);
378
+ }
379
+ if (supplied !== proposalId) invalidTx("govProposalVote.proposalId does not match recomputed proposalId");
380
+ }
381
+ const indexKey = (0, _ocap_mcrypto.bridgeGovIndexKey)(bridge);
382
+ const docKey = (0, _ocap_mcrypto.bridgeGovDocKey)(bridge, proposalId);
383
+ const [existingDocRow, existingIndexRow] = await Promise.all([context.statedb.evidence.get(docKey, context), context.statedb.evidence.get(indexKey, context)]);
384
+ const existingDoc = parseStoredEvidenceObject(existingDocRow);
385
+ const existingVotes = Array.isArray(existingDoc?.votes) ? existingDoc.votes : [];
386
+ const ocapScored = await verifyAndScoreOcapVote(context, ocapProposal, voteRec, envelope, existingVotes, !existingDocRow, txSec);
387
+ return finalizeGovVotePlan({
388
+ bridge,
389
+ proposalId,
390
+ signedDigest: ocapScored.signedDigest,
391
+ plane: "ocap",
392
+ actionKind,
393
+ summary,
394
+ proposalCreatedAt: ocapProposal.createdAt,
395
+ expiresAt,
396
+ optionalTitle,
397
+ optionalRationaleUrl,
398
+ canonicalProposalStr,
399
+ canonicalProposalObj,
400
+ signer: ocapScored.signer,
401
+ nextVotes: ocapScored.nextVotes,
402
+ quorumReached: ocapScored.quorumReached,
403
+ txSec,
404
+ indexKey,
405
+ docKey,
406
+ existingDocRow,
407
+ existingIndexRow
408
+ });
409
+ }
410
+ const MAX_EVICTED_OCAP_DIGESTS = 512;
411
+ function pruneGovIndexItems(items, priorEvictedOcapDigests, txSec) {
412
+ const out = [...items];
413
+ const evicted = [...priorEvictedOcapDigests];
414
+ const evictedSet = new Set(evicted.map((d) => d.toLowerCase()));
415
+ const recordEvicted = (victim) => {
416
+ if (victim.plane !== "ocap" || !victim.signedDigest) return;
417
+ const lc = victim.signedDigest.toLowerCase();
418
+ if (!evictedSet.has(lc)) {
419
+ evictedSet.add(lc);
420
+ evicted.push(lc);
421
+ while (evicted.length > MAX_EVICTED_OCAP_DIGESTS) {
422
+ const dropped = evicted.shift();
423
+ if (dropped) evictedSet.delete(dropped);
424
+ }
425
+ }
426
+ };
427
+ const now = BigInt(txSec);
428
+ while (out.length > MAX_GOV_INDEX_RING_CAP) {
429
+ let victimIdx = -1;
430
+ for (let i = out.length - 1; i >= 0; i--) if (BigInt(out[i].expiresAt) <= now) {
431
+ victimIdx = i;
432
+ break;
433
+ }
434
+ if (victimIdx === -1) {
435
+ for (let i = out.length - 1; i >= 0; i--) if (out[i].quorumReached) {
436
+ victimIdx = i;
437
+ break;
438
+ }
439
+ }
440
+ if (victimIdx === -1) invalidTx(`Governance index active draft ring capacity (${MAX_GOV_INDEX_RING_CAP}) full`);
441
+ const [victim] = out.splice(victimIdx, 1);
442
+ if (victim) recordEvicted(victim);
443
+ }
444
+ return {
445
+ nextItems: out,
446
+ evictedOcapDigests: evicted
447
+ };
448
+ }
449
+ function finalizeGovVotePlan(o) {
450
+ const existingDoc = parseStoredEvidenceObject(o.existingDocRow);
451
+ const existingIndex = parseStoredEvidenceObject(o.existingIndexRow);
452
+ if (o.existingIndexRow && (existingIndex?.kind !== "bridge-gov-index" || existingIndex?.bridge !== o.bridge)) invalidTx("Corrupted bridge governance index record");
453
+ if (o.existingDocRow && !existingDoc) invalidTx("Corrupted bridge governance document record");
454
+ const existingItems = Array.isArray(existingIndex?.items) ? existingIndex.items : [];
455
+ const priorEvictedOcapDigests = Array.isArray(existingIndex?.evictedOcapDigests) ? existingIndex.evictedOcapDigests.filter((x) => typeof x === "string" && /^0x[0-9a-fA-F]{64}$/.test(x)).map((x) => x.toLowerCase()) : [];
456
+ let proposer = o.signer;
457
+ let createdAt = o.txSec;
458
+ let finalTitle = o.optionalTitle;
459
+ let finalRationaleUrl = o.optionalRationaleUrl;
460
+ const singleSig = existingDoc ? Boolean(existingDoc.singleSig) : o.quorumReached;
461
+ if (existingDoc) {
462
+ if (existingDoc.kind !== "bridge-gov-doc" || existingDoc.bridge !== o.bridge || existingDoc.proposalId !== o.proposalId || existingDoc.plane !== o.plane || (0, _ocap_mcrypto.canonicalJson)(existingDoc.proposal) !== o.canonicalProposalStr) invalidTx("Existing governance proposal document is immutable");
463
+ if (o.optionalTitle !== void 0 && o.optionalTitle !== existingDoc.title) invalidTx("Existing governance proposal title is immutable");
464
+ if (o.optionalRationaleUrl !== void 0 && o.optionalRationaleUrl !== existingDoc.rationaleUrl) invalidTx("Existing governance proposal rationaleUrl is immutable");
465
+ proposer = existingDoc.proposer;
466
+ createdAt = existingDoc.createdAt;
467
+ finalTitle = existingDoc.title;
468
+ finalRationaleUrl = existingDoc.rationaleUrl;
469
+ } else {
470
+ if (o.proposalCreatedAt > BigInt(o.txSec) + BigInt(MAX_GOV_CREATED_AT_SKEW_SEC)) invalidTx("Governance proposal createdAt cannot be more than 300s in the future");
471
+ if (o.expiresAt > BigInt(o.txSec) + BigInt(MAX_GOV_PROPOSAL_TTL_SEC)) invalidTx("Governance proposal expiresAt exceeds maximum 45-day TTL");
472
+ const signedDigestLc = o.signedDigest.toLowerCase();
473
+ if (existingItems.some((item) => item.signedDigest.toLowerCase() === signedDigestLc && item.proposalId !== o.proposalId) || priorEvictedOcapDigests.includes(signedDigestLc)) invalidTx("Duplicate governance signedDigest already bound to another proposal");
474
+ if (existingItems.filter((item) => item.proposer.toLowerCase() === o.signer.toLowerCase() && (!item.quorumReached || item.singleSig === true) && BigInt(item.expiresAt) > BigInt(o.txSec)).length >= MAX_ACTIVE_DRAFTS_PER_PROPOSER) invalidTx(o.quorumReached ? `Proposer ${o.signer} already has ${MAX_SINGLE_SIG_PROPOSALS_PER_PROPOSER} active single-signer proposals` : `Proposer ${o.signer} already has ${MAX_ACTIVE_DRAFTS_PER_PROPOSER} active un-quorumed drafts`);
475
+ }
476
+ const docValue = {
477
+ kind: "bridge-gov-doc",
478
+ version: 1,
479
+ bridge: o.bridge,
480
+ proposalId: o.proposalId,
481
+ signedDigest: o.signedDigest,
482
+ plane: o.plane,
483
+ actionKind: o.actionKind,
484
+ proposer,
485
+ createdAt,
486
+ updatedAt: o.txSec,
487
+ expiresAt: o.expiresAt.toString(10),
488
+ summary: o.summary,
489
+ ...finalTitle !== void 0 ? { title: finalTitle } : {},
490
+ ...finalRationaleUrl !== void 0 ? { rationaleUrl: finalRationaleUrl } : {},
491
+ ...o.certJson !== void 0 ? { cert: o.certJson } : {},
492
+ quorumReached: o.quorumReached,
493
+ ...singleSig ? { singleSig: true } : {},
494
+ proposal: o.canonicalProposalObj,
495
+ votes: o.nextVotes
496
+ };
497
+ const docJsonStr = JSON.stringify(docValue);
498
+ if ((0, _ocap_mcrypto.utf8ByteLength)(docJsonStr) > _ocap_mcrypto.MAX_GOV_DOC_JSON_BYTES) invalidTx(`Governance document exceeds ${_ocap_mcrypto.MAX_GOV_DOC_JSON_BYTES} byte limit`);
499
+ const summaryItem = {
500
+ proposalId: o.proposalId,
501
+ signedDigest: o.signedDigest,
502
+ plane: o.plane,
503
+ actionKind: o.actionKind,
504
+ proposer,
505
+ summary: o.summary,
506
+ ...finalTitle !== void 0 ? { title: finalTitle } : {},
507
+ createdAt,
508
+ updatedAt: o.txSec,
509
+ expiresAt: o.expiresAt.toString(10),
510
+ voteCount: o.nextVotes.length,
511
+ quorumReached: o.quorumReached,
512
+ ...singleSig ? { singleSig: true } : {}
513
+ };
514
+ const { nextItems, evictedOcapDigests } = pruneGovIndexItems(existingDoc ? existingItems.some((i) => i.proposalId === o.proposalId) ? existingItems.map((i) => i.proposalId === o.proposalId ? summaryItem : i) : [summaryItem, ...existingItems] : [summaryItem, ...existingItems.filter((i) => i.proposalId !== o.proposalId)], priorEvictedOcapDigests, o.txSec);
515
+ const createDoc = !o.existingDocRow;
516
+ const createIndex = !o.existingIndexRow;
517
+ return {
518
+ indexKey: o.indexKey,
519
+ docKey: o.docKey,
520
+ createDoc,
521
+ createIndex,
522
+ gasEstimate: {
523
+ create: (createDoc ? 1 : 0) + (createIndex ? 1 : 0),
524
+ update: 1 + (createDoc ? 0 : 1) + (createIndex ? 0 : 1),
525
+ payment: 0
526
+ },
527
+ docData: docJsonStr,
528
+ indexData: JSON.stringify({
529
+ kind: "bridge-gov-index",
530
+ version: 1,
531
+ bridge: o.bridge,
532
+ items: nextItems,
533
+ ...evictedOcapDigests.length > 0 ? { evictedOcapDigests } : {}
534
+ })
535
+ };
536
+ }
537
+ async function commitBridgeGovProposalVote(context, plan) {
538
+ const { tx, statedb, senderState, senderUpdates, updateVaults } = context;
539
+ const writeDoc = plan.createDoc ? statedb.evidence.create(plan.docKey, _ocap_state.evidence.create({
540
+ hash: plan.docKey,
541
+ data: plan.docData
542
+ }, context), context) : statedb.evidence.update(plan.docKey, _ocap_state.evidence.create({
543
+ hash: plan.docKey,
544
+ data: plan.docData
545
+ }, context), context);
546
+ const writeIndex = plan.createIndex ? statedb.evidence.create(plan.indexKey, _ocap_state.evidence.create({
547
+ hash: plan.indexKey,
548
+ data: plan.indexData
549
+ }, context), context) : statedb.evidence.update(plan.indexKey, _ocap_state.evidence.create({
550
+ hash: plan.indexKey,
551
+ data: plan.indexData
552
+ }, context), context);
553
+ const [newSenderState] = await Promise.all([
554
+ statedb.account.update(senderState.address, _ocap_state.account.update(senderState, {
555
+ nonce: tx.nonce,
556
+ ...senderUpdates
557
+ }, context), context),
558
+ writeDoc,
559
+ writeIndex
560
+ ]);
561
+ if (updateVaults) await updateVaults();
562
+ context.senderState = newSenderState;
563
+ }
564
+
565
+ //#endregion
566
+ exports.MAX_ACTIVE_DRAFTS_PER_PROPOSER = MAX_ACTIVE_DRAFTS_PER_PROPOSER;
567
+ exports.MAX_GOV_CREATED_AT_SKEW_SEC = MAX_GOV_CREATED_AT_SKEW_SEC;
568
+ exports.MAX_GOV_INDEX_RING_CAP = MAX_GOV_INDEX_RING_CAP;
569
+ exports.MAX_GOV_PROPOSAL_TTL_SEC = MAX_GOV_PROPOSAL_TTL_SEC;
570
+ exports.MAX_SINGLE_SIG_PROPOSALS_PER_PROPOSER = MAX_SINGLE_SIG_PROPOSALS_PER_PROPOSER;
571
+ exports.commitBridgeGovProposalVote = commitBridgeGovProposalVote;
572
+ exports.isGovProposalVotePayload = isGovProposalVotePayload;
573
+ exports.planBridgeGovProposalVote = planBridgeGovProposalVote;
@@ -0,0 +1,49 @@
1
+ //#region src/protocols/rollup/bridge-governance-vote.d.ts
2
+ declare const MAX_ACTIVE_DRAFTS_PER_PROPOSER = 2;
3
+ declare const MAX_SINGLE_SIG_PROPOSALS_PER_PROPOSER = 2;
4
+ declare const MAX_GOV_INDEX_RING_CAP = 100;
5
+ declare const MAX_GOV_PROPOSAL_TTL_SEC: number;
6
+ declare const MAX_GOV_CREATED_AT_SKEW_SEC = 300;
7
+ interface BridgeGovVoteEntry {
8
+ signer: string;
9
+ role: string;
10
+ signature: string;
11
+ envelope: 'eip712' | 'eip191';
12
+ isSeed: boolean;
13
+ votedAt: number;
14
+ publicKeyHex?: string;
15
+ }
16
+ interface BridgeGovIndexItem {
17
+ proposalId: string;
18
+ signedDigest: string;
19
+ plane: 'ethereum' | 'ocap';
20
+ actionKind: string;
21
+ proposer: string;
22
+ summary: string;
23
+ title?: string;
24
+ createdAt: number;
25
+ updatedAt: number;
26
+ expiresAt: string;
27
+ voteCount: number;
28
+ quorumReached: boolean;
29
+ singleSig?: boolean;
30
+ }
31
+ interface BridgeGovVotePlan {
32
+ indexKey: string;
33
+ docKey: string;
34
+ createDoc: boolean;
35
+ createIndex: boolean;
36
+ gasEstimate: {
37
+ create: number;
38
+ update: number;
39
+ payment: 0;
40
+ };
41
+ docData: string;
42
+ indexData: string;
43
+ }
44
+ type Ctx = any;
45
+ declare function isGovProposalVotePayload(rawData: Record<string, unknown>): boolean;
46
+ declare function planBridgeGovProposalVote(context: Ctx, rawData: Record<string, unknown>): Promise<BridgeGovVotePlan>;
47
+ declare function commitBridgeGovProposalVote(context: Ctx, plan: BridgeGovVotePlan): Promise<void>;
48
+ //#endregion
49
+ export { BridgeGovIndexItem, BridgeGovVoteEntry, BridgeGovVotePlan, MAX_ACTIVE_DRAFTS_PER_PROPOSER, MAX_GOV_CREATED_AT_SKEW_SEC, MAX_GOV_INDEX_RING_CAP, MAX_GOV_PROPOSAL_TTL_SEC, MAX_SINGLE_SIG_PROPOSALS_PER_PROPOSER, commitBridgeGovProposalVote, isGovProposalVotePayload, planBridgeGovProposalVote };
@@ -36,6 +36,7 @@ const migrateSchemaV2 = function MigrateSchemaV2(context, next) {
36
36
  return next();
37
37
  };
38
38
  const TOKEN_AUTHORITY_ERROR = "Only the token authority can cancel a reserve migration";
39
+ const ZERO_ETH_ADDRESS = "0x0000000000000000000000000000000000000000";
39
40
  /** The token authority of #1411: the moderator for the official token, the token issuer otherwise. */
40
41
  function tokenAuthority(context, tokenState) {
41
42
  const { config } = context;
@@ -51,8 +52,10 @@ async function migrateBridgeChecks(context, next) {
51
52
  if (itx.type === "vault") {
52
53
  if (state.closed) throw new _ocap_util_lib_error.CustomError("INVALID_TX", "The rollup is closed");
53
54
  if (!_ocap_state.rollup.isBridgePausedAt(state, txSec)) throw new _ocap_util_lib_error.CustomError("INVALID_TX", "The rollup is not paused");
54
- if (!itx.to || !_ocap_state.rollup.isValidRollupVaultAddress(itx.to, "EVM")) throw new _ocap_util_lib_error.CustomError("INVALID_TX", "Invalid itx: \"to\" Expected wallet type to be \"ethereum\"");
55
- const same = (a) => _ocap_state.rollup.lc(a) === _ocap_state.rollup.lc(itx.to);
55
+ if (!itx.to || typeof itx.to !== "string" || itx.to !== itx.to.trim() || !_ocap_state.rollup.isValidRollupVaultAddress(itx.to, "EVM")) throw new _ocap_util_lib_error.CustomError("INVALID_TX", "Invalid itx: \"to\" Expected wallet type to be \"ethereum\"");
56
+ const nextVault = _ocap_state.rollup.bareEthAddress(itx.to);
57
+ if (nextVault === ZERO_ETH_ADDRESS || nextVault === _ocap_state.rollup.bareEthAddress(state.contractAddress) || nextVault === _ocap_state.rollup.bareEthAddress(body.gateway)) throw new _ocap_util_lib_error.CustomError("INVALID_TX", "vaultAddress must be a non-zero ethereum address distinct from contractAddress and gateway");
58
+ const same = (a) => _ocap_state.rollup.bareEthAddress(a) === nextVault;
56
59
  if (state.vaultAddress && same(state.vaultAddress)) throw new _ocap_util_lib_error.CustomError("INVALID_TX", "can not migrate vault to self");
57
60
  if ((state.vaultHistory || []).some(same)) throw new _ocap_util_lib_error.CustomError("INVALID_TX", "can not migrate vault to history vaults");
58
61
  context.migratePlan = { kind: "vault" };
@@ -85,7 +88,7 @@ async function migrateBridgeChecks(context, next) {
85
88
  if (_ocap_state.rollup.sameAddress(target.address, state.address)) throw new _ocap_util_lib_error.CustomError("INVALID_TX", "Can not migrate a reserve to its own bridge");
86
89
  if (target.closed) throw new _ocap_util_lib_error.CustomError("INVALID_TX", "The migration target is closed");
87
90
  if (target.tokenAddress !== state.tokenAddress) throw new _ocap_util_lib_error.CustomError("INVALID_TX", "The migration target bridges a different OCAP token");
88
- if (tbody.ethChainId !== body.ethChainId || _ocap_state.rollup.lc(target.contractAddress) !== _ocap_state.rollup.lc(state.contractAddress)) throw new _ocap_util_lib_error.CustomError("INVALID_TX", "The migration target bridges a different ethereum token");
91
+ if (tbody.ethChainId !== body.ethChainId || _ocap_state.rollup.bareEthAddress(target.contractAddress) !== _ocap_state.rollup.bareEthAddress(state.contractAddress)) throw new _ocap_util_lib_error.CustomError("INVALID_TX", "The migration target bridges a different ethereum token");
89
92
  if (_ocap_state.rollup.toSeconds(target.context?.genesisTime) < body.finalAt) throw new _ocap_util_lib_error.CustomError("INVALID_TX", "The migration target must be created after the source bridge is final");
90
93
  context.migrateTarget = target;
91
94
  context.migratePlan = { kind: action };
@@ -127,6 +127,11 @@ const VerifyBridgeAuthority = (rule) => function VerifyBridgeAuthorityPipe(conte
127
127
  if (tx.delegator) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", "Delegation is not allowed for bridge governance"));
128
128
  const signatures = (0, _ocap_util_lib_get_list_field.getListField)(context, "tx.signaturesList");
129
129
  if (signatures.some((x) => Boolean(x.delegator))) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", "Delegation is not allowed for bridge governance"));
130
+ if (r.externalAuth) {
131
+ if (signatures.length > 0) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", "Outer tx.signatures are not allowed when governance proof is carried in itx.data"));
132
+ context.signers = [];
133
+ return next();
134
+ }
130
135
  const signerList = signatures.map((x) => x.signer);
131
136
  if (new Set(signerList.map(_ocap_state.rollup.lc)).size !== signerList.length) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", "Duplicate signers are not allowed"));
132
137
  const signers = new Set([_ocap_state.rollup.lc(tx.from), ...signerList.map(_ocap_state.rollup.lc)]);