@typeberry/lib 0.5.4 → 0.5.5

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 (101) hide show
  1. package/package.json +1 -1
  2. package/packages/core/json-parser/descriptors.d.ts.map +1 -1
  3. package/packages/core/json-parser/descriptors.js +3 -0
  4. package/packages/core/json-parser/index.test.js +30 -0
  5. package/packages/core/networking/package.json +1 -1
  6. package/packages/core/telemetry/package.json +1 -1
  7. package/packages/core/utils/compatibility.d.ts +0 -1
  8. package/packages/core/utils/compatibility.d.ts.map +1 -1
  9. package/packages/core/utils/compatibility.js +1 -2
  10. package/packages/core/utils/compatibility.test.js +6 -10
  11. package/packages/jam/block/index.d.ts +11 -11
  12. package/packages/jam/block/index.d.ts.map +1 -1
  13. package/packages/jam/block/index.js +11 -11
  14. package/packages/jam/block-json/block.d.ts +25 -25
  15. package/packages/jam/database-lmdb/states.test.js +3 -5
  16. package/packages/jam/fuzz-proto/v1/types.d.ts +1 -1
  17. package/packages/jam/jam-host-calls/accumulate/bless.d.ts.map +1 -1
  18. package/packages/jam/jam-host-calls/accumulate/bless.js +6 -10
  19. package/packages/jam/jam-host-calls/accumulate/bless.test.js +32 -72
  20. package/packages/jam/jam-host-calls/accumulate/new.d.ts.map +1 -1
  21. package/packages/jam/jam-host-calls/accumulate/new.js +2 -4
  22. package/packages/jam/jam-host-calls/accumulate/new.test.js +4 -5
  23. package/packages/jam/jam-host-calls/general/fetch.d.ts +1 -57
  24. package/packages/jam/jam-host-calls/general/fetch.d.ts.map +1 -1
  25. package/packages/jam/jam-host-calls/general/fetch.js +6 -29
  26. package/packages/jam/jam-host-calls/general/fetch.test.js +2 -58
  27. package/packages/jam/jamnp-s/protocol/ce-133-work-package-submission.d.ts +4 -4
  28. package/packages/jam/jamnp-s/protocol/ce-135-work-report-distribution.d.ts +13 -13
  29. package/packages/jam/jamnp-s/protocol/up-0-block-announcement.d.ts +1 -1
  30. package/packages/jam/node/package.json +1 -1
  31. package/packages/jam/node/reader.d.ts +25 -25
  32. package/packages/jam/node/workers.d.ts +183 -183
  33. package/packages/jam/state/accumulation-queue.d.ts +26 -26
  34. package/packages/jam/state/assurances.d.ts +26 -26
  35. package/packages/jam/state/privileged-services.d.ts +1 -1
  36. package/packages/jam/state/privileged-services.d.ts.map +1 -1
  37. package/packages/jam/state/privileged-services.js +1 -6
  38. package/packages/jam/state/service.d.ts +1 -1
  39. package/packages/jam/state/service.d.ts.map +1 -1
  40. package/packages/jam/state/statistics.d.ts +0 -8
  41. package/packages/jam/state/statistics.d.ts.map +1 -1
  42. package/packages/jam/state/statistics.js +14 -44
  43. package/packages/jam/state/statistics.test.js +1 -8
  44. package/packages/jam/state/test.utils.d.ts +1 -1
  45. package/packages/jam/state/test.utils.d.ts.map +1 -1
  46. package/packages/jam/state/test.utils.js +4 -22
  47. package/packages/jam/state-json/accounts.d.ts +10 -0
  48. package/packages/jam/state-json/accounts.d.ts.map +1 -1
  49. package/packages/jam/state-json/accounts.js +47 -19
  50. package/packages/jam/state-json/dump.d.ts.map +1 -1
  51. package/packages/jam/state-json/dump.js +5 -9
  52. package/packages/jam/state-json/dump.test.js +2 -10
  53. package/packages/jam/state-json/statistics.d.ts +1 -1
  54. package/packages/jam/state-json/statistics.d.ts.map +1 -1
  55. package/packages/jam/state-json/statistics.js +1 -13
  56. package/packages/jam/state-merkleization/in-memory-state-codec.d.ts +29 -31
  57. package/packages/jam/state-merkleization/in-memory-state-codec.d.ts.map +1 -1
  58. package/packages/jam/state-merkleization/serialize.d.ts +4 -4
  59. package/packages/jam/state-merkleization/serialize.d.ts.map +1 -1
  60. package/packages/jam/state-merkleization/serialize.js +5 -8
  61. package/packages/jam/state-merkleization/serialized-state-view.d.ts.map +1 -1
  62. package/packages/jam/state-merkleization/state-entries.test.js +1 -7
  63. package/packages/jam/state-vectors/index.d.ts +75 -75
  64. package/packages/jam/transition/accumulate/accumulate-state.d.ts +1 -2
  65. package/packages/jam/transition/accumulate/accumulate-state.d.ts.map +1 -1
  66. package/packages/jam/transition/accumulate/accumulate-utils.d.ts.map +1 -1
  67. package/packages/jam/transition/accumulate/accumulate-utils.js +2 -6
  68. package/packages/jam/transition/accumulate/accumulate-utils.test.js +2 -4
  69. package/packages/jam/transition/accumulate/accumulate.d.ts.map +1 -1
  70. package/packages/jam/transition/accumulate/accumulate.js +11 -20
  71. package/packages/jam/transition/accumulate/index.d.ts +0 -1
  72. package/packages/jam/transition/accumulate/index.d.ts.map +1 -1
  73. package/packages/jam/transition/accumulate/index.js +0 -1
  74. package/packages/jam/transition/accumulate/operand.d.ts +7 -7
  75. package/packages/jam/transition/chain-stf.d.ts +3 -5
  76. package/packages/jam/transition/chain-stf.d.ts.map +1 -1
  77. package/packages/jam/transition/chain-stf.js +5 -29
  78. package/packages/jam/transition/disputes/disputes.test.data2.d.ts +3 -3
  79. package/packages/jam/transition/disputes/disputes.test.data2.d.ts.map +1 -1
  80. package/packages/jam/transition/externalities/accumulate-externalities.d.ts.map +1 -1
  81. package/packages/jam/transition/externalities/accumulate-externalities.js +22 -49
  82. package/packages/jam/transition/externalities/accumulate-externalities.test.js +8 -72
  83. package/packages/jam/transition/externalities/fetch-externalities.d.ts +3 -22
  84. package/packages/jam/transition/externalities/fetch-externalities.d.ts.map +1 -1
  85. package/packages/jam/transition/externalities/fetch-externalities.js +3 -55
  86. package/packages/jam/transition/externalities/fetch-externalities.test.js +199 -112
  87. package/packages/jam/transition/statistics.d.ts +0 -7
  88. package/packages/jam/transition/statistics.d.ts.map +1 -1
  89. package/packages/jam/transition/statistics.js +2 -11
  90. package/packages/jam/transition/statistics.test.js +0 -40
  91. package/packages/workers/block-authorship/generator.test.d.ts +2 -0
  92. package/packages/workers/block-authorship/generator.test.d.ts.map +1 -0
  93. package/packages/workers/block-authorship/generator.test.js +200 -0
  94. package/packages/workers/block-authorship/package.json +1 -1
  95. package/packages/workers/block-authorship/protocol.d.ts +50 -50
  96. package/packages/workers/importer/package.json +1 -1
  97. package/packages/workers/importer/protocol.d.ts +54 -54
  98. package/packages/workers/jam-network/protocol.d.ts +79 -79
  99. package/packages/jam/transition/accumulate/deferred-transfers.d.ts +0 -36
  100. package/packages/jam/transition/accumulate/deferred-transfers.d.ts.map +0 -1
  101. package/packages/jam/transition/accumulate/deferred-transfers.js +0 -94
@@ -10,7 +10,7 @@ import { FixedSizeArray, HashSet } from "#@typeberry/collections";
10
10
  import { tinyChainSpec } from "#@typeberry/config";
11
11
  import { Blake2b, HASH_SIZE } from "#@typeberry/hash";
12
12
  import { tryAsU16, tryAsU32 } from "#@typeberry/numbers";
13
- import { Compatibility, deepEqual, GpVersion } from "#@typeberry/utils";
13
+ import { deepEqual } from "#@typeberry/utils";
14
14
  import { generateNextServiceId, getWorkPackageHashes, uniquePreserveOrder } from "./accumulate-utils.js";
15
15
  let blake2b;
16
16
  before(async () => {
@@ -78,9 +78,7 @@ describe("accumulate-utils", () => {
78
78
  const serviceId = tryAsServiceId(5);
79
79
  const entropy = Bytes.fill(HASH_SIZE, 4).asOpaque();
80
80
  const timeslot = tryAsTimeSlot(6);
81
- const expectedServiceId = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
82
- ? tryAsServiceId(2596254713)
83
- : tryAsServiceId(2596189433);
81
+ const expectedServiceId = tryAsServiceId(2596254713);
84
82
  const result = generateNextServiceId({ serviceId, entropy, timeslot }, tinyChainSpec, blake2b);
85
83
  assert.strictEqual(result, expectedServiceId);
86
84
  });
@@ -1 +1 @@
1
- {"version":3,"file":"accumulate.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/accumulate/accumulate.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,SAAS,EAIf,MAAM,kBAAkB,CAAC;AAM1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,KAAK,OAAO,EAA8B,MAAM,iBAAiB,CAAC;AAiB3E,OAAO,EAAyC,MAAM,EAAa,MAAM,kBAAkB,CAAC;AAM5F,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EAGrB,MAAM,uBAAuB,CAAC;AAO/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,eAAO,MAAM,kBAAkB,8BAA8B,CAAC;AAC9D,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAC;AA2B3D,qBAAa,UAAU;aAEH,SAAS,EAAE,SAAS;aACpB,OAAO,EAAE,OAAO;aAChB,KAAK,EAAE,eAAe;aACtB,OAAO,EAAE,iBAAiB;gBAH1B,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,eAAe,EACtB,OAAO,EAAE,iBAAiB;IAO5C;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAkB7B;;;;OAIG;YACW,uBAAuB;IAqGrC;;;;OAIG;YACW,uBAAuB;IAoDrC;;;;;;;OAOG;YACW,4BAA4B;IA8D1C;;;;;;;OAOG;YACW,sBAAsB;IAsEpC,OAAO,CAAC,gBAAgB;IAuCxB,OAAO,CAAC,kBAAkB;IAsB1B;;;;;;;;;OASG;YACW,oBAAoB;IA6ClC;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAkDlC;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAcnB;;;;;;OAMG;IACI,6BAA6B,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,OAAO;IAKhE,UAAU,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;CAwGrH"}
1
+ {"version":3,"file":"accumulate.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/accumulate/accumulate.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,SAAS,EAIf,MAAM,kBAAkB,CAAC;AAM1B,OAAO,KAAK,EAAE,SAAS,E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nextServiceId = generateNextServiceId({ serviceId, entropy, timeslot: slot }, this.chainSpec, this.blake2b);
88
88
  const partialState = new AccumulateExternalities(this.chainSpec, this.blake2b, updatedState, serviceId, nextServiceId, slot);
89
- const fetchExternalities = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
90
- ? FetchExternalities.createForAccumulate({ entropy, transfers, operands }, this.chainSpec)
91
- : FetchExternalities.createForPre071Accumulate({ entropy, operands }, this.chainSpec);
89
+ const fetchExternalities = FetchExternalities.createForAccumulate({ entropy, transfers, operands }, this.chainSpec);
92
90
  const externalities = {
93
91
  partialState,
94
92
  serviceExternalities: partialState,
@@ -137,19 +135,16 @@ export class Accumulate {
137
135
  async accumulateSingleService(serviceId, transfers, operands, gasCost, slot, entropy, inputStateUpdate) {
138
136
  logger.log `Accumulating service ${serviceId}, transfers: ${transfers.length} operands: ${operands.length} at slot: ${slot}`;
139
137
  const updatedState = new PartiallyUpdatedState(this.state, inputStateUpdate);
140
- // update service balance from incoming transfers
141
- if (Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)) {
142
- const serviceInfo = updatedState.getServiceInfo(serviceId);
143
- if (serviceInfo !== null) {
144
- // update the balance from incoming tranfsers
145
- const newBalance = sumU64(serviceInfo.balance, ...transfers.map((item) => item.amount));
146
- if (newBalance.overflow) {
147
- logger.log `Accumulation failed because of overflowing balance ${serviceId}.`;
148
- return { stateUpdate: null, consumedGas: tryAsServiceGas(0n) };
149
- }
150
- const newInfo = ServiceAccountInfo.create({ ...serviceInfo, balance: newBalance.value });
151
- updatedState.updateServiceInfo(serviceId, newInfo);
138
+ const serviceInfo = updatedState.getServiceInfo(serviceId);
139
+ if (serviceInfo !== null) {
140
+ // update the balance from incoming transfers
141
+ const newBalance = sumU64(serviceInfo.balance, ...transfers.map((item) => item.amount));
142
+ if (newBalance.overflow) {
143
+ logger.log `Accumulation failed because of overflowing balance ${serviceId}.`;
144
+ return { stateUpdate: null, consumedGas: tryAsServiceGas(0n) };
152
145
  }
146
+ const newInfo = ServiceAccountInfo.create({ ...serviceInfo, balance: newBalance.value });
147
+ updatedState.updateServiceInfo(serviceId, newInfo);
153
148
  }
154
149
  const result = await this.pvmAccumulateInvocation(slot, serviceId, transfers, operands, gasCost, entropy, updatedState);
155
150
  if (result.isError) {
@@ -384,7 +379,6 @@ export class Accumulate {
384
379
  }
385
380
  async transition({ reports, slot, entropy }) {
386
381
  const statistics = new Map();
387
- const legacyTransfers = [];
388
382
  const yieldedRoots = new Map();
389
383
  const accumulateQueue = new AccumulateQueue(this.chainSpec, this.state);
390
384
  const toAccumulateImmediately = accumulateQueue.getWorkReportsToAccumulateImmediately(reports);
@@ -395,9 +389,7 @@ export class Accumulate {
395
389
  const accumulatableReports = ArrayView.from(toAccumulateImmediately.concat(queue));
396
390
  const gasLimit = this.getGasLimit();
397
391
  const autoAccumulateServices = this.state.privilegedServices.autoAccumulateServices;
398
- const { accumulatedReports, gasCost, state, ...rest } = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
399
- ? await this.accumulateSequentially(gasLimit, accumulatableReports, [], slot, entropy, statistics, AccumulationStateUpdate.empty(), autoAccumulateServices, yieldedRoots)
400
- : await this.accumulateSequentiallyLegacy(gasLimit, accumulatableReports, slot, entropy, statistics, AccumulationStateUpdate.empty(), autoAccumulateServices, yieldedRoots, legacyTransfers);
392
+ const { accumulatedReports, gasCost, state, ...rest } = await this.accumulateSequentially(gasLimit, accumulatableReports, [], slot, entropy, statistics, AccumulationStateUpdate.empty(), autoAccumulateServices, yieldedRoots);
401
393
  // we can safely ignore top-level gas cost from accSequentially.
402
394
  const _gasCost = gasCost;
403
395
  assertEmpty(rest);
@@ -434,7 +426,6 @@ export class Accumulate {
434
426
  ...authQueues,
435
427
  },
436
428
  accumulationStatistics: statistics,
437
- pendingTransfers: legacyTransfers,
438
429
  accumulationOutputLog: accumulationOutput,
439
430
  });
440
431
  }
@@ -1,5 +1,4 @@
1
1
  export * from "./accumulate.js";
2
2
  export * from "./accumulate-state.js";
3
- export * from "./deferred-transfers.js";
4
3
  export * from "./options.js";
5
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/accumulate/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/accumulate/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC"}
@@ -1,4 +1,3 @@
1
1
  export * from "./accumulate.js";
2
2
  export * from "./accumulate-state.js";
3
- export * from "./deferred-transfers.js";
4
3
  export * from "./options.js";
@@ -18,20 +18,20 @@ export declare class Operand extends WithDebug {
18
18
  payloadHash: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32>, import("@typeberry/bytes").Bytes<32>>;
19
19
  gas: import("@typeberry/codec").Descriptor<bigint & import("@typeberry/numbers").WithBytesRepresentation<8> & import("@typeberry/utils").WithOpaque<"ServiceGas[u64]">, import("@typeberry/numbers").U64>;
20
20
  result: import("@typeberry/codec").Descriptor<WorkExecResult, {
21
- kind: import("@typeberry/block/work-result.js").WorkExecResultKind.ok;
21
+ kind: import("@typeberry/block").WorkExecResultKind.ok;
22
22
  okBlob: BytesBlob;
23
23
  } | {
24
- kind: import("@typeberry/block/work-result.js").WorkExecResultKind.outOfGas;
24
+ kind: import("@typeberry/block").WorkExecResultKind.outOfGas;
25
25
  } | {
26
- kind: import("@typeberry/block/work-result.js").WorkExecResultKind.panic;
26
+ kind: import("@typeberry/block").WorkExecResultKind.panic;
27
27
  } | {
28
- kind: import("@typeberry/block/work-result.js").WorkExecResultKind.incorrectNumberOfExports;
28
+ kind: import("@typeberry/block").WorkExecResultKind.incorrectNumberOfExports;
29
29
  } | {
30
- kind: import("@typeberry/block/work-result.js").WorkExecResultKind.digestTooBig;
30
+ kind: import("@typeberry/block").WorkExecResultKind.digestTooBig;
31
31
  } | {
32
- kind: import("@typeberry/block/work-result.js").WorkExecResultKind.badCode;
32
+ kind: import("@typeberry/block").WorkExecResultKind.badCode;
33
33
  } | {
34
- kind: import("@typeberry/block/work-result.js").WorkExecResultKind.codeOversize;
34
+ kind: import("@typeberry/block").WorkExecResultKind.codeOversize;
35
35
  }>;
36
36
  authorizationOutput: import("@typeberry/codec").Descriptor<BytesBlob, BytesBlob>;
37
37
  }>>;
@@ -7,7 +7,7 @@ import type { SafroleErrorCode, SafroleStateUpdate } from "#@typeberry/safrole/s
7
7
  import { type SafroleSealError } from "#@typeberry/safrole/safrole-seal.js";
8
8
  import type { State, WithStateView } from "#@typeberry/state";
9
9
  import { type ErrorResult, Result, type TaggedError } from "#@typeberry/utils";
10
- import { type ACCUMULATION_ERROR, type AccumulateOptions, type AccumulateStateUpdate, type DeferredTransfersErrorCode } from "./accumulate/index.js";
10
+ import { type ACCUMULATION_ERROR, type AccumulateOptions, type AccumulateStateUpdate } from "./accumulate/index.js";
11
11
  import { type AssurancesError, type AssurancesStateUpdate } from "./assurances.js";
12
12
  import { type AuthorizationStateUpdate } from "./authorization.js";
13
13
  import type { TransitionHasher } from "./hasher.js";
@@ -32,10 +32,9 @@ export declare enum StfErrorKind {
32
32
  Preimages = 4,
33
33
  SafroleSeal = 5,
34
34
  Accumulate = 6,
35
- DeferredTransfers = 7,
36
- Offenders = 8
35
+ Offenders = 7
37
36
  }
38
- export type StfError = TaggedError<StfErrorKind.Assurances, AssurancesError> | TaggedError<StfErrorKind.Reports, ReportsError> | TaggedError<StfErrorKind.Disputes, DisputesErrorCode> | TaggedError<StfErrorKind.Safrole, SafroleErrorCode> | TaggedError<StfErrorKind.Preimages, PreimagesErrorCode> | TaggedError<StfErrorKind.SafroleSeal, SafroleSealError> | TaggedError<StfErrorKind.Accumulate, ACCUMULATION_ERROR> | TaggedError<StfErrorKind.DeferredTransfers, DeferredTransfersErrorCode> | TaggedError<StfErrorKind.Offenders, OFFENDERS_ERROR>;
37
+ export type StfError = TaggedError<StfErrorKind.Assurances, AssurancesError> | TaggedError<StfErrorKind.Reports, ReportsError> | TaggedError<StfErrorKind.Disputes, DisputesErrorCode> | TaggedError<StfErrorKind.Safrole, SafroleErrorCode> | TaggedError<StfErrorKind.Preimages, PreimagesErrorCode> | TaggedError<StfErrorKind.SafroleSeal, SafroleSealError> | TaggedError<StfErrorKind.Accumulate, ACCUMULATION_ERROR> | TaggedError<StfErrorKind.Offenders, OFFENDERS_ERROR>;
39
38
  export declare const stfError: <Kind extends StfErrorKind, Err extends StfError["error"]>(kind: Kind, nested: ErrorResult<Err>) => Result<Ok, {
40
39
  readonly kind: Kind;
41
40
  readonly error: Err;
@@ -55,7 +54,6 @@ export declare class OnChain {
55
54
  private readonly assurances;
56
55
  private readonly accumulate;
57
56
  private readonly accumulateOutput;
58
- private readonly deferredTransfers;
59
57
  private readonly preimages;
60
58
  private readonly recentHistory;
61
59
  private readonly authorization;
@@ -1 +1 @@
1
- {"version":3,"file":"chain-stf.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/transition/chain-stf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAa,UAAU,EAAa,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI9F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAGnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAY,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAIpF,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAC1F,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,oCAAo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Q,CAAC,gBAAgB,CAAmB;IAEpD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IAGtC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAE9C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAE9C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IAExC,OAAO,CAAC,mBAAmB,CAA4C;gBAGrD,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,GAAG,aAAa,EAC5B,MAAM,EAAE,gBAAgB,EACxC,OAAO,EAAE,iBAAiB,EAC1B,WAAW,EAAE,WAAW;IAqB1B,4DAA4D;IACtD,mBAAmB;YAQX,UAAU;IAKlB,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IAqNzF,OAAO,CAAC,uBAAuB;CAWhC"}
@@ -5,9 +5,9 @@ import { Logger } from "#@typeberry/logger";
5
5
  import { Safrole } from "#@typeberry/safrole";
6
6
  import { BandernsatchWasm } from "#@typeberry/safrole/bandersnatch-wasm.js";
7
7
  import { SafroleSeal } from "#@typeberry/safrole/safrole-seal.js";
8
- import { assertEmpty, Compatibility, check, GpVersion, measure, OK, Result, } from "#@typeberry/utils";
8
+ import { assertEmpty, measure, OK, Result } from "#@typeberry/utils";
9
9
  import { AccumulateOutput } from "./accumulate/accumulate-output.js";
10
- import { Accumulate, DeferredTransfers, } from "./accumulate/index.js";
10
+ import { Accumulate, } from "./accumulate/index.js";
11
11
  import { Assurances } from "./assurances.js";
12
12
  import { Authorization } from "./authorization.js";
13
13
  import { Preimages } from "./preimages.js";
@@ -53,8 +53,7 @@ export var StfErrorKind;
53
53
  StfErrorKind[StfErrorKind["Preimages"] = 4] = "Preimages";
54
54
  StfErrorKind[StfErrorKind["SafroleSeal"] = 5] = "SafroleSeal";
55
55
  StfErrorKind[StfErrorKind["Accumulate"] = 6] = "Accumulate";
56
- StfErrorKind[StfErrorKind["DeferredTransfers"] = 7] = "DeferredTransfers";
57
- StfErrorKind[StfErrorKind["Offenders"] = 8] = "Offenders";
56
+ StfErrorKind[StfErrorKind["Offenders"] = 7] = "Offenders";
58
57
  })(StfErrorKind || (StfErrorKind = {}));
59
58
  export const stfError = (kind, nested) => {
60
59
  return Result.taggedError(StfErrorKind, kind, nested);
@@ -75,8 +74,6 @@ export class OnChain {
75
74
  // chapter 12: https://graypaper.fluffylabs.dev/#/68eaa1f/159f02159f02?v=0.6.4
76
75
  accumulate;
77
76
  accumulateOutput;
78
- // chapter 12.3: https://graypaper.fluffylabs.dev/#/68eaa1f/178203178203?v=0.6.4
79
- deferredTransfers;
80
77
  // chapter 12.4: https://graypaper.fluffylabs.dev/#/68eaa1f/18cc0018cc00?v=0.6.4
81
78
  preimages;
82
79
  // after accumulation
@@ -101,7 +98,6 @@ export class OnChain {
101
98
  this.assurances = new Assurances(chainSpec, state, hasher.blake2b);
102
99
  this.accumulate = new Accumulate(chainSpec, hasher.blake2b, state, options);
103
100
  this.accumulateOutput = new AccumulateOutput();
104
- this.deferredTransfers = new DeferredTransfers(chainSpec, hasher.blake2b, state, options.pvm);
105
101
  this.preimages = new Preimages(state, hasher.blake2b);
106
102
  this.authorization = new Authorization(chainSpec, state);
107
103
  }
@@ -216,29 +212,10 @@ export class OnChain {
216
212
  if (accumulateResult.isError) {
217
213
  return stfError(StfErrorKind.Accumulate, accumulateResult);
218
214
  }
219
- const { stateUpdate: accumulateUpdate, accumulationStatistics, pendingTransfers, accumulationOutputLog, ...accumulateRest } = accumulateResult.ok;
215
+ const { stateUpdate: accumulateUpdate, accumulationStatistics, accumulationOutputLog, ...accumulateRest } = accumulateResult.ok;
220
216
  assertEmpty(accumulateRest);
221
217
  const { privilegedServices: maybePrivilegedServices, authQueues: maybeAuthorizationQueues, designatedValidatorData: maybeDesignatedValidatorData, preimages: accumulatePreimages, accumulationQueue, recentlyAccumulated, ...servicesUpdateFromAccumulate } = accumulateUpdate;
222
- let transferStatistics = new Map();
223
- let servicesUpdate = { ...servicesUpdateFromAccumulate, preimages: accumulatePreimages };
224
- if (!Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)) {
225
- const deferredTransfersResult = await this.deferredTransfers.transition({
226
- entropy: entropy[0],
227
- pendingTransfers,
228
- servicesUpdate,
229
- timeslot: timeSlot,
230
- });
231
- if (deferredTransfersResult.isError) {
232
- return stfError(StfErrorKind.DeferredTransfers, deferredTransfersResult);
233
- }
234
- const { servicesUpdate: servicesUpdateFromDeferredTransfers, transferStatistics: transferStatisticsFromDeferredTransfers, ...deferredTransfersRest } = deferredTransfersResult.ok;
235
- transferStatistics = transferStatisticsFromDeferredTransfers;
236
- servicesUpdate = servicesUpdateFromDeferredTransfers;
237
- assertEmpty(deferredTransfersRest);
238
- }
239
- else {
240
- check `${pendingTransfers.length === 0} All transfers should be already accumulated.`;
241
- }
218
+ const servicesUpdate = { ...servicesUpdateFromAccumulate, preimages: accumulatePreimages };
242
219
  const accumulateRoot = await this.accumulateOutput.transition({ accumulationOutputLog });
243
220
  // recent history
244
221
  const recentHistoryUpdate = this.recentHistory.transition({
@@ -264,7 +241,6 @@ export class OnChain {
264
241
  incomingReports: extrinsic.guarantees.map((g) => g.report),
265
242
  availableReports,
266
243
  accumulationStatistics,
267
- transferStatistics,
268
244
  reporters: reporters,
269
245
  currentValidatorData,
270
246
  });
@@ -2,8 +2,8 @@ import { type WorkPackageHash } from "#@typeberry/block/refine-context.js";
2
2
  import { WorkReport } from "#@typeberry/block/work-report.js";
3
3
  export declare const currentValidatorData: readonly import("@typeberry/state").ValidatorData[] & import("@typeberry/utils").WithOpaque<"ValidatorsCount">;
4
4
  export declare const previousValidatorData: readonly import("@typeberry/state").ValidatorData[] & import("@typeberry/utils").WithOpaque<"ValidatorsCount">;
5
- export declare const verdicts: import("@typeberry/block/disputes.js").Verdict[];
6
- export declare const culprits: import("@typeberry/block/disputes.js").Culprit[];
7
- export declare const faults: import("@typeberry/block/disputes.js").Fault[];
5
+ export declare const verdicts: import("@typeberry/block").Verdict[];
6
+ export declare const culprits: import("@typeberry/block").Culprit[];
7
+ export declare const faults: import("@typeberry/block").Fault[];
8
8
  export declare function workReport(packageHash: WorkPackageHash, coreIndex: number): WorkReport;
9
9
  //# sourceMappingURL=disputes.test.data2.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"disputes.test.data2.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/disputes/disputes.test.data2.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,KAAK,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACzF,OAAO,EAAmB,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAS9E,eAAO,MAAM,oBAAoB,gHA4BhC,CAAC;AAEF,eAAO,MAAM,qBAAqB,gHA4BjC,CAAC;AAEF,eAAO,MAAM,QAAQ,kDAyED,CAAC;AAErB,eAAO,MAAM,QAAQ,kDAaD,CAAC;AAErB,eAAO,MAAM,MAAM,gDAQD,CAAC;AAEnB,wBAAgB,UAAU,CAAC,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cA4CzE"}
1
+ {"version":3,"file":"disputes.test.data2.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/disputes/disputes.test.data2.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,KAAK,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACzF,OAAO,EAAmB,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAS9E,eAAO,MAAM,oBAAoB,gHA4BhC,CAAC;AAEF,eAAO,MAAM,qBAAqB,gHA4BjC,CAAC;AAEF,eAAO,MAAM,QAAQ,sCAyED,CAAC;AAErB,eAAO,MAAM,QAAQ,sCAaD,CAAC;AAErB,eAAO,MAAM,MAAM,oCAQD,CAAC;AAEnB,wBAAgB,UAAU,CAAC,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cA4CzE"}
@@ -1 +1 @@
1
- {"version":3,"file":"accumulate-externalities.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/externalities/accumulate-externalities.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,QAAQ,EAId,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,KAAK,OAAO,EAAa,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EACL,uBAAuB,EAEvB,UAAU,EACV,mBAAmB,EACnB,KAAK,OAAO,EACZ,eAAe,EACf,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EAEjB,KAAK,cAAc,EAEnB,oBAAoB,EACpB,oBAAoB,EAEpB,KAAK,mBAAmB,EACxB,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EAEtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAsC,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EACL,KAAK,wBAAwB,EAE7B,KAAK,OAAO,EAGZ,kBAAkB,EAClB,KAAK,UAAU,EAGf,KAAK,aAAa,EACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAgD,EAAE,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAmB5F,qBAAa,uBACX,YAAW,YAAY,EAAE,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,OAAO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F,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,EAAE,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI;IAOvE,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,CAAC;IAyBhF,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,EAAE,IAAI,EAAE,YAAY,GAAG,SAAS,GAAG,IAAI;CAO1E"}
1
+ {"version":3,"file":"accumulate-externalities.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/externalities/accumulate-externalities.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,QAAQ,EAId,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,KAAK,OAAO,EAAa,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EACL,uBAAuB,EAEvB,UAAU,EACV,mBAAmB,EACnB,KAAK,OAAO,EACZ,eAAe,EACf,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EAEjB,KAAK,cAAc,EAEnB,oBAAoB,EACpB,oBAAoB,EAEpB,KAAK,mBAAmB,EACxB,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EAEtB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAsC,KAAK,GA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,GACjD,MAAM,CAAC,EAAE,EAAE,qBAAqB,CAAC;IAoBpC,KAAK,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAK7B,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,EAAE,QAAQ,EAAE,SAAS,GAAG,MAAM,CAAC,EAAE,EAAE,oBAAoB,CAAC;IAuDnG,KAAK,CAAC,WAAW,EAAE,SAAS,GAAG,IAAI,EAAE,gBAAgB,EAAE,YAAY,GAAG,MAAM,CAAC,EAAE,EAAE,UAAU,CAAC;IA8D5F,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,EAAE,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI;IAOvE,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,CAAC;IAyBhF,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,EAAE,IAAI,EAAE,YAAY,GAAG,SAAS,GAAG,IAAI;CAO1E"}
@@ -6,7 +6,7 @@ import { AccumulationStateUpdate, clampU64ToU32, EjectError, ForgetPreimageError
6
6
  import { Logger } from "#@typeberry/logger";
7
7
  import { maxU64, sumU64, tryAsU32, tryAsU64 } from "#@typeberry/numbers";
8
8
  import { LookupHistoryItem, PreimageItem, PrivilegedServices, ServiceAccountInfo, tryAsLookupHistorySlots, UpdatePreimage, } from "#@typeberry/state";
9
- import { assertNever, Compatibility, check, GpVersion, OK, Result } from "#@typeberry/utils";
9
+ import { assertNever, check, OK, Result } from "#@typeberry/utils";
10
10
  /**
11
11
  * Number of storage items required for ejection of the service.
12
12
  *
@@ -102,10 +102,7 @@ export class AccumulateExternalities {
102
102
  /** `check`: https://graypaper.fluffylabs.dev/#/ab2cdbd/30c60330c603?v=0.7.2 */
103
103
  getNextAvailableServiceId(serviceId) {
104
104
  let currentServiceId = serviceId;
105
- const mod = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
106
- ? 2 ** 32 - MIN_PUBLIC_SERVICE_INDEX - 2 ** 8
107
- : 2 ** 32 - 2 ** 9;
108
- const offset = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1) ? MIN_PUBLIC_SERVICE_INDEX : 2 ** 8;
105
+ const mod = 2 ** 32 - MIN_PUBLIC_SERVICE_INDEX - 2 ** 8;
109
106
  for (;;) {
110
107
  const service = this.getServiceInfo(currentServiceId);
111
108
  // we found an empty id
@@ -113,7 +110,7 @@ export class AccumulateExternalities {
113
110
  return currentServiceId;
114
111
  }
115
112
  // keep trying
116
- currentServiceId = tryAsServiceId(((currentServiceId - offset + 1 + mod) % mod) + offset);
113
+ currentServiceId = tryAsServiceId(((currentServiceId - MIN_PUBLIC_SERVICE_INDEX + 1 + mod) % mod) + MIN_PUBLIC_SERVICE_INDEX);
117
114
  }
118
115
  }
119
116
  checkPreimageStatus(hash, length) {
@@ -304,25 +301,23 @@ export class AccumulateExternalities {
304
301
  ...currentService,
305
302
  balance: tryAsU64(balanceLeftForCurrent),
306
303
  });
307
- if (Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)) {
308
- if (wantedServiceId < MIN_PUBLIC_SERVICE_INDEX &&
309
- this.currentServiceId === this.updatedState.getPrivilegedServices().registrar) {
310
- // NOTE: It's safe to cast to `Number` here, bcs here service ID cannot be bigger than 2**16
311
- const newServiceId = tryAsServiceId(Number(wantedServiceId));
312
- if (this.getServiceInfo(newServiceId) !== null) {
313
- return Result.error(NewServiceError.RegistrarServiceIdAlreadyTaken, () => `Service ID ${newServiceId} already taken`);
314
- }
315
- // add the new service with selected ID
316
- // https://graypaper.fluffylabs.dev/#/ab2cdbd/36be0336c003?v=0.7.2
317
- this.updatedState.createService(newServiceId, newAccount, newLookupItem);
318
- // update the balance of current service
319
- // https://graypaper.fluffylabs.dev/#/ab2cdbd/36c20336c403?v=0.7.2
320
- this.updatedState.updateServiceInfo(this.currentServiceId, updatedCurrentAccount);
321
- return Result.ok(newServiceId);
304
+ if (wantedServiceId < MIN_PUBLIC_SERVICE_INDEX &&
305
+ this.currentServiceId === this.updatedState.getPrivilegedServices().registrar) {
306
+ // NOTE: It's safe to cast to `Number` here, bcs here service ID cannot be bigger than 2**16
307
+ const newServiceId = tryAsServiceId(Number(wantedServiceId));
308
+ if (this.getServiceInfo(newServiceId) !== null) {
309
+ return Result.error(NewServiceError.RegistrarServiceIdAlreadyTaken, () => `Service ID ${newServiceId} already taken`);
322
310
  }
323
- // NOTE: in case the service is not a registrar or the requested serviceId is out of range,
324
- // we completely ignore the `wantedServiceId` and assign a random one
325
- }
311
+ // add the new service with selected ID
312
+ // https://graypaper.fluffylabs.dev/#/ab2cdbd/36be0336c003?v=0.7.2
313
+ this.updatedState.createService(newServiceId, newAccount, newLookupItem);
314
+ // update the balance of current service
315
+ // https://graypaper.fluffylabs.dev/#/ab2cdbd/36c20336c403?v=0.7.2
316
+ this.updatedState.updateServiceInfo(this.currentServiceId, updatedCurrentAccount);
317
+ return Result.ok(newServiceId);
318
+ }
319
+ // NOTE: in case the service is not a registrar or the requested serviceId is out of range,
320
+ // we completely ignore the `wantedServiceId` and assign a random one
326
321
  const newServiceId = this.nextNewServiceId;
327
322
  // add the new service
328
323
  // https://graypaper.fluffylabs.dev/#/7e6ff6a/36cb0236cb02?v=0.6.7
@@ -367,7 +362,7 @@ export class AccumulateExternalities {
367
362
  logger.trace `Current service id (${this.currentServiceId}) is not an auth manager of core ${coreIndex} (expected: ${currentAssigners}) and cannot update authorization queue.`;
368
363
  return Result.error(UpdatePrivilegesError.UnprivilegedService, () => `Service ${this.currentServiceId} not assigner for core ${coreIndex} (expected: ${currentAssigners})`);
369
364
  }
370
- if (assigners === null && Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)) {
365
+ if (assigners === null) {
371
366
  logger.trace `The new auth manager is not a valid service id.`;
372
367
  return Result.error(UpdatePrivilegesError.InvalidServiceId, () => `New auth manager is null for core ${coreIndex}`);
373
368
  }
@@ -375,25 +370,6 @@ export class AccumulateExternalities {
375
370
  return Result.ok(OK);
376
371
  }
377
372
  updatePrivilegedServices(manager, assigners, delegator, registrar, autoAccumulateServices) {
378
- if (!Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)) {
379
- /** https://graypaper.fluffylabs.dev/#/7e6ff6a/36d90036de00?v=0.6.7 */
380
- const current = this.updatedState.getPrivilegedServices();
381
- const isManager = current.manager === this.currentServiceId;
382
- if (!isManager) {
383
- return Result.error(UpdatePrivilegesError.UnprivilegedService, () => `Service ${this.currentServiceId} is not manager`);
384
- }
385
- if (manager === null || delegator === null) {
386
- return Result.error(UpdatePrivilegesError.InvalidServiceId, () => "Either manager or delegator is not a valid service id.");
387
- }
388
- this.updatedState.stateUpdate.privilegedServices = PrivilegedServices.create({
389
- manager,
390
- assigners,
391
- delegator,
392
- registrar: registrar ?? tryAsServiceId(0),
393
- autoAccumulateServices,
394
- });
395
- return Result.ok(OK);
396
- }
397
373
  if (manager === null || delegator === null || registrar === null) {
398
374
  return Result.error(UpdatePrivilegesError.InvalidServiceId, () => "Either manager or delegator or registrar is not a valid service id.");
399
375
  }
@@ -527,9 +503,6 @@ export class AccumulateExternalities {
527
503
  }
528
504
  }
529
505
  function bumpServiceId(serviceId) {
530
- const mod = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
531
- ? 2 ** 32 - MIN_PUBLIC_SERVICE_INDEX - 2 ** 8
532
- : 2 ** 32 - 2 ** 9;
533
- const offset = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1) ? MIN_PUBLIC_SERVICE_INDEX : 2 ** 8;
534
- return tryAsServiceId(offset + ((serviceId - offset + 42 + mod) % mod));
506
+ const mod = 2 ** 32 - MIN_PUBLIC_SERVICE_INDEX - 2 ** 8;
507
+ return tryAsServiceId(MIN_PUBLIC_SERVICE_INDEX + ((serviceId - MIN_PUBLIC_SERVICE_INDEX + 42 + mod) % mod));
535
508
  }
@@ -10,7 +10,7 @@ import { EjectError, ForgetPreimageError, NewServiceError, PartiallyUpdatedState
10
10
  import { tryAsU32, tryAsU64 } from "#@typeberry/numbers";
11
11
  import { AUTHORIZATION_QUEUE_SIZE, InMemoryService, InMemoryState, LookupHistoryItem, PreimageItem, PrivilegedServices, ServiceAccountInfo, StorageItem, tryAsLookupHistorySlots, tryAsPerCore, UpdatePreimage, UpdateService, VALIDATOR_META_BYTES, ValidatorData, } from "#@typeberry/state";
12
12
  import { testState } from "#@typeberry/state/test.utils.js";
13
- import { asOpaqueType, Compatibility, deepEqual, GpVersion, OK, Result } from "#@typeberry/utils";
13
+ import { asOpaqueType, deepEqual, OK, Result } from "#@typeberry/utils";
14
14
  import { AccumulateExternalities } from "./accumulate-externalities.js";
15
15
  let blake2b;
16
16
  before(async () => {
@@ -19,9 +19,7 @@ before(async () => {
19
19
  function partiallyUpdatedState() {
20
20
  return new PartiallyUpdatedState(testState());
21
21
  }
22
- const INVALID_SERVICE_ID_ERROR = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
23
- ? "Either manager or delegator or registrar is not a valid service id."
24
- : "Either manager or delegator is not a valid service id.";
22
+ const INVALID_SERVICE_ID_ERROR = "Either manager or delegator or registrar is not a valid service id.";
25
23
  describe("PartialState.checkPreimageStatus", () => {
26
24
  it("should check preimage status from state", () => {
27
25
  const state = partiallyUpdatedState();
@@ -342,7 +340,6 @@ describe("PartialState.forgetPreimage", () => {
342
340
  });
343
341
  });
344
342
  describe("PartialState.newService", () => {
345
- const itPost071 = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1) ? it : it.skip;
346
343
  it("should create a new service and update balance + next service ID", () => {
347
344
  const state = partiallyUpdatedState();
348
345
  const maybeService = state.state.services.get(tryAsServiceId(0));
@@ -398,14 +395,9 @@ describe("PartialState.newService", () => {
398
395
  ]));
399
396
  assert.deepStrictEqual(state.stateUpdate.services.created, [expectedServiceId]);
400
397
  // Verify next service ID bumped
401
- if (Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)) {
402
- assert.deepStrictEqual(partialState.getNextNewServiceId(), tryAsServiceId(4294901556));
403
- }
404
- else {
405
- assert.deepStrictEqual(partialState.getNextNewServiceId(), tryAsServiceId(4294966836));
406
- }
398
+ assert.deepStrictEqual(partialState.getNextNewServiceId(), tryAsServiceId(4294901556));
407
399
  });
408
- itPost071("should create a new service with givent id and update balance + not changed next service ID", () => {
400
+ it("should create a new service with given id and update balance + not changed next service ID", () => {
409
401
  const state = partiallyUpdatedState();
410
402
  const serviceId = 0;
411
403
  // setting registrar privileges for our service
@@ -534,7 +526,7 @@ describe("PartialState.newService", () => {
534
526
  // Verify no side effects
535
527
  assert.deepStrictEqual(state.stateUpdate.services.updated, new Map());
536
528
  });
537
- itPost071("should return an error if attempting to create new service with selected id that already exists", () => {
529
+ it("should return an error if attempting to create new service with selected id that already exists", () => {
538
530
  const state = partiallyUpdatedState();
539
531
  const serviceId = 0;
540
532
  // setting registrar privileges for our service
@@ -562,7 +554,7 @@ describe("PartialState.newService", () => {
562
554
  // Verify next service ID is not bumped
563
555
  assert.deepStrictEqual(partialState.getNextNewServiceId(), tryAsServiceId(10));
564
556
  });
565
- itPost071("should create a new service with random id if service is unprivileged to select new service id + next service id", () => {
557
+ it("should create a new service with random id if service is unprivileged to select new service id + next service id", () => {
566
558
  const state = partiallyUpdatedState();
567
559
  // setting different service than our privileged registrar
568
560
  state.stateUpdate.privilegedServices = {
@@ -671,7 +663,6 @@ describe("PartialState.upgradeService", () => {
671
663
  });
672
664
  });
673
665
  describe("PartialState.updateAuthorizationQueue", () => {
674
- const itPost071 = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1) ? it : it.skip;
675
666
  it("should update the authorization queue for a given core index", () => {
676
667
  const state = partiallyUpdatedState();
677
668
  const partialState = new AccumulateExternalities(tinyChainSpec, blake2b, state, tryAsServiceId(0), tryAsServiceId(10), tryAsTimeSlot(16));
@@ -683,7 +674,7 @@ describe("PartialState.updateAuthorizationQueue", () => {
683
674
  // then
684
675
  assert.deepStrictEqual(state.stateUpdate.authorizationQueues.get(coreIndex), queue);
685
676
  });
686
- itPost071("should return InvalidServiceId when given auth manager is invalid", () => {
677
+ it("should return InvalidServiceId when given auth manager is invalid", () => {
687
678
  const state = partiallyUpdatedState();
688
679
  const partialState = new AccumulateExternalities(tinyChainSpec, blake2b, state, tryAsServiceId(0), tryAsServiceId(10), tryAsTimeSlot(16));
689
680
  const coreIndex = tryAsCoreIndex(0);
@@ -729,7 +720,6 @@ describe("PartialState.updateAuthorizationQueue", () => {
729
720
  });
730
721
  });
731
722
  describe("PartialState.updatePrivilegedServices", () => {
732
- const [itPre071, itPost071] = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1) ? [it.skip, it] : [it, it.skip];
733
723
  it("should update privileged services", () => {
734
724
  const state = partiallyUpdatedState();
735
725
  const partialState = new AccumulateExternalities(tinyChainSpec, blake2b, state, tryAsServiceId(0), tryAsServiceId(10), tryAsTimeSlot(16));
@@ -753,60 +743,6 @@ describe("PartialState.updatePrivilegedServices", () => {
753
743
  autoAccumulateServices,
754
744
  }));
755
745
  });
756
- itPre071("should return UnprivilegedError when current service is unprivileged", () => {
757
- const state = partiallyUpdatedState();
758
- state.state.privilegedServices = { ...state.state.privilegedServices, manager: tryAsServiceId(1) };
759
- const partialState = new AccumulateExternalities(tinyChainSpec, blake2b, state, tryAsServiceId(0), tryAsServiceId(10), tryAsTimeSlot(16));
760
- const manager = tryAsServiceId(1);
761
- const assigners = tryAsPerCore(new Array(tinyChainSpec.coresCount).fill(tryAsServiceId(2)), tinyChainSpec);
762
- const delegator = tryAsServiceId(3);
763
- const registrar = tryAsServiceId(4);
764
- const autoAccumulate = new Map([
765
- [tryAsServiceId(4), tryAsServiceGas(10n)],
766
- [tryAsServiceId(5), tryAsServiceGas(20n)],
767
- ]);
768
- // when
769
- const result = partialState.updatePrivilegedServices(manager, assigners, delegator, registrar, autoAccumulate);
770
- // then
771
- deepEqual(result, Result.error(UpdatePrivilegesError.UnprivilegedService, () => "Service 0 is not manager"));
772
- assert.deepStrictEqual(state.stateUpdate.privilegedServices, null);
773
- });
774
- itPre071("should return UnprivilegedError when current service is unprivileged and manager is invalid service id", () => {
775
- const state = partiallyUpdatedState();
776
- state.state.privilegedServices = { ...state.state.privilegedServices, manager: tryAsServiceId(1) };
777
- const partialState = new AccumulateExternalities(tinyChainSpec, blake2b, state, tryAsServiceId(0), tryAsServiceId(10), tryAsTimeSlot(16));
778
- const manager = null;
779
- const assigners = tryAsPerCore(new Array(tinyChainSpec.coresCount).fill(tryAsServiceId(2)), tinyChainSpec);
780
- const delegator = tryAsServiceId(3);
781
- const registrar = tryAsServiceId(4);
782
- const autoAccumulate = new Map([
783
- [tryAsServiceId(4), tryAsServiceGas(10n)],
784
- [tryAsServiceId(5), tryAsServiceGas(20n)],
785
- ]);
786
- // when
787
- const result = partialState.updatePrivilegedServices(manager, assigners, delegator, registrar, autoAccumulate);
788
- // then
789
- deepEqual(result, Result.error(UpdatePrivilegesError.UnprivilegedService, () => "Service 0 is not manager"));
790
- assert.deepStrictEqual(state.stateUpdate.privilegedServices, null);
791
- });
792
- itPre071("should return UnprivilegedError when current service is unprivileged and validator is invalid service id", () => {
793
- const state = partiallyUpdatedState();
794
- state.state.privilegedServices = { ...state.state.privilegedServices, manager: tryAsServiceId(1) };
795
- const partialState = new AccumulateExternalities(tinyChainSpec, blake2b, state, tryAsServiceId(0), tryAsServiceId(10), tryAsTimeSlot(16));
796
- const manager = tryAsServiceId(1);
797
- const assigners = tryAsPerCore(new Array(tinyChainSpec.coresCount).fill(tryAsServiceId(2)), tinyChainSpec);
798
- const delegator = null;
799
- const registrar = tryAsServiceId(4);
800
- const autoAccumulate = new Map([
801
- [tryAsServiceId(4), tryAsServiceGas(10n)],
802
- [tryAsServiceId(5), tryAsServiceGas(20n)],
803
- ]);
804
- // when
805
- const result = partialState.updatePrivilegedServices(manager, assigners, delegator, registrar, autoAccumulate);
806
- // then
807
- deepEqual(result, Result.error(UpdatePrivilegesError.UnprivilegedService, () => "Service 0 is not manager"));
808
- assert.deepStrictEqual(state.stateUpdate.privilegedServices, null);
809
- });
810
746
  it("should return InvalidService when given manager is invalid service id", () => {
811
747
  const state = partiallyUpdatedState();
812
748
  const partialState = new AccumulateExternalities(tinyChainSpec, blake2b, state, tryAsServiceId(0), tryAsServiceId(10), tryAsTimeSlot(16));
@@ -841,7 +777,7 @@ describe("PartialState.updatePrivilegedServices", () => {
841
777
  deepEqual(result, Result.error(UpdatePrivilegesError.InvalidServiceId, () => INVALID_SERVICE_ID_ERROR));
842
778
  assert.deepStrictEqual(state.stateUpdate.privilegedServices, null);
843
779
  });
844
- itPost071("should return InvalidService when given registrar is invalid service id", () => {
780
+ it("should return InvalidService when given registrar is invalid service id", () => {
845
781
  const state = partiallyUpdatedState();
846
782
  const partialState = new AccumulateExternalities(tinyChainSpec, blake2b, state, tryAsServiceId(0), tryAsServiceId(10), tryAsTimeSlot(16));
847
783
  const manager = tryAsServiceId(1);