@typeberry/lib 0.5.3 → 0.5.4-472e282
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/package.json +8 -4
- package/packages/core/hash/hash.d.ts.map +1 -1
- package/packages/core/hash/hash.js +1 -0
- package/packages/core/networking/certificate.d.ts.map +1 -1
- package/packages/core/networking/certificate.js +1 -0
- package/packages/core/networking/package.json +1 -1
- package/packages/core/networking/setup.d.ts.map +1 -1
- package/packages/core/networking/setup.js +16 -12
- package/packages/core/numbers/index.d.ts +4 -0
- package/packages/core/numbers/index.d.ts.map +1 -1
- package/packages/core/numbers/index.js +4 -4
- package/packages/core/pvm-host-calls/host-calls-executor.d.ts +23 -17
- package/packages/core/pvm-host-calls/host-calls-executor.d.ts.map +1 -1
- package/packages/core/pvm-host-calls/host-calls-executor.js +23 -31
- package/packages/core/pvm-interpreter/ops/math-consts.d.ts +2 -3
- package/packages/core/pvm-interpreter/ops/math-consts.d.ts.map +1 -1
- package/packages/core/pvm-interpreter/ops/math-consts.js +2 -3
- package/packages/core/pvm-interpreter/ops/math-ops.js +3 -3
- package/packages/core/pvm-interpreter/ops/math-utils.js +13 -13
- package/packages/core/pvm-interpreter/ops/math-utils.test.js +17 -16
- package/packages/core/telemetry/package.json +1 -1
- package/packages/core/utils/compatibility.d.ts +0 -1
- package/packages/core/utils/compatibility.d.ts.map +1 -1
- package/packages/core/utils/compatibility.js +1 -2
- package/packages/core/utils/compatibility.test.js +6 -10
- package/packages/extensions/ipc/jamnp/handler.d.ts +5 -4
- package/packages/extensions/ipc/jamnp/handler.d.ts.map +1 -1
- package/packages/extensions/ipc/jamnp/handler.js +59 -34
- package/packages/extensions/ipc/jamnp/stream.d.ts +6 -4
- package/packages/extensions/ipc/jamnp/stream.d.ts.map +1 -1
- package/packages/jam/block/index.d.ts +11 -11
- package/packages/jam/block/index.d.ts.map +1 -1
- package/packages/jam/block/index.js +11 -11
- package/packages/jam/block/work-item.d.ts +13 -4
- package/packages/jam/block/work-item.d.ts.map +1 -1
- package/packages/jam/block/work-package.d.ts +3 -1
- package/packages/jam/block/work-package.d.ts.map +1 -1
- package/packages/jam/block/work-package.js +6 -2
- package/packages/jam/block/work-result.d.ts +3 -5
- package/packages/jam/block/work-result.d.ts.map +1 -1
- package/packages/jam/block/work-result.js +6 -0
- package/packages/jam/block-json/block.d.ts +125 -0
- package/packages/jam/block-json/block.d.ts.map +1 -1
- package/packages/jam/block-json/block.js +9 -2
- package/packages/jam/block-json/work-result.d.ts.map +1 -1
- package/packages/jam/block-json/work-result.js +6 -6
- package/packages/jam/database-lmdb/states.test.js +2 -3
- package/packages/jam/executor/index.d.ts +4 -0
- package/packages/jam/executor/index.d.ts.map +1 -0
- package/packages/jam/executor/index.js +2 -0
- package/packages/jam/{transition/accumulate → executor}/pvm-executor.d.ts +19 -16
- package/packages/jam/executor/pvm-executor.d.ts.map +1 -0
- package/packages/jam/{transition/accumulate → executor}/pvm-executor.js +46 -3
- package/packages/jam/fuzz-proto/v1/handler.d.ts +1 -1
- package/packages/jam/fuzz-proto/v1/handler.d.ts.map +1 -1
- package/packages/jam/fuzz-proto/v1/handler.js +43 -19
- package/packages/jam/fuzz-proto/v1/types.d.ts +1 -1
- package/packages/jam/in-core/externalities/refine.d.ts +24 -0
- package/packages/jam/in-core/externalities/refine.d.ts.map +1 -0
- package/packages/jam/in-core/externalities/refine.js +36 -0
- package/packages/jam/in-core/in-core.d.ts +60 -0
- package/packages/jam/in-core/in-core.d.ts.map +1 -0
- package/packages/jam/in-core/in-core.js +294 -0
- package/packages/jam/in-core/in-core.test.d.ts +2 -0
- package/packages/jam/in-core/in-core.test.d.ts.map +1 -0
- package/packages/jam/in-core/in-core.test.js +81 -0
- package/packages/jam/in-core/index.d.ts +2 -0
- package/packages/jam/in-core/index.d.ts.map +1 -0
- package/packages/jam/in-core/index.js +1 -0
- package/packages/jam/jam-host-calls/accumulate/bless.d.ts.map +1 -1
- package/packages/jam/jam-host-calls/accumulate/bless.js +6 -10
- package/packages/jam/jam-host-calls/accumulate/bless.test.js +32 -73
- package/packages/jam/jam-host-calls/accumulate/new.d.ts.map +1 -1
- package/packages/jam/jam-host-calls/accumulate/new.js +2 -4
- package/packages/jam/jam-host-calls/accumulate/new.test.js +4 -5
- package/packages/jam/jam-host-calls/general/fetch.d.ts +1 -57
- package/packages/jam/jam-host-calls/general/fetch.d.ts.map +1 -1
- package/packages/jam/jam-host-calls/general/fetch.js +6 -29
- package/packages/jam/jam-host-calls/general/fetch.test.js +2 -58
- package/packages/jam/jamnp-s/peers.d.ts.map +1 -1
- package/packages/jam/jamnp-s/peers.js +10 -0
- package/packages/jam/jamnp-s/protocol/ce-128-block-request.d.ts +1 -1
- package/packages/jam/jamnp-s/protocol/ce-128-block-request.d.ts.map +1 -1
- package/packages/jam/jamnp-s/protocol/ce-128-block-request.js +10 -8
- package/packages/jam/jamnp-s/protocol/ce-129-state-request.d.ts.map +1 -1
- package/packages/jam/jamnp-s/protocol/ce-129-state-request.js +11 -9
- package/packages/jam/jamnp-s/protocol/ce-131-ce-132-safrole-ticket-distribution.d.ts +3 -3
- package/packages/jam/jamnp-s/protocol/ce-131-ce-132-safrole-ticket-distribution.d.ts.map +1 -1
- package/packages/jam/jamnp-s/protocol/ce-131-ce-132-safrole-ticket-distribution.js +2 -2
- package/packages/jam/jamnp-s/protocol/ce-133-work-package-submission.d.ts +9 -9
- package/packages/jam/jamnp-s/protocol/ce-133-work-package-submission.d.ts.map +1 -1
- package/packages/jam/jamnp-s/protocol/ce-133-work-package-submission.js +2 -2
- package/packages/jam/jamnp-s/protocol/ce-134-work-package-sharing.d.ts.map +1 -1
- package/packages/jam/jamnp-s/protocol/ce-134-work-package-sharing.js +8 -6
- package/packages/jam/jamnp-s/protocol/ce-135-work-report-distribution.d.ts +16 -16
- package/packages/jam/jamnp-s/protocol/ce-135-work-report-distribution.d.ts.map +1 -1
- package/packages/jam/jamnp-s/protocol/ce-135-work-report-distribution.js +2 -2
- package/packages/jam/jamnp-s/protocol/ce-135-work-report-distribution.test.js +2 -2
- package/packages/jam/jamnp-s/protocol/stream.d.ts +13 -7
- package/packages/jam/jamnp-s/protocol/stream.d.ts.map +1 -1
- package/packages/jam/jamnp-s/protocol/stream.js +5 -4
- package/packages/jam/jamnp-s/protocol/test-utils.d.ts +1 -1
- package/packages/jam/jamnp-s/protocol/test-utils.d.ts.map +1 -1
- package/packages/jam/jamnp-s/protocol/test-utils.js +9 -12
- package/packages/jam/jamnp-s/protocol/up-0-block-announcement.d.ts +2 -2
- package/packages/jam/jamnp-s/protocol/up-0-block-announcement.d.ts.map +1 -1
- package/packages/jam/jamnp-s/protocol/up-0-block-announcement.js +1 -1
- package/packages/jam/jamnp-s/stream-manager.d.ts.map +1 -1
- package/packages/jam/jamnp-s/stream-manager.js +7 -5
- package/packages/jam/jamnp-s/stream-manager.test.js +8 -5
- package/packages/jam/jamnp-s/tasks/sync.js +1 -1
- package/packages/jam/node/jam-config.d.ts +4 -1
- package/packages/jam/node/jam-config.d.ts.map +1 -1
- package/packages/jam/node/jam-config.js +6 -2
- package/packages/jam/node/main.d.ts.map +1 -1
- package/packages/jam/node/main.js +5 -4
- package/packages/jam/node/package.json +1 -1
- package/packages/jam/node/reader.d.ts +25 -25
- package/packages/jam/node/workers.d.ts +183 -183
- package/packages/jam/rpc-validation/types.d.ts +7 -3
- package/packages/jam/rpc-validation/types.d.ts.map +1 -1
- package/packages/jam/rpc-validation/validation.d.ts +254 -36
- package/packages/jam/rpc-validation/validation.d.ts.map +1 -1
- package/packages/jam/rpc-validation/validation.js +20 -2
- package/packages/jam/state/accumulation-queue.d.ts +26 -26
- package/packages/jam/state/assurances.d.ts +26 -26
- package/packages/jam/state/in-memory-state.d.ts.map +1 -1
- package/packages/jam/state/in-memory-state.js +2 -3
- package/packages/jam/state/privileged-services.d.ts +1 -1
- package/packages/jam/state/privileged-services.d.ts.map +1 -1
- package/packages/jam/state/privileged-services.js +1 -6
- package/packages/jam/state/service.d.ts +1 -1
- package/packages/jam/state/service.d.ts.map +1 -1
- package/packages/jam/state/statistics.d.ts +0 -8
- package/packages/jam/state/statistics.d.ts.map +1 -1
- package/packages/jam/state/statistics.js +14 -44
- package/packages/jam/state/statistics.test.js +1 -8
- package/packages/jam/state/test.utils.d.ts +1 -1
- package/packages/jam/state/test.utils.d.ts.map +1 -1
- package/packages/jam/state/test.utils.js +6 -25
- package/packages/jam/state-json/accounts.d.ts +10 -0
- package/packages/jam/state-json/accounts.d.ts.map +1 -1
- package/packages/jam/state-json/accounts.js +47 -19
- package/packages/jam/state-json/dump.d.ts.map +1 -1
- package/packages/jam/state-json/dump.js +5 -9
- package/packages/jam/state-json/dump.test.js +2 -10
- package/packages/jam/state-json/statistics.d.ts +1 -1
- package/packages/jam/state-json/statistics.d.ts.map +1 -1
- package/packages/jam/state-json/statistics.js +1 -13
- package/packages/jam/state-merkleization/in-memory-state-codec.d.ts +29 -31
- package/packages/jam/state-merkleization/in-memory-state-codec.d.ts.map +1 -1
- package/packages/jam/state-merkleization/serialize.d.ts +4 -4
- package/packages/jam/state-merkleization/serialize.d.ts.map +1 -1
- package/packages/jam/state-merkleization/serialize.js +5 -8
- package/packages/jam/state-merkleization/serialized-state-view.d.ts.map +1 -1
- package/packages/jam/state-merkleization/state-entries.test.js +1 -7
- package/packages/jam/state-vectors/index.d.ts +377 -5
- package/packages/jam/state-vectors/index.d.ts.map +1 -1
- package/packages/jam/state-vectors/index.js +3 -3
- package/packages/jam/transition/accumulate/accumulate-data.d.ts.map +1 -1
- package/packages/jam/transition/accumulate/accumulate-data.js +1 -2
- package/packages/jam/transition/accumulate/accumulate-queue.test.js +2 -2
- package/packages/jam/transition/accumulate/accumulate-state.d.ts +1 -2
- package/packages/jam/transition/accumulate/accumulate-state.d.ts.map +1 -1
- package/packages/jam/transition/accumulate/accumulate-utils.d.ts.map +1 -1
- package/packages/jam/transition/accumulate/accumulate-utils.js +2 -6
- package/packages/jam/transition/accumulate/accumulate-utils.test.js +4 -6
- package/packages/jam/transition/accumulate/accumulate.d.ts.map +1 -1
- package/packages/jam/transition/accumulate/accumulate.js +19 -33
- package/packages/jam/transition/accumulate/accumulate.test.js +2 -2
- package/packages/jam/transition/accumulate/accumulation-result-merge-utils.d.ts.map +1 -1
- package/packages/jam/transition/accumulate/accumulation-result-merge-utils.js +1 -2
- package/packages/jam/transition/accumulate/accumulation-result-merge-utils.test.js +1 -2
- package/packages/jam/transition/accumulate/index.d.ts +0 -1
- package/packages/jam/transition/accumulate/index.d.ts.map +1 -1
- package/packages/jam/transition/accumulate/index.js +0 -1
- package/packages/jam/transition/accumulate/operand.d.ts +7 -7
- package/packages/jam/transition/chain-stf.d.ts +3 -5
- package/packages/jam/transition/chain-stf.d.ts.map +1 -1
- package/packages/jam/transition/chain-stf.js +5 -29
- package/packages/jam/transition/disputes/disputes.test.data2.d.ts +3 -3
- package/packages/jam/transition/disputes/disputes.test.data2.d.ts.map +1 -1
- package/packages/jam/transition/disputes/disputes.test.data2.js +2 -2
- package/packages/jam/transition/externalities/accumulate-externalities.d.ts.map +1 -1
- package/packages/jam/transition/externalities/accumulate-externalities.js +22 -49
- package/packages/jam/transition/externalities/accumulate-externalities.test.js +8 -72
- package/packages/jam/transition/externalities/fetch-externalities.d.ts +8 -21
- package/packages/jam/transition/externalities/fetch-externalities.d.ts.map +1 -1
- package/packages/jam/transition/externalities/fetch-externalities.js +5 -53
- package/packages/jam/transition/externalities/fetch-externalities.test.js +201 -114
- package/packages/jam/transition/hasher.test.js +2 -2
- package/packages/jam/transition/reports/error.d.ts +3 -1
- package/packages/jam/transition/reports/error.d.ts.map +1 -1
- package/packages/jam/transition/reports/error.js +2 -0
- package/packages/jam/transition/reports/test.utils.d.ts.map +1 -1
- package/packages/jam/transition/reports/test.utils.js +2 -2
- package/packages/jam/transition/reports/verify-basic.d.ts.map +1 -1
- package/packages/jam/transition/reports/verify-basic.js +10 -0
- package/packages/jam/transition/reports/verify-basic.test.js +29 -0
- package/packages/jam/transition/statistics.d.ts +0 -7
- package/packages/jam/transition/statistics.d.ts.map +1 -1
- package/packages/jam/transition/statistics.js +2 -11
- package/packages/jam/transition/statistics.test.js +0 -40
- package/packages/workers/block-authorship/generator.test.d.ts +2 -0
- package/packages/workers/block-authorship/generator.test.d.ts.map +1 -0
- package/packages/workers/block-authorship/generator.test.js +200 -0
- package/packages/workers/block-authorship/main.d.ts.map +1 -1
- package/packages/workers/block-authorship/main.js +23 -4
- package/packages/workers/block-authorship/package.json +1 -1
- package/packages/workers/block-authorship/protocol.d.ts +53 -51
- package/packages/workers/block-authorship/protocol.d.ts.map +1 -1
- package/packages/workers/block-authorship/protocol.js +6 -3
- package/packages/workers/importer/importer.d.ts.map +1 -1
- package/packages/workers/importer/importer.js +0 -1
- package/packages/workers/importer/package.json +1 -1
- package/packages/workers/importer/protocol.d.ts +54 -54
- package/packages/workers/jam-network/protocol.d.ts +79 -79
- package/packages/jam/transition/accumulate/deferred-transfers.d.ts +0 -36
- package/packages/jam/transition/accumulate/deferred-transfers.d.ts.map +0 -1
- package/packages/jam/transition/accumulate/deferred-transfers.js +0 -95
- package/packages/jam/transition/accumulate/pvm-executor.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accumulate-state.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/accumulate/accumulate-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"accumulate-state.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/accumulate/accumulate-state.ts"],"names":[],"mappings":"AAA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;CACxD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accumulate-utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/accumulate/accumulate-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAkB,MAAM,kBAAkB,CAAC;AAEnG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,KAAK,OAAO,EAAa,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"accumulate-utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/accumulate/accumulate-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAkB,MAAM,kBAAkB,CAAC;AAEnG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,KAAK,OAAO,EAAa,MAAM,iBAAiB,CAAC;AAG1D;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAQnE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC,CAGpF;AAED,KAAK,kBAAkB,GAAG;IACxB,oCAAoC;IACpC,SAAS,EAAE,SAAS,CAAC;IACrB,eAAe;IACf,OAAO,EAAE,WAAW,CAAC;IACrB,sCAAsC;IACtC,QAAQ,EAAE,QAAQ,CAAC;CACpB,CAAC;AAQF;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,kBAAkB,EACpD,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,GACf,SAAS,CAeX"}
|
|
@@ -4,7 +4,6 @@ import { codec, Encoder } from "#@typeberry/codec";
|
|
|
4
4
|
import { HashSet } from "#@typeberry/collections";
|
|
5
5
|
import { HASH_SIZE } from "#@typeberry/hash";
|
|
6
6
|
import { leBytesAsU32 } from "#@typeberry/numbers";
|
|
7
|
-
import { Compatibility, GpVersion } from "#@typeberry/utils";
|
|
8
7
|
/**
|
|
9
8
|
* A function that removes duplicates but does not change order - it keeps the first occurence.
|
|
10
9
|
*/
|
|
@@ -44,9 +43,6 @@ export function generateNextServiceId({ serviceId, entropy, timeslot }, chainSpe
|
|
|
44
43
|
}, chainSpec);
|
|
45
44
|
const result = blake2b.hashBytes(encoded).raw.subarray(0, 4);
|
|
46
45
|
const number = leBytesAsU32(result) >>> 0;
|
|
47
|
-
const mod =
|
|
48
|
-
|
|
49
|
-
: 2 ** 32 - 2 ** 9;
|
|
50
|
-
const offset = Compatibility.isGreaterOrEqual(GpVersion.V0_7_1) ? MIN_PUBLIC_SERVICE_INDEX : 2 ** 8;
|
|
51
|
-
return tryAsServiceId((number % mod) + offset);
|
|
46
|
+
const mod = 2 ** 32 - MIN_PUBLIC_SERVICE_INDEX - 2 ** 8;
|
|
47
|
+
return tryAsServiceId((number % mod) + MIN_PUBLIC_SERVICE_INDEX);
|
|
52
48
|
}
|
|
@@ -4,13 +4,13 @@ import { tryAsCoreIndex, tryAsServiceGas, tryAsServiceId, tryAsTimeSlot } from "
|
|
|
4
4
|
import { RefineContext } from "#@typeberry/block/refine-context.js";
|
|
5
5
|
import { tryAsWorkItemsCount } from "#@typeberry/block/work-package.js";
|
|
6
6
|
import { WorkPackageSpec, WorkReport } from "#@typeberry/block/work-report.js";
|
|
7
|
-
import { WorkExecResult,
|
|
7
|
+
import { WorkExecResult, WorkRefineLoad, WorkResult } from "#@typeberry/block/work-result.js";
|
|
8
8
|
import { Bytes, BytesBlob } from "#@typeberry/bytes";
|
|
9
9
|
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 {
|
|
13
|
+
import { deepEqual } from "#@typeberry/utils";
|
|
14
14
|
import { generateNextServiceId, getWorkPackageHashes, uniquePreserveOrder } from "./accumulate-utils.js";
|
|
15
15
|
let blake2b;
|
|
16
16
|
before(async () => {
|
|
@@ -52,7 +52,7 @@ describe("accumulate-utils", () => {
|
|
|
52
52
|
importedSegments: tryAsU32(0),
|
|
53
53
|
}),
|
|
54
54
|
payloadHash: Bytes.zero(HASH_SIZE).asOpaque(),
|
|
55
|
-
result:
|
|
55
|
+
result: WorkExecResult.ok(BytesBlob.empty()),
|
|
56
56
|
serviceId: tryAsServiceId(0),
|
|
57
57
|
}),
|
|
58
58
|
], tryAsWorkItemsCount(1)),
|
|
@@ -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 =
|
|
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;
|
|
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;IAmGrC;;;;OAIG;YACW,uBAAuB;IAiDrC;;;;;;;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;CA0FrH"}
|
|
@@ -3,12 +3,11 @@ import { W_C } from "#@typeberry/block/gp-constants.js";
|
|
|
3
3
|
import { Bytes } from "#@typeberry/bytes";
|
|
4
4
|
import { codec, Encoder } from "#@typeberry/codec";
|
|
5
5
|
import { ArrayView, HashSet, SortedArray } from "#@typeberry/collections";
|
|
6
|
+
import { PvmExecutor, ReturnStatus } from "#@typeberry/executor";
|
|
6
7
|
import { HASH_SIZE } from "#@typeberry/hash";
|
|
7
8
|
import { AccumulationStateUpdate, PartiallyUpdatedState, } from "#@typeberry/jam-host-calls/externalities/state-update.js";
|
|
8
9
|
import { Logger } from "#@typeberry/logger";
|
|
9
|
-
import { sumU64, tryAsU32 } from "#@typeberry/numbers";
|
|
10
|
-
import { Status, tryAsGas } from "#@typeberry/pvm-interface";
|
|
11
|
-
import { MAX_VALUE_U64 } from "#@typeberry/pvm-interpreter/ops/math-consts.js";
|
|
10
|
+
import { MAX_VALUE_U64, sumU64, tryAsU32 } from "#@typeberry/numbers";
|
|
12
11
|
import { accumulationOutputComparator, hashComparator, ServiceAccountInfo, tryAsPerCore, } from "#@typeberry/state";
|
|
13
12
|
import { assertEmpty, Compatibility, GpVersion, Result, TestSuite } from "#@typeberry/utils";
|
|
14
13
|
import { AccumulateExternalities } from "../externalities/accumulate-externalities.js";
|
|
@@ -18,7 +17,6 @@ import { AccumulateQueue, pruneQueue } from "./accumulate-queue.js";
|
|
|
18
17
|
import { GAS_TO_INVOKE_WORK_REPORT, } from "./accumulate-state.js";
|
|
19
18
|
import { generateNextServiceId, getWorkPackageHashes } from "./accumulate-utils.js";
|
|
20
19
|
import { mergePerallelAccumulationResults, } from "./accumulation-result-merge-utils.js";
|
|
21
|
-
import { PvmExecutor } from "./pvm-executor.js";
|
|
22
20
|
export const ACCUMULATION_ERROR = "duplicate service created";
|
|
23
21
|
var PvmInvocationError;
|
|
24
22
|
(function (PvmInvocationError) {
|
|
@@ -88,9 +86,7 @@ export class Accumulate {
|
|
|
88
86
|
}
|
|
89
87
|
const nextServiceId = generateNextServiceId({ serviceId, entropy, timeslot: slot }, this.chainSpec, this.blake2b);
|
|
90
88
|
const partialState = new AccumulateExternalities(this.chainSpec, this.blake2b, updatedState, serviceId, nextServiceId, slot);
|
|
91
|
-
const fetchExternalities =
|
|
92
|
-
? FetchExternalities.createForAccumulate({ entropy, transfers, operands }, this.chainSpec)
|
|
93
|
-
: FetchExternalities.createForPre071Accumulate({ entropy, operands }, this.chainSpec);
|
|
89
|
+
const fetchExternalities = FetchExternalities.createForAccumulate({ entropy, transfers, operands }, this.chainSpec);
|
|
94
90
|
const externalities = {
|
|
95
91
|
partialState,
|
|
96
92
|
serviceExternalities: partialState,
|
|
@@ -102,28 +98,25 @@ export class Accumulate {
|
|
|
102
98
|
serviceId,
|
|
103
99
|
argsLength: tryAsU32(transfers.length + operands.length),
|
|
104
100
|
});
|
|
105
|
-
const result = await executor.run(invocationArgs,
|
|
101
|
+
const result = await executor.run(invocationArgs, gas);
|
|
106
102
|
const [newState, checkpoint] = partialState.getStateUpdates();
|
|
107
103
|
/**
|
|
108
104
|
* PVM invocation returned and error so we return the checkpoint
|
|
109
105
|
*
|
|
110
106
|
* https://graypaper.fluffylabs.dev/#/7e6ff6a/300002300002?v=0.6.7
|
|
111
107
|
*/
|
|
112
|
-
if (result.
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
logger.trace `[${serviceId}] accumulate finished with ${Status[status]} reverting to checkpoint.`;
|
|
116
|
-
return Result.ok({ stateUpdate: checkpoint, consumedGas: tryAsServiceGas(result.consumedGas) });
|
|
117
|
-
}
|
|
118
|
-
logger.trace `[${serviceId}] accumulate finished with ${Status[status]}`;
|
|
108
|
+
if (result.status !== ReturnStatus.OK) {
|
|
109
|
+
logger.trace `[${serviceId}] accumulate finished with ${ReturnStatus[result.status]} reverting to checkpoint.`;
|
|
110
|
+
return Result.ok({ stateUpdate: checkpoint, consumedGas: tryAsServiceGas(result.consumedGas) });
|
|
119
111
|
}
|
|
112
|
+
logger.trace `[${serviceId}] accumulate finished with ${ReturnStatus[result.status]}`;
|
|
120
113
|
/**
|
|
121
114
|
* PVM invocation returned a hash so we override whatever `yield` host call
|
|
122
115
|
* provided.
|
|
123
116
|
*
|
|
124
117
|
* https://graypaper.fluffylabs.dev/#/7e6ff6a/301202301202?v=0.6.7
|
|
125
118
|
*/
|
|
126
|
-
if (result.
|
|
119
|
+
if (result.memorySlice.length === HASH_SIZE) {
|
|
127
120
|
const memorySlice = Bytes.fromBlob(result.memorySlice, HASH_SIZE);
|
|
128
121
|
newState.yieldedRoot = memorySlice.asOpaque();
|
|
129
122
|
}
|
|
@@ -142,19 +135,16 @@ export class Accumulate {
|
|
|
142
135
|
async accumulateSingleService(serviceId, transfers, operands, gasCost, slot, entropy, inputStateUpdate) {
|
|
143
136
|
logger.log `Accumulating service ${serviceId}, transfers: ${transfers.length} operands: ${operands.length} at slot: ${slot}`;
|
|
144
137
|
const updatedState = new PartiallyUpdatedState(this.state, inputStateUpdate);
|
|
145
|
-
|
|
146
|
-
if (
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
logger.log `Accumulation failed because of overflowing balance ${serviceId}.`;
|
|
153
|
-
return { stateUpdate: null, consumedGas: tryAsServiceGas(0n) };
|
|
154
|
-
}
|
|
155
|
-
const newInfo = ServiceAccountInfo.create({ ...serviceInfo, balance: newBalance.value });
|
|
156
|
-
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) };
|
|
157
145
|
}
|
|
146
|
+
const newInfo = ServiceAccountInfo.create({ ...serviceInfo, balance: newBalance.value });
|
|
147
|
+
updatedState.updateServiceInfo(serviceId, newInfo);
|
|
158
148
|
}
|
|
159
149
|
const result = await this.pvmAccumulateInvocation(slot, serviceId, transfers, operands, gasCost, entropy, updatedState);
|
|
160
150
|
if (result.isError) {
|
|
@@ -389,7 +379,6 @@ export class Accumulate {
|
|
|
389
379
|
}
|
|
390
380
|
async transition({ reports, slot, entropy }) {
|
|
391
381
|
const statistics = new Map();
|
|
392
|
-
const legacyTransfers = [];
|
|
393
382
|
const yieldedRoots = new Map();
|
|
394
383
|
const accumulateQueue = new AccumulateQueue(this.chainSpec, this.state);
|
|
395
384
|
const toAccumulateImmediately = accumulateQueue.getWorkReportsToAccumulateImmediately(reports);
|
|
@@ -400,9 +389,7 @@ export class Accumulate {
|
|
|
400
389
|
const accumulatableReports = ArrayView.from(toAccumulateImmediately.concat(queue));
|
|
401
390
|
const gasLimit = this.getGasLimit();
|
|
402
391
|
const autoAccumulateServices = this.state.privilegedServices.autoAccumulateServices;
|
|
403
|
-
const { accumulatedReports, gasCost, state, ...rest } =
|
|
404
|
-
? await this.accumulateSequentially(gasLimit, accumulatableReports, [], slot, entropy, statistics, AccumulationStateUpdate.empty(), autoAccumulateServices, yieldedRoots)
|
|
405
|
-
: 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);
|
|
406
393
|
// we can safely ignore top-level gas cost from accSequentially.
|
|
407
394
|
const _gasCost = gasCost;
|
|
408
395
|
assertEmpty(rest);
|
|
@@ -439,7 +426,6 @@ export class Accumulate {
|
|
|
439
426
|
...authQueues,
|
|
440
427
|
},
|
|
441
428
|
accumulationStatistics: statistics,
|
|
442
|
-
pendingTransfers: legacyTransfers,
|
|
443
429
|
accumulationOutputLog: accumulationOutput,
|
|
444
430
|
});
|
|
445
431
|
}
|
|
@@ -5,7 +5,7 @@ import { MIN_PUBLIC_SERVICE_INDEX } from "#@typeberry/block/gp-constants.js";
|
|
|
5
5
|
import { RefineContext } from "#@typeberry/block/refine-context.js";
|
|
6
6
|
import { tryAsWorkItemsCount } from "#@typeberry/block/work-package.js";
|
|
7
7
|
import { WorkPackageSpec, WorkReport } from "#@typeberry/block/work-report.js";
|
|
8
|
-
import { WorkExecResult,
|
|
8
|
+
import { WorkExecResult, WorkRefineLoad, WorkResult } from "#@typeberry/block/work-result.js";
|
|
9
9
|
import { Bytes, BytesBlob } from "#@typeberry/bytes";
|
|
10
10
|
import { asKnownSize, FixedSizeArray, HashDictionary, HashSet } from "#@typeberry/collections";
|
|
11
11
|
import { PvmBackend, PvmBackendNames, tinyChainSpec } from "#@typeberry/config";
|
|
@@ -266,7 +266,7 @@ const createWorkReport = (workPackageHash, prerequisites = [], serviceId = tryAs
|
|
|
266
266
|
importedSegments: tryAsU32(0),
|
|
267
267
|
}),
|
|
268
268
|
payloadHash: Bytes.zero(HASH_SIZE).asOpaque(),
|
|
269
|
-
result:
|
|
269
|
+
result: WorkExecResult.ok(BytesBlob.empty()),
|
|
270
270
|
serviceId,
|
|
271
271
|
}),
|
|
272
272
|
], tryAsWorkItemsCount(1)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accumulation-result-merge-utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/accumulate/accumulation-result-merge-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAmB,MAAM,kBAAkB,CAAC;AACpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"accumulation-result-merge-utils.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/accumulate/accumulation-result-merge-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAmB,MAAM,kBAAkB,CAAC;AACpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAG1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,wBAAgB,gCAAgC,CAC9C,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,eAAe,EACtB,UAAU,EAAE,uBAAuB,EACnC,OAAO,EAAE,0BAA0B,GAClC,WAAW,CAab;AAED,KAAK,SAAS,GAAG,SAAS,CAAC;AAC3B,KAAK,WAAW,GAAG;IAAE,WAAW,EAAE,UAAU,CAAC;IAAC,WAAW,EAAE,uBAAuB,CAAA;CAAE,CAAC;AAGrF,MAAM,MAAM,0BAA0B,GAAG,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAErE,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,YAAY,EAAE,UAAU,CAAC;IACzB,KAAK,EAAE,uBAAuB,CAAC;CAChC,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { tryAsServiceGas } from "#@typeberry/block";
|
|
2
2
|
import { AccumulationStateUpdate } from "#@typeberry/jam-host-calls";
|
|
3
|
-
import { sumU64 } from "#@typeberry/numbers";
|
|
4
|
-
import { MAX_VALUE_U64 } from "#@typeberry/pvm-interpreter/ops/math-consts.js";
|
|
3
|
+
import { MAX_VALUE_U64, sumU64 } from "#@typeberry/numbers";
|
|
5
4
|
import { PrivilegedServices, tryAsPerCore, UpdatePreimageKind } from "#@typeberry/state";
|
|
6
5
|
export function mergePerallelAccumulationResults(chainSpec, state, inputState, results) {
|
|
7
6
|
const mergeContext = createMergeContext(chainSpec, state, inputState, results);
|
|
@@ -7,8 +7,7 @@ import { BANDERSNATCH_KEY_BYTES, BLS_KEY_BYTES, ED25519_KEY_BYTES } from "#@type
|
|
|
7
7
|
import { HASH_SIZE } from "#@typeberry/hash";
|
|
8
8
|
import { AccumulationStateUpdate, PendingTransfer } from "#@typeberry/jam-host-calls";
|
|
9
9
|
import { TRANSFER_MEMO_BYTES } from "#@typeberry/jam-host-calls/externalities/partial-state.js";
|
|
10
|
-
import { tryAsU32, tryAsU64 } from "#@typeberry/numbers";
|
|
11
|
-
import { MAX_VALUE_U64 } from "#@typeberry/pvm-interpreter/ops/math-consts.js";
|
|
10
|
+
import { MAX_VALUE_U64, tryAsU32, tryAsU64 } from "#@typeberry/numbers";
|
|
12
11
|
import { AUTHORIZATION_QUEUE_SIZE, InMemoryState, PreimageItem, PrivilegedServices, ServiceAccountInfo, StorageItem, tryAsPerCore, UpdatePreimage, UpdateService, UpdateStorage, VALIDATOR_META_BYTES, ValidatorData, } from "#@typeberry/state";
|
|
13
12
|
import { deepEqual } from "#@typeberry/utils";
|
|
14
13
|
import { mergePerallelAccumulationResults } from "./accumulation-result-merge-utils.js";
|
|
@@ -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,
|
|
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"}
|
|
@@ -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
|
|
21
|
+
kind: import("@typeberry/block").WorkExecResultKind.ok;
|
|
22
22
|
okBlob: BytesBlob;
|
|
23
23
|
} | {
|
|
24
|
-
kind: import("@typeberry/block
|
|
24
|
+
kind: import("@typeberry/block").WorkExecResultKind.outOfGas;
|
|
25
25
|
} | {
|
|
26
|
-
kind: import("@typeberry/block
|
|
26
|
+
kind: import("@typeberry/block").WorkExecResultKind.panic;
|
|
27
27
|
} | {
|
|
28
|
-
kind: import("@typeberry/block
|
|
28
|
+
kind: import("@typeberry/block").WorkExecResultKind.incorrectNumberOfExports;
|
|
29
29
|
} | {
|
|
30
|
-
kind: import("@typeberry/block
|
|
30
|
+
kind: import("@typeberry/block").WorkExecResultKind.digestTooBig;
|
|
31
31
|
} | {
|
|
32
|
-
kind: import("@typeberry/block
|
|
32
|
+
kind: import("@typeberry/block").WorkExecResultKind.badCode;
|
|
33
33
|
} | {
|
|
34
|
-
kind: import("@typeberry/block
|
|
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
|
|
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
|
-
|
|
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.
|
|
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,
|
|
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,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAInF,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,gBAAg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QAAQ,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,
|
|
8
|
+
import { assertEmpty, measure, OK, Result } from "#@typeberry/utils";
|
|
9
9
|
import { AccumulateOutput } from "./accumulate/accumulate-output.js";
|
|
10
|
-
import { Accumulate,
|
|
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["
|
|
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,
|
|
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
|
-
|
|
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
|
|
6
|
-
export declare const culprits: import("@typeberry/block
|
|
7
|
-
export declare const faults: import("@typeberry/block
|
|
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,
|
|
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"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { tryAsCoreIndex, tryAsPerValidator, tryAsServiceGas, tryAsServiceId, tryAsTimeSlot } from "#@typeberry/block";
|
|
3
3
|
import { RefineContext } from "#@typeberry/block/refine-context.js";
|
|
4
4
|
import { WorkPackageSpec, WorkReport } from "#@typeberry/block/work-report.js";
|
|
5
|
-
import { WorkExecResult,
|
|
5
|
+
import { WorkExecResult, WorkRefineLoad, WorkResult } from "#@typeberry/block/work-result.js";
|
|
6
6
|
import { Bytes, BytesBlob } from "#@typeberry/bytes";
|
|
7
7
|
import { FixedSizeArray } from "#@typeberry/collections";
|
|
8
8
|
import { tinyChainSpec } from "#@typeberry/config";
|
|
@@ -174,7 +174,7 @@ export function workReport(packageHash, coreIndex) {
|
|
|
174
174
|
codeHash: Bytes.zero(HASH_SIZE).asOpaque(),
|
|
175
175
|
payloadHash: Bytes.zero(HASH_SIZE).asOpaque(),
|
|
176
176
|
gas: tryAsServiceGas(42),
|
|
177
|
-
result:
|
|
177
|
+
result: WorkExecResult.ok(BytesBlob.parseBlob("0x010203")),
|
|
178
178
|
load: WorkRefineLoad.create({
|
|
179
179
|
gasUsed: tryAsServiceGas(0),
|
|
180
180
|
importedSegments: tryAsU32(0),
|
|
@@ -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,
|
|
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,O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AAG,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,
|
|
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 =
|
|
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 -
|
|
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 (
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
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
|
-
//
|
|
324
|
-
//
|
|
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
|
|
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 =
|
|
531
|
-
|
|
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
|
}
|