@typeberry/lib 0.5.10-6923c44 → 0.5.10-7338c21
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 +1 -1
- package/packages/jam/block/work-package.d.ts +7 -7
- package/packages/jam/block/work-package.d.ts.map +1 -1
- package/packages/jam/block/work-package.js +12 -12
- package/packages/jam/executor/pvm-executor.d.ts +7 -0
- package/packages/jam/executor/pvm-executor.d.ts.map +1 -1
- package/packages/jam/executor/pvm-executor.js +15 -0
- package/packages/jam/in-core/externalities/refine.d.ts +3 -3
- package/packages/jam/in-core/externalities/refine.d.ts.map +1 -1
- package/packages/jam/in-core/externalities/refine.js +33 -5
- package/packages/jam/in-core/externalities/refine.test.js +65 -0
- package/packages/jam/in-core/in-core.d.ts +7 -22
- package/packages/jam/in-core/in-core.d.ts.map +1 -1
- package/packages/jam/in-core/in-core.js +16 -184
- package/packages/jam/in-core/in-core.test.js +47 -15
- package/packages/jam/in-core/is-authorized.d.ts +33 -0
- package/packages/jam/in-core/is-authorized.d.ts.map +1 -0
- package/packages/jam/in-core/is-authorized.js +72 -0
- package/packages/jam/in-core/is-authorized.test.d.ts +2 -0
- package/packages/jam/in-core/is-authorized.test.d.ts.map +1 -0
- package/packages/jam/in-core/is-authorized.test.js +125 -0
- package/packages/jam/in-core/refine.d.ts +34 -0
- package/packages/jam/in-core/refine.d.ts.map +1 -0
- package/packages/jam/in-core/refine.js +176 -0
- package/packages/jam/in-core/refine.test.d.ts +2 -0
- package/packages/jam/in-core/refine.test.d.ts.map +1 -0
- package/packages/jam/in-core/refine.test.js +6 -0
- package/packages/jam/jam-host-calls/accumulate/bless.js +9 -9
- package/packages/jam/jam-host-calls/externalities/partial-state.d.ts +1 -1
- package/packages/jam/jam-host-calls/general/fetch.d.ts +40 -40
- package/packages/jam/jam-host-calls/general/fetch.d.ts.map +1 -1
- package/packages/jam/jam-host-calls/general/fetch.js +30 -30
- package/packages/jam/jam-host-calls/general/fetch.test.js +17 -14
- package/packages/jam/jamnp-s/protocol/ce-133-work-package-submission.d.ts +2 -2
- package/packages/jam/transition/accumulate/accumulation-result-merge-utils.js +48 -39
- package/packages/jam/transition/externalities/accumulate-externalities.d.ts +2 -2
- package/packages/jam/transition/externalities/accumulate-externalities.d.ts.map +1 -1
- package/packages/jam/transition/externalities/accumulate-externalities.js +20 -7
- package/packages/jam/transition/externalities/accumulate-externalities.test.js +74 -4
- package/packages/jam/transition/externalities/index.d.ts +1 -0
- package/packages/jam/transition/externalities/index.d.ts.map +1 -1
- package/packages/jam/transition/externalities/index.js +1 -0
- package/packages/jam/transition/externalities/is-authorized-fetch-externalities.d.ts +22 -0
- package/packages/jam/transition/externalities/is-authorized-fetch-externalities.d.ts.map +1 -0
- package/packages/jam/transition/externalities/is-authorized-fetch-externalities.js +41 -0
- package/packages/jam/transition/externalities/refine-fetch-externalities.d.ts +7 -7
- package/packages/jam/transition/externalities/refine-fetch-externalities.d.ts.map +1 -1
- package/packages/jam/transition/externalities/refine-fetch-externalities.js +17 -9
|
@@ -35,9 +35,12 @@ describe("Fetch", () => {
|
|
|
35
35
|
it("should write empty result and set IN_OUT_REG to NONE if fetch returns null", async () => {
|
|
36
36
|
const currentServiceId = tryAsServiceId(10_000);
|
|
37
37
|
const fetchMock = new RefineFetchMock();
|
|
38
|
-
//
|
|
38
|
+
// oneWorkItem returns null when the work item index has no mock response registered
|
|
39
39
|
const blob = BytesBlob.blobFromNumbers([]);
|
|
40
|
-
const { registers, memory, readBack } = prepareRegsAndMemory(blob, FetchKind.
|
|
40
|
+
const { registers, memory, readBack } = prepareRegsAndMemory(blob, FetchKind.OneWorkItem);
|
|
41
|
+
// set work item index to one that has no response → oneWorkItem returns null
|
|
42
|
+
registers.set(11, tryAsU64(999));
|
|
43
|
+
fetchMock.oneWorkItemResponses.set("999", null);
|
|
41
44
|
const fetch = new Fetch(currentServiceId, fetchMock);
|
|
42
45
|
const result = await fetch.execute(gas, registers, memory);
|
|
43
46
|
assert.strictEqual(result, undefined);
|
|
@@ -203,7 +206,7 @@ describe("Fetch", () => {
|
|
|
203
206
|
const blob = BytesBlob.blobFromNumbers([201, 202, 203]);
|
|
204
207
|
const fetchMock = new RefineFetchMock();
|
|
205
208
|
fetchMock.authorizerResponse = blob;
|
|
206
|
-
const { registers, memory, readBack, expectedLength } = prepareRegsAndMemory(blob, FetchKind.
|
|
209
|
+
const { registers, memory, readBack, expectedLength } = prepareRegsAndMemory(blob, FetchKind.AuthConfiguration);
|
|
207
210
|
const fetch = new Fetch(currentServiceId, fetchMock);
|
|
208
211
|
const result = await fetch.execute(gas, registers, memory);
|
|
209
212
|
assert.strictEqual(result, undefined);
|
|
@@ -215,7 +218,7 @@ describe("Fetch", () => {
|
|
|
215
218
|
const blob = BytesBlob.blobFromNumbers([210, 211, 212]);
|
|
216
219
|
const fetchMock = new RefineFetchMock();
|
|
217
220
|
fetchMock.authorizationTokenResponse = blob;
|
|
218
|
-
const { registers, memory, readBack, expectedLength } = prepareRegsAndMemory(blob, FetchKind.
|
|
221
|
+
const { registers, memory, readBack, expectedLength } = prepareRegsAndMemory(blob, FetchKind.AuthToken);
|
|
219
222
|
const fetch = new Fetch(currentServiceId, fetchMock);
|
|
220
223
|
const result = await fetch.execute(gas, registers, memory);
|
|
221
224
|
assert.strictEqual(result, undefined);
|
|
@@ -314,8 +317,8 @@ describe("Fetch", () => {
|
|
|
314
317
|
FetchKind.OtherWorkItemImports,
|
|
315
318
|
FetchKind.MyImports,
|
|
316
319
|
FetchKind.WorkPackage,
|
|
317
|
-
FetchKind.
|
|
318
|
-
FetchKind.
|
|
320
|
+
FetchKind.AuthConfiguration,
|
|
321
|
+
FetchKind.AuthToken,
|
|
319
322
|
FetchKind.RefineContext,
|
|
320
323
|
FetchKind.AllWorkItems,
|
|
321
324
|
FetchKind.OneWorkItem,
|
|
@@ -373,14 +376,14 @@ class RefineFetchMock {
|
|
|
373
376
|
workItemPayloadData = [];
|
|
374
377
|
constantsResponse = null;
|
|
375
378
|
entropyResponse = null;
|
|
376
|
-
authorizerTraceResponse =
|
|
379
|
+
authorizerTraceResponse = BytesBlob.empty();
|
|
377
380
|
workItemExtrinsicResponses = new Map();
|
|
378
381
|
workItemImportResponses = new Map();
|
|
379
|
-
workPackageResponse =
|
|
380
|
-
authorizerResponse =
|
|
381
|
-
authorizationTokenResponse =
|
|
382
|
-
refineContextResponse =
|
|
383
|
-
allWorkItemsResponse =
|
|
382
|
+
workPackageResponse = BytesBlob.empty();
|
|
383
|
+
authorizerResponse = BytesBlob.empty();
|
|
384
|
+
authorizationTokenResponse = BytesBlob.empty();
|
|
385
|
+
refineContextResponse = BytesBlob.empty();
|
|
386
|
+
allWorkItemsResponse = BytesBlob.empty();
|
|
384
387
|
oneWorkItemResponses = new Map();
|
|
385
388
|
workItemPayloadResponses = new Map();
|
|
386
389
|
constants() {
|
|
@@ -417,10 +420,10 @@ class RefineFetchMock {
|
|
|
417
420
|
workPackage() {
|
|
418
421
|
return this.workPackageResponse;
|
|
419
422
|
}
|
|
420
|
-
|
|
423
|
+
authConfiguration() {
|
|
421
424
|
return this.authorizerResponse;
|
|
422
425
|
}
|
|
423
|
-
|
|
426
|
+
authToken() {
|
|
424
427
|
return this.authorizationTokenResponse;
|
|
425
428
|
}
|
|
426
429
|
refineContext() {
|
|
@@ -29,8 +29,8 @@ export declare class CoreWorkPackage extends WithDebug {
|
|
|
29
29
|
lookupAnchorSlot: import("@typeberry/codec").Descriptor<number & import("@typeberry/numbers").WithBytesRepresentation<4> & import("@typeberry/utils").WithOpaque<"TimeSlot[u32]">, import("@typeberry/bytes").Bytes<4>>;
|
|
30
30
|
prerequisites: import("@typeberry/codec").Descriptor<(import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"WorkPackageHash">)[], import("@typeberry/codec").SequenceView<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"WorkPackageHash">, import("@typeberry/bytes").Bytes<32>>>;
|
|
31
31
|
}>>;
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
authToken: import("@typeberry/codec").Descriptor<BytesBlob, BytesBlob>;
|
|
33
|
+
authConfiguration: import("@typeberry/codec").Descriptor<BytesBlob, BytesBlob>;
|
|
34
34
|
items: import("@typeberry/codec").Descriptor<import("@typeberry/collections").FixedSizeArray<import("@typeberry/block").WorkItem, import("@typeberry/numbers").U8>, import("@typeberry/codec").SequenceView<import("@typeberry/block").WorkItem, import("@typeberry/codec").ViewOf<import("@typeberry/block").WorkItem, {
|
|
35
35
|
service: import("@typeberry/codec").Descriptor<number & import("@typeberry/numbers").WithBytesRepresentation<4> & import("@typeberry/utils").WithOpaque<"ServiceId[u32]">, import("@typeberry/bytes").Bytes<4>>;
|
|
36
36
|
codeHash: import("@typeberry/codec").Descriptor<import("@typeberry/bytes").Bytes<32> & import("@typeberry/utils").WithOpaque<"CodeHash">, import("@typeberry/bytes").Bytes<32>>;
|
|
@@ -44,47 +44,56 @@ function mergePrivilegedServices(mergeContext, [serviceId, { stateUpdate }]) {
|
|
|
44
44
|
const currentDelegator = currentPrivilegedServices.delegator;
|
|
45
45
|
const currentAssigners = currentPrivilegedServices.assigners;
|
|
46
46
|
const { privilegedServices } = stateUpdate;
|
|
47
|
-
if (privilegedServices
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
let shouldUpdateAssigners = false;
|
|
73
|
-
const newAssigners = currentAssigners.map((currentAssigner, coreIndex) => {
|
|
74
|
-
if (serviceId === currentAssigner) {
|
|
75
|
-
const newAssigner = updatePrivilegedService(currentPrivilegedServices.assigners[coreIndex], privilegedServicesUpdatedByManager.assigners[coreIndex], privilegedServices.assigners[coreIndex]);
|
|
76
|
-
shouldUpdateAssigners = shouldUpdateAssigners || newAssigner !== currentAssigner;
|
|
77
|
-
return newAssigner;
|
|
78
|
-
}
|
|
79
|
-
return currentAssigner;
|
|
47
|
+
if (privilegedServices === null) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
// initial value (ignore the update, because it might not be authorized)
|
|
51
|
+
if (outputState.privilegedServices === null) {
|
|
52
|
+
outputState.privilegedServices = PrivilegedServices.create({
|
|
53
|
+
...currentPrivilegedServices,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
// manager can override everything and it always takes precedence over
|
|
57
|
+
// everything else
|
|
58
|
+
if (serviceId === currentManager) {
|
|
59
|
+
outputState.privilegedServices = PrivilegedServices.create({
|
|
60
|
+
...privilegedServices,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
// current registrar can transfer out it's permissions, but only if
|
|
64
|
+
// it wasn't overwritten by manager in current run
|
|
65
|
+
if (serviceId === currentRegistrar) {
|
|
66
|
+
const newRegistrar = updatePrivilegedService(currentPrivilegedServices.registrar, privilegedServicesUpdatedByManager.registrar, privilegedServices.registrar);
|
|
67
|
+
outputState.privilegedServices = PrivilegedServices.create({
|
|
68
|
+
...outputState.privilegedServices,
|
|
69
|
+
registrar: newRegistrar,
|
|
80
70
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
71
|
+
}
|
|
72
|
+
// current delegator can transfer out it's permissions, but only if
|
|
73
|
+
// it wasn't overwritten by manager in current run
|
|
74
|
+
if (serviceId === currentDelegator) {
|
|
75
|
+
const newDelegator = updatePrivilegedService(currentPrivilegedServices.delegator, privilegedServicesUpdatedByManager.delegator, privilegedServices.delegator);
|
|
76
|
+
outputState.privilegedServices = PrivilegedServices.create({
|
|
77
|
+
...outputState.privilegedServices,
|
|
78
|
+
delegator: newDelegator,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
let shouldUpdateAssigners = false;
|
|
82
|
+
// same with assigners - they are free to transfer out their core
|
|
83
|
+
const newAssigners = currentAssigners.map((currentAssigner, coreIndex) => {
|
|
84
|
+
if (serviceId === currentAssigner) {
|
|
85
|
+
const newAssigner = updatePrivilegedService(currentPrivilegedServices.assigners[coreIndex], privilegedServicesUpdatedByManager.assigners[coreIndex], privilegedServices.assigners[coreIndex]);
|
|
86
|
+
shouldUpdateAssigners = shouldUpdateAssigners || newAssigner !== currentAssigner;
|
|
87
|
+
return newAssigner;
|
|
87
88
|
}
|
|
89
|
+
return currentAssigner;
|
|
90
|
+
});
|
|
91
|
+
if (shouldUpdateAssigners) {
|
|
92
|
+
const newAssignersPerCore = tryAsPerCore(newAssigners, chainSpec);
|
|
93
|
+
outputState.privilegedServices = PrivilegedServices.create({
|
|
94
|
+
...outputState.privilegedServices,
|
|
95
|
+
assigners: newAssignersPerCore,
|
|
96
|
+
});
|
|
88
97
|
}
|
|
89
98
|
}
|
|
90
99
|
function mergeValidatorsData(mergeContext, [serviceId, { stateUpdate }]) {
|
|
@@ -2,7 +2,7 @@ import { type CodeHash, type CoreIndex, type PerValidator, type ServiceGas, type
|
|
|
2
2
|
import type { PreimageHash } from "#@typeberry/block/preimage.js";
|
|
3
3
|
import type { AuthorizerHash } from "#@typeberry/block/refine-context.js";
|
|
4
4
|
import { Bytes, type BytesBlob } from "#@typeberry/bytes";
|
|
5
|
-
import type
|
|
5
|
+
import { type FixedSizeArray } from "#@typeberry/collections";
|
|
6
6
|
import type { ChainSpec } from "#@typeberry/config";
|
|
7
7
|
import { type Blake2b, type OpaqueHash } from "#@typeberry/hash";
|
|
8
8
|
import { AccumulationStateUpdate, EjectError, ForgetPreimageError, type general, NewServiceError, type PartiallyUpdatedState, type PartialState, type PreimageStatus, ProvidePreimageError, RequestPreimageError, type TRANSFER_MEMO_BYTES, TransferError, UnprivilegedError, UpdatePrivilegesError } from "#@typeberry/jam-host-calls";
|
|
@@ -64,7 +64,7 @@ export declare class AccumulateExternalities implements PartialState, general.Ac
|
|
|
64
64
|
upgradeService(codeHash: CodeHash, gas: U64, allowance: U64): void;
|
|
65
65
|
updateValidatorsData(validatorsData: PerValidator<ValidatorData>): Result<OK, UnprivilegedError>;
|
|
66
66
|
checkpoint(): void;
|
|
67
|
-
updateAuthorizationQueue(coreIndex: CoreIndex, authQueue: FixedSizeArray<AuthorizerHash, AUTHORIZATION_QUEUE_SIZE>,
|
|
67
|
+
updateAuthorizationQueue(coreIndex: CoreIndex, authQueue: FixedSizeArray<AuthorizerHash, AUTHORIZATION_QUEUE_SIZE>, newAssigner: ServiceId | null): Result<OK, UpdatePrivilegesError>;
|
|
68
68
|
updatePrivilegedServices(manager: ServiceId | null, assigners: PerCore<ServiceId>, delegator: ServiceId | null, registrar: ServiceId | null, autoAccumulateServices: Map<ServiceId, ServiceGas>): Result<OK, UpdatePrivilegesError>;
|
|
69
69
|
yield(hash: OpaqueHash): void;
|
|
70
70
|
providePreimage(serviceId: ServiceId | null, preimage: BytesBlob): Result<OK, ProvidePreimageError>;
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"accumulate-externalities.d.ts","sourceRoot":"","sources":["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,IAAI,EAAE,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,IAAI;IAOvE,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,CAAC;IAyBhF,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,EAAE,IAAI,EAAE,YAAY,GAAG,SAAS,GAAG,IAAI;CAO1E"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { tryAsServiceGas, tryAsServiceId, tryAsTimeSlot, } from "#@typeberry/block";
|
|
2
2
|
import { MIN_PUBLIC_SERVICE_INDEX } from "#@typeberry/block/gp-constants.js";
|
|
3
3
|
import { Bytes } from "#@typeberry/bytes";
|
|
4
|
+
import { asKnownSize } from "#@typeberry/collections";
|
|
4
5
|
import { HASH_SIZE } from "#@typeberry/hash";
|
|
5
6
|
import { AccumulationStateUpdate, clampU64ToU32, EjectError, ForgetPreimageError, NewServiceError, PendingTransfer, PreimageStatusKind, ProvidePreimageError, RequestPreimageError, slotsToPreimageStatus, TransferError, UnprivilegedError, UpdatePrivilegesError, writeServiceIdAsLeBytes, } from "#@typeberry/jam-host-calls";
|
|
6
7
|
import { Logger } from "#@typeberry/logger";
|
|
@@ -354,19 +355,31 @@ export class AccumulateExternalities {
|
|
|
354
355
|
/** https://graypaper.fluffylabs.dev/#/9a08063/362202362202?v=0.6.6 */
|
|
355
356
|
this.checkpointedState = AccumulationStateUpdate.copyFrom(this.updatedState.stateUpdate);
|
|
356
357
|
}
|
|
357
|
-
updateAuthorizationQueue(coreIndex, authQueue,
|
|
358
|
+
updateAuthorizationQueue(coreIndex, authQueue, newAssigner) {
|
|
358
359
|
/** https://graypaper.fluffylabs.dev/#/7e6ff6a/36a40136a401?v=0.6.7 */
|
|
359
360
|
// NOTE `coreIndex` is already verified in the HC, so this is infallible.
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
361
|
+
const privilegedServices = this.updatedState.getPrivilegedServices();
|
|
362
|
+
const currentAssigners = privilegedServices.assigners;
|
|
363
|
+
const assigner = currentAssigners[coreIndex];
|
|
364
|
+
if (assigner !== this.currentServiceId) {
|
|
365
|
+
logger.trace `Current service id (${this.currentServiceId}) is not an auth manager of core ${coreIndex} (expected: ${assigner}) and cannot update authorization queue.`;
|
|
366
|
+
return Result.error(UpdatePrivilegesError.UnprivilegedService, () => `Service ${this.currentServiceId} not assigner for core ${coreIndex} (expected: ${assigner})`);
|
|
367
|
+
}
|
|
368
|
+
if (newAssigner === null) {
|
|
366
369
|
logger.trace `The new auth manager is not a valid service id.`;
|
|
367
370
|
return Result.error(UpdatePrivilegesError.InvalidServiceId, () => `New auth manager is null for core ${coreIndex}`);
|
|
368
371
|
}
|
|
372
|
+
// update the authorization queue
|
|
369
373
|
this.updatedState.stateUpdate.authorizationQueues.set(coreIndex, authQueue);
|
|
374
|
+
// move permissions to the new assigner
|
|
375
|
+
const assigners = currentAssigners.slice();
|
|
376
|
+
assigners[coreIndex] = newAssigner;
|
|
377
|
+
this.updatedState.stateUpdate.privilegedServices = PrivilegedServices.create({
|
|
378
|
+
...privilegedServices,
|
|
379
|
+
// since coreindex is validated, we do not alter the size,
|
|
380
|
+
// hence it's safe to convert back
|
|
381
|
+
assigners: asKnownSize(assigners),
|
|
382
|
+
});
|
|
370
383
|
return Result.ok(OK);
|
|
371
384
|
}
|
|
372
385
|
updatePrivilegedServices(manager, assigners, delegator, registrar, autoAccumulateServices) {
|
|
@@ -6,7 +6,7 @@ import { asKnownSize, FixedSizeArray, HashDictionary } from "#@typeberry/collect
|
|
|
6
6
|
import { tinyChainSpec } from "#@typeberry/config";
|
|
7
7
|
import { BANDERSNATCH_KEY_BYTES, BLS_KEY_BYTES, ED25519_KEY_BYTES } from "#@typeberry/crypto";
|
|
8
8
|
import { Blake2b, HASH_SIZE } from "#@typeberry/hash";
|
|
9
|
-
import { EjectError, ForgetPreimageError, NewServiceError, PartiallyUpdatedState, PendingTransfer, PreimageStatusKind, ProvidePreimageError, RequestPreimageError, TRANSFER_MEMO_BYTES, TransferError, UnprivilegedError, UpdatePrivilegesError, writeServiceIdAsLeBytes, } from "#@typeberry/jam-host-calls";
|
|
9
|
+
import { CURRENT_SERVICE_ID, EjectError, ForgetPreimageError, NewServiceError, PartiallyUpdatedState, PendingTransfer, PreimageStatusKind, ProvidePreimageError, RequestPreimageError, TRANSFER_MEMO_BYTES, TransferError, UnprivilegedError, UpdatePrivilegesError, writeServiceIdAsLeBytes, } from "#@typeberry/jam-host-calls";
|
|
10
10
|
import { tryAsU32, tryAsU64 } from "#@typeberry/numbers";
|
|
11
11
|
import { AUTHORIZATION_QUEUE_SIZE, InMemoryService, InMemoryState, LookupHistoryItem, PreimageItem, PrivilegedServices, ServiceAccountInfo, StorageItem, tryAsLookupHistorySlots, tryAsPerCore, UpdatePreimage, UpdateService, VALIDATOR_META_BYTES, ValidatorData, } from "#@typeberry/state";
|
|
12
12
|
import { testState } from "#@typeberry/state/test.utils.js";
|
|
@@ -663,16 +663,28 @@ describe("PartialState.upgradeService", () => {
|
|
|
663
663
|
});
|
|
664
664
|
});
|
|
665
665
|
describe("PartialState.updateAuthorizationQueue", () => {
|
|
666
|
-
it("should update the authorization queue for
|
|
666
|
+
it("should update the authorization queue and transfer the assigner for the given core", () => {
|
|
667
667
|
const state = partiallyUpdatedState();
|
|
668
|
+
const initialPrivileged = state.state.privilegedServices;
|
|
668
669
|
const partialState = new AccumulateExternalities(tinyChainSpec, blake2b, state, tryAsServiceId(0), tryAsServiceId(10), tryAsTimeSlot(16));
|
|
669
670
|
const coreIndex = tryAsCoreIndex(0);
|
|
670
|
-
const
|
|
671
|
+
const newAssigner = tryAsServiceId(99);
|
|
671
672
|
const queue = FixedSizeArray.new(Array.from({ length: AUTHORIZATION_QUEUE_SIZE }, () => Bytes.fill(HASH_SIZE, 0xee).asOpaque()), AUTHORIZATION_QUEUE_SIZE);
|
|
672
673
|
// when
|
|
673
|
-
partialState.updateAuthorizationQueue(coreIndex, queue,
|
|
674
|
+
const result = partialState.updateAuthorizationQueue(coreIndex, queue, newAssigner);
|
|
674
675
|
// then
|
|
676
|
+
deepEqual(result, Result.ok(OK));
|
|
675
677
|
assert.deepStrictEqual(state.stateUpdate.authorizationQueues.get(coreIndex), queue);
|
|
678
|
+
// the privilegedServices update must be written, with only the targeted
|
|
679
|
+
// core's assigner transferred; all other fields must be preserved.
|
|
680
|
+
const updated = state.stateUpdate.privilegedServices;
|
|
681
|
+
assert.ok(updated !== null, "stateUpdate.privilegedServices should be written");
|
|
682
|
+
assert.strictEqual(updated.assigners[0], newAssigner);
|
|
683
|
+
assert.strictEqual(updated.assigners[1], initialPrivileged.assigners[1]);
|
|
684
|
+
assert.strictEqual(updated.manager, initialPrivileged.manager);
|
|
685
|
+
assert.strictEqual(updated.delegator, initialPrivileged.delegator);
|
|
686
|
+
assert.strictEqual(updated.registrar, initialPrivileged.registrar);
|
|
687
|
+
assert.strictEqual(updated.autoAccumulateServices, initialPrivileged.autoAccumulateServices);
|
|
676
688
|
});
|
|
677
689
|
it("should return InvalidServiceId when given auth manager is invalid", () => {
|
|
678
690
|
const state = partiallyUpdatedState();
|
|
@@ -685,6 +697,8 @@ describe("PartialState.updateAuthorizationQueue", () => {
|
|
|
685
697
|
// then
|
|
686
698
|
deepEqual(result, Result.error(UpdatePrivilegesError.InvalidServiceId, () => "New auth manager is null for core 0"));
|
|
687
699
|
assert.deepStrictEqual(state.stateUpdate.authorizationQueues.get(coreIndex), undefined);
|
|
700
|
+
// no partial privilegedServices write on error
|
|
701
|
+
assert.strictEqual(state.stateUpdate.privilegedServices, null);
|
|
688
702
|
});
|
|
689
703
|
it("should return UnprivilegedService when current service is not privileged", () => {
|
|
690
704
|
const state = partiallyUpdatedState();
|
|
@@ -701,6 +715,8 @@ describe("PartialState.updateAuthorizationQueue", () => {
|
|
|
701
715
|
// then
|
|
702
716
|
deepEqual(result, Result.error(UpdatePrivilegesError.UnprivilegedService, () => "Service 0 not assigner for core 0 (expected: 1)"));
|
|
703
717
|
assert.deepStrictEqual(state.stateUpdate.authorizationQueues.get(coreIndex), undefined);
|
|
718
|
+
// no partial privilegedServices write on error
|
|
719
|
+
assert.strictEqual(state.stateUpdate.privilegedServices, null);
|
|
704
720
|
});
|
|
705
721
|
it("should return UnprivilegedService before InvalidServiceId if given auth manager is incorrect, but current servis is also unprivileged", () => {
|
|
706
722
|
const state = partiallyUpdatedState();
|
|
@@ -717,6 +733,60 @@ describe("PartialState.updateAuthorizationQueue", () => {
|
|
|
717
733
|
// then
|
|
718
734
|
deepEqual(result, Result.error(UpdatePrivilegesError.UnprivilegedService, () => "Service 0 not assigner for core 0 (expected: 1)"));
|
|
719
735
|
assert.deepStrictEqual(state.stateUpdate.authorizationQueues.get(coreIndex), undefined);
|
|
736
|
+
// no partial privilegedServices write on error
|
|
737
|
+
assert.strictEqual(state.stateUpdate.privilegedServices, null);
|
|
738
|
+
});
|
|
739
|
+
it("should succeed on a self-transfer using CURRENT_SERVICE_ID", () => {
|
|
740
|
+
const state = partiallyUpdatedState();
|
|
741
|
+
// inject a service info for CURRENT_SERVICE_ID so it can act as the
|
|
742
|
+
// current (and assigning) service on core 0
|
|
743
|
+
const baseService = state.state.services.get(tryAsServiceId(0));
|
|
744
|
+
if (baseService === undefined) {
|
|
745
|
+
throw new Error("Invalid service!");
|
|
746
|
+
}
|
|
747
|
+
state.state.services.set(CURRENT_SERVICE_ID, new InMemoryService(CURRENT_SERVICE_ID, {
|
|
748
|
+
info: baseService.data.info,
|
|
749
|
+
preimages: HashDictionary.new(),
|
|
750
|
+
lookupHistory: HashDictionary.new(),
|
|
751
|
+
storage: new Map(),
|
|
752
|
+
}));
|
|
753
|
+
state.state.privilegedServices = PrivilegedServices.create({
|
|
754
|
+
...state.state.privilegedServices,
|
|
755
|
+
assigners: asOpaqueType(FixedSizeArray.new([CURRENT_SERVICE_ID, tryAsServiceId(0)], tinyChainSpec.coresCount)),
|
|
756
|
+
});
|
|
757
|
+
const partialState = new AccumulateExternalities(tinyChainSpec, blake2b, state, CURRENT_SERVICE_ID, tryAsServiceId(10), tryAsTimeSlot(16));
|
|
758
|
+
const coreIndex = tryAsCoreIndex(0);
|
|
759
|
+
const queue = FixedSizeArray.new(Array.from({ length: AUTHORIZATION_QUEUE_SIZE }, () => Bytes.fill(HASH_SIZE, 0xee).asOpaque()), AUTHORIZATION_QUEUE_SIZE);
|
|
760
|
+
// when
|
|
761
|
+
const result = partialState.updateAuthorizationQueue(coreIndex, queue, CURRENT_SERVICE_ID);
|
|
762
|
+
// then
|
|
763
|
+
deepEqual(result, Result.ok(OK));
|
|
764
|
+
assert.deepStrictEqual(state.stateUpdate.authorizationQueues.get(coreIndex), queue);
|
|
765
|
+
const updated = state.stateUpdate.privilegedServices;
|
|
766
|
+
assert.ok(updated !== null, "stateUpdate.privilegedServices should be written");
|
|
767
|
+
assert.strictEqual(updated.assigners[0], CURRENT_SERVICE_ID);
|
|
768
|
+
assert.strictEqual(updated.assigners[1], tryAsServiceId(0));
|
|
769
|
+
});
|
|
770
|
+
it("should prevent the previous assigner from re-assigning after transfer", () => {
|
|
771
|
+
const state = partiallyUpdatedState();
|
|
772
|
+
const partialState = new AccumulateExternalities(tinyChainSpec, blake2b, state, tryAsServiceId(0), tryAsServiceId(10), tryAsTimeSlot(16));
|
|
773
|
+
const coreIndex = tryAsCoreIndex(0);
|
|
774
|
+
const newAssigner = tryAsServiceId(99);
|
|
775
|
+
const firstQueue = FixedSizeArray.new(Array.from({ length: AUTHORIZATION_QUEUE_SIZE }, () => Bytes.fill(HASH_SIZE, 0xee).asOpaque()), AUTHORIZATION_QUEUE_SIZE);
|
|
776
|
+
const secondQueue = FixedSizeArray.new(Array.from({ length: AUTHORIZATION_QUEUE_SIZE }, () => Bytes.fill(HASH_SIZE, 0xff).asOpaque()), AUTHORIZATION_QUEUE_SIZE);
|
|
777
|
+
// when: first call succeeds and transfers the assigner to service 99
|
|
778
|
+
const first = partialState.updateAuthorizationQueue(coreIndex, firstQueue, newAssigner);
|
|
779
|
+
// and the previous assigner (service 0) immediately tries to re-assign
|
|
780
|
+
const second = partialState.updateAuthorizationQueue(coreIndex, secondQueue, tryAsServiceId(0));
|
|
781
|
+
// then
|
|
782
|
+
deepEqual(first, Result.ok(OK));
|
|
783
|
+
deepEqual(second, Result.error(UpdatePrivilegesError.UnprivilegedService, () => "Service 0 not assigner for core 0 (expected: 99)"));
|
|
784
|
+
// the first queue remains — the failing second call must not overwrite it
|
|
785
|
+
assert.deepStrictEqual(state.stateUpdate.authorizationQueues.get(coreIndex), firstQueue);
|
|
786
|
+
// and the transferred assigner is still in place
|
|
787
|
+
const updated = state.stateUpdate.privilegedServices;
|
|
788
|
+
assert.ok(updated !== null);
|
|
789
|
+
assert.strictEqual(updated.assigners[0], newAssigner);
|
|
720
790
|
});
|
|
721
791
|
});
|
|
722
792
|
describe("PartialState.updatePrivilegedServices", () => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export * from "./accumulate-externalities.js";
|
|
2
2
|
export * from "./accumulate-fetch-externalities.js";
|
|
3
3
|
export * from "./fetch-externalities.js";
|
|
4
|
+
export * from "./is-authorized-fetch-externalities.js";
|
|
4
5
|
export * from "./refine-fetch-externalities.js";
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/externalities/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/externalities/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,0BAA0B,CAAC;AACzC,cAAc,wCAAwC,CAAC;AACvD,cAAc,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BytesBlob } from "#@typeberry/bytes";
|
|
2
|
+
import type { ChainSpec } from "#@typeberry/config";
|
|
3
|
+
import { general } from "#@typeberry/jam-host-calls";
|
|
4
|
+
import type { U64 } from "#@typeberry/numbers";
|
|
5
|
+
export declare class IsAuthorizedFetchExternalities implements general.IIsAuthorizedFetch {
|
|
6
|
+
private readonly chainSpec;
|
|
7
|
+
private readonly params;
|
|
8
|
+
readonly context = general.FetchContext.IsAuthorized;
|
|
9
|
+
constructor(chainSpec: ChainSpec, params: {
|
|
10
|
+
authToken: BytesBlob;
|
|
11
|
+
authConfiguration: BytesBlob;
|
|
12
|
+
});
|
|
13
|
+
constants(): BytesBlob;
|
|
14
|
+
workPackage(): BytesBlob;
|
|
15
|
+
authConfiguration(): BytesBlob;
|
|
16
|
+
authToken(): BytesBlob;
|
|
17
|
+
refineContext(): BytesBlob;
|
|
18
|
+
allWorkItems(): BytesBlob;
|
|
19
|
+
oneWorkItem(_workItem: U64): BytesBlob | null;
|
|
20
|
+
workItemPayload(_workItem: U64): BytesBlob | null;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=is-authorized-fetch-externalities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-authorized-fetch-externalities.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/externalities/is-authorized-fetch-externalities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAG9C,qBAAa,8BAA+B,YAAW,OAAO,CAAC,kBAAkB;IAI7E,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJzB,QAAQ,CAAC,OAAO,qCAAqC;gBAGlC,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE;QACvB,SAAS,EAAE,SAAS,CAAC;QACrB,iBAAiB,EAAE,SAAS,CAAC;KAC9B;IAGH,SAAS,IAAI,SAAS;IAKtB,WAAW,IAAI,SAAS;IAIxB,iBAAiB,IAAI,SAAS;IAI9B,SAAS,IAAI,SAAS;IAKtB,aAAa,IAAI,SAAS;IAK1B,YAAY,IAAI,SAAS;IAKzB,WAAW,CAAC,SAAS,EAAE,GAAG,GAAG,SAAS,GAAG,IAAI;IAK7C,eAAe,CAAC,SAAS,EAAE,GAAG,GAAG,SAAS,GAAG,IAAI;CAGlD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { BytesBlob } from "#@typeberry/bytes";
|
|
2
|
+
import { general } from "#@typeberry/jam-host-calls";
|
|
3
|
+
import { getEncodedConstants } from "./fetch-externalities.js";
|
|
4
|
+
export class IsAuthorizedFetchExternalities {
|
|
5
|
+
chainSpec;
|
|
6
|
+
params;
|
|
7
|
+
context = general.FetchContext.IsAuthorized;
|
|
8
|
+
constructor(chainSpec, params) {
|
|
9
|
+
this.chainSpec = chainSpec;
|
|
10
|
+
this.params = params;
|
|
11
|
+
}
|
|
12
|
+
constants() {
|
|
13
|
+
return getEncodedConstants(this.chainSpec);
|
|
14
|
+
}
|
|
15
|
+
// TODO [ToDr] Return encoded work package E(p)
|
|
16
|
+
workPackage() {
|
|
17
|
+
return BytesBlob.empty();
|
|
18
|
+
}
|
|
19
|
+
authConfiguration() {
|
|
20
|
+
return this.params.authConfiguration;
|
|
21
|
+
}
|
|
22
|
+
authToken() {
|
|
23
|
+
return this.params.authToken;
|
|
24
|
+
}
|
|
25
|
+
// TODO [ToDr] Return encoded refinement context
|
|
26
|
+
refineContext() {
|
|
27
|
+
return BytesBlob.empty();
|
|
28
|
+
}
|
|
29
|
+
// TODO [ToDr] Return encoded work items
|
|
30
|
+
allWorkItems() {
|
|
31
|
+
return BytesBlob.empty();
|
|
32
|
+
}
|
|
33
|
+
// TODO [ToDr] Return single work item summary
|
|
34
|
+
oneWorkItem(_workItem) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
// TODO [ToDr] Return work item payload
|
|
38
|
+
workItemPayload(_workItem) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EntropyHash } from "#@typeberry/block";
|
|
2
|
-
import {
|
|
2
|
+
import { BytesBlob } from "#@typeberry/bytes";
|
|
3
3
|
import type { ChainSpec } from "#@typeberry/config";
|
|
4
4
|
import { general } from "#@typeberry/jam-host-calls";
|
|
5
5
|
import type { U64 } from "#@typeberry/numbers";
|
|
@@ -9,14 +9,14 @@ export declare class RefineFetchExternalities implements general.IRefineFetch {
|
|
|
9
9
|
constructor(chainSpec: ChainSpec);
|
|
10
10
|
constants(): BytesBlob;
|
|
11
11
|
entropy(): EntropyHash;
|
|
12
|
-
authorizerTrace(): BytesBlob
|
|
12
|
+
authorizerTrace(): BytesBlob;
|
|
13
13
|
workItemExtrinsic(_workItem: U64 | null, _index: U64): BytesBlob | null;
|
|
14
14
|
workItemImport(_workItem: U64 | null, _index: U64): BytesBlob | null;
|
|
15
|
-
workPackage(): BytesBlob
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
refineContext(): BytesBlob
|
|
19
|
-
allWorkItems(): BytesBlob
|
|
15
|
+
workPackage(): BytesBlob;
|
|
16
|
+
authConfiguration(): BytesBlob;
|
|
17
|
+
authToken(): BytesBlob;
|
|
18
|
+
refineContext(): BytesBlob;
|
|
19
|
+
allWorkItems(): BytesBlob;
|
|
20
20
|
oneWorkItem(_workItem: U64): BytesBlob | null;
|
|
21
21
|
workItemPayload(_workItem: U64): BytesBlob | null;
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refine-fetch-externalities.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/externalities/refine-fetch-externalities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAS,
|
|
1
|
+
{"version":3,"file":"refine-fetch-externalities.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/transition/externalities/refine-fetch-externalities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAS,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACpD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAG9C,qBAAa,wBAAyB,YAAW,OAAO,CAAC,YAAY;IAGvD,OAAO,CAAC,QAAQ,CAAC,SAAS;IAFtC,QAAQ,CAAC,OAAO,+BAA+B;gBAElB,SAAS,EAAE,SAAS;IAEjD,SAAS,IAAI,SAAS;IAKtB,OAAO,IAAI,WAAW;IAKtB,eAAe,IAAI,SAAS;IAK5B,iBAAiB,CAAC,SAAS,EAAE,GAAG,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,SAAS,GAAG,IAAI;IAKvE,cAAc,CAAC,SAAS,EAAE,GAAG,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,GAAG,SAAS,GAAG,IAAI;IAKpE,WAAW,IAAI,SAAS;IAKxB,iBAAiB,IAAI,SAAS;IAK9B,SAAS,IAAI,SAAS;IAKtB,aAAa,IAAI,SAAS;IAK1B,YAAY,IAAI,SAAS;IAIzB,WAAW,CAAC,SAAS,EAAE,GAAG,GAAG,SAAS,GAAG,IAAI;IAI7C,eAAe,CAAC,SAAS,EAAE,GAAG,GAAG,SAAS,GAAG,IAAI;CAGlD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Bytes } from "#@typeberry/bytes";
|
|
1
|
+
import { Bytes, BytesBlob } from "#@typeberry/bytes";
|
|
2
2
|
import { HASH_SIZE } from "#@typeberry/hash";
|
|
3
3
|
import { general } from "#@typeberry/jam-host-calls";
|
|
4
4
|
import { getEncodedConstants } from "./fetch-externalities.js";
|
|
@@ -15,29 +15,37 @@ export class RefineFetchExternalities {
|
|
|
15
15
|
entropy() {
|
|
16
16
|
return Bytes.zero(HASH_SIZE).asOpaque();
|
|
17
17
|
}
|
|
18
|
+
// TODO [ToDr] implement
|
|
18
19
|
authorizerTrace() {
|
|
19
|
-
return
|
|
20
|
+
return BytesBlob.empty();
|
|
20
21
|
}
|
|
22
|
+
// TODO [ToDr] implement
|
|
21
23
|
workItemExtrinsic(_workItem, _index) {
|
|
22
24
|
return null;
|
|
23
25
|
}
|
|
26
|
+
// TODO [ToDr] implement
|
|
24
27
|
workItemImport(_workItem, _index) {
|
|
25
28
|
return null;
|
|
26
29
|
}
|
|
30
|
+
// TODO [ToDr] implement
|
|
27
31
|
workPackage() {
|
|
28
|
-
return
|
|
32
|
+
return BytesBlob.empty();
|
|
29
33
|
}
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
// TODO [ToDr] implement
|
|
35
|
+
authConfiguration() {
|
|
36
|
+
return BytesBlob.empty();
|
|
32
37
|
}
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
// TODO [ToDr] implement
|
|
39
|
+
authToken() {
|
|
40
|
+
return BytesBlob.empty();
|
|
35
41
|
}
|
|
42
|
+
// TODO [ToDr] implement
|
|
36
43
|
refineContext() {
|
|
37
|
-
return
|
|
44
|
+
return BytesBlob.empty();
|
|
38
45
|
}
|
|
46
|
+
// TODO [ToDr] implement
|
|
39
47
|
allWorkItems() {
|
|
40
|
-
return
|
|
48
|
+
return BytesBlob.empty();
|
|
41
49
|
}
|
|
42
50
|
oneWorkItem(_workItem) {
|
|
43
51
|
return null;
|