@ethernity-cloud/sdk-js 1.5.16 → 1.5.17

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.
@@ -104,8 +104,10 @@ class MemContract {
104
104
  return ethers.BigNumber.from(e ? e.version : 0);
105
105
  }
106
106
 
107
- async relayNonce(enclave) {
108
- return ethers.BigNumber.from(this._nonce[String(enclave).toLowerCase()] || 0);
107
+ async relayNonce(enclave, keyHash) {
108
+ // Per (enclave, key), like the contract: same-key commits serialize,
109
+ // different keys are independent.
110
+ return ethers.BigNumber.from(this._nonce[key(enclave, keyHash)] || 0);
109
111
  }
110
112
 
111
113
  async commitDigest(enclave, keyHash, cid, expectedVersion, relayNonce, nonce = 0) {
@@ -150,8 +152,7 @@ class MemContract {
150
152
  storedNonce = n;
151
153
  }
152
154
  this._entries[k] = { cid, version: cur + 1, updatedAt: 0, nonce: storedNonce };
153
- const e = String(enclave).toLowerCase();
154
- this._nonce[e] = (this._nonce[e] || 0) + 1;
155
+ this._nonce[k] = (this._nonce[k] || 0) + 1;
155
156
  this._persist();
156
157
  }
157
158
  }
@@ -210,6 +210,11 @@ async function exec(payload, input, globals = null) {
210
210
  if (error && error.constructor && error.constructor.name === 'StateNonceError') {
211
211
  return [TaskStatus.ESR_NONCE_VIOLATION, 'ESR_NONCE_VIOLATION: ' + error.message];
212
212
  }
213
+ // Over the per-run commit cap (100): the over-limit commit was NOT
214
+ // applied; the earlier commits stand and will be relayed.
215
+ if (error && error.constructor && error.constructor.name === 'StateLimitError') {
216
+ return [TaskStatus.ESR_COMMIT_LIMIT_EXCEEDED, 'ESR_COMMIT_LIMIT_EXCEEDED: ' + error.message];
217
+ }
213
218
  const detail = (error && (error.stack || error.message)) || String(error);
214
219
  console.error('Error in payload execution -- full stack follows:\n' + detail);
215
220
 
@@ -19,6 +19,12 @@ class TaskStatus {
19
19
  static ESR_GAS_LIMIT_EXCEEDED = 34; // ESR commits would exceed the per-order relayed-gas budget.
20
20
  static SECURITY_VIOLATION = 35; // A state commit was authorized under a caller other than
21
21
  static ESR_NONCE_VIOLATION = 36; // A commit's idempotency nonce was already used -- duplicate
22
+ // The enclave signed state commits but they did not land on the registry
23
+ // within 5 blocks -- the node did not relay them. The validator REFUNDS.
24
+ static ESR_RELAY_TIMEOUT = 37;
25
+ // More than 100 state commits in one run -- the per-run cap that bounds
26
+ // relayed transactions and the result size. dApp-side fault: NO refund.
27
+ static ESR_COMMIT_LIMIT_EXCEEDED = 38;
22
28
  // suppressed, state unchanged (StateNonceError).
23
29
  // the task's submitter (the in-enclave ownership check was
24
30
  // bypassed). Set by the securelock on a detected forged
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ethernity-cloud/sdk-js",
3
- "version": "1.5.16",
3
+ "version": "1.5.17",
4
4
  "description": "A package to run ethernity cloud build scripts",
5
5
  "scripts": {
6
6
  "ecld-build": "cross-env node ./node_modules/@ethernity-cloud/sdk-js/build.js",
package/test.js CHANGED
@@ -58,6 +58,8 @@ const TASK_STATUS_NAMES = {
58
58
  34: 'ESR_GAS_LIMIT_EXCEEDED',
59
59
  35: 'SECURITY_VIOLATION',
60
60
  36: 'ESR_NONCE_VIOLATION',
61
+ 37: 'ESR_RELAY_TIMEOUT',
62
+ 38: 'ESR_COMMIT_LIMIT_EXCEEDED',
61
63
  };
62
64
 
63
65
  const VENDORED_SRC = path.join(__dirname, 'nodenithy', 'build', 'securelock', 'src');