@ocap/tx-pipeline 1.30.9 → 1.30.11

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.
@@ -72,6 +72,7 @@ function DecodeItx(context, next) {
72
72
  } catch (_err) {
73
73
  return next(new CustomError("INVALID_TX", "Failed to decode itx"));
74
74
  }
75
+ context.timer?.mark?.("decode");
75
76
  next();
76
77
  }
77
78
 
@@ -24,6 +24,7 @@ function CreateTakeStateSnapshotPipe({ key = "stateSnapshot" } = {}) {
24
24
  });
25
25
  }
26
26
  ctx[key] = cloneDeep(statesMap);
27
+ ctx.timer?.mark?.("protocolRead");
27
28
  return next();
28
29
  };
29
30
  }
@@ -4,7 +4,7 @@ import { CustomError } from "@ocap/util/lib/error";
4
4
  import get from "lodash/get.js";
5
5
  import { decodeAny } from "@ocap/message";
6
6
  import { getListField, setListField } from "@ocap/util/lib/get-list-field";
7
- import { toTypeInfo } from "@arcblock/did";
7
+ import { isFromPublicKey, toTypeInfo } from "@arcblock/did";
8
8
  import cloneDeep from "lodash/cloneDeep.js";
9
9
  import { fromPublicKey } from "@ocap/wallet";
10
10
  import omit from "lodash/omit.js";
