@typeberry/lib 0.5.2 → 0.5.3-aa4626d
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 +9 -5
- package/packages/core/collections/blob-dictionary.d.ts.map +1 -1
- package/packages/core/collections/blob-dictionary.js +3 -3
- package/packages/core/crypto/bandersnatch.d.ts +2 -1
- package/packages/core/crypto/bandersnatch.d.ts.map +1 -1
- package/packages/core/crypto/bandersnatch.js +9 -2
- package/packages/core/crypto/key-derivation.test.js +8 -7
- package/packages/core/hash/hash.d.ts.map +1 -1
- package/packages/core/hash/hash.js +1 -0
- package/packages/core/networking/package.json +1 -1
- 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/bin.js +6 -6
- package/packages/core/pvm-host-calls/ecalli-io-tracker.d.ts +32 -0
- package/packages/core/pvm-host-calls/ecalli-io-tracker.d.ts.map +1 -0
- package/packages/core/pvm-host-calls/ecalli-io-tracker.js +14 -0
- package/packages/core/pvm-host-calls/ecalli-trace-logger.d.ts +139 -0
- package/packages/core/pvm-host-calls/ecalli-trace-logger.d.ts.map +1 -0
- package/packages/core/pvm-host-calls/ecalli-trace-logger.js +209 -0
- package/packages/core/pvm-host-calls/ecalli-trace-logger.test.d.ts +2 -0
- package/packages/core/pvm-host-calls/ecalli-trace-logger.test.d.ts.map +1 -0
- package/packages/core/pvm-host-calls/ecalli-trace-logger.test.js +231 -0
- package/packages/core/pvm-host-calls/host-call-memory.d.ts +2 -0
- package/packages/core/pvm-host-calls/host-call-memory.d.ts.map +1 -1
- package/packages/core/pvm-host-calls/host-call-memory.js +12 -2
- package/packages/core/pvm-host-calls/host-call-registers.d.ts +6 -0
- package/packages/core/pvm-host-calls/host-call-registers.d.ts.map +1 -1
- package/packages/core/pvm-host-calls/host-call-registers.js +24 -0
- package/packages/core/pvm-host-calls/host-calls-executor.d.ts +37 -0
- package/packages/core/pvm-host-calls/host-calls-executor.d.ts.map +1 -0
- package/packages/core/pvm-host-calls/host-calls-executor.js +129 -0
- package/packages/core/pvm-host-calls/host-calls.d.ts +20 -26
- package/packages/core/pvm-host-calls/host-calls.d.ts.map +1 -1
- package/packages/core/pvm-host-calls/host-calls.js +40 -112
- package/packages/core/pvm-host-calls/index.d.ts +7 -6
- package/packages/core/pvm-host-calls/index.d.ts.map +1 -1
- package/packages/core/pvm-host-calls/index.js +7 -6
- package/packages/core/pvm-host-calls/{interpreter-instance-manager.d.ts → pvm-instance-manager.d.ts} +3 -3
- package/packages/core/pvm-host-calls/pvm-instance-manager.d.ts.map +1 -0
- package/packages/core/pvm-host-calls/{interpreter-instance-manager.js → pvm-instance-manager.js} +2 -2
- 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/jam/block/work-item.d.ts +13 -4
- package/packages/jam/block/work-item.d.ts.map +1 -1
- 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/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 +4 -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 +48 -5
- 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.test.js +4 -5
- package/packages/jam/jamnp-s/protocol/ce-133-work-package-submission.d.ts +3 -3
- package/packages/jam/jamnp-s/protocol/ce-133-work-package-submission.d.ts.map +1 -1
- package/packages/jam/jamnp-s/protocol/ce-135-work-report-distribution.test.js +2 -2
- package/packages/jam/node/main-importer.d.ts.map +1 -1
- package/packages/jam/node/main-importer.js +3 -1
- package/packages/jam/node/package.json +1 -1
- 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/safrole/bandersnatch-vrf.d.ts +2 -0
- package/packages/jam/safrole/bandersnatch-vrf.d.ts.map +1 -1
- package/packages/jam/safrole/bandersnatch-vrf.js +11 -0
- package/packages/jam/safrole/bandersnatch-vrf.test.js +3 -3
- package/packages/jam/safrole/bandersnatch-wasm.d.ts +1 -0
- package/packages/jam/safrole/bandersnatch-wasm.d.ts.map +1 -1
- package/packages/jam/safrole/bandersnatch-wasm.js +8 -5
- package/packages/jam/safrole/safrole-seal.d.ts +1 -3
- package/packages/jam/safrole/safrole-seal.d.ts.map +1 -1
- package/packages/jam/safrole/safrole-seal.js +14 -25
- package/packages/jam/safrole/safrole-seal.test.js +4 -10
- 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/test.utils.d.ts.map +1 -1
- package/packages/jam/state/test.utils.js +2 -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-utils.test.js +2 -2
- package/packages/jam/transition/accumulate/accumulate.d.ts.map +1 -1
- package/packages/jam/transition/accumulate/accumulate.js +8 -13
- 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/deferred-transfers.d.ts +1 -1
- package/packages/jam/transition/accumulate/deferred-transfers.d.ts.map +1 -1
- package/packages/jam/transition/accumulate/deferred-transfers.js +6 -7
- package/packages/jam/transition/disputes/disputes.d.ts.map +1 -1
- package/packages/jam/transition/disputes/disputes.js +5 -4
- package/packages/jam/transition/disputes/disputes.test.data2.js +2 -2
- package/packages/jam/transition/externalities/fetch-externalities.d.ts +7 -1
- package/packages/jam/transition/externalities/fetch-externalities.d.ts.map +1 -1
- package/packages/jam/transition/externalities/fetch-externalities.js +4 -0
- package/packages/jam/transition/externalities/fetch-externalities.test.js +2 -2
- package/packages/jam/transition/hasher.test.js +2 -2
- package/packages/jam/transition/reports/test.utils.d.ts.map +1 -1
- package/packages/jam/transition/reports/test.utils.js +2 -2
- package/packages/workers/block-authorship/package.json +1 -1
- package/packages/workers/importer/package.json +1 -1
- package/packages/core/pvm-host-calls/host-calls-manager.d.ts +0 -23
- package/packages/core/pvm-host-calls/host-calls-manager.d.ts.map +0 -1
- package/packages/core/pvm-host-calls/host-calls-manager.js +0 -44
- package/packages/core/pvm-host-calls/interpreter-instance-manager.d.ts.map +0 -1
- package/packages/jam/transition/accumulate/pvm-executor.d.ts.map +0 -1
|
@@ -8,6 +8,19 @@ import type { ServiceGas, ServiceId } from "./common.js";
|
|
|
8
8
|
import type { CodeHash } from "./hash.js";
|
|
9
9
|
import { MAX_NUMBER_OF_SEGMENTS, type SegmentIndex } from "./work-item-segment.js";
|
|
10
10
|
type WorkItemExtrinsicHash = Opaque<OpaqueHash, "ExtrinsicHash">;
|
|
11
|
+
/**
|
|
12
|
+
* An opaque piece of data that the work item brings in.
|
|
13
|
+
*
|
|
14
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/1a1b001a1d00?v=0.7.2
|
|
15
|
+
*/
|
|
16
|
+
export type WorkItemExtrinsic = Opaque<BytesBlob, "Extrinsic">;
|
|
17
|
+
/**
|
|
18
|
+
* Extrinsics that are needed by all [`WorkItem`]s and are specified via [`WorkItemExtrinsicSpec`].
|
|
19
|
+
*
|
|
20
|
+
* This is a flat-package of all extrinsics in a work package across all work items.
|
|
21
|
+
* For encoding it also requires the length of items to be known in advance.
|
|
22
|
+
*/
|
|
23
|
+
export type WorkPackageExtrinsics = KnownSizeArray<Bytes<U32>, "Count of all extrinsics within work items in a work package">;
|
|
11
24
|
/**
|
|
12
25
|
* Definition of data segment that was exported by some work package earlier
|
|
13
26
|
* and now is being imported by another work-item.
|
|
@@ -40,10 +53,6 @@ export declare class WorkItemExtrinsicSpec extends WithDebug {
|
|
|
40
53
|
static create({ hash, len }: CodecRecord<WorkItemExtrinsicSpec>): WorkItemExtrinsicSpec;
|
|
41
54
|
private constructor();
|
|
42
55
|
}
|
|
43
|
-
/**
|
|
44
|
-
* Extrinsics that are needed by [`WorkItem`]s and are specified via [`WorkItemExtrinsicSpec`].
|
|
45
|
-
*/
|
|
46
|
-
export type WorkItemExtrinsics = KnownSizeArray<Bytes<U32>, "Count of all extrinsics within work items in a work package">;
|
|
47
56
|
/**
|
|
48
57
|
* To encode/decode extrinsics that are specified via [`WorkItemExtrinsicSpec`]
|
|
49
58
|
* we need to know their lenghts. Hence this is created dynamically.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work-item.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/block/work-item.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,KAAK,WAAW,EAAS,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAa,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAU,KAAK,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,KAAK,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEnF,KAAK,qBAAqB,GAAG,MAAM,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;AAEjE;;;GAGG;AACH,qBAAa,UAAW,SAAQ,SAAS;IAWrC;;;OAGG;aACa,QAAQ,EAAE,UAAU;IACpC,2CAA2C;aAC3B,KAAK,EAAE,YAAY;IAhBrC,MAAM,CAAC,KAAK;;;QAGT;IAEH,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,WAAW,CAAC,UAAU,CAAC;IAI1D,OAAO;CAWR;AAED,gDAAgD;AAChD,qBAAa,qBAAsB,SAAQ,SAAS;IAWhD,+FAA+F;aAC/E,IAAI,EAAE,qBAAqB;IAC3C,2DAA2D;aAC3C,GAAG,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=== ok` */
|
|
46
46
|
readonly okBlob: BytesBlob | null;
|
|
47
47
|
static Codec: import("@typeberry/codec").Descriptor<WorkExecResult, WorkExecResultUnion>;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
/** Optional octet sequence - available only if `kind === ok` */
|
|
52
|
-
okBlob?: BytesBlob | null);
|
|
48
|
+
static ok(blob: BytesBlob): WorkExecResult;
|
|
49
|
+
static error(kind: Exclude<WorkExecResultKind, WorkExecResultKind.ok>): WorkExecResult;
|
|
50
|
+
private constructor();
|
|
53
51
|
}
|
|
54
52
|
/**
|
|
55
53
|
* Five fields describing the level of activity which this workload
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work-result.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/block/work-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,KAAK,WAAW,EAAS,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAa,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE1C,wDAAwD;AACxD,oBAAY,kBAAkB;IAC5B,6EAA6E;IAC7E,EAAE,IAAI;IACN,yDAAyD;IACzD,QAAQ,IAAI;IACZ,2CAA2C;IAC3C,KAAK,IAAI;IACT,8DAA8D;IAC9D,wBAAwB,IAAI;IAC5B,wFAAwF;IACxF,YAAY,IAAI;IAChB,iEAAiE;IACjE,OAAO,IAAI;IACX,0EAA0E;IAC1E,YAAY,IAAI;CACjB;AAED,KAAK,mBAAmB,GACpB;IAAE,IAAI,EAAE,kBA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;GAIG;AACH,qBAAa,UAAU;IAenB,wFAAwF;aACxE,SAAS,EAAE,SAAS;IACpC,0EAA0E;aAC1D,QAAQ,EAAE,QAAQ;IAClC;;;;;;OAMG;aACa,WAAW,EAAE,UAAU;IACvC;;;;;OAKG;aACa,GAAG,EAAE,UAAU;IAC/B,6DAA6D;aAC7C,MAAM,EAAE,cAAc;IACtC;;;;;;OAMG;aACa,IAAI,EAAE,cAAc;IA1CtC,MAAM,CAAC,KAAK;;;;;;;;;;;;;QAOT;IAEH,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,WAAW,CAAC,UAAU,CAAC;IAI9F,OAAO;CA+BR"}
|
|
@@ -40,6 +40,12 @@ export class WorkExecResult extends WithDebug {
|
|
|
40
40
|
}
|
|
41
41
|
return { kind: x.kind };
|
|
42
42
|
}, (x) => new WorkExecResult(x.kind, x.kind === WorkExecResultKind.ok ? x.okBlob : null));
|
|
43
|
+
static ok(blob) {
|
|
44
|
+
return new WorkExecResult(WorkExecResultKind.ok, blob);
|
|
45
|
+
}
|
|
46
|
+
static error(kind) {
|
|
47
|
+
return new WorkExecResult(kind, null);
|
|
48
|
+
}
|
|
43
49
|
constructor(
|
|
44
50
|
/** The execution result tag. */
|
|
45
51
|
kind,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"work-result.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/block-json/work-result.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsD,UAAU,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"work-result.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/block-json/work-result.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsD,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAkFjH,eAAO,MAAM,kBAAkB,0EAkB9B,CAAC"}
|
|
@@ -15,22 +15,22 @@ const workExecResultFromJson = json.object({
|
|
|
15
15
|
}, (val) => {
|
|
16
16
|
const { ok, out_of_gas, panic, bad_code, code_oversize, output_oversize } = val;
|
|
17
17
|
if (ok !== undefined) {
|
|
18
|
-
return
|
|
18
|
+
return WorkExecResult.ok(ok);
|
|
19
19
|
}
|
|
20
20
|
if (out_of_gas === null) {
|
|
21
|
-
return
|
|
21
|
+
return WorkExecResult.error(WorkExecResultKind.outOfGas);
|
|
22
22
|
}
|
|
23
23
|
if (panic === null) {
|
|
24
|
-
return
|
|
24
|
+
return WorkExecResult.error(WorkExecResultKind.panic);
|
|
25
25
|
}
|
|
26
26
|
if (bad_code === null) {
|
|
27
|
-
return
|
|
27
|
+
return WorkExecResult.error(WorkExecResultKind.badCode);
|
|
28
28
|
}
|
|
29
29
|
if (code_oversize === null) {
|
|
30
|
-
return
|
|
30
|
+
return WorkExecResult.error(WorkExecResultKind.codeOversize);
|
|
31
31
|
}
|
|
32
32
|
if (output_oversize === null) {
|
|
33
|
-
return
|
|
33
|
+
return WorkExecResult.error(WorkExecResultKind.digestTooBig);
|
|
34
34
|
}
|
|
35
35
|
throw new Error("Invalid WorkExecResult");
|
|
36
36
|
});
|
|
@@ -6,8 +6,7 @@ import { Bytes, BytesBlob } from "#@typeberry/bytes";
|
|
|
6
6
|
import { SortedSet } from "#@typeberry/collections";
|
|
7
7
|
import { tinyChainSpec } from "#@typeberry/config";
|
|
8
8
|
import { Blake2b, HASH_SIZE } from "#@typeberry/hash";
|
|
9
|
-
import { tryAsU32, tryAsU64 } from "#@typeberry/numbers";
|
|
10
|
-
import { MAX_VALUE } from "#@typeberry/pvm-interpreter/ops/math-consts.js";
|
|
9
|
+
import { MAX_VALUE_U32, tryAsU32, tryAsU64 } from "#@typeberry/numbers";
|
|
11
10
|
import { InMemoryState, LookupHistoryItem, PrivilegedServices, ServiceAccountInfo, tryAsLookupHistorySlots, tryAsPerCore, UpdateService, } from "#@typeberry/state";
|
|
12
11
|
import { testState } from "#@typeberry/state/test.utils.js";
|
|
13
12
|
import { StateEntries } from "#@typeberry/state-merkleization";
|
|
@@ -74,7 +73,9 @@ describe("LMDB States database", () => {
|
|
|
74
73
|
manager: tryAsServiceId(1),
|
|
75
74
|
assigners: tryAsPerCore(new Array(spec.coresCount).fill(tryAsServiceId(2)), spec),
|
|
76
75
|
delegator: tryAsServiceId(3),
|
|
77
|
-
registrar: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
|
|
76
|
+
registrar: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
|
|
77
|
+
? tryAsServiceId(4)
|
|
78
|
+
: tryAsServiceId(MAX_VALUE_U32),
|
|
78
79
|
autoAccumulateServices: new Map(),
|
|
79
80
|
}),
|
|
80
81
|
updated: new Map([
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/executor/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,cAAc,mBAAmB,CAAC"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ServiceGas, type ServiceId } from "#@typeberry/block";
|
|
2
2
|
import type { BytesBlob } from "#@typeberry/bytes";
|
|
3
3
|
import type { ChainSpec, PvmBackend } from "#@typeberry/config";
|
|
4
4
|
import { general } from "#@typeberry/jam-host-calls";
|
|
5
5
|
import type { PartialState } from "#@typeberry/jam-host-calls/externalities/partial-state.js";
|
|
6
|
-
import type
|
|
7
|
-
type
|
|
6
|
+
import { type RefineExternalities } from "#@typeberry/jam-host-calls/externalities/refine-externalities.js";
|
|
7
|
+
export type RefineHostCallExternalities = {
|
|
8
|
+
refine: RefineExternalities;
|
|
9
|
+
fetchExternalities: general.IFetchExternalities;
|
|
10
|
+
};
|
|
11
|
+
export type AccumulateHostCallExternalities = {
|
|
8
12
|
partialState: PartialState;
|
|
9
13
|
fetchExternalities: general.IFetchExternalities;
|
|
10
14
|
serviceExternalities: general.AccountsInfo & general.AccountsLookup & general.AccountsWrite & general.AccountsRead;
|
|
@@ -23,6 +27,8 @@ export declare class PvmExecutor {
|
|
|
23
27
|
private hostCalls;
|
|
24
28
|
private constructor();
|
|
25
29
|
private static prepareBackend;
|
|
30
|
+
/** Prepare refine host call handlers */
|
|
31
|
+
private static prepareRefineHostCalls;
|
|
26
32
|
/** Prepare accumulation host call handlers */
|
|
27
33
|
private static prepareAccumulateHostCalls;
|
|
28
34
|
/** Prepare on transfer host call handlers */
|
|
@@ -32,21 +38,18 @@ export declare class PvmExecutor {
|
|
|
32
38
|
*
|
|
33
39
|
* @param args additional arguments that will be placed in PVM memory before execution
|
|
34
40
|
* @param gas gas limit
|
|
35
|
-
* @returns `ReturnValue` object
|
|
41
|
+
* @returns `ReturnValue` object containing consumed gas, status and an optional memory slice
|
|
36
42
|
*/
|
|
37
|
-
run(args: BytesBlob, gas:
|
|
38
|
-
consumedGas:
|
|
39
|
-
status: import("@typeberry/pvm-
|
|
40
|
-
memorySlice: Uint8Array
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
hasStatus(): this is /*elided*/ any & {
|
|
46
|
-
status: import("@typeberry/pvm-interface").Status;
|
|
47
|
-
memorySlice: null;
|
|
48
|
-
};
|
|
43
|
+
run(args: BytesBlob, gas: ServiceGas): Promise<{
|
|
44
|
+
consumedGas: bigint & import("@typeberry/numbers").WithBytesRepresentation<8> & import("@typeberry/utils").WithOpaque<"ServiceGas[u64]">;
|
|
45
|
+
status: import("@typeberry/pvm-host-calls").ReturnStatus.OK;
|
|
46
|
+
memorySlice: Uint8Array;
|
|
47
|
+
} | {
|
|
48
|
+
consumedGas: bigint & import("@typeberry/numbers").WithBytesRepresentation<8> & import("@typeberry/utils").WithOpaque<"ServiceGas[u64]">;
|
|
49
|
+
status: import("@typeberry/pvm-host-calls").ReturnStatus.OOG | import("@typeberry/pvm-host-calls").ReturnStatus.PANIC;
|
|
49
50
|
}>;
|
|
51
|
+
/** A utility function that can be used to prepare refine executor */
|
|
52
|
+
static createRefineExecutor(serviceId: ServiceId, serviceCode: BytesBlob, externalities: RefineHostCallExternalities, pvm: PvmBackend): Promise<PvmExecutor>;
|
|
50
53
|
/** A utility function that can be used to prepare accumulate executor */
|
|
51
54
|
static createAccumulateExecutor(serviceId: ServiceId, serviceCode: BytesBlob, externalities: AccumulateHostCallExternalities, chainSpec: ChainSpec, pvm: PvmBackend): Promise<PvmExecutor>;
|
|
52
55
|
/** A utility function that can be used to prepare on transfer executor */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pvm-executor.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/executor/pvm-executor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAmB,MAAM,kBAAkB,CAAC;AACpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAc,OAAO,EAAU,MAAM,2BAA2B,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0DAA0D,CAAC;AAC7F,OAAO,EAEL,KAAK,mBAAmB,EAEzB,MAAM,iEAAiE,CAAC;AAuCzE,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,EAAE,mBAAmB,CAAC;IAC5B,kBAAkB,EAAE,OAAO,CAAC,mBAAmB,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,YAAY,EAAE,YAAY,CAAC;IAC3B,kBAAkB,EAAE,OAAO,CAAC,mBAAmB,CAAC;IAChD,oBAAoB,EAAE,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;CACpH,CAAC;AAEF,KAAK,+BAA+B,GAAG;IACrC,YAAY,EAAE,OAAO,CAAC,YAAY,GAAG,OAAO,CAAC,cAAc,GAAG,OAAO,CAAC,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC;IAC3G,kBAAkB,EAAE,OAAO,CAAC,mBAAmB,CAAC;CACjD,CAAC;AAUF;;GAEG;AACH,qBAAa,WAAW;IAKpB,OAAO,CAAC,WAAW;IAEnB,OAAO,CAAC,UAAU;IANpB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAoB;IACxC,OAAO,CAAC,SAAS,CAAY;IAE7B,OAAO;mBAac,cAAc;IAInC,wCAAwC;IACxC,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAerC,8CAA8C;IAC9C,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAuBzC,6CAA6C;IAC7C,OAAO,CAAC,MAAM,CAAC,0BAA0B;IAazC;;;;;;OAMG;IACG,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU;;;;;;;;IAQ1C,qEAAqE;WACxD,oBAAoB,CAC/B,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,SAAS,EACtB,aAAa,EAAE,2BAA2B,EAC1C,GAAG,EAAE,UAAU;IAOjB,yEAAyE;WAC5D,wBAAwB,CACnC,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,SAAS,EACtB,aAAa,EAAE,+BAA+B,EAC9C,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,UAAU;IAQjB,0EAA0E;WAC7D,wBAAwB,CACnC,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,SAAS,EACtB,aAAa,EAAE,+BAA+B,EAC9C,GAAG,EAAE,UAAU;CAMlB"}
|
|
@@ -1,6 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tryAsServiceGas } from "#@typeberry/block";
|
|
2
|
+
import { accumulate, general, refine } from "#@typeberry/jam-host-calls";
|
|
2
3
|
import { tryAsProgramCounter, } from "#@typeberry/jam-host-calls/externalities/refine-externalities.js";
|
|
3
|
-
import { HostCalls,
|
|
4
|
+
import { HostCalls, HostCallsExecutor, PvmInstanceManager } from "#@typeberry/pvm-host-calls";
|
|
5
|
+
import { tryAsGas } from "#@typeberry/pvm-interface";
|
|
6
|
+
/**
|
|
7
|
+
* Refine-specific host calls with common constructor.
|
|
8
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/2fa7022fa702?v=0.7.2
|
|
9
|
+
*/
|
|
10
|
+
const REFINE_HOST_CALL_CLASSES = [
|
|
11
|
+
refine.HistoricalLookup,
|
|
12
|
+
refine.Export,
|
|
13
|
+
refine.Machine,
|
|
14
|
+
refine.Peek,
|
|
15
|
+
refine.Poke,
|
|
16
|
+
refine.Pages,
|
|
17
|
+
refine.Invoke,
|
|
18
|
+
refine.Expunge,
|
|
19
|
+
];
|
|
20
|
+
/**
|
|
21
|
+
* Accumulate-specific host calls with common constructor.
|
|
22
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/30d00130d001?v=0.7.2
|
|
23
|
+
*/
|
|
4
24
|
const ACCUMULATE_HOST_CALL_CLASSES = [
|
|
5
25
|
accumulate.Bless,
|
|
6
26
|
accumulate.Assign,
|
|
@@ -21,6 +41,7 @@ var entrypoint;
|
|
|
21
41
|
entrypoint.IS_AUTHORIZED = tryAsProgramCounter(0);
|
|
22
42
|
entrypoint.REFINE = tryAsProgramCounter(0);
|
|
23
43
|
entrypoint.ACCUMULATE = tryAsProgramCounter(5);
|
|
44
|
+
/** @deprecated since 0.7.1 */
|
|
24
45
|
entrypoint.ON_TRANSFER = tryAsProgramCounter(10);
|
|
25
46
|
})(entrypoint || (entrypoint = {}));
|
|
26
47
|
/**
|
|
@@ -38,14 +59,26 @@ export class PvmExecutor {
|
|
|
38
59
|
missing: new general.Missing(),
|
|
39
60
|
handlers: hostCallHandlers,
|
|
40
61
|
});
|
|
41
|
-
this.pvm = new
|
|
62
|
+
this.pvm = new HostCallsExecutor(pvmInstanceManager, this.hostCalls);
|
|
42
63
|
}
|
|
43
64
|
static async prepareBackend(pvm) {
|
|
44
65
|
return PvmInstanceManager.new(pvm);
|
|
45
66
|
}
|
|
67
|
+
/** Prepare refine host call handlers */
|
|
68
|
+
static prepareRefineHostCalls(serviceId, externalities) {
|
|
69
|
+
const refineHandlers = REFINE_HOST_CALL_CLASSES.map((HandlerClass) => new HandlerClass(externalities.refine));
|
|
70
|
+
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/2fa7022fa702?v=0.7.2 */
|
|
71
|
+
const generalHandlers = [
|
|
72
|
+
new general.LogHostCall(serviceId),
|
|
73
|
+
new general.GasHostCall(serviceId),
|
|
74
|
+
new general.Fetch(serviceId, externalities.fetchExternalities),
|
|
75
|
+
];
|
|
76
|
+
return refineHandlers.concat(generalHandlers);
|
|
77
|
+
}
|
|
46
78
|
/** Prepare accumulation host call handlers */
|
|
47
79
|
static prepareAccumulateHostCalls(serviceId, externalities, chainSpec) {
|
|
48
80
|
const accumulateHandlers = ACCUMULATE_HOST_CALL_CLASSES.map((HandlerClass) => new HandlerClass(serviceId, externalities.partialState, chainSpec));
|
|
81
|
+
/** https://graypaper.fluffylabs.dev/#/ab2cdbd/30d00130d001?v=0.7.2 */
|
|
49
82
|
const generalHandlers = [
|
|
50
83
|
new general.LogHostCall(serviceId),
|
|
51
84
|
new general.GasHostCall(serviceId),
|
|
@@ -75,10 +108,20 @@ export class PvmExecutor {
|
|
|
75
108
|
*
|
|
76
109
|
* @param args additional arguments that will be placed in PVM memory before execution
|
|
77
110
|
* @param gas gas limit
|
|
78
|
-
* @returns `ReturnValue` object
|
|
111
|
+
* @returns `ReturnValue` object containing consumed gas, status and an optional memory slice
|
|
79
112
|
*/
|
|
80
113
|
async run(args, gas) {
|
|
81
|
-
|
|
114
|
+
const ret = await this.pvm.runProgram(this.serviceCode.raw, args.raw, Number(this.entrypoint), tryAsGas(gas));
|
|
115
|
+
return {
|
|
116
|
+
...ret,
|
|
117
|
+
consumedGas: tryAsServiceGas(ret.consumedGas),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/** A utility function that can be used to prepare refine executor */
|
|
121
|
+
static async createRefineExecutor(serviceId, serviceCode, externalities, pvm) {
|
|
122
|
+
const hostCallHandlers = PvmExecutor.prepareRefineHostCalls(serviceId, externalities);
|
|
123
|
+
const instances = await PvmExecutor.prepareBackend(pvm);
|
|
124
|
+
return new PvmExecutor(serviceCode, hostCallHandlers, entrypoint.REFINE, instances);
|
|
82
125
|
}
|
|
83
126
|
/** A utility function that can be used to prepare accumulate executor */
|
|
84
127
|
static async createAccumulateExecutor(serviceId, serviceCode, externalities, chainSpec, pvm) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Segment, SegmentIndex, ServiceId } from "#@typeberry/block";
|
|
2
|
+
import type { BytesBlob } from "#@typeberry/bytes";
|
|
3
|
+
import type { Blake2bHash } from "#@typeberry/hash";
|
|
4
|
+
import type { MachineId, MachineResult, MemoryOperation, NoMachineError, PagesError, PeekPokeError, ProgramCounter, RefineExternalities, SegmentExportError, ZeroVoidError } from "#@typeberry/jam-host-calls";
|
|
5
|
+
import type { U64 } from "#@typeberry/numbers";
|
|
6
|
+
import type { HostCallMemory, HostCallRegisters } from "#@typeberry/pvm-host-calls";
|
|
7
|
+
import type { BigGas } from "#@typeberry/pvm-interface";
|
|
8
|
+
import type { ProgramDecoderError } from "#@typeberry/pvm-interpreter";
|
|
9
|
+
import type { OK, Result } from "#@typeberry/utils";
|
|
10
|
+
export declare class RefineExternalitiesImpl implements RefineExternalities {
|
|
11
|
+
static create(): RefineExternalitiesImpl;
|
|
12
|
+
private constructor();
|
|
13
|
+
machineExpunge(_machineIndex: MachineId): Promise<Result<ProgramCounter, NoMachineError>>;
|
|
14
|
+
machinePages(_machineIndex: MachineId, _pageStart: U64, _pageCount: U64, _requestType: MemoryOperation | null): Promise<Result<OK, PagesError>>;
|
|
15
|
+
machineVoidPages(_machineIndex: MachineId, _pageStart: U64, _pageCount: U64): Promise<Result<OK, ZeroVoidError>>;
|
|
16
|
+
machineZeroPages(_machineIndex: MachineId, _pageStart: U64, _pageCount: U64): Promise<Result<OK, ZeroVoidError>>;
|
|
17
|
+
machinePeekFrom(_machineIndex: MachineId, _destinationStart: U64, _sourceStart: U64, _length: U64, _destination: HostCallMemory): Promise<Result<OK, PeekPokeError>>;
|
|
18
|
+
machinePokeInto(_machineIndex: MachineId, _sourceStart: U64, _destinationStart: U64, _length: U64, _source: HostCallMemory): Promise<Result<OK, PeekPokeError>>;
|
|
19
|
+
machineInit(_code: BytesBlob, _programCounter: ProgramCounter): Promise<Result<MachineId, ProgramDecoderError>>;
|
|
20
|
+
machineInvoke(_machineIndex: MachineId, _gas: BigGas, _registers: HostCallRegisters): Promise<Result<MachineResult, NoMachineError>>;
|
|
21
|
+
exportSegment(_segment: Segment): Result<SegmentIndex, SegmentExportError>;
|
|
22
|
+
historicalLookup(_serviceId: ServiceId | null, _hash: Blake2bHash): Promise<BytesBlob | null>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=refine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refine.d.ts","sourceRoot":"","sources":["../../../../../../packages/jam/in-core/externalities/refine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EACb,eAAe,EACf,cAAc,EACd,UAAU,EACV,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,EACd,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,E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M,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;IAIrC,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;IAI/G,aAAa,CACX,aAAa,EAAE,SAAS,EACxB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,iBAAiB,GAC5B,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;IAIjD,aAAa,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,CAAC,YAAY,EAAE,kBAAkB,CAAC;IAI1E,gBAAgB,CAAC,UAAU,EAAE,SAAS,GAAG,IAAI,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;CAG9F"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export class RefineExternalitiesImpl {
|
|
2
|
+
static create() {
|
|
3
|
+
return new RefineExternalitiesImpl();
|
|
4
|
+
}
|
|
5
|
+
constructor() { }
|
|
6
|
+
machineExpunge(_machineIndex) {
|
|
7
|
+
throw new Error("Method not implemented.");
|
|
8
|
+
}
|
|
9
|
+
machinePages(_machineIndex, _pageStart, _pageCount, _requestType) {
|
|
10
|
+
throw new Error("Method not implemented.");
|
|
11
|
+
}
|
|
12
|
+
machineVoidPages(_machineIndex, _pageStart, _pageCount) {
|
|
13
|
+
throw new Error("Method not implemented.");
|
|
14
|
+
}
|
|
15
|
+
machineZeroPages(_machineIndex, _pageStart, _pageCount) {
|
|
16
|
+
throw new Error("Method not implemented.");
|
|
17
|
+
}
|
|
18
|
+
machinePeekFrom(_machineIndex, _destinationStart, _sourceStart, _length, _destination) {
|
|
19
|
+
throw new Error("Method not implemented.");
|
|
20
|
+
}
|
|
21
|
+
machinePokeInto(_machineIndex, _sourceStart, _destinationStart, _length, _source) {
|
|
22
|
+
throw new Error("Method not implemented.");
|
|
23
|
+
}
|
|
24
|
+
machineInit(_code, _programCounter) {
|
|
25
|
+
throw new Error("Method not implemented.");
|
|
26
|
+
}
|
|
27
|
+
machineInvoke(_machineIndex, _gas, _registers) {
|
|
28
|
+
throw new Error("Method not implemented.");
|
|
29
|
+
}
|
|
30
|
+
exportSegment(_segment) {
|
|
31
|
+
throw new Error("Method not implemented.");
|
|
32
|
+
}
|
|
33
|
+
historicalLookup(_serviceId, _hash) {
|
|
34
|
+
throw new Error("Method not implemented.");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type CoreIndex, type Segment, type SegmentIndex, type ServiceGas } from "#@typeberry/block";
|
|
2
|
+
import { type WorkPackageHash } from "#@typeberry/block/refine-context.js";
|
|
3
|
+
import type { WorkItemExtrinsic } from "#@typeberry/block/work-item.js";
|
|
4
|
+
import type { WorkPackage } from "#@typeberry/block/work-package.js";
|
|
5
|
+
import { WorkReport } from "#@typeberry/block/work-report.js";
|
|
6
|
+
import { WorkExecResult, WorkResult } from "#@typeberry/block/work-result.js";
|
|
7
|
+
import { type KnownSizeArray } from "#@typeberry/collections";
|
|
8
|
+
import type { ChainSpec, PvmBackend } from "#@typeberry/config";
|
|
9
|
+
import type { StatesDb } from "#@typeberry/database";
|
|
10
|
+
import { type ReturnValue } from "#@typeberry/executor";
|
|
11
|
+
import { type Blake2b, type WithHash } from "#@typeberry/hash";
|
|
12
|
+
import { Result } from "#@typeberry/utils";
|
|
13
|
+
export type RefineResult = {
|
|
14
|
+
report: WorkReport;
|
|
15
|
+
exports: PerWorkItem<Segment[]>;
|
|
16
|
+
};
|
|
17
|
+
export type RefineItemResult = {
|
|
18
|
+
result: WorkResult;
|
|
19
|
+
exports: Segment[];
|
|
20
|
+
};
|
|
21
|
+
export declare enum RefineError {
|
|
22
|
+
/** State for context anchor block or lookup anchor is not found in the DB. */
|
|
23
|
+
StateMissing = 0,
|
|
24
|
+
/** Posterior state root of context anchor block does not match the one in the DB. */
|
|
25
|
+
StateRootMismatch = 1,
|
|
26
|
+
/** Lookup anchor state-slot does not match the one given in context. */
|
|
27
|
+
InvalidLookupAnchorSlot = 2,
|
|
28
|
+
/** Authorization error. */
|
|
29
|
+
AuthorizationError = 3
|
|
30
|
+
}
|
|
31
|
+
export type PerWorkItem<T> = KnownSizeArray<T, "for each work item">;
|
|
32
|
+
export type ImportedSegment = {
|
|
33
|
+
index: SegmentIndex;
|
|
34
|
+
data: Segment;
|
|
35
|
+
};
|
|
36
|
+
export declare class InCore {
|
|
37
|
+
readonly chainSpec: ChainSpec;
|
|
38
|
+
private readonly states;
|
|
39
|
+
private readonly pvmBackend;
|
|
40
|
+
private readonly blake2b;
|
|
41
|
+
constructor(chainSpec: ChainSpec, states: StatesDb, pvmBackend: PvmBackend, blake2b: Blake2b);
|
|
42
|
+
/**
|
|
43
|
+
* Work-report computation function.
|
|
44
|
+
*
|
|
45
|
+
* Note this requires all of the imports and extrinsics to be already fetched
|
|
46
|
+
* and only performs the refinement.
|
|
47
|
+
*
|
|
48
|
+
* Any validation must be done externally!
|
|
49
|
+
*
|
|
50
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/1b7f021b7f02?v=0.7.2
|
|
51
|
+
*/
|
|
52
|
+
refine(workPackageAndHash: WithHash<WorkPackageHash, WorkPackage>, core: CoreIndex, imports: PerWorkItem<ImportedSegment[]>, extrinsics: PerWorkItem<WorkItemExtrinsic[]>): Promise<Result<RefineResult, RefineError>>;
|
|
53
|
+
private amalgamateWorkReport;
|
|
54
|
+
private authorizePackage;
|
|
55
|
+
private refineItem;
|
|
56
|
+
extractWorkResult(execResult: ReturnValue<ServiceGas>): WorkExecResult;
|
|
57
|
+
private getServiceCode;
|
|
58
|
+
private createRefineExternalities;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=in-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-core.d.ts","sourceRoot":"","sources":["../../../../../packages/jam/in-core/in-core.ts"],"names":[],"m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