@ocap/state 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.
- package/esm/index.d.mts +2 -2
- package/esm/index.mjs +2 -2
- package/esm/states/blacklist.mjs +3 -2
- package/esm/states/chain.d.mts +10 -4
- package/esm/states/chain.mjs +51 -3
- package/esm/states/evidence.d.mts +1 -1
- package/esm/states/evidence.mjs +6 -2
- package/esm/states/rollup-bridge.d.mts +9 -9
- package/esm/states/rollup-bridge.mjs +20 -5
- package/esm/states/rollup-v2.d.mts +42 -6
- package/esm/states/rollup-v2.mjs +176 -11
- package/esm/states/rollup.d.mts +3 -3
- package/esm/states/rollup.mjs +6 -3
- package/lib/index.cjs +1 -0
- package/lib/index.d.cts +2 -2
- package/lib/states/blacklist.cjs +3 -2
- package/lib/states/chain.cjs +51 -2
- package/lib/states/chain.d.cts +10 -4
- package/lib/states/evidence.cjs +5 -1
- package/lib/states/evidence.d.cts +1 -1
- package/lib/states/rollup-bridge.cjs +19 -4
- package/lib/states/rollup-bridge.d.cts +9 -9
- package/lib/states/rollup-v2.cjs +179 -11
- package/lib/states/rollup-v2.d.cts +42 -6
- package/lib/states/rollup.cjs +8 -2
- package/lib/states/rollup.d.cts +3 -3
- package/package.json +10 -9
|
@@ -8,32 +8,32 @@ import { v } from "@arcblock/validator";
|
|
|
8
8
|
declare const bridgeSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
9
9
|
readonly address: any;
|
|
10
10
|
readonly tokenAddress: any;
|
|
11
|
-
readonly contractAddress: any
|
|
12
|
-
readonly vaultAddress: v.
|
|
13
|
-
readonly migrateHistory: v.OptionalSchema<v.ArraySchema<
|
|
14
|
-
readonly vaultHistory: v.OptionalSchema<v.ArraySchema<
|
|
11
|
+
readonly contractAddress: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, v.ErrorMessage<v.CheckIssue<TInput$1>> | undefined>, any]>;
|
|
12
|
+
readonly vaultAddress: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, v.ErrorMessage<v.CheckIssue<TInput$1>> | undefined>, any]>;
|
|
13
|
+
readonly migrateHistory: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, v.ErrorMessage<v.CheckIssue<TInput$1>> | undefined>, any]>, undefined>, readonly []>;
|
|
14
|
+
readonly vaultHistory: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, v.ErrorMessage<v.CheckIssue<TInput$1>> | undefined>, any]>, undefined>, readonly []>;
|
|
15
15
|
readonly paused: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
16
16
|
readonly closed: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
17
17
|
readonly seedValidators: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
|
|
18
18
|
readonly pk: v.StringSchema<undefined>;
|
|
19
|
-
readonly address: any
|
|
19
|
+
readonly address: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, v.ErrorMessage<v.CheckIssue<TInput$1>> | undefined>, any]>;
|
|
20
20
|
readonly endpoint: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Must be a valid HTTP/HTTPS URL">]>;
|
|
21
21
|
}, undefined>, undefined>, v.MinLengthAction<{
|
|
22
22
|
pk: string;
|
|
23
|
-
readonly address
|
|
23
|
+
readonly address: any;
|
|
24
24
|
endpoint: string;
|
|
25
25
|
}[], 1, undefined>, v.MaxLengthAction<{
|
|
26
26
|
pk: string;
|
|
27
|
-
readonly address
|
|
27
|
+
readonly address: any;
|
|
28
28
|
endpoint: string;
|
|
29
29
|
}[], 1, undefined>]>;
|
|
30
30
|
readonly validators: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
|
|
31
31
|
readonly pk: v.StringSchema<undefined>;
|
|
32
|
-
readonly address: any
|
|
32
|
+
readonly address: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, v.ErrorMessage<v.CheckIssue<TInput$1>> | undefined>, any]>;
|
|
33
33
|
readonly endpoint: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Must be a valid HTTP/HTTPS URL">]>;
|
|
34
34
|
}, undefined>, undefined>, v.MaxLengthAction<{
|
|
35
35
|
pk: string;
|
|
36
|
-
readonly address
|
|
36
|
+
readonly address: any;
|
|
37
37
|
endpoint: string;
|
|
38
38
|
}[], 24, undefined>]>, readonly []>;
|
|
39
39
|
readonly minSignerCount: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>]>;
|
package/lib/states/rollup-v2.cjs
CHANGED
|
@@ -2,6 +2,7 @@ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
|
2
2
|
let _arcblock_did = require("@arcblock/did");
|
|
3
3
|
let _arcblock_did_lib_type = require("@arcblock/did/lib/type");
|
|
4
4
|
let _ocap_util_lib_error = require("@ocap/util/lib/error");
|
|
5
|
+
let _ocap_mcrypto = require("@ocap/mcrypto");
|
|
5
6
|
|
|
6
7
|
//#region src/states/rollup-v2.ts
|
|
7
8
|
/**
|
|
@@ -44,7 +45,8 @@ const BRIDGE_CREATE_KEYS = [
|
|
|
44
45
|
"pausers",
|
|
45
46
|
"ethOwnerAttestation",
|
|
46
47
|
"consents",
|
|
47
|
-
"initialReserve"
|
|
48
|
+
"initialReserve",
|
|
49
|
+
"evmGovernance"
|
|
48
50
|
];
|
|
49
51
|
/** Keys `update_rollup` may patch. `proposeOwner` / `cancelOwnerProposal` / `cancelPendingEpoch` are actions. */
|
|
50
52
|
const BRIDGE_PATCH_VALUE_KEYS = [
|
|
@@ -55,13 +57,15 @@ const BRIDGE_PATCH_VALUE_KEYS = [
|
|
|
55
57
|
"refundDailyCap",
|
|
56
58
|
"releaseGrace",
|
|
57
59
|
"refundDelay",
|
|
58
|
-
"pausers"
|
|
60
|
+
"pausers",
|
|
61
|
+
"evmGovernance"
|
|
59
62
|
];
|
|
60
63
|
const BRIDGE_PATCH_ACTION_KEYS = [
|
|
61
64
|
"cancelPendingEpoch",
|
|
62
65
|
"proposeOwner",
|
|
63
66
|
"cancelOwnerProposal"
|
|
64
67
|
];
|
|
68
|
+
const BRIDGE_PATCH_PROOF_KEYS = ["evmGovernanceSync"];
|
|
65
69
|
const bad = (message) => {
|
|
66
70
|
throw new _ocap_util_lib_error.CustomError("INVALID_ROLLUP_PROPS", message);
|
|
67
71
|
};
|
|
@@ -86,8 +90,10 @@ const toSeconds = (iso) => {
|
|
|
86
90
|
return Math.floor(ms / 1e3);
|
|
87
91
|
};
|
|
88
92
|
const lc = (address) => String(address || "").toLowerCase();
|
|
93
|
+
/** Strip a case-insensitive `did:abt:` prefix and whitespace, returning a lowercase bare Ethereum address. */
|
|
94
|
+
const bareEthAddress = (a) => String(a ?? "").trim().replace(/^did:abt:/i, "").toLowerCase();
|
|
89
95
|
/** Ethereum addresses compare case-insensitively; OCAP addresses may carry a DID prefix. */
|
|
90
|
-
const sameAddress = (a, b) => typeof a === "string" && typeof b === "string" && !!a &&
|
|
96
|
+
const sameAddress = (a, b) => typeof a === "string" && typeof b === "string" && !!bareEthAddress(a) && bareEthAddress(a) === bareEthAddress(b);
|
|
91
97
|
const isDecimal = (s) => typeof s === "string" && /^(0|[1-9][0-9]*)$/.test(s);
|
|
92
98
|
const isUint = (n, max = Number.MAX_SAFE_INTEGER) => typeof n === "number" && Number.isInteger(n) && n >= 0 && n <= max;
|
|
93
99
|
const isEthAddr = (s) => typeof s === "string" && /^0x[0-9a-fA-F]{40}$/.test(s) && !/^0x0{40}$/.test(s);
|
|
@@ -245,11 +251,103 @@ function validatePausers(pausers) {
|
|
|
245
251
|
if (!Array.isArray(pausers) || pausers.length > BRIDGE_MAX_PAUSERS) bad(`pausers must be an array of at most ${BRIDGE_MAX_PAUSERS} addresses`);
|
|
246
252
|
const seen = /* @__PURE__ */ new Set();
|
|
247
253
|
for (const p of pausers) {
|
|
248
|
-
if (typeof p !== "string" || !p || p.length > 128 ||
|
|
254
|
+
if (typeof p !== "string" || !p || p.length > 128 || /^did:abt:/i.test(p)) bad("pausers must be address strings without a DID prefix");
|
|
249
255
|
if (seen.has(lc(p))) bad("pausers must be unique");
|
|
250
256
|
seen.add(lc(p));
|
|
251
257
|
}
|
|
252
258
|
}
|
|
259
|
+
function validateStrictEvmGovernance(raw, errorCode) {
|
|
260
|
+
const fail = (msg) => {
|
|
261
|
+
throw new _ocap_util_lib_error.CustomError(errorCode, msg);
|
|
262
|
+
};
|
|
263
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) fail("evmGovernance must be an object");
|
|
264
|
+
const checkStrictSet = (setRaw, label) => {
|
|
265
|
+
if (!setRaw || typeof setRaw !== "object" || Array.isArray(setRaw)) fail(`${label} must be an object`);
|
|
266
|
+
const s = setRaw;
|
|
267
|
+
if (typeof s.address !== "string" || !ETH_ADDRESS_FORMAT.test(s.address) || s.address !== (0, _arcblock_did_lib_type.toChecksumAddress)(s.address)) fail(`${label}.address must be an EIP-55 checksummed non-zero ethereum address`);
|
|
268
|
+
for (const field of ["signers", "seeds"]) {
|
|
269
|
+
if (!Array.isArray(s[field]) || s[field].length === 0) fail(`${label}.${field} must be a non-empty array`);
|
|
270
|
+
let prevBig = -1n;
|
|
271
|
+
for (let i = 0; i < s[field].length; i++) {
|
|
272
|
+
const addr = s[field][i];
|
|
273
|
+
if (typeof addr !== "string" || !ETH_ADDRESS_FORMAT.test(addr) || addr !== (0, _arcblock_did_lib_type.toChecksumAddress)(addr)) fail(`${label}.${field}[${i}] must be an EIP-55 checksummed non-zero ethereum address`);
|
|
274
|
+
const curBig = BigInt(addr);
|
|
275
|
+
if (curBig <= 0n || curBig <= prevBig) fail(`${label}.${field} must be strictly ascending unique non-zero EIP-55 addresses`);
|
|
276
|
+
prevBig = curBig;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
const r = raw;
|
|
281
|
+
checkStrictSet(r.signerManager, "evmGovernance.signerManager");
|
|
282
|
+
if (r.vaultSignerManager !== null) checkStrictSet(r.vaultSignerManager, "evmGovernance.vaultSignerManager");
|
|
283
|
+
try {
|
|
284
|
+
return (0, _ocap_mcrypto.validateEvmGovernanceRosterConfig)(raw);
|
|
285
|
+
} catch (err) {
|
|
286
|
+
return fail(`invalid evmGovernance: ${err.message}`);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Verifies a `BridgeEvmGovernanceSync` EIP-712 proof signed by the OLD `prev` EVM governance roster (`signerManager`,
|
|
291
|
+
* and `vaultSignerManager` when distinct and modified), bound to `(ocapChainId, bridge, next.version, configHash(next))`
|
|
292
|
+
* and `txSec < expiresAt`.
|
|
293
|
+
*/
|
|
294
|
+
function verifyBridgeEvmGovernanceSync(o) {
|
|
295
|
+
const prev = o.prev;
|
|
296
|
+
if (!prev) throw new _ocap_util_lib_error.CustomError("INVALID_ROLLUP_UPDATE", "evmGovernanceSync requires an existing evmGovernance roster; bootstrap from null needs owner + quorum");
|
|
297
|
+
if (o.next.version !== prev.version + 1) badUpdate(`evmGovernance.version must equal ${prev.version + 1}, got ${o.next.version}`);
|
|
298
|
+
if (!o.proof || typeof o.proof !== "object" || Array.isArray(o.proof)) badUpdate("evmGovernanceSync must be { expiresAt, signatures }");
|
|
299
|
+
const p = o.proof;
|
|
300
|
+
for (const k of Object.keys(p)) if (k !== "expiresAt" && k !== "signatures") badUpdate(`unknown key in evmGovernanceSync: ${k}`);
|
|
301
|
+
let expiresAt;
|
|
302
|
+
try {
|
|
303
|
+
expiresAt = (0, _ocap_mcrypto.parseDecimalBigInt)(typeof p.expiresAt === "number" && Number.isSafeInteger(p.expiresAt) ? String(p.expiresAt) : p.expiresAt, "evmGovernanceSync.expiresAt", 1n, (1n << 64n) - 1n);
|
|
304
|
+
} catch (err) {
|
|
305
|
+
badUpdate(err.message);
|
|
306
|
+
}
|
|
307
|
+
if (BigInt(o.txSec) >= expiresAt) badUpdate("evmGovernanceSync proof has expired");
|
|
308
|
+
if (!Array.isArray(p.signatures) || p.signatures.length === 0 || p.signatures.length > 64) badUpdate("evmGovernanceSync.signatures must contain 1..64 signatures");
|
|
309
|
+
const configHash = (0, _ocap_mcrypto.computeEvmGovernanceConfigHash)(o.next);
|
|
310
|
+
const msg = {
|
|
311
|
+
bridge: o.bridge,
|
|
312
|
+
version: BigInt(o.next.version),
|
|
313
|
+
configHash,
|
|
314
|
+
expiresAt
|
|
315
|
+
};
|
|
316
|
+
const recoveredSigners = /* @__PURE__ */ new Set();
|
|
317
|
+
for (const sig of p.signatures) {
|
|
318
|
+
if (typeof sig !== "string") badUpdate("evmGovernanceSync signature must be a 0x hex string");
|
|
319
|
+
let signer;
|
|
320
|
+
try {
|
|
321
|
+
signer = (0, _ocap_mcrypto.recoverBridgeEvmGovernanceSyncSigner)(o.ocapChainId, msg, sig).signer;
|
|
322
|
+
} catch (err) {
|
|
323
|
+
throw new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", `Invalid evmGovernanceSync signature: ${err.message}`);
|
|
324
|
+
}
|
|
325
|
+
if (recoveredSigners.has(signer)) throw new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", `Duplicate evmGovernanceSync signature from ${signer}`);
|
|
326
|
+
recoveredSigners.add(signer);
|
|
327
|
+
}
|
|
328
|
+
const smChanged = (0, _ocap_mcrypto.canonicalJson)(prev.signerManager) !== (0, _ocap_mcrypto.canonicalJson)(o.next.signerManager);
|
|
329
|
+
const vsmChanged = (0, _ocap_mcrypto.canonicalJson)(prev.vaultSignerManager) !== (0, _ocap_mcrypto.canonicalJson)(o.next.vaultSignerManager);
|
|
330
|
+
if (!smChanged && !vsmChanged) badUpdate("evmGovernanceSync must modify signerManager or vaultSignerManager");
|
|
331
|
+
if (prev.vaultSignerManager !== null && o.next.vaultSignerManager === null) badUpdate("evmGovernance.vaultSignerManager can not be set to null once configured");
|
|
332
|
+
const distinctPrevVsm = prev.vaultSignerManager !== null && prev.vaultSignerManager.address !== prev.signerManager.address;
|
|
333
|
+
const requiredSets = [{
|
|
334
|
+
label: "signerManager",
|
|
335
|
+
roster: prev.signerManager
|
|
336
|
+
}];
|
|
337
|
+
if (distinctPrevVsm && vsmChanged && prev.vaultSignerManager !== null) requiredSets.push({
|
|
338
|
+
label: "vaultSignerManager",
|
|
339
|
+
roster: prev.vaultSignerManager
|
|
340
|
+
});
|
|
341
|
+
const allowedAll = /* @__PURE__ */ new Set();
|
|
342
|
+
for (const { roster } of requiredSets) for (const s of roster.signers) allowedAll.add(s);
|
|
343
|
+
for (const signer of recoveredSigners) if (!allowedAll.has(signer)) throw new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", `evmGovernanceSync signer ${signer} is not in the previous EVM governance roster`);
|
|
344
|
+
for (const { label, roster } of requiredSets) {
|
|
345
|
+
const validCount = roster.signers.filter((s) => recoveredSigners.has(s)).length;
|
|
346
|
+
const seedCount = roster.seeds.filter((s) => recoveredSigners.has(s)).length;
|
|
347
|
+
if (validCount < roster.threshold) throw new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", `evmGovernanceSync requires at least ${roster.threshold} ${label} signatures, got ${validCount}`);
|
|
348
|
+
if (seedCount < roster.seedThreshold) throw new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", `evmGovernanceSync requires at least ${roster.seedThreshold} ${label} seed signatures, got ${seedCount}`);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
253
351
|
/** Full structural validation of a stored v2 body. */
|
|
254
352
|
function validateBridgeBody(body) {
|
|
255
353
|
if (!body || typeof body !== "object" || body.version !== BRIDGE_VERSION) bad("bridge body version must be 2");
|
|
@@ -288,6 +386,7 @@ function validateBridgeBody(body) {
|
|
|
288
386
|
if (body.depositCutoffEthBlock !== null && !isDecimal(body.depositCutoffEthBlock)) bad("depositCutoffEthBlock must be null or a decimal string");
|
|
289
387
|
if (body.migratedTo !== null && typeof body.migratedTo !== "string") bad("migratedTo must be null or an address");
|
|
290
388
|
if (body.migratedAmount !== void 0 && body.migratedAmount !== null && !isDecimal(body.migratedAmount)) bad("migratedAmount must be null or a decimal string");
|
|
389
|
+
if (body.evmGovernance !== void 0 && body.evmGovernance !== null) validateStrictEvmGovernance(body.evmGovernance, "INVALID_ROLLUP_PROPS");
|
|
291
390
|
const att = body.ethOwnerAttestation;
|
|
292
391
|
if (!att || !isEthAddr(att.address) || typeof att.signature !== "string" || !/^0x[0-9a-fA-F]{130}$/.test(att.signature)) bad("ethOwnerAttestation must be { address, signature }");
|
|
293
392
|
return body;
|
|
@@ -395,6 +494,34 @@ function assertBridgeTransition(prev, next, txSec) {
|
|
|
395
494
|
if (pa !== null && (na === null || BigInt(na) > BigInt(pa))) badUpdate("migratedAmount can only decrease");
|
|
396
495
|
if (p.closingAt !== null && (p.closingAt !== nb.closingAt || p.finalAt !== nb.finalAt)) badUpdate("closingAt and finalAt are written once");
|
|
397
496
|
if (p.closingAt !== null && (added > 0 || removed > 0)) badUpdate("epochs are frozen after closingAt");
|
|
497
|
+
if (JSON.stringify(prev.migrateHistory ?? []) !== JSON.stringify(next.migrateHistory ?? [])) badUpdate("migrateHistory is immutable in a v2 bridge");
|
|
498
|
+
const prevGov = p.evmGovernance ?? null;
|
|
499
|
+
const nextGov = nb.evmGovernance ?? null;
|
|
500
|
+
if ((0, _ocap_mcrypto.canonicalJson)(prevGov) !== (0, _ocap_mcrypto.canonicalJson)(nextGov)) {
|
|
501
|
+
if (p.closingAt !== null) badUpdate("evmGovernance is frozen after closingAt");
|
|
502
|
+
if (prevGov !== null && nextGov === null) badUpdate("evmGovernance can not be cleared once configured");
|
|
503
|
+
if (nextGov !== null) {
|
|
504
|
+
validateStrictEvmGovernance(nextGov, "INVALID_ROLLUP_UPDATE");
|
|
505
|
+
if (prevGov?.vaultSignerManager !== null && prevGov?.vaultSignerManager !== void 0 && nextGov.vaultSignerManager === null) badUpdate("evmGovernance.vaultSignerManager can not be set to null once configured");
|
|
506
|
+
const nextVault = bareEthAddress(next.vaultAddress);
|
|
507
|
+
if (nextVault && !/^0x0{40}$/.test(nextVault) && nextGov.vaultSignerManager === null) badUpdate("evmGovernance.vaultSignerManager is required when vaultAddress is configured");
|
|
508
|
+
const expectedVersion = prevGov ? prevGov.version + 1 : 1;
|
|
509
|
+
if (nextGov.version !== expectedVersion) badUpdate(`evmGovernance.version must equal ${expectedVersion}, got ${nextGov.version}`);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
const prevHistory = Array.isArray(prev.vaultHistory) ? prev.vaultHistory : [];
|
|
513
|
+
const nextHistory = Array.isArray(next.vaultHistory) ? next.vaultHistory : [];
|
|
514
|
+
if (prev.vaultAddress === next.vaultAddress) {
|
|
515
|
+
if (JSON.stringify(prevHistory) !== JSON.stringify(nextHistory)) badUpdate("vaultHistory only changes when vaultAddress migrates");
|
|
516
|
+
} else {
|
|
517
|
+
if (p.closingAt !== null || prev.closed) badUpdate("vaultAddress is frozen after closingAt");
|
|
518
|
+
if (txSec !== null ? !isBridgePausedAt(prev, txSec) : !prev.paused) badUpdate("vaultAddress can only change while the bridge is paused");
|
|
519
|
+
if (typeof prev.vaultAddress !== "string" || !prev.vaultAddress) badUpdate("previous vaultAddress is missing");
|
|
520
|
+
if (typeof next.vaultAddress !== "string" || !next.vaultAddress || next.vaultAddress !== next.vaultAddress.trim()) badUpdate("vaultAddress must be a trimmed non-empty ethereum address");
|
|
521
|
+
if (sameAddress(prev.vaultAddress, next.vaultAddress)) badUpdate("can not migrate vault to self");
|
|
522
|
+
if (prevHistory.some((h) => sameAddress(h, next.vaultAddress))) badUpdate("can not migrate vault to history vaults");
|
|
523
|
+
if (JSON.stringify(nextHistory) !== JSON.stringify([...prevHistory, prev.vaultAddress])) badUpdate("vaultHistory must append the previous vaultAddress");
|
|
524
|
+
}
|
|
398
525
|
}
|
|
399
526
|
/** Parse and validate `itx.data.value` of a v2 `create_rollup` (pure shape checks; signatures are checked by the protocol). */
|
|
400
527
|
function parseBridgeCreateData(value) {
|
|
@@ -417,6 +544,11 @@ function parseBridgeCreateData(value) {
|
|
|
417
544
|
if (!isDecimal(initialReserve)) bad("initialReserve must be a decimal string");
|
|
418
545
|
const att = value.ethOwnerAttestation;
|
|
419
546
|
if (!att || !isEthAddr(att.address)) bad("ethOwnerAttestation.address is required");
|
|
547
|
+
let evmGovernance = null;
|
|
548
|
+
if (value.evmGovernance !== void 0 && value.evmGovernance !== null) {
|
|
549
|
+
evmGovernance = validateStrictEvmGovernance(value.evmGovernance, "INVALID_ROLLUP_PROPS");
|
|
550
|
+
if (evmGovernance.version !== 1) bad("initial evmGovernance.version must be 1");
|
|
551
|
+
}
|
|
420
552
|
const body = {
|
|
421
553
|
version: BRIDGE_VERSION,
|
|
422
554
|
ethChainId: value.ethChainId,
|
|
@@ -433,6 +565,7 @@ function parseBridgeCreateData(value) {
|
|
|
433
565
|
epochs: [epoch],
|
|
434
566
|
salt: typeof value.salt === "string" ? lc(value.salt) : value.salt,
|
|
435
567
|
pausers: value.pausers === void 0 ? [] : value.pausers,
|
|
568
|
+
evmGovernance,
|
|
436
569
|
ethOwnerAttestation: {
|
|
437
570
|
address: lc(att.address),
|
|
438
571
|
signature: att.signature
|
|
@@ -454,17 +587,26 @@ function parseBridgeCreateData(value) {
|
|
|
454
587
|
}
|
|
455
588
|
/**
|
|
456
589
|
* Validate an `update_rollup` patch (`itx.data.value`) against the allow-list and compute the resulting body.
|
|
457
|
-
* `proposeOwner` is its own transaction kind (2/3 quorum), `cancelOwnerProposal` needs the current owner alone,
|
|
590
|
+
* `proposeOwner` is its own transaction kind (2/3 quorum), `cancelOwnerProposal` needs the current owner alone,
|
|
591
|
+
* standalone `{ evmGovernance, evmGovernanceSync }` is verified against the previous EVM governance roster, and anything
|
|
458
592
|
* else needs owner + quorum. Frozen keys (version, epochs, reserve, gateway, ethChainId, token fields...) are rejected.
|
|
459
593
|
*/
|
|
460
|
-
function planBridgePatch(body, patch, txSec) {
|
|
594
|
+
function planBridgePatch(body, patch, txSec, syncCtx) {
|
|
461
595
|
if (!patch || typeof patch !== "object" || Array.isArray(patch)) badUpdate("update data must be a typed patch object");
|
|
462
596
|
const keys = Object.keys(patch);
|
|
463
597
|
if (keys.length === 0) badUpdate("update patch is empty");
|
|
464
|
-
const allowed = [
|
|
598
|
+
const allowed = [
|
|
599
|
+
...BRIDGE_PATCH_VALUE_KEYS,
|
|
600
|
+
...BRIDGE_PATCH_ACTION_KEYS,
|
|
601
|
+
...BRIDGE_PATCH_PROOF_KEYS
|
|
602
|
+
];
|
|
465
603
|
for (const k of keys) if (!allowed.includes(k)) badUpdate(`key ${k} can not be updated in a v2 bridge`);
|
|
466
604
|
const has = (k) => patch[k] !== void 0;
|
|
467
|
-
|
|
605
|
+
if (has("evmGovernanceSync") && !has("evmGovernance")) badUpdate("evmGovernanceSync requires evmGovernance in patch");
|
|
606
|
+
const next = {
|
|
607
|
+
...body,
|
|
608
|
+
evmGovernance: body.evmGovernance ?? null
|
|
609
|
+
};
|
|
468
610
|
const ownerOnly = has("proposeOwner") || has("cancelOwnerProposal");
|
|
469
611
|
if (body.closingAt !== null && (!ownerOnly || body.migratedTo !== null)) badUpdate(body.migratedTo !== null ? "the reserve has migrated: the bridge is frozen" : "a closed bridge is frozen");
|
|
470
612
|
if (has("proposeOwner") || has("cancelOwnerProposal")) {
|
|
@@ -526,6 +668,28 @@ function planBridgePatch(body, patch, txSec) {
|
|
|
526
668
|
cancelledEpoch = pending;
|
|
527
669
|
next.epochs = body.epochs.slice(0, -1);
|
|
528
670
|
}
|
|
671
|
+
if (has("evmGovernance")) {
|
|
672
|
+
if (patch.evmGovernance === null) badUpdate("evmGovernance can not be set to null via update_rollup");
|
|
673
|
+
const prevGov = body.evmGovernance ?? null;
|
|
674
|
+
const validatedGov = validateStrictEvmGovernance(patch.evmGovernance, "INVALID_ROLLUP_UPDATE");
|
|
675
|
+
if (prevGov?.vaultSignerManager !== null && prevGov?.vaultSignerManager !== void 0 && validatedGov.vaultSignerManager === null) badUpdate("evmGovernance.vaultSignerManager can not be set to null once configured");
|
|
676
|
+
const vaultAddr = syncCtx?.vaultAddress ? bareEthAddress(syncCtx.vaultAddress) : "";
|
|
677
|
+
if (vaultAddr && !/^0x0{40}$/.test(vaultAddr) && validatedGov.vaultSignerManager === null) badUpdate("evmGovernance.vaultSignerManager is required when vaultAddress is configured");
|
|
678
|
+
const expectedVersion = prevGov ? prevGov.version + 1 : 1;
|
|
679
|
+
if (validatedGov.version !== expectedVersion) badUpdate(`evmGovernance.version must equal ${expectedVersion}, got ${validatedGov.version}`);
|
|
680
|
+
if (has("evmGovernanceSync")) {
|
|
681
|
+
if (!syncCtx) throw new _ocap_util_lib_error.CustomError("INVALID_ROLLUP_UPDATE", "evmGovernanceSync verification requires chain and bridge context");
|
|
682
|
+
verifyBridgeEvmGovernanceSync({
|
|
683
|
+
ocapChainId: syncCtx.ocapChainId,
|
|
684
|
+
bridge: syncCtx.bridge,
|
|
685
|
+
prev: prevGov,
|
|
686
|
+
next: validatedGov,
|
|
687
|
+
proof: patch.evmGovernanceSync,
|
|
688
|
+
txSec
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
next.evmGovernance = validatedGov;
|
|
692
|
+
}
|
|
529
693
|
try {
|
|
530
694
|
validateAmounts(next);
|
|
531
695
|
validateDelays(next);
|
|
@@ -533,9 +697,10 @@ function planBridgePatch(body, patch, txSec) {
|
|
|
533
697
|
badUpdate(err.message);
|
|
534
698
|
}
|
|
535
699
|
return {
|
|
536
|
-
kind: "owner-quorum",
|
|
700
|
+
kind: has("evmGovernance") && has("evmGovernanceSync") && keys.every((k) => k === "evmGovernance" || k === "evmGovernanceSync") ? "evm-governance-sync" : "owner-quorum",
|
|
537
701
|
body: next,
|
|
538
|
-
cancelledEpoch
|
|
702
|
+
cancelledEpoch,
|
|
703
|
+
...has("evmGovernanceSync") ? { evmGovernanceSync: patch.evmGovernanceSync } : {}
|
|
539
704
|
};
|
|
540
705
|
}
|
|
541
706
|
/** Epoch rules of §v2.2: `epoch = last + 1`, lead window, `2*threshold > n`, `n >= 3`, at most one pending epoch. */
|
|
@@ -606,6 +771,7 @@ exports.BRIDGE_MIN_EPOCH_LEAD = BRIDGE_MIN_EPOCH_LEAD;
|
|
|
606
771
|
exports.BRIDGE_MIN_VALIDATORS = BRIDGE_MIN_VALIDATORS;
|
|
607
772
|
exports.BRIDGE_OWNER_TIMELOCK = BRIDGE_OWNER_TIMELOCK;
|
|
608
773
|
exports.BRIDGE_PATCH_ACTION_KEYS = BRIDGE_PATCH_ACTION_KEYS;
|
|
774
|
+
exports.BRIDGE_PATCH_PROOF_KEYS = BRIDGE_PATCH_PROOF_KEYS;
|
|
609
775
|
exports.BRIDGE_PATCH_VALUE_KEYS = BRIDGE_PATCH_VALUE_KEYS;
|
|
610
776
|
exports.BRIDGE_RESERVE_MIGRATION_WINDOW = BRIDGE_RESERVE_MIGRATION_WINDOW;
|
|
611
777
|
exports.BRIDGE_V1_ZERO_FIELDS = BRIDGE_V1_ZERO_FIELDS;
|
|
@@ -614,6 +780,7 @@ exports.activeEpochAt = activeEpochAt;
|
|
|
614
780
|
exports.applyLonePause = applyLonePause;
|
|
615
781
|
exports.assertBridgeTransition = assertBridgeTransition;
|
|
616
782
|
exports.assertV1FieldsUnused = assertV1FieldsUnused;
|
|
783
|
+
exports.bareEthAddress = bareEthAddress;
|
|
617
784
|
exports.effectiveOwnerAt = effectiveOwnerAt;
|
|
618
785
|
exports.getBridgeBody = getBridgeBody;
|
|
619
786
|
exports.isBridgeFinalAt = isBridgeFinalAt;
|
|
@@ -634,4 +801,5 @@ exports.planMembership = planMembership;
|
|
|
634
801
|
exports.sameAddress = sameAddress;
|
|
635
802
|
exports.syncBridgeView = syncBridgeView;
|
|
636
803
|
exports.toSeconds = toSeconds;
|
|
637
|
-
exports.validateBridgeBody = validateBridgeBody;
|
|
804
|
+
exports.validateBridgeBody = validateBridgeBody;
|
|
805
|
+
exports.verifyBridgeEvmGovernanceSync = verifyBridgeEvmGovernanceSync;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { EvmGovernanceRosterConfig, EvmSignerManagerRoster } from "@ocap/mcrypto";
|
|
2
|
+
|
|
1
3
|
//#region src/states/rollup-v2.d.ts
|
|
2
4
|
declare const BRIDGE_MIN_EPOCH_LEAD = 3600;
|
|
3
5
|
declare const BRIDGE_MAX_EPOCH_LEAD: number;
|
|
@@ -11,10 +13,11 @@ declare const BRIDGE_MAX_VALIDATORS = 16;
|
|
|
11
13
|
declare const BRIDGE_MAX_DELAY: number;
|
|
12
14
|
declare const BRIDGE_VERSION = 2;
|
|
13
15
|
/** Keys a creator may put in `itx.data.value` of a v2 `create_rollup`. Everything else is derived by the chain. */
|
|
14
|
-
declare const BRIDGE_CREATE_KEYS: readonly ["version", "ethChainId", "gateway", "minDeposit", "minWithdraw", "maxWithdraw", "withdrawFee", "releaseDailyCap", "refundDailyCap", "releaseGrace", "refundDelay", "transitionPeriod", "epochs", "salt", "pausers", "ethOwnerAttestation", "consents", "initialReserve"];
|
|
16
|
+
declare const BRIDGE_CREATE_KEYS: readonly ["version", "ethChainId", "gateway", "minDeposit", "minWithdraw", "maxWithdraw", "withdrawFee", "releaseDailyCap", "refundDailyCap", "releaseGrace", "refundDelay", "transitionPeriod", "epochs", "salt", "pausers", "ethOwnerAttestation", "consents", "initialReserve", "evmGovernance"];
|
|
15
17
|
/** Keys `update_rollup` may patch. `proposeOwner` / `cancelOwnerProposal` / `cancelPendingEpoch` are actions. */
|
|
16
|
-
declare const BRIDGE_PATCH_VALUE_KEYS: readonly ["minDeposit", "minWithdraw", "maxWithdraw", "releaseDailyCap", "refundDailyCap", "releaseGrace", "refundDelay", "pausers"];
|
|
18
|
+
declare const BRIDGE_PATCH_VALUE_KEYS: readonly ["minDeposit", "minWithdraw", "maxWithdraw", "releaseDailyCap", "refundDailyCap", "releaseGrace", "refundDelay", "pausers", "evmGovernance"];
|
|
17
19
|
declare const BRIDGE_PATCH_ACTION_KEYS: readonly ["cancelPendingEpoch", "proposeOwner", "cancelOwnerProposal"];
|
|
20
|
+
declare const BRIDGE_PATCH_PROOF_KEYS: readonly ["evmGovernanceSync"];
|
|
18
21
|
interface BridgeEpoch {
|
|
19
22
|
epoch: number;
|
|
20
23
|
activeFrom: number;
|
|
@@ -28,6 +31,12 @@ interface BridgeMember {
|
|
|
28
31
|
pk: string;
|
|
29
32
|
endpoint: string;
|
|
30
33
|
}
|
|
34
|
+
type BridgeEvmGovernance = EvmGovernanceRosterConfig;
|
|
35
|
+
type BridgeEvmSignerSet = EvmSignerManagerRoster;
|
|
36
|
+
interface BridgeEvmGovernanceSyncProof {
|
|
37
|
+
expiresAt: number | string;
|
|
38
|
+
signatures: string[];
|
|
39
|
+
}
|
|
31
40
|
interface BridgeBodyV2 {
|
|
32
41
|
version: 2;
|
|
33
42
|
owner: string;
|
|
@@ -81,6 +90,11 @@ interface BridgeBodyV2 {
|
|
|
81
90
|
* Absent on bodies written before #1505 (read as null).
|
|
82
91
|
*/
|
|
83
92
|
migratedAmount?: string | null;
|
|
93
|
+
/**
|
|
94
|
+
* Registered Ethereum `SignerManagerV2` governance roster (#1880). Stored as `null` when unconfigured (never `undefined`)
|
|
95
|
+
* so `canonicalJson(body)` in off-chain readers stays deterministic.
|
|
96
|
+
*/
|
|
97
|
+
evmGovernance?: BridgeEvmGovernance | null;
|
|
84
98
|
ethOwnerAttestation: {
|
|
85
99
|
address: string;
|
|
86
100
|
signature: string;
|
|
@@ -94,6 +108,8 @@ declare function isBridgeV2(state: unknown): boolean;
|
|
|
94
108
|
declare function getBridgeBody(state: unknown): BridgeBodyV2 | null;
|
|
95
109
|
declare const toSeconds: (iso: string | number | Date | undefined | null) => number;
|
|
96
110
|
declare const lc: (address: string) => string;
|
|
111
|
+
/** Strip a case-insensitive `did:abt:` prefix and whitespace, returning a lowercase bare Ethereum address. */
|
|
112
|
+
declare const bareEthAddress: (a: unknown) => string;
|
|
97
113
|
/** Ethereum addresses compare case-insensitively; OCAP addresses may carry a DID prefix. */
|
|
98
114
|
declare const sameAddress: (a: unknown, b: unknown) => boolean;
|
|
99
115
|
/** `epochAt(t) = max{ e : activeFrom(e) <= t }`, undefined (null) before the first epoch. */
|
|
@@ -127,6 +143,19 @@ declare function syncBridgeView(state: AnyState, txSec: number): AnyState;
|
|
|
127
143
|
* has run out rewrites BOTH `owner` and `seedValidators`. Returns the (possibly new) state; never mutates its input.
|
|
128
144
|
*/
|
|
129
145
|
declare function materializeBridgeAt(state: AnyState, txSec: number): AnyState;
|
|
146
|
+
/**
|
|
147
|
+
* Verifies a `BridgeEvmGovernanceSync` EIP-712 proof signed by the OLD `prev` EVM governance roster (`signerManager`,
|
|
148
|
+
* and `vaultSignerManager` when distinct and modified), bound to `(ocapChainId, bridge, next.version, configHash(next))`
|
|
149
|
+
* and `txSec < expiresAt`.
|
|
150
|
+
*/
|
|
151
|
+
declare function verifyBridgeEvmGovernanceSync(o: {
|
|
152
|
+
ocapChainId: string;
|
|
153
|
+
bridge: string;
|
|
154
|
+
prev: BridgeEvmGovernance | null | undefined;
|
|
155
|
+
next: BridgeEvmGovernance;
|
|
156
|
+
proof: unknown;
|
|
157
|
+
txSec: number;
|
|
158
|
+
}): void;
|
|
130
159
|
/** Full structural validation of a stored v2 body. */
|
|
131
160
|
declare function validateBridgeBody(body: BridgeBodyV2): BridgeBodyV2;
|
|
132
161
|
/** Whether a v1 numeric field is "zero or empty" (the v2 requirement for unused v1 fields). */
|
|
@@ -153,20 +182,27 @@ interface BridgeCreateInput {
|
|
|
153
182
|
}
|
|
154
183
|
/** Parse and validate `itx.data.value` of a v2 `create_rollup` (pure shape checks; signatures are checked by the protocol). */
|
|
155
184
|
declare function parseBridgeCreateData(value: AnyState): BridgeCreateInput;
|
|
156
|
-
type BridgePatchKind = 'owner-quorum' | 'propose-owner' | 'cancel-owner-proposal';
|
|
185
|
+
type BridgePatchKind = 'owner-quorum' | 'propose-owner' | 'cancel-owner-proposal' | 'evm-governance-sync';
|
|
157
186
|
interface BridgePatchPlan {
|
|
158
187
|
kind: BridgePatchKind;
|
|
159
188
|
/** the body after the patch */
|
|
160
189
|
body: BridgeBodyV2;
|
|
161
190
|
/** a pending epoch was removed */
|
|
162
191
|
cancelledEpoch: BridgeEpoch | null;
|
|
192
|
+
/** optional Path-A EIP-712 proof from the previous EVM governance roster */
|
|
193
|
+
evmGovernanceSync?: unknown;
|
|
163
194
|
}
|
|
164
195
|
/**
|
|
165
196
|
* Validate an `update_rollup` patch (`itx.data.value`) against the allow-list and compute the resulting body.
|
|
166
|
-
* `proposeOwner` is its own transaction kind (2/3 quorum), `cancelOwnerProposal` needs the current owner alone,
|
|
197
|
+
* `proposeOwner` is its own transaction kind (2/3 quorum), `cancelOwnerProposal` needs the current owner alone,
|
|
198
|
+
* standalone `{ evmGovernance, evmGovernanceSync }` is verified against the previous EVM governance roster, and anything
|
|
167
199
|
* else needs owner + quorum. Frozen keys (version, epochs, reserve, gateway, ethChainId, token fields...) are rejected.
|
|
168
200
|
*/
|
|
169
|
-
declare function planBridgePatch(body: BridgeBodyV2, patch: AnyState, txSec: number
|
|
201
|
+
declare function planBridgePatch(body: BridgeBodyV2, patch: AnyState, txSec: number, syncCtx?: {
|
|
202
|
+
ocapChainId: string;
|
|
203
|
+
bridge: string;
|
|
204
|
+
vaultAddress?: string | null;
|
|
205
|
+
}): BridgePatchPlan;
|
|
170
206
|
interface MembershipRequest {
|
|
171
207
|
action: 'join' | 'leave';
|
|
172
208
|
validator: string;
|
|
@@ -185,4 +221,4 @@ declare function lonePauseTrack(body: BridgeBodyV2, by: string): 'owner' | 'othe
|
|
|
185
221
|
/** Validate and apply a lone pause by `by` (a member of `pausers`) at `txSec`. */
|
|
186
222
|
declare function applyLonePause(body: BridgeBodyV2, by: string, txSec: number): BridgeBodyV2;
|
|
187
223
|
//#endregion
|
|
188
|
-
export { BRIDGE_CREATE_KEYS, BRIDGE_LONE_PAUSE_COOLDOWN, BRIDGE_LONE_PAUSE_TTL, BRIDGE_MAX_DELAY, BRIDGE_MAX_EPOCH_LEAD, BRIDGE_MAX_PAUSERS, BRIDGE_MAX_VALIDATORS, BRIDGE_MIN_EPOCH_LEAD, BRIDGE_MIN_VALIDATORS, BRIDGE_OWNER_TIMELOCK, BRIDGE_PATCH_ACTION_KEYS, BRIDGE_PATCH_VALUE_KEYS, BRIDGE_RESERVE_MIGRATION_WINDOW, BRIDGE_V1_ZERO_FIELDS, BRIDGE_VERSION, BridgeBodyV2, BridgeConsent, BridgeCreateInput, BridgeEpoch, BridgeMember, BridgePatchKind, BridgePatchPlan, MembershipPlan, MembershipRequest, activeEpochAt, applyLonePause, assertBridgeTransition, assertV1FieldsUnused, effectiveOwnerAt, getBridgeBody, isBridgeFinalAt, isBridgePausedAt, isBridgeV2, isBridgeV2Data, isQuorumPaused, isValidOwnerCandidate, isZeroish, lc, lonePauseTrack, materializeBridgeAt, maxVoucherValidity, parseBridgeCreateData, pendingEpochAt, planBridgePatch, planMembership, sameAddress, syncBridgeView, toSeconds, validateBridgeBody };
|
|
224
|
+
export { BRIDGE_CREATE_KEYS, BRIDGE_LONE_PAUSE_COOLDOWN, BRIDGE_LONE_PAUSE_TTL, BRIDGE_MAX_DELAY, BRIDGE_MAX_EPOCH_LEAD, BRIDGE_MAX_PAUSERS, BRIDGE_MAX_VALIDATORS, BRIDGE_MIN_EPOCH_LEAD, BRIDGE_MIN_VALIDATORS, BRIDGE_OWNER_TIMELOCK, BRIDGE_PATCH_ACTION_KEYS, BRIDGE_PATCH_PROOF_KEYS, BRIDGE_PATCH_VALUE_KEYS, BRIDGE_RESERVE_MIGRATION_WINDOW, BRIDGE_V1_ZERO_FIELDS, BRIDGE_VERSION, BridgeBodyV2, BridgeConsent, BridgeCreateInput, BridgeEpoch, BridgeEvmGovernance, BridgeEvmGovernanceSyncProof, BridgeEvmSignerSet, BridgeMember, BridgePatchKind, BridgePatchPlan, MembershipPlan, MembershipRequest, activeEpochAt, applyLonePause, assertBridgeTransition, assertV1FieldsUnused, bareEthAddress, effectiveOwnerAt, getBridgeBody, isBridgeFinalAt, isBridgePausedAt, isBridgeV2, isBridgeV2Data, isQuorumPaused, isValidOwnerCandidate, isZeroish, lc, lonePauseTrack, materializeBridgeAt, maxVoucherValidity, parseBridgeCreateData, pendingEpochAt, planBridgePatch, planMembership, sameAddress, syncBridgeView, toSeconds, validateBridgeBody, verifyBridgeEvmGovernanceSync };
|
package/lib/states/rollup.cjs
CHANGED
|
@@ -23,6 +23,7 @@ var rollup_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
|
23
23
|
BRIDGE_MIN_VALIDATORS: () => require_states_rollup_v2.BRIDGE_MIN_VALIDATORS,
|
|
24
24
|
BRIDGE_OWNER_TIMELOCK: () => require_states_rollup_v2.BRIDGE_OWNER_TIMELOCK,
|
|
25
25
|
BRIDGE_PATCH_ACTION_KEYS: () => require_states_rollup_v2.BRIDGE_PATCH_ACTION_KEYS,
|
|
26
|
+
BRIDGE_PATCH_PROOF_KEYS: () => require_states_rollup_v2.BRIDGE_PATCH_PROOF_KEYS,
|
|
26
27
|
BRIDGE_PATCH_VALUE_KEYS: () => require_states_rollup_v2.BRIDGE_PATCH_VALUE_KEYS,
|
|
27
28
|
BRIDGE_RESERVE_MIGRATION_WINDOW: () => require_states_rollup_v2.BRIDGE_RESERVE_MIGRATION_WINDOW,
|
|
28
29
|
BRIDGE_V1_ZERO_FIELDS: () => require_states_rollup_v2.BRIDGE_V1_ZERO_FIELDS,
|
|
@@ -32,6 +33,7 @@ var rollup_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
|
32
33
|
applyLonePause: () => require_states_rollup_v2.applyLonePause,
|
|
33
34
|
assertBridgeTransition: () => require_states_rollup_v2.assertBridgeTransition,
|
|
34
35
|
assertV1FieldsUnused: () => require_states_rollup_v2.assertV1FieldsUnused,
|
|
36
|
+
bareEthAddress: () => require_states_rollup_v2.bareEthAddress,
|
|
35
37
|
bridgeSchema: () => require_states_rollup_bridge.bridgeSchema,
|
|
36
38
|
close: () => close,
|
|
37
39
|
create: () => create,
|
|
@@ -77,7 +79,8 @@ var rollup_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
|
|
|
77
79
|
updateBridge: () => require_states_rollup_bridge.updateBridge,
|
|
78
80
|
validate: () => validate,
|
|
79
81
|
validateBridge: () => require_states_rollup_bridge.validateBridge,
|
|
80
|
-
validateBridgeBody: () => require_states_rollup_v2.validateBridgeBody
|
|
82
|
+
validateBridgeBody: () => require_states_rollup_v2.validateBridgeBody,
|
|
83
|
+
verifyBridgeEvmGovernanceSync: () => require_states_rollup_v2.verifyBridgeEvmGovernanceSync
|
|
81
84
|
});
|
|
82
85
|
const VALID_ROLLUP_TARGET_TYPES = ["EVM", "OCAP_ISOMORPHIC"];
|
|
83
86
|
const ethDidSchema = (0, _arcblock_validator.vDID)({
|
|
@@ -471,6 +474,7 @@ exports.BRIDGE_MIN_EPOCH_LEAD = require_states_rollup_v2.BRIDGE_MIN_EPOCH_LEAD;
|
|
|
471
474
|
exports.BRIDGE_MIN_VALIDATORS = require_states_rollup_v2.BRIDGE_MIN_VALIDATORS;
|
|
472
475
|
exports.BRIDGE_OWNER_TIMELOCK = require_states_rollup_v2.BRIDGE_OWNER_TIMELOCK;
|
|
473
476
|
exports.BRIDGE_PATCH_ACTION_KEYS = require_states_rollup_v2.BRIDGE_PATCH_ACTION_KEYS;
|
|
477
|
+
exports.BRIDGE_PATCH_PROOF_KEYS = require_states_rollup_v2.BRIDGE_PATCH_PROOF_KEYS;
|
|
474
478
|
exports.BRIDGE_PATCH_VALUE_KEYS = require_states_rollup_v2.BRIDGE_PATCH_VALUE_KEYS;
|
|
475
479
|
exports.BRIDGE_RESERVE_MIGRATION_WINDOW = require_states_rollup_v2.BRIDGE_RESERVE_MIGRATION_WINDOW;
|
|
476
480
|
exports.BRIDGE_V1_ZERO_FIELDS = require_states_rollup_v2.BRIDGE_V1_ZERO_FIELDS;
|
|
@@ -480,6 +484,7 @@ exports.activeEpochAt = require_states_rollup_v2.activeEpochAt;
|
|
|
480
484
|
exports.applyLonePause = require_states_rollup_v2.applyLonePause;
|
|
481
485
|
exports.assertBridgeTransition = require_states_rollup_v2.assertBridgeTransition;
|
|
482
486
|
exports.assertV1FieldsUnused = require_states_rollup_v2.assertV1FieldsUnused;
|
|
487
|
+
exports.bareEthAddress = require_states_rollup_v2.bareEthAddress;
|
|
483
488
|
exports.bridgeSchema = require_states_rollup_bridge.bridgeSchema;
|
|
484
489
|
exports.close = close;
|
|
485
490
|
exports.create = create;
|
|
@@ -531,4 +536,5 @@ exports.update = update;
|
|
|
531
536
|
exports.updateBridge = require_states_rollup_bridge.updateBridge;
|
|
532
537
|
exports.validate = validate;
|
|
533
538
|
exports.validateBridge = require_states_rollup_bridge.validateBridge;
|
|
534
|
-
exports.validateBridgeBody = require_states_rollup_v2.validateBridgeBody;
|
|
539
|
+
exports.validateBridgeBody = require_states_rollup_v2.validateBridgeBody;
|
|
540
|
+
exports.verifyBridgeEvmGovernanceSync = require_states_rollup_v2.verifyBridgeEvmGovernanceSync;
|
package/lib/states/rollup.d.cts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { StateContextInput } from "../contexts/state.cjs";
|
|
2
|
-
import { BRIDGE_CREATE_KEYS, BRIDGE_LONE_PAUSE_COOLDOWN, BRIDGE_LONE_PAUSE_TTL, BRIDGE_MAX_DELAY, BRIDGE_MAX_EPOCH_LEAD, BRIDGE_MAX_PAUSERS, BRIDGE_MAX_VALIDATORS, BRIDGE_MIN_EPOCH_LEAD, BRIDGE_MIN_VALIDATORS, BRIDGE_OWNER_TIMELOCK, BRIDGE_PATCH_ACTION_KEYS, BRIDGE_PATCH_VALUE_KEYS, BRIDGE_RESERVE_MIGRATION_WINDOW, BRIDGE_V1_ZERO_FIELDS, BRIDGE_VERSION, BridgeBodyV2, BridgeConsent, BridgeCreateInput, BridgeEpoch, BridgeMember, BridgePatchKind, BridgePatchPlan, MembershipPlan, MembershipRequest, activeEpochAt, applyLonePause, assertBridgeTransition, assertV1FieldsUnused, effectiveOwnerAt, getBridgeBody, isBridgeFinalAt, isBridgePausedAt, isBridgeV2, isBridgeV2Data, isQuorumPaused, isValidOwnerCandidate, isZeroish, lc, lonePauseTrack, materializeBridgeAt, maxVoucherValidity, parseBridgeCreateData, pendingEpochAt, planBridgePatch, planMembership, sameAddress, syncBridgeView, toSeconds, validateBridgeBody } from "./rollup-v2.cjs";
|
|
2
|
+
import { BRIDGE_CREATE_KEYS, BRIDGE_LONE_PAUSE_COOLDOWN, BRIDGE_LONE_PAUSE_TTL, BRIDGE_MAX_DELAY, BRIDGE_MAX_EPOCH_LEAD, BRIDGE_MAX_PAUSERS, BRIDGE_MAX_VALIDATORS, BRIDGE_MIN_EPOCH_LEAD, BRIDGE_MIN_VALIDATORS, BRIDGE_OWNER_TIMELOCK, BRIDGE_PATCH_ACTION_KEYS, BRIDGE_PATCH_PROOF_KEYS, BRIDGE_PATCH_VALUE_KEYS, BRIDGE_RESERVE_MIGRATION_WINDOW, BRIDGE_V1_ZERO_FIELDS, BRIDGE_VERSION, BridgeBodyV2, BridgeConsent, BridgeCreateInput, BridgeEpoch, BridgeEvmGovernance, BridgeEvmGovernanceSyncProof, BridgeEvmSignerSet, BridgeMember, BridgePatchKind, BridgePatchPlan, MembershipPlan, MembershipRequest, activeEpochAt, applyLonePause, assertBridgeTransition, assertV1FieldsUnused, bareEthAddress, effectiveOwnerAt, getBridgeBody, isBridgeFinalAt, isBridgePausedAt, isBridgeV2, isBridgeV2Data, isQuorumPaused, isValidOwnerCandidate, isZeroish, lc, lonePauseTrack, materializeBridgeAt, maxVoucherValidity, parseBridgeCreateData, pendingEpochAt, planBridgePatch, planMembership, sameAddress, syncBridgeView, toSeconds, validateBridgeBody, verifyBridgeEvmGovernanceSync } from "./rollup-v2.cjs";
|
|
3
3
|
import { bridgeSchema, createBridge, updateBridge, validateBridge } from "./rollup-bridge.cjs";
|
|
4
4
|
import { IRollupState } from "@ocap/types";
|
|
5
5
|
import { v } from "@arcblock/validator";
|
|
6
6
|
|
|
7
7
|
//#region src/states/rollup.d.ts
|
|
8
8
|
declare namespace rollup_d_exports {
|
|
9
|
-
export { BRIDGE_CREATE_KEYS, BRIDGE_LONE_PAUSE_COOLDOWN, BRIDGE_LONE_PAUSE_TTL, BRIDGE_MAX_DELAY, BRIDGE_MAX_EPOCH_LEAD, BRIDGE_MAX_PAUSERS, BRIDGE_MAX_VALIDATORS, BRIDGE_MIN_EPOCH_LEAD, BRIDGE_MIN_VALIDATORS, BRIDGE_OWNER_TIMELOCK, BRIDGE_PATCH_ACTION_KEYS, BRIDGE_PATCH_VALUE_KEYS, BRIDGE_RESERVE_MIGRATION_WINDOW, BRIDGE_V1_ZERO_FIELDS, BRIDGE_VERSION, BridgeBodyV2, BridgeConsent, BridgeCreateInput, BridgeEpoch, BridgeMember, BridgePatchKind, BridgePatchPlan, MembershipPlan, MembershipRequest, RollupTargetType, RollupTokenReserve, VALID_ROLLUP_TARGET_TYPES, activeEpochAt, applyLonePause, assertBridgeTransition, assertV1FieldsUnused, bridgeSchema, close, create, createBridge, effectiveOwnerAt, getBridgeBody, getRollupSupportedTokens, getRollupTargetType, getRollupTokenReserve, hasRollupReserveTracking, isBridgeFinalAt, isBridgePausedAt, isBridgeV2, isBridgeV2Data, isProposerSponsoredDepositAllowed, isQuorumPaused, isTokenSupportedByRollup, isValidOwnerCandidate, isValidRollupContractAddress, isValidRollupTargetType, isValidRollupValidatorAddress, isValidRollupVaultAddress, isZeroish, lc, lonePauseTrack, materializeBridgeAt, maxVoucherValidity, migrateContract, migrateVault, parseBridgeCreateData, pause, pendingEpochAt, planBridgePatch, planMembership, recordRollupDeposit, recordRollupWithdraw, resume, sameAddress, schema, syncBridgeView, toSeconds, update, updateBridge, validate, validateBridge, validateBridgeBody };
|
|
9
|
+
export { BRIDGE_CREATE_KEYS, BRIDGE_LONE_PAUSE_COOLDOWN, BRIDGE_LONE_PAUSE_TTL, BRIDGE_MAX_DELAY, BRIDGE_MAX_EPOCH_LEAD, BRIDGE_MAX_PAUSERS, BRIDGE_MAX_VALIDATORS, BRIDGE_MIN_EPOCH_LEAD, BRIDGE_MIN_VALIDATORS, BRIDGE_OWNER_TIMELOCK, BRIDGE_PATCH_ACTION_KEYS, BRIDGE_PATCH_PROOF_KEYS, BRIDGE_PATCH_VALUE_KEYS, BRIDGE_RESERVE_MIGRATION_WINDOW, BRIDGE_V1_ZERO_FIELDS, BRIDGE_VERSION, BridgeBodyV2, BridgeConsent, BridgeCreateInput, BridgeEpoch, BridgeEvmGovernance, BridgeEvmGovernanceSyncProof, BridgeEvmSignerSet, BridgeMember, BridgePatchKind, BridgePatchPlan, MembershipPlan, MembershipRequest, RollupTargetType, RollupTokenReserve, VALID_ROLLUP_TARGET_TYPES, activeEpochAt, applyLonePause, assertBridgeTransition, assertV1FieldsUnused, bareEthAddress, bridgeSchema, close, create, createBridge, effectiveOwnerAt, getBridgeBody, getRollupSupportedTokens, getRollupTargetType, getRollupTokenReserve, hasRollupReserveTracking, isBridgeFinalAt, isBridgePausedAt, isBridgeV2, isBridgeV2Data, isProposerSponsoredDepositAllowed, isQuorumPaused, isTokenSupportedByRollup, isValidOwnerCandidate, isValidRollupContractAddress, isValidRollupTargetType, isValidRollupValidatorAddress, isValidRollupVaultAddress, isZeroish, lc, lonePauseTrack, materializeBridgeAt, maxVoucherValidity, migrateContract, migrateVault, parseBridgeCreateData, pause, pendingEpochAt, planBridgePatch, planMembership, recordRollupDeposit, recordRollupWithdraw, resume, sameAddress, schema, syncBridgeView, toSeconds, update, updateBridge, validate, validateBridge, validateBridgeBody, verifyBridgeEvmGovernanceSync };
|
|
10
10
|
}
|
|
11
11
|
type RollupTargetType = 'EVM' | 'OCAP_ISOMORPHIC';
|
|
12
12
|
interface RollupTokenReserve {
|
|
@@ -105,4 +105,4 @@ declare const recordRollupDeposit: (state: IRollupState & Record<string, any>, t
|
|
|
105
105
|
declare const recordRollupWithdraw: (state: IRollupState & Record<string, any>, tokenAddress: string, amount: string, context: StateContextInput) => IRollupState;
|
|
106
106
|
declare const validate: (state: IRollupState & Record<string, any>) => IRollupState;
|
|
107
107
|
//#endregion
|
|
108
|
-
export { BRIDGE_CREATE_KEYS, BRIDGE_LONE_PAUSE_COOLDOWN, BRIDGE_LONE_PAUSE_TTL, BRIDGE_MAX_DELAY, BRIDGE_MAX_EPOCH_LEAD, BRIDGE_MAX_PAUSERS, BRIDGE_MAX_VALIDATORS, BRIDGE_MIN_EPOCH_LEAD, BRIDGE_MIN_VALIDATORS, BRIDGE_OWNER_TIMELOCK, BRIDGE_PATCH_ACTION_KEYS, BRIDGE_PATCH_VALUE_KEYS, BRIDGE_RESERVE_MIGRATION_WINDOW, BRIDGE_V1_ZERO_FIELDS, BRIDGE_VERSION, BridgeBodyV2, BridgeConsent, BridgeCreateInput, BridgeEpoch, BridgeMember, BridgePatchKind, BridgePatchPlan, MembershipPlan, MembershipRequest, RollupTargetType, RollupTokenReserve, VALID_ROLLUP_TARGET_TYPES, activeEpochAt, applyLonePause, assertBridgeTransition, assertV1FieldsUnused, bridgeSchema, close, create, createBridge, effectiveOwnerAt, getBridgeBody, getRollupSupportedTokens, getRollupTargetType, getRollupTokenReserve, hasRollupReserveTracking, isBridgeFinalAt, isBridgePausedAt, isBridgeV2, isBridgeV2Data, isProposerSponsoredDepositAllowed, isQuorumPaused, isTokenSupportedByRollup, isValidOwnerCandidate, isValidRollupContractAddress, isValidRollupTargetType, isValidRollupValidatorAddress, isValidRollupVaultAddress, isZeroish, lc, lonePauseTrack, materializeBridgeAt, maxVoucherValidity, migrateContract, migrateVault, parseBridgeCreateData, pause, pendingEpochAt, planBridgePatch, planMembership, recordRollupDeposit, recordRollupWithdraw, resume, rollup_d_exports, sameAddress, schema, syncBridgeView, toSeconds, update, updateBridge, validate, validateBridge, validateBridgeBody };
|
|
108
|
+
export { BRIDGE_CREATE_KEYS, BRIDGE_LONE_PAUSE_COOLDOWN, BRIDGE_LONE_PAUSE_TTL, BRIDGE_MAX_DELAY, BRIDGE_MAX_EPOCH_LEAD, BRIDGE_MAX_PAUSERS, BRIDGE_MAX_VALIDATORS, BRIDGE_MIN_EPOCH_LEAD, BRIDGE_MIN_VALIDATORS, BRIDGE_OWNER_TIMELOCK, BRIDGE_PATCH_ACTION_KEYS, BRIDGE_PATCH_PROOF_KEYS, BRIDGE_PATCH_VALUE_KEYS, BRIDGE_RESERVE_MIGRATION_WINDOW, BRIDGE_V1_ZERO_FIELDS, BRIDGE_VERSION, BridgeBodyV2, BridgeConsent, BridgeCreateInput, BridgeEpoch, BridgeEvmGovernance, BridgeEvmGovernanceSyncProof, BridgeEvmSignerSet, BridgeMember, BridgePatchKind, BridgePatchPlan, MembershipPlan, MembershipRequest, RollupTargetType, RollupTokenReserve, VALID_ROLLUP_TARGET_TYPES, activeEpochAt, applyLonePause, assertBridgeTransition, assertV1FieldsUnused, bareEthAddress, bridgeSchema, close, create, createBridge, effectiveOwnerAt, getBridgeBody, getRollupSupportedTokens, getRollupTargetType, getRollupTokenReserve, hasRollupReserveTracking, isBridgeFinalAt, isBridgePausedAt, isBridgeV2, isBridgeV2Data, isProposerSponsoredDepositAllowed, isQuorumPaused, isTokenSupportedByRollup, isValidOwnerCandidate, isValidRollupContractAddress, isValidRollupTargetType, isValidRollupValidatorAddress, isValidRollupVaultAddress, isZeroish, lc, lonePauseTrack, materializeBridgeAt, maxVoucherValidity, migrateContract, migrateVault, parseBridgeCreateData, pause, pendingEpochAt, planBridgePatch, planMembership, recordRollupDeposit, recordRollupWithdraw, resume, rollup_d_exports, sameAddress, schema, syncBridgeView, toSeconds, update, updateBridge, validate, validateBridge, validateBridgeBody, verifyBridgeEvmGovernanceSync };
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.32.0",
|
|
7
7
|
"description": "State management utilities for OCAP blockchain",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./lib/index.cjs",
|
|
@@ -40,14 +40,15 @@
|
|
|
40
40
|
"clean": "rm -rf lib esm"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@arcblock/did": "1.
|
|
44
|
-
"@arcblock/
|
|
45
|
-
"@
|
|
46
|
-
"@ocap/
|
|
47
|
-
"@ocap/
|
|
48
|
-
"@ocap/
|
|
49
|
-
"@ocap/
|
|
50
|
-
"@ocap/
|
|
43
|
+
"@arcblock/did": "1.32.0",
|
|
44
|
+
"@arcblock/did-util": "1.32.0",
|
|
45
|
+
"@arcblock/validator": "1.32.0",
|
|
46
|
+
"@ocap/contract": "1.32.0",
|
|
47
|
+
"@ocap/mcrypto": "1.32.0",
|
|
48
|
+
"@ocap/message": "1.32.0",
|
|
49
|
+
"@ocap/types": "1.32.0",
|
|
50
|
+
"@ocap/util": "1.32.0",
|
|
51
|
+
"@ocap/wallet": "1.32.0",
|
|
51
52
|
"bloom-filters": "^1.3.9",
|
|
52
53
|
"lodash": "^4.17.23"
|
|
53
54
|
},
|