@@ -26,6 +26,7 @@ function CreateVerifyMultiSigV2Pipe({ signersKey }) {
26
26
  for (let i = 0; i < signatures.length; i++) {
27
27
  const { signer, pk, delegator, signature, extra = "" } = signatures[i];
28
28
  const address = delegator || signer;
29
+ if (isFromPublicKey(address, pk) === false) return next(new CustomError("INVALID_SIGNATURE", `signer ${address} and pk do not match`));
29
30
  const wallet = fromPublicKey(pk, toTypeInfo(address));
30
31
  const txBytes = encodeTxByEncoding(context.txEncoding, tx);
31
32
  try {
@@ -3,7 +3,7 @@ import { unwrapOpaqueAnyData } from "../helpers/unwrap-opaque-any.mjs";
3
3
  import { CustomError } from "@ocap/util/lib/error";
4
4
  import { decodeAny } from "@ocap/message";
5
5
  import { deleteListField, getListField, setListField } from "@ocap/util/lib/get-list-field";
6
- import { toTypeInfo } from "@arcblock/did";
6
+ import { isFromPublicKey, toTypeInfo } from "@arcblock/did";
7
7
  import cloneDeep from "lodash/cloneDeep.js";
8
8
  import { fromPublicKey } from "@ocap/wallet";
9
9
 
@@ -18,6 +18,7 @@ function CreateVerifyMultiSigPipe(numSigs = 0) {
18
18
  while (signatures.length > 0) {
19
19
  const { signer, pk, delegator, signature, data } = signatures.shift();
20
20
  const address = delegator || signer;
21
+ if (isFromPublicKey(address, pk) === false) return next(new CustomError("INVALID_SIGNATURE", `signer ${address} and pk do not match`));
21
22
  const wallet = fromPublicKey(pk, toTypeInfo(address));
22
23
  setListField(tx, "signatures", [{
23
24
  signer,
@@ -28,6 +28,7 @@ async function VerifySignature(context, next) {
28
28
  console.error("tx.signature verify failed", err);
29
29
  return next(new CustomError("INVALID_SIGNATURE", "tx.signature verify failed"));
30
30
  }
31
+ context.timer?.mark?.("verify");
31
32
  next();
32
33
  }
33
34
 
@@ -77,6 +77,7 @@ function fixMigratedReceipts(receipts, statesMap) {
77
77
  function CreateVerifyStateDiffPipe({ snapshotKey = "stateSnapshot" } = {}) {
78
78
  return function VerifyStateDiff(context, next) {
79
79
  const { logger, [snapshotKey]: snapshotStates } = context;
80
+ context.timer?.mark?.("protocolWrite");
80
81
  if (!snapshotStates) return next(new CustomError("FORBIDDEN", `context.${snapshotKey} is missing, please call VerifyStateDiff after TakeStateSnapshot`));
81
82
  const txState = create(context, "OK", false);
82
83
  const contextStates = groupStatesByAddress(context);
@@ -125,6 +126,7 @@ function CreateVerifyStateDiffPipe({ snapshotKey = "stateSnapshot" } = {}) {
125
126
  }
126
127
  }
127
128
  }
129
+ context.timer?.mark?.("protocolDiff");
128
130
  next();
129
131
  };
130
132
  }
@@ -74,6 +74,7 @@ function DecodeItx(context, next) {
74
74
  } catch (_err) {
75
75
  return next(new _ocap_util_lib_error.CustomError("INVALID_TX", "Failed to decode itx"));
76
76
  }
77
+ context.timer?.mark?.("decode");
77
78
  next();
78
79
  }
79
80
 
@@ -27,6 +27,7 @@ function CreateTakeStateSnapshotPipe({ key = "stateSnapshot" } = {}) {
27
27
  });
28
28
  }
29
29
  ctx[key] = (0, lodash_cloneDeep.default)(statesMap);
30
+ ctx.timer?.mark?.("protocolRead");
30
31
  return next();
31
32
  };
32
33
  }
@@ -31,6 +31,7 @@ function CreateVerifyMultiSigV2Pipe({ signersKey }) {
31
31
  for (let i = 0; i < signatures.length; i++) {
32
32
  const { signer, pk, delegator, signature, extra = "" } = signatures[i];
33
33
  const address = delegator || signer;
34
+ if ((0, _arcblock_did.isFromPublicKey)(address, pk) === false) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", `signer ${address} and pk do not match`));
34
35
  const wallet = (0, _ocap_wallet.fromPublicKey)(pk, (0, _arcblock_did.toTypeInfo)(address));
35
36
  const txBytes = require_helpers_encode_tx_by_context.encodeTxByEncoding(context.txEncoding, tx);
36
37
  try {
@@ -21,6 +21,7 @@ function CreateVerifyMultiSigPipe(numSigs = 0) {
21
21
  while (signatures.length > 0) {
22
22
  const { signer, pk, delegator, signature, data } = signatures.shift();
23
23
  const address = delegator || signer;
24
+ if ((0, _arcblock_did.isFromPublicKey)(address, pk) === false) return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", `signer ${address} and pk do not match`));
24
25
  const wallet = (0, _ocap_wallet.fromPublicKey)(pk, (0, _arcblock_did.toTypeInfo)(address));
25
26
  (0, _ocap_util_lib_get_list_field.setListField)(tx, "signatures", [{
26
27
  signer,
@@ -32,6 +32,7 @@ async function VerifySignature(context, next) {
32
32
  console.error("tx.signature verify failed", err);
33
33
  return next(new _ocap_util_lib_error.CustomError("INVALID_SIGNATURE", "tx.signature verify failed"));
34
34
  }
35
+ context.timer?.mark?.("verify");
35
36
  next();
36
37
  }
37
38
 
@@ -83,6 +83,7 @@ function fixMigratedReceipts(receipts, statesMap) {
83
83
  function CreateVerifyStateDiffPipe({ snapshotKey = "stateSnapshot" } = {}) {
84
84
  return function VerifyStateDiff(context, next) {
85
85
  const { logger, [snapshotKey]: snapshotStates } = context;
86
+ context.timer?.mark?.("protocolWrite");
86
87
  if (!snapshotStates) return next(new _ocap_util_lib_error.CustomError("FORBIDDEN", `context.${snapshotKey} is missing, please call VerifyStateDiff after TakeStateSnapshot`));
87
88
  const txState = (0, _ocap_state_lib_states_tx.create)(context, "OK", false);
88
89
  const contextStates = groupStatesByAddress(context);
@@ -131,6 +132,7 @@ function CreateVerifyStateDiffPipe({ snapshotKey = "stateSnapshot" } = {}) {
131
132
  }
132
133
  }
133
134
  }
135
+ context.timer?.mark?.("protocolDiff");
134
136
  next();
135
137
  };
136
138
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.30.9",
6
+ "version": "1.30.11",
7
7
  "description": "Pipeline runner and common pipelines to process transactions",
8
8
  "type": "module",
9
9
  "main": "./lib/index.cjs",
@@ -49,15 +49,15 @@
49
49
  "elliptic": "6.5.3"
50
50
  },
51
51
  "dependencies": {
52
- "@arcblock/did": "1.30.9",
53
- "@arcblock/did-util": "1.30.9",
54
- "@ocap/client": "1.30.9",
55
- "@ocap/mcrypto": "1.30.9",
56
- "@ocap/message": "1.30.9",
57
- "@ocap/state": "1.30.9",
58
- "@ocap/types": "1.30.9",
59
- "@ocap/util": "1.30.9",
60
- "@ocap/wallet": "1.30.9",
52
+ "@arcblock/did": "1.30.11",
53
+ "@arcblock/did-util": "1.30.11",
54
+ "@ocap/client": "1.30.11",
55
+ "@ocap/mcrypto": "1.30.11",
56
+ "@ocap/message": "1.30.11",
57
+ "@ocap/state": "1.30.11",
58
+ "@ocap/types": "1.30.11",
59
+ "@ocap/util": "1.30.11",
60
+ "@ocap/wallet": "1.30.11",
61
61
  "debug": "^4.4.3",
62
62
  "lodash": "^4.17.23"
63
63
  }