@typeberry/lib 0.5.4 → 0.5.5-befa219

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 (123) hide show
  1. package/bin/lib/scripts/build-lib.js +1 -0
  2. package/package.json +5 -1
  3. package/packages/core/json-parser/descriptors.d.ts.map +1 -1
  4. package/packages/core/json-parser/descriptors.js +3 -0
  5. package/packages/core/json-parser/index.test.js +30 -0
  6. package/packages/core/networking/package.json +1 -1
  7. package/packages/core/pvm-host-calls/ecalli-trace-logger.js +1 -1
  8. package/packages/core/pvm-host-calls/ecalli-trace-logger.test.js +7 -7
  9. package/packages/core/pvm-host-calls/host-call-registers.js +1 -1
  10. package/packages/core/telemetry/package.json +1 -1
  11. package/packages/core/utils/compatibility.d.ts +0 -1
  12. package/packages/core/utils/compatibility.d.ts.map +1 -1
  13. package/packages/core/utils/compatibility.js +1 -2
  14. package/packages/core/utils/compatibility.test.js +6 -10
  15. package/packages/jam/block/index.d.ts +11 -11
  16. package/packages/jam/block/index.d.ts.map +1 -1
  17. package/packages/jam/block/index.js +11 -11
  18. package/packages/jam/block-json/block.d.ts +25 -25
  19. package/packages/jam/database-lmdb/states.test.js +3 -5
  20. package/packages/jam/fuzz-proto/v1/types.d.ts +1 -1
  21. package/packages/jam/jam-host-calls/accumulate/bless.d.ts.map +1 -1
  22. package/packages/jam/jam-host-calls/accumulate/bless.js +6 -10
  23. package/packages/jam/jam-host-calls/accumulate/bless.test.js +32 -72
  24. package/packages/jam/jam-host-calls/accumulate/new.d.ts.map +1 -1
  25. package/packages/jam/jam-host-calls/accumulate/new.js +2 -4
  26. package/packages/jam/jam-host-calls/accumulate/new.test.js +4 -5
  27. package/packages/jam/jam-host-calls/general/fetch.d.ts +1 -57
  28. package/packages/jam/jam-host-calls/general/fetch.d.ts.map +1 -1
  29. package/packages/jam/jam-host-calls/general/fetch.js +6 -29
  30. package/packages/jam/jam-host-calls/general/fetch.test.js +2 -58
  31. package/packages/jam/jamnp-s/protocol/ce-133-work-package-submission.d.ts +4 -4
  32. package/packages/jam/jamnp-s/protocol/ce-135-work-report-distribution.d.ts +13 -13
  33. package/packages/jam/jamnp-s/protocol/up-0-block-announcement.d.ts +1 -1
  34. package/packages/jam/node/package.json +1 -1
  35. package/packages/jam/node/reader.d.ts +25 -25
  36. package/packages/jam/node/workers.d.ts +183 -183
  37. package/packages/jam/safrole/bandersnatch-vrf.d.ts +7 -2
  38. package/packages/jam/safrole/bandersnatch-vrf.d.ts.map +1 -1
  39. package/packages/jam/safrole/bandersnatch-vrf.js +34 -1
  40. package/packages/jam/safrole/bandersnatch-vrf.test.js +15 -0
  41. package/packages/jam/safrole/bandersnatch-wasm.d.ts +1 -0
  42. package/packages/jam/safrole/bandersnatch-wasm.d.ts.map +1 -1
  43. package/packages/jam/safrole/bandersnatch-wasm.js +3 -0
  44. package/packages/jam/state/accumulation-queue.d.ts +26 -26
  45. package/packages/jam/state/assurances.d.ts +26 -26
  46. package/packages/jam/state/privileged-services.d.ts +1 -1
  47. package/packages/jam/state/privileged-services.d.ts.map +1 -1
  48. package/packages/jam/state/privileged-services.js +1 -6
  49. package/packages/jam/state/service.d.ts +1 -1
  50. package/packages/jam/state/service.d.ts.map +1 -1
  51. package/packages/jam/state/statistics.d.ts +0 -8
  52. package/packages/jam/state/statistics.d.ts.map +1 -1
  53. package/packages/jam/state/statistics.js +14 -44
  54. package/packages/jam/state/statistics.test.js +1 -8
  55. package/packages/jam/state/test.utils.d.ts +1 -1
  56. package/packages/jam/state/test.utils.d.ts.map +1 -1
  57. package/packages/jam/state/test.utils.js +4 -22
  58. package/packages/jam/state-json/accounts.d.ts +10 -0
  59. package/packages/jam/state-json/accounts.d.ts.map +1 -1
  60. package/packages/jam/state-json/accounts.js +47 -19
  61. package/packages/jam/state-json/dump.d.ts.map +1 -1
  62. package/packages/jam/state-json/dump.js +5 -9
  63. package/packages/jam/state-json/dump.test.js +2 -10
  64. package/packages/jam/state-json/statistics.d.ts +1 -1
  65. package/packages/jam/state-json/statistics.d.ts.map +1 -1
  66. package/packages/jam/state-json/statistics.js +1 -13
  67. package/packages/jam/state-merkleization/in-memory-state-codec.d.ts +29 -31
  68. package/packages/jam/state-merkleization/in-memory-state-codec.d.ts.map +1 -1
  69. package/packages/jam/state-merkleization/serialize.d.ts +4 -4
  70. package/packages/jam/state-merkleization/serialize.d.ts.map +1 -1
  71. package/packages/jam/state-merkleization/serialize.js +5 -8
  72. package/packages/jam/state-merkleization/serialized-state-view.d.ts.map +1 -1
  73. package/packages/jam/state-merkleization/state-entries.test.js +1 -7
  74. package/packages/jam/state-vectors/index.d.ts +75 -75
  75. package/packages/jam/transition/accumulate/accumulate-data.d.ts.map +1 -1
  76. package/packages/jam/transition/accumulate/accumulate-data.js +6 -1
  77. package/packages/jam/transition/accumulate/accumulate-state.d.ts +1 -2
  78. package/packages/jam/transition/accumulate/accumulate-state.d.ts.map +1 -1
  79. package/packages/jam/transition/accumulate/accumulate-utils.d.ts.map +1 -1
  80. package/packages/jam/transition/accumulate/accumulate-utils.js +2 -6
  81. package/packages/jam/transition/accumulate/accumulate-utils.test.js +2 -4
  82. package/packages/jam/transition/accumulate/accumulate.d.ts +0 -9
  83. package/packages/jam/transition/accumulate/accumulate.d.ts.map +1 -1
  84. package/packages/jam/transition/accumulate/accumulate.js +15 -57
  85. package/packages/jam/transition/accumulate/index.d.ts +0 -1
  86. package/packages/jam/transition/accumulate/index.d.ts.map +1 -1
  87. package/packages/jam/transition/accumulate/index.js +0 -1
  88. package/packages/jam/transition/accumulate/operand.d.ts +7 -7
  89. package/packages/jam/transition/chain-stf.d.ts +3 -5
  90. package/packages/jam/transition/chain-stf.d.ts.map +1 -1
  91. package/packages/jam/transition/chain-stf.js +5 -29
  92. package/packages/jam/transition/disputes/disputes.test.data2.d.ts +3 -3
  93. package/packages/jam/transition/disputes/disputes.test.data2.d.ts.map +1 -1
  94. package/packages/jam/transition/externalities/accumulate-externalities.d.ts.map +1 -1
  95. package/packages/jam/transition/externalities/accumulate-externalities.js +22 -49
  96. package/packages/jam/transition/externalities/accumulate-externalities.test.js +8 -72
  97. package/packages/jam/transition/externalities/fetch-externalities.d.ts +3 -22
  98. package/packages/jam/transition/externalities/fetch-externalities.d.ts.map +1 -1
  99. package/packages/jam/transition/externalities/fetch-externalities.js +3 -55
  100. package/packages/jam/transition/externalities/fetch-externalities.test.js +199 -112
  101. package/packages/jam/transition/statistics.d.ts +0 -7
  102. package/packages/jam/transition/statistics.d.ts.map +1 -1
  103. package/packages/jam/transition/statistics.js +2 -11
  104. package/packages/jam/transition/statistics.test.js +0 -40
  105. package/packages/workers/block-authorship/generator.test.d.ts +2 -0
  106. package/packages/workers/block-authorship/generator.test.d.ts.map +1 -0
  107. package/packages/workers/block-authorship/generator.test.js +200 -0
  108. package/packages/workers/block-authorship/main.d.ts.map +1 -1
  109. package/packages/workers/block-authorship/main.js +31 -1
  110. package/packages/workers/block-authorship/package.json +1 -1
  111. package/packages/workers/block-authorship/protocol.d.ts +50 -50
  112. package/packages/workers/block-authorship/ticket-generator.d.ts +21 -0
  113. package/packages/workers/block-authorship/ticket-generator.d.ts.map +1 -0
  114. package/packages/workers/block-authorship/ticket-generator.js +37 -0
  115. package/packages/workers/block-authorship/ticket-generator.test.d.ts +2 -0
  116. package/packages/workers/block-authorship/ticket-generator.test.d.ts.map +1 -0
  117. package/packages/workers/block-authorship/ticket-generator.test.js +100 -0
  118. package/packages/workers/importer/package.json +1 -1
  119. package/packages/workers/importer/protocol.d.ts +54 -54
  120. package/packages/workers/jam-network/protocol.d.ts +79 -79
  121. package/packages/jam/transition/accumulate/deferred-transfers.d.ts +0 -36
  122. package/packages/jam/transition/accumulate/deferred-transfers.d.ts.map +0 -1
  123. 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
  });
@@ -30,15 +30,6 @@ export declare class Accumulate {
30
30
  * https://graypaper.fluffylabs.dev/#/7e6ff6a/18d70118d701?v=0.6.7
31
31
  */
32
32
  private accumulateSingleService;
33
- /**
34
- * The outer accumulation function ∆+ which transforms a gas-limit, a sequence of work-reports,
35
- * an initial partial-state and a dictionary of services enjoying free accumulation,
36
- * into a tuple of the number of work-results accumulated, a posterior state-context,
37
- * the resultant deferred-transfers and accumulation-output pairing.
38
- *
39
- * https://graypaper.fluffylabs.dev/#/7e6ff6a/179d00179d00?v=0.6.7
40
- */
41
- private accumulateSequentiallyLegacy;
42
33
  /**
43
34
  * The outer accumulation function ∆+ which transforms a gas-limit, a sequence of work-reports,
44
35
  * an initial partial-state and a dictionary of services enjoying free accumulation,
@@ -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,EA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O,CAAC,MAAM,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,CAAC;CA0FrH"}
@@ -86,9 +86,7 @@ export class Accumulate {
86
86
  }
87
87
  const 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) {
@@ -162,40 +157,6 @@ export class Accumulate {
162
157
  logger.log `Accumulation successful for ${serviceId}. Consumed: ${result.ok.consumedGas}`;
163
158
  return result.ok;
164
159
  }
165
- /**
166
- * The outer accumulation function ∆+ which transforms a gas-limit, a sequence of work-reports,
167
- * an initial partial-state and a dictionary of services enjoying free accumulation,
168
- * into a tuple of the number of work-results accumulated, a posterior state-context,
169
- * the resultant deferred-transfers and accumulation-output pairing.
170
- *
171
- * https://graypaper.fluffylabs.dev/#/7e6ff6a/179d00179d00?v=0.6.7
172
- */
173
- async accumulateSequentiallyLegacy(gasLimit, reports, slot, entropy, statistics, stateUpdate, autoAccumulateServices, yieldedRoots, transfers) {
174
- const i = this.findReportCutoffIndex(gasLimit, reports);
175
- if (i === 0) {
176
- return {
177
- accumulatedReports: tryAsU32(0),
178
- gasCost: tryAsServiceGas(0),
179
- state: stateUpdate,
180
- };
181
- }
182
- const reportsToAccumulateInParallel = reports.subview(0, i);
183
- const accumulateData = new AccumulateData(reportsToAccumulateInParallel, [], autoAccumulateServices);
184
- const reportsToAccumulateSequentially = reports.subview(i);
185
- const results = await this.accumulateInParallel(accumulateData, slot, entropy, stateUpdate);
186
- this.updateStatistics(results, statistics, accumulateData);
187
- this.updateYieldedRoots(results, yieldedRoots);
188
- const { state: stateAfterParallelAcc, totalGasCost, transfers: newTransfers, } = mergePerallelAccumulationResults(this.chainSpec, this.state, stateUpdate, results);
189
- transfers.push(...newTransfers);
190
- // NOTE [ToDr] recursive invocation
191
- const { accumulatedReports, gasCost: seqGasCost, state, ...seqRest } = await this.accumulateSequentiallyLegacy(tryAsServiceGas(gasLimit - totalGasCost), reportsToAccumulateSequentially, slot, entropy, statistics, stateAfterParallelAcc, new Map(), yieldedRoots, transfers);
192
- assertEmpty(seqRest);
193
- return {
194
- accumulatedReports: tryAsU32(i + accumulatedReports),
195
- gasCost: tryAsServiceGas(totalGasCost + seqGasCost),
196
- state,
197
- };
198
- }
199
160
  /**
200
161
  * The outer accumulation function ∆+ which transforms a gas-limit, a sequence of work-reports,
201
162
  * an initial partial-state and a dictionary of services enjoying free accumulation,
@@ -206,7 +167,8 @@ export class Accumulate {
206
167
  */
207
168
  async accumulateSequentially(gasLimit, reports, transfers, slot, entropy, statistics, stateUpdate, autoAccumulateServices, yieldedRoots) {
208
169
  const i = this.findReportCutoffIndex(gasLimit, reports);
209
- const n = transfers.length + i + reports.length;
170
+ /** https://graypaper.fluffylabs.dev/#/ab2cdbd/17e50117e501?v=0.7.2 */
171
+ const n = transfers.length + i + autoAccumulateServices.size;
210
172
  if (n === 0) {
211
173
  return {
212
174
  accumulatedReports: tryAsU32(0),
@@ -222,11 +184,11 @@ export class Accumulate {
222
184
  this.updateYieldedRoots(results, yieldedRoots);
223
185
  const { state: stateAfterParallelAcc, totalGasCost, transfers: newTransfers, } = mergePerallelAccumulationResults(this.chainSpec, this.state, stateUpdate, results);
224
186
  /**
225
- * Gas limit from transfers is added to the next round of accumulation
187
+ * Gas limit from transfers (from `t`, not `t*`) is added to the next round of accumulation
226
188
  *
227
189
  * https://graypaper.fluffylabs.dev/#/ab2cdbd/172b02172b02?v=0.7.2
228
190
  */
229
- const transfersGas = newTransfers.map((t) => t.gas);
191
+ const transfersGas = transfers.map((t) => t.gas);
230
192
  const { value: newGasLimit, overflow } = sumU64(tryAsServiceGas(gasLimit - totalGasCost), ...transfersGas);
231
193
  // NOTE [ToDr] recursive invocation
232
194
  const { accumulatedReports, gasCost: seqGasCost, state, ...seqRest } = await this.accumulateSequentially(tryAsServiceGas(overflow ? MAX_VALUE_U64 : newGasLimit), reportsToAccumulateSequentially, newTransfers, slot, entropy, statistics, stateAfterParallelAcc, new Map(), yieldedRoots);
@@ -384,7 +346,6 @@ export class Accumulate {
384
346
  }
385
347
  async transition({ reports, slot, entropy }) {
386
348
  const statistics = new Map();
387
- const legacyTransfers = [];
388
349
  const yieldedRoots = new Map();
389
350
  const accumulateQueue = new AccumulateQueue(this.chainSpec, this.state);
390
351
  const toAccumulateImmediately = accumulateQueue.getWorkReportsToAccumulateImmediately(reports);
@@ -395,9 +356,7 @@ export class Accumulate {
395
356
  const accumulatableReports = ArrayView.from(toAccumulateImmediately.concat(queue));
396
357
  const gasLimit = this.getGasLimit();
397
358
  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);
359
+ const { accumulatedReports, gasCost, state, ...rest } = await this.accumulateSequentially(gasLimit, accumulatableReports, [], slot, entropy, statistics, AccumulationStateUpdate.empty(), autoAccumulateServices, yieldedRoots);
401
360
  // we can safely ignore top-level gas cost from accSequentially.
402
361
  const _gasCost = gasCost;
403
362
  assertEmpty(rest);
@@ -434,7 +393,6 @@ export class Accumulate {
434
393
  ...authQueues,
435
394
  },
436
395
  accumulationStatistics: statistics,
437
- pendingTransfers: legacyTransfers,
438
396
  accumulationOutputLog: accumulationOutput,
439
397
  });
440
398
  }
@@ -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,oCAAoC,CAAC;AACxF,OAAO,KAAK,EAAkB,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC7E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AAC,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":[],"m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G,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,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAClF,OAAO,EACL,KAAK,wBAAwB,EAE7B,KAAK,OAAO,EAG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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
  }