@ocap/tx-protocols 1.31.8 → 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
@@ -50,6 +50,12 @@ interface AuthorityRule {
50
50
  owner: 'required' | 'alone' | 'none';
51
51
  /** `threshold`: >= threshold of the active epoch; `twoThirds`: >= ceil(2n/3); `none` */
52
52
  quorum: 'threshold' | 'twoThirds' | 'none';
53
+ /**
54
+ * When true (`evm-governance-sync` Path A and `govProposalVote`), governance authority was verified from EIP-712
55
+ * signatures inside `itx.data`: `tx.from` is a single gas-payer account (`tx.delegator` and outer `tx.signatures`
56
+ * are forbidden) and `context.signers` is set to `[]`.
57
+ */
58
+ externalAuth?: boolean;
53
59
  }
54
60
  /**
55
61
  * Governance authority of a v2 bridge. The signers are `tx.from` plus the signers of `tx.signatures` (their signatures
@@ -7,6 +7,7 @@ const require_protocols_rollup_bridge_v2 = require('./bridge-v2.cjs');
7
7
  const require_protocols_rollup_pipes_ensure_validator = require('./pipes/ensure-validator.cjs');
8
8
  const require_protocols_rollup_pipes_verify_signers = require('./pipes/verify-signers.cjs');
9
9
  const require_protocols_rollup_pipes_verify_status = require('./pipes/verify-status.cjs');
10
+ const require_protocols_rollup_bridge_governance_vote = require('./bridge-governance-vote.cjs');
10
11
  let _ocap_tx_pipeline = require("@ocap/tx-pipeline");
11
12
  let _ocap_util_lib_error = require("@ocap/util/lib/error");
12
13
  let _ocap_state = require("@ocap/state");
@@ -67,13 +68,24 @@ runner.use(require_protocols_rollup_bridge_v2.loadBridge);
67
68
  runner.use(require_protocols_rollup_bridge_v2.rejectRollupV1IfDisabled("update_rollup"));
68
69
  runner.use(require_protocols_rollup_bridge_v2.ifV1(require_protocols_rollup_pipes_ensure_validator.default(true)));
69
70
  runner.use(require_protocols_rollup_bridge_v2.ifV1(require_protocols_rollup_pipes_verify_status.default({ paused: false })));
70
- runner.use((context, next) => {
71
+ runner.use(async (context, next) => {
71
72
  if (!context.isBridgeV2) return next();
72
73
  try {
73
74
  _ocap_state.rollup.assertV1FieldsUnused(context.itx, "INVALID_ROLLUP_UPDATE");
74
- context.bridgePlan = _ocap_state.rollup.planBridgePatch(context.bridgeBody, require_protocols_rollup_bridge_v2.readItxData(context.itx), context.txSec);
75
+ const rawData = require_protocols_rollup_bridge_v2.readItxData(context.itx);
76
+ if (require_protocols_rollup_bridge_governance_vote.isGovProposalVotePayload(rawData)) {
77
+ context.govVotePlan = await require_protocols_rollup_bridge_governance_vote.planBridgeGovProposalVote(context, rawData);
78
+ return next();
79
+ }
80
+ context.bridgePlan = _ocap_state.rollup.planBridgePatch(context.bridgeBody, rawData, context.txSec, {
81
+ ocapChainId: context.config.chainId,
82
+ bridge: context.itx.rollup,
83
+ vaultAddress: context.rollupState.vaultAddress
84
+ });
75
85
  } catch (err) {
76
- return next(new _ocap_util_lib_error.CustomError("INVALID_TX", err.message));
86
+ const e = err;
87
+ if (e?.code === "INVALID_SIGNATURE") return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", e.message || "Invalid governance signature"));
88
+ return next(new _ocap_util_lib_error.CustomError("INVALID_TX", e?.message || "Invalid rollup update"));
77
89
  }
78
90
  return next();
79
91
  });
@@ -89,7 +101,13 @@ runner.use(require_protocols_rollup_bridge_v2.ifV1(require_protocols_rollup_pipe
89
101
  allowSender: true
90
102
  })));
91
103
  runner.use(require_protocols_rollup_bridge_v2.VerifyBridgeAuthority((context) => {
92
- const kind = context.bridgePlan?.kind;
104
+ const ctx = context;
105
+ if (ctx.govVotePlan || ctx.bridgePlan?.kind === "evm-governance-sync") return {
106
+ owner: "none",
107
+ quorum: "none",
108
+ externalAuth: true
109
+ };
110
+ const kind = ctx.bridgePlan?.kind;
93
111
  if (kind === "propose-owner") return {
94
112
  owner: "none",
95
113
  quorum: "twoThirds"
@@ -121,16 +139,20 @@ runner.use(_ocap_tx_pipeline.pipes.VerifyAccountMigration({
121
139
  stateKey: "senderState",
122
140
  addressKey: "tx.from"
123
141
  }));
124
- runner.use(require_pipes_ensure_gas.default(() => ({
142
+ runner.use(require_pipes_ensure_gas.default((context) => context.govVotePlan ? context.govVotePlan.gasEstimate : {
125
143
  create: 0,
126
144
  update: 2,
127
145
  payment: 0
128
- })));
146
+ }));
129
147
  runner.use(require_pipes_ensure_cost.default({ attachSenderChanges: true }));
130
148
  runner.use(_ocap_tx_pipeline.pipes.TakeStateSnapshot());
131
149
  runner.use(async (context, next) => {
132
150
  const { tx, itx, rollupState, statedb, senderState, senderUpdates, updateVaults } = context;
133
151
  if (context.isBridgeV2) {
152
+ if (context.govVotePlan) {
153
+ await require_protocols_rollup_bridge_governance_vote.commitBridgeGovProposalVote(context, context.govVotePlan);
154
+ return next();
155
+ }
134
156
  const updates = require_protocols_rollup_bridge_v2.bridgeUpdates(context, context.bridgePlan.body);
135
157
  const [newSenderState$1, newRollupState$1] = await Promise.all([statedb.account.update(senderState.address, _ocap_state.account.update(senderState, {
136
158
  nonce: tx.nonce,
@@ -1,4 +1,5 @@
1
1
  import { BridgeCtxMixin } from "./bridge-v2.cjs";
2
+ import { BridgeGovVotePlan } from "./bridge-governance-vote.cjs";
2
3
  import { rollup } from "@ocap/state";
3
4
  import { IReadyContext, IWithRollup, IWithSender, IWithSigners, TUpdateRollupTx } from "@ocap/types";
4
5
  import { Runner } from "@ocap/tx-pipeline";
@@ -12,6 +13,7 @@ import { Runner } from "@ocap/tx-pipeline";
12
13
  */
13
14
  type Context = IReadyContext<TUpdateRollupTx> & IWithRollup & IWithSender & IWithSigners & BridgeCtxMixin & {
14
15
  bridgePlan?: rollup.BridgePatchPlan;
16
+ govVotePlan?: BridgeGovVotePlan;
15
17
  };
16
18
  declare const runner: Runner<Context>;
17
19
  //#endregion
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.31.8",
6
+ "version": "1.32.0",
7
7
  "description": "Predefined tx pipeline sets to execute certain type of transactions",
8
8
  "type": "module",
9
9
  "main": "./lib/index.cjs",
@@ -46,22 +46,22 @@
46
46
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
47
47
  "license": "MIT",
48
48
  "dependencies": {
49
- "@arcblock/did": "1.31.8",
50
- "@arcblock/did-util": "1.31.8",
51
- "@arcblock/jwt": "1.31.8",
52
- "@arcblock/validator": "1.31.8",
53
- "@arcblock/vc": "1.31.8",
49
+ "@arcblock/did": "1.32.0",
50
+ "@arcblock/did-util": "1.32.0",
51
+ "@arcblock/jwt": "1.32.0",
52
+ "@arcblock/validator": "1.32.0",
53
+ "@arcblock/vc": "1.32.0",
54
54
  "@blocklet/xss": "^0.3.7",
55
- "@ocap/asset": "1.31.8",
56
- "@ocap/client": "1.31.8",
57
- "@ocap/mcrypto": "1.31.8",
58
- "@ocap/merkle-tree": "1.31.8",
59
- "@ocap/message": "1.31.8",
60
- "@ocap/state": "1.31.8",
61
- "@ocap/tx-pipeline": "1.31.8",
62
- "@ocap/types": "1.31.8",
63
- "@ocap/util": "1.31.8",
64
- "@ocap/wallet": "1.31.8",
55
+ "@ocap/asset": "1.32.0",
56
+ "@ocap/client": "1.32.0",
57
+ "@ocap/mcrypto": "1.32.0",
58
+ "@ocap/merkle-tree": "1.32.0",
59
+ "@ocap/message": "1.32.0",
60
+ "@ocap/state": "1.32.0",
61
+ "@ocap/tx-pipeline": "1.32.0",
62
+ "@ocap/types": "1.32.0",
63
+ "@ocap/util": "1.32.0",
64
+ "@ocap/wallet": "1.32.0",
65
65
  "debug": "^4.4.3",
66
66
  "deep-diff": "^1.0.2",
67
67
  "lodash": "^4.17.23",