@autonomys/auto-consensus 0.6.6 → 0.6.7

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/dist/info.d.ts CHANGED
@@ -15,7 +15,7 @@ export declare const shouldAdjustSolutionRange: (api: Api) => Promise<boolean>;
15
15
  export declare const segmentCommitment: (api: Api) => Promise<[StorageKey<AnyTuple>, Codec][]>;
16
16
  export declare const slotProbability: (api: Api) => [number, number];
17
17
  export declare const maxPiecesInSector: (api: Api) => bigint;
18
- export declare function solutionRangeToSectors(solutionRange: bigint, slotProbability: [bigint, bigint], piecesInSector: bigint): bigint;
18
+ export declare function solutionRangeToPieces(solutionRange: bigint, slotProbability: [bigint, bigint]): bigint;
19
19
  export declare const spacePledge: (api: Api) => Promise<bigint>;
20
20
  export declare const blockchainSize: (api: Api) => Promise<bigint>;
21
21
  //# sourceMappingURL=info.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../src/info.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAMxE,eAAO,MAAM,GAAG,GAAU,CAAC,OAAO,GAAG,cAAc,MAAM,WAAU,GAAG,EAAE,KAAQ,OAAO,CAAC,CAAC,CAC7B,CAAA;AAE5D,eAAO,MAAM,KAAK,GAAU,CAAC,OAAO,GAAG,cAAc,MAAM,WAAU,GAAG,EAAE,KAAQ,OAAO,CAAC,CAAC,CAC7B,CAAA;AAE9D,eAAO,MAAM,KAAK,GAAU,QAAQ,OAAO,GAAG,sBAAmD,CAAA;AAEjG,eAAO,MAAM,WAAW,QAAe,GAAG,KAAG,OAAO,CAAC,MAAM,CAK1D,CAAA;AAED,eAAO,MAAM,SAAS,QAAe,GAAG,oBAGvC,CAAA;AAED,eAAO,MAAM,gBAAgB,QAAe,GAAG,mBAAiD,CAAA;AAEhG,eAAO,MAAM,c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c,QAAe,GAAG;;;;;EAc5C,CAAA;AAED,eAAO,MAAM,yBAAyB,QAAe,GAAG,KAAG,OAAO,CAAC,OAAO,CACL,CAAA;AAErE,eAAO,MAAM,iBAAiB,QAAe,GAAG,6CACqC,CAAA;AAErF,eAAO,MAAM,eAAe,QAAS,GAAG,KAAG,CAAC,MAAM,EAAE,MAAM,CACa,CAAA;AAEvE,eAAO,MAAM,iBAAiB,QAAS,GAAG,KAAG,MAC0B,CAAA;AAEvE,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,EACrB,eAAe,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,MAAM,CAUR;AAED,eAAO,MAAM,WAAW,QAAe,GAAG,KAAG,OAAO,CAAC,MAAM,CAa1D,CAAA;AAED,eAAO,MAAM,cAAc,QAAe,GAAG,KAAG,OAAO,CAAC,MAAM,CAM7D,CAAA"}
package/dist/info.js CHANGED
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.blockchainSize = exports.spacePledge = exports.maxPiecesInSector = exports.slotProbability = exports.segmentCommitment = exports.shouldAdjustSolutionRange = exports.solutionRanges = exports.networkTimestamp = exports.blockHash = exports.blockNumber = exports.block = exports.query = exports.rpc = void 0;
14
- exports.solutionRangeToSectors = solutionRangeToSectors;
14
+ exports.solutionRangeToPieces = solutionRangeToPieces;
15
15
  const query_1 = require("./utils/query");
16
16
  const PIECE_SIZE = BigInt(1048576);
17
17
  const rpc = (api_1, methodPath_1, ...args_1) => __awaiter(void 0, [api_1, methodPath_1, ...args_1], void 0, function* (api, methodPath, params = []) { return yield (0, query_1.queryMethodPath)(api, `rpc.${methodPath}`, params); });
@@ -52,22 +52,24 @@ const slotProbability = (api) => api.consts.subspace.slotProbability.toPrimitive
52
52
  exports.slotProbability = slotProbability;
53
53
  const maxPiecesInSector = (api) => BigInt(api.consts.subspace.maxPiecesInSector.toPrimitive());
54
54
  exports.maxPiecesInSector = maxPiecesInSector;
55
- function solutionRangeToSectors(solutionRange, slotProbability, piecesInSector) {
55
+ function solutionRangeToPieces(solutionRange, slotProbability) {
56
56
  const MAX_U64 = BigInt(Math.pow(2, 64) - 1);
57
57
  const RECORD_NUM_CHUNKS = BigInt(32768);
58
58
  const RECORD_NUM_S_BUCKETS = BigInt(65536);
59
- const sectors = ((MAX_U64 / slotProbability[1]) * slotProbability[0]) /
60
- ((piecesInSector * RECORD_NUM_CHUNKS) / RECORD_NUM_S_BUCKETS);
61
- return sectors / solutionRange;
59
+ const pieces = (((MAX_U64 / slotProbability[1]) * slotProbability[0]) / RECORD_NUM_CHUNKS) *
60
+ RECORD_NUM_S_BUCKETS;
61
+ return pieces / solutionRange;
62
62
  }
63
63
  const spacePledge = (api) => __awaiter(void 0, void 0, void 0, function* () {
64
64
  const _solutionRanges = yield (0, exports.solutionRanges)(api);
65
65
  const _slotProbability = (0, exports.slotProbability)(api);
66
- const _maxPiecesInSector = (0, exports.maxPiecesInSector)(api);
67
- if (!_solutionRanges.current || !_slotProbability || !_maxPiecesInSector)
66
+ if (!_solutionRanges.current || !_slotProbability)
68
67
  return BigInt(0);
69
- const sectors = solutionRangeToSectors(_solutionRanges.current, [BigInt(_slotProbability[0]), BigInt(_slotProbability[1])], _maxPiecesInSector);
70
- const totalSpacePledged = sectors * _maxPiecesInSector * PIECE_SIZE;
68
+ const pieces = solutionRangeToPieces(_solutionRanges.current, [
69
+ BigInt(_slotProbability[0]),
70
+ BigInt(_slotProbability[1]),
71
+ ]);
72
+ const totalSpacePledged = pieces * PIECE_SIZE;
71
73
  return totalSpacePledged;
72
74
  });
73
75
  exports.spacePledge = spacePledge;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autonomys/auto-consensus",
3
- "version": "0.6.6",
3
+ "version": "0.6.7",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -22,7 +22,7 @@
22
22
  "url": "https://www.autonomys.net"
23
23
  },
24
24
  "dependencies": {
25
- "@autonomys/auto-utils": "^0.6.6"
25
+ "@autonomys/auto-utils": "^0.6.7"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/jest": "^29.5.12",
@@ -32,5 +32,5 @@
32
32
  "ts-jest": "^29.1.4",
33
33
  "typescript": "^5.4.5"
34
34
  },
35
- "gitHead": "94646ea042d018cd883558fb6ca750ed49d95dae"
35
+ "gitHead": "2ba65337aa923eaac7269aaea70db97112bfc033"
36
36
  }