@typeberry/lib 0.1.1-e48de40 → 0.1.2-3178190
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/index.cjs +35 -20
- package/index.d.ts +26 -23
- package/index.js +35 -20
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -10,6 +10,7 @@ var GpVersion;
|
|
|
10
10
|
GpVersion["V0_6_7"] = "0.6.7";
|
|
11
11
|
GpVersion["V0_7_0"] = "0.7.0";
|
|
12
12
|
GpVersion["V0_7_1"] = "0.7.1-preview";
|
|
13
|
+
GpVersion["V0_7_2"] = "0.7.2-preview";
|
|
13
14
|
})(GpVersion || (GpVersion = {}));
|
|
14
15
|
var TestSuite;
|
|
15
16
|
(function (TestSuite) {
|
|
@@ -17,7 +18,7 @@ var TestSuite;
|
|
|
17
18
|
TestSuite["JAMDUNA"] = "jamduna";
|
|
18
19
|
})(TestSuite || (TestSuite = {}));
|
|
19
20
|
const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
20
|
-
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1];
|
|
21
|
+
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1, GpVersion.V0_7_2];
|
|
21
22
|
const env$1 = typeof process === "undefined" ? {} : process.env;
|
|
22
23
|
const DEFAULT_VERSION = GpVersion.V0_7_0;
|
|
23
24
|
let CURRENT_VERSION = parseCurrentVersion(env$1.GP_VERSION) ?? DEFAULT_VERSION;
|
|
@@ -26,20 +27,26 @@ function parseCurrentVersion(env) {
|
|
|
26
27
|
if (env === undefined) {
|
|
27
28
|
return undefined;
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
switch (env) {
|
|
31
|
+
case GpVersion.V0_6_7:
|
|
32
|
+
case GpVersion.V0_7_0:
|
|
33
|
+
case GpVersion.V0_7_1:
|
|
34
|
+
case GpVersion.V0_7_2:
|
|
35
|
+
return env;
|
|
36
|
+
default:
|
|
37
|
+
throw new Error(`Configured environment variable GP_VERSION is unknown: '${env}'. Use one of: ${ALL_VERSIONS_IN_ORDER}`);
|
|
32
38
|
}
|
|
33
|
-
return version;
|
|
34
39
|
}
|
|
35
40
|
function parseCurrentSuite(env) {
|
|
36
41
|
if (env === undefined)
|
|
37
42
|
return undefined;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
switch (env) {
|
|
44
|
+
case TestSuite.W3F_DAVXY:
|
|
45
|
+
case TestSuite.JAMDUNA:
|
|
46
|
+
return env;
|
|
47
|
+
default:
|
|
48
|
+
throw new Error(`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`);
|
|
41
49
|
}
|
|
42
|
-
return val;
|
|
43
50
|
}
|
|
44
51
|
class Compatibility {
|
|
45
52
|
static override(version) {
|
|
@@ -8045,8 +8052,8 @@ function print(level, levelAndName, strings, data) {
|
|
|
8045
8052
|
return;
|
|
8046
8053
|
}
|
|
8047
8054
|
const lvlText = Level[level].padEnd(5);
|
|
8048
|
-
const val = strings.map((v, idx) => `${v}${data[idx]}`);
|
|
8049
|
-
const msg = `${lvlText} [${levelAndName[1]}] ${val}`;
|
|
8055
|
+
const val = strings.map((v, idx) => `${v}${idx < data.length ? data[idx] : ""}`);
|
|
8056
|
+
const msg = `${lvlText} [${levelAndName[1]}] ${val.join("")}`;
|
|
8050
8057
|
if (level === Level.WARN) {
|
|
8051
8058
|
console.warn(msg);
|
|
8052
8059
|
}
|
|
@@ -12397,16 +12404,12 @@ class PartiallyUpdatedState {
|
|
|
12397
12404
|
*
|
|
12398
12405
|
* NOTE the info may be updated compared to what is in the state.
|
|
12399
12406
|
*
|
|
12400
|
-
* Takes into account newly created services as well.
|
|
12407
|
+
* Takes into account ejected and newly created services as well.
|
|
12401
12408
|
*/
|
|
12402
12409
|
getServiceInfo(destination) {
|
|
12403
12410
|
if (destination === null) {
|
|
12404
12411
|
return null;
|
|
12405
12412
|
}
|
|
12406
|
-
const isEjected = this.stateUpdate.services.servicesRemoved.some((x) => x === destination);
|
|
12407
|
-
if (isEjected) {
|
|
12408
|
-
return null;
|
|
12409
|
-
}
|
|
12410
12413
|
const maybeNewService = this.stateUpdate.services.servicesUpdates.find((update) => update.serviceId === destination);
|
|
12411
12414
|
if (maybeNewService !== undefined) {
|
|
12412
12415
|
return maybeNewService.action.account;
|
|
@@ -14122,6 +14125,17 @@ class PageRange {
|
|
|
14122
14125
|
}
|
|
14123
14126
|
return new PageRange(start, length);
|
|
14124
14127
|
}
|
|
14128
|
+
/** Returns true if the page range is wrapped (`start` >= `end`) and is not empty */
|
|
14129
|
+
isWrapped() {
|
|
14130
|
+
return this.start >= this.end && !this.isEmpty();
|
|
14131
|
+
}
|
|
14132
|
+
/** Checks if given page number is within the range */
|
|
14133
|
+
isInRange(page) {
|
|
14134
|
+
if (this.isWrapped()) {
|
|
14135
|
+
return page >= this.start || page < this.end;
|
|
14136
|
+
}
|
|
14137
|
+
return page >= this.start && page < this.end;
|
|
14138
|
+
}
|
|
14125
14139
|
/** Checks if a range is empty (`length === 0`) */
|
|
14126
14140
|
isEmpty() {
|
|
14127
14141
|
return this.length === 0;
|
|
@@ -14462,10 +14476,11 @@ class MemoryBuilder {
|
|
|
14462
14476
|
startHeapIndex (${startHeapIndex}) has to be less than or equal to endHeapIndex (${endHeapIndex})
|
|
14463
14477
|
`;
|
|
14464
14478
|
this.ensureNotFinalized();
|
|
14465
|
-
const
|
|
14466
|
-
const
|
|
14467
|
-
|
|
14468
|
-
|
|
14479
|
+
const heapRange = MemoryRange.fromStartAndLength(startHeapIndex, endHeapIndex - startHeapIndex);
|
|
14480
|
+
const heapPagesRange = PageRange.fromMemoryRange(heapRange);
|
|
14481
|
+
const initializedPageNumbers = Array.from(this.initialMemory.keys());
|
|
14482
|
+
for (const pageNumber of initializedPageNumbers) {
|
|
14483
|
+
if (heapPagesRange.isInRange(pageNumber)) {
|
|
14469
14484
|
throw new IncorrectSbrkIndex();
|
|
14470
14485
|
}
|
|
14471
14486
|
}
|
package/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ declare enum GpVersion {
|
|
|
2
2
|
V0_6_7 = "0.6.7",
|
|
3
3
|
V0_7_0 = "0.7.0",
|
|
4
4
|
V0_7_1 = "0.7.1-preview",
|
|
5
|
+
V0_7_2 = "0.7.2-preview",
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
declare enum TestSuite {
|
|
@@ -11,7 +12,7 @@ declare enum TestSuite {
|
|
|
11
12
|
|
|
12
13
|
declare const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
13
14
|
|
|
14
|
-
declare const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1];
|
|
15
|
+
declare const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1, GpVersion.V0_7_2];
|
|
15
16
|
declare const DEFAULT_VERSION = GpVersion.V0_7_0;
|
|
16
17
|
declare let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
|
|
17
18
|
declare let CURRENT_SUITE = parseCurrentSuite(env.TEST_SUITE) ?? DEFAULT_SUITE;
|
|
@@ -20,24 +21,30 @@ declare function parseCurrentVersion(env?: string): GpVersion | undefined {
|
|
|
20
21
|
if (env === undefined) {
|
|
21
22
|
return undefined;
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
switch (env) {
|
|
25
|
+
case GpVersion.V0_6_7:
|
|
26
|
+
case GpVersion.V0_7_0:
|
|
27
|
+
case GpVersion.V0_7_1:
|
|
28
|
+
case GpVersion.V0_7_2:
|
|
29
|
+
return env;
|
|
30
|
+
default:
|
|
31
|
+
throw new Error(
|
|
32
|
+
`Configured environment variable GP_VERSION is unknown: '${env}'. Use one of: ${ALL_VERSIONS_IN_ORDER}`,
|
|
33
|
+
);
|
|
28
34
|
}
|
|
29
|
-
return version;
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
declare function parseCurrentSuite(env?: string): TestSuite | undefined {
|
|
33
38
|
if (env === undefined) return undefined;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
switch (env) {
|
|
40
|
+
case TestSuite.W3F_DAVXY:
|
|
41
|
+
case TestSuite.JAMDUNA:
|
|
42
|
+
return env;
|
|
43
|
+
default:
|
|
44
|
+
throw new Error(
|
|
45
|
+
`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`,
|
|
46
|
+
);
|
|
39
47
|
}
|
|
40
|
-
return val;
|
|
41
48
|
}
|
|
42
49
|
|
|
43
50
|
declare class Compatibility {
|
|
@@ -14773,11 +14780,12 @@ declare class MemoryBuilder {
|
|
|
14773
14780
|
`;
|
|
14774
14781
|
this.ensureNotFinalized();
|
|
14775
14782
|
|
|
14776
|
-
const
|
|
14777
|
-
const
|
|
14783
|
+
const heapRange = MemoryRange.fromStartAndLength(startHeapIndex, endHeapIndex - startHeapIndex);
|
|
14784
|
+
const heapPagesRange = PageRange.fromMemoryRange(heapRange);
|
|
14785
|
+
const initializedPageNumbers = Array.from(this.initialMemory.keys());
|
|
14778
14786
|
|
|
14779
|
-
for (const pageNumber of
|
|
14780
|
-
if (
|
|
14787
|
+
for (const pageNumber of initializedPageNumbers) {
|
|
14788
|
+
if (heapPagesRange.isInRange(pageNumber)) {
|
|
14781
14789
|
throw new IncorrectSbrkIndex();
|
|
14782
14790
|
}
|
|
14783
14791
|
}
|
|
@@ -17150,18 +17158,13 @@ declare class PartiallyUpdatedState<T extends StateSlice = StateSlice> {
|
|
|
17150
17158
|
*
|
|
17151
17159
|
* NOTE the info may be updated compared to what is in the state.
|
|
17152
17160
|
*
|
|
17153
|
-
* Takes into account newly created services as well.
|
|
17161
|
+
* Takes into account ejected and newly created services as well.
|
|
17154
17162
|
*/
|
|
17155
17163
|
getServiceInfo(destination: ServiceId | null): ServiceAccountInfo | null {
|
|
17156
17164
|
if (destination === null) {
|
|
17157
17165
|
return null;
|
|
17158
17166
|
}
|
|
17159
17167
|
|
|
17160
|
-
const isEjected = this.stateUpdate.services.servicesRemoved.some((x) => x === destination);
|
|
17161
|
-
if (isEjected) {
|
|
17162
|
-
return null;
|
|
17163
|
-
}
|
|
17164
|
-
|
|
17165
17168
|
const maybeNewService = this.stateUpdate.services.servicesUpdates.find(
|
|
17166
17169
|
(update) => update.serviceId === destination,
|
|
17167
17170
|
);
|
package/index.js
CHANGED
|
@@ -7,6 +7,7 @@ var GpVersion;
|
|
|
7
7
|
GpVersion["V0_6_7"] = "0.6.7";
|
|
8
8
|
GpVersion["V0_7_0"] = "0.7.0";
|
|
9
9
|
GpVersion["V0_7_1"] = "0.7.1-preview";
|
|
10
|
+
GpVersion["V0_7_2"] = "0.7.2-preview";
|
|
10
11
|
})(GpVersion || (GpVersion = {}));
|
|
11
12
|
var TestSuite;
|
|
12
13
|
(function (TestSuite) {
|
|
@@ -14,7 +15,7 @@ var TestSuite;
|
|
|
14
15
|
TestSuite["JAMDUNA"] = "jamduna";
|
|
15
16
|
})(TestSuite || (TestSuite = {}));
|
|
16
17
|
const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
17
|
-
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1];
|
|
18
|
+
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1, GpVersion.V0_7_2];
|
|
18
19
|
const env$1 = typeof process === "undefined" ? {} : process.env;
|
|
19
20
|
const DEFAULT_VERSION = GpVersion.V0_7_0;
|
|
20
21
|
let CURRENT_VERSION = parseCurrentVersion(env$1.GP_VERSION) ?? DEFAULT_VERSION;
|
|
@@ -23,20 +24,26 @@ function parseCurrentVersion(env) {
|
|
|
23
24
|
if (env === undefined) {
|
|
24
25
|
return undefined;
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
switch (env) {
|
|
28
|
+
case GpVersion.V0_6_7:
|
|
29
|
+
case GpVersion.V0_7_0:
|
|
30
|
+
case GpVersion.V0_7_1:
|
|
31
|
+
case GpVersion.V0_7_2:
|
|
32
|
+
return env;
|
|
33
|
+
default:
|
|
34
|
+
throw new Error(`Configured environment variable GP_VERSION is unknown: '${env}'. Use one of: ${ALL_VERSIONS_IN_ORDER}`);
|
|
29
35
|
}
|
|
30
|
-
return version;
|
|
31
36
|
}
|
|
32
37
|
function parseCurrentSuite(env) {
|
|
33
38
|
if (env === undefined)
|
|
34
39
|
return undefined;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
switch (env) {
|
|
41
|
+
case TestSuite.W3F_DAVXY:
|
|
42
|
+
case TestSuite.JAMDUNA:
|
|
43
|
+
return env;
|
|
44
|
+
default:
|
|
45
|
+
throw new Error(`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`);
|
|
38
46
|
}
|
|
39
|
-
return val;
|
|
40
47
|
}
|
|
41
48
|
class Compatibility {
|
|
42
49
|
static override(version) {
|
|
@@ -8042,8 +8049,8 @@ function print(level, levelAndName, strings, data) {
|
|
|
8042
8049
|
return;
|
|
8043
8050
|
}
|
|
8044
8051
|
const lvlText = Level[level].padEnd(5);
|
|
8045
|
-
const val = strings.map((v, idx) => `${v}${data[idx]}`);
|
|
8046
|
-
const msg = `${lvlText} [${levelAndName[1]}] ${val}`;
|
|
8052
|
+
const val = strings.map((v, idx) => `${v}${idx < data.length ? data[idx] : ""}`);
|
|
8053
|
+
const msg = `${lvlText} [${levelAndName[1]}] ${val.join("")}`;
|
|
8047
8054
|
if (level === Level.WARN) {
|
|
8048
8055
|
console.warn(msg);
|
|
8049
8056
|
}
|
|
@@ -12394,16 +12401,12 @@ class PartiallyUpdatedState {
|
|
|
12394
12401
|
*
|
|
12395
12402
|
* NOTE the info may be updated compared to what is in the state.
|
|
12396
12403
|
*
|
|
12397
|
-
* Takes into account newly created services as well.
|
|
12404
|
+
* Takes into account ejected and newly created services as well.
|
|
12398
12405
|
*/
|
|
12399
12406
|
getServiceInfo(destination) {
|
|
12400
12407
|
if (destination === null) {
|
|
12401
12408
|
return null;
|
|
12402
12409
|
}
|
|
12403
|
-
const isEjected = this.stateUpdate.services.servicesRemoved.some((x) => x === destination);
|
|
12404
|
-
if (isEjected) {
|
|
12405
|
-
return null;
|
|
12406
|
-
}
|
|
12407
12410
|
const maybeNewService = this.stateUpdate.services.servicesUpdates.find((update) => update.serviceId === destination);
|
|
12408
12411
|
if (maybeNewService !== undefined) {
|
|
12409
12412
|
return maybeNewService.action.account;
|
|
@@ -14119,6 +14122,17 @@ class PageRange {
|
|
|
14119
14122
|
}
|
|
14120
14123
|
return new PageRange(start, length);
|
|
14121
14124
|
}
|
|
14125
|
+
/** Returns true if the page range is wrapped (`start` >= `end`) and is not empty */
|
|
14126
|
+
isWrapped() {
|
|
14127
|
+
return this.start >= this.end && !this.isEmpty();
|
|
14128
|
+
}
|
|
14129
|
+
/** Checks if given page number is within the range */
|
|
14130
|
+
isInRange(page) {
|
|
14131
|
+
if (this.isWrapped()) {
|
|
14132
|
+
return page >= this.start || page < this.end;
|
|
14133
|
+
}
|
|
14134
|
+
return page >= this.start && page < this.end;
|
|
14135
|
+
}
|
|
14122
14136
|
/** Checks if a range is empty (`length === 0`) */
|
|
14123
14137
|
isEmpty() {
|
|
14124
14138
|
return this.length === 0;
|
|
@@ -14459,10 +14473,11 @@ class MemoryBuilder {
|
|
|
14459
14473
|
startHeapIndex (${startHeapIndex}) has to be less than or equal to endHeapIndex (${endHeapIndex})
|
|
14460
14474
|
`;
|
|
14461
14475
|
this.ensureNotFinalized();
|
|
14462
|
-
const
|
|
14463
|
-
const
|
|
14464
|
-
|
|
14465
|
-
|
|
14476
|
+
const heapRange = MemoryRange.fromStartAndLength(startHeapIndex, endHeapIndex - startHeapIndex);
|
|
14477
|
+
const heapPagesRange = PageRange.fromMemoryRange(heapRange);
|
|
14478
|
+
const initializedPageNumbers = Array.from(this.initialMemory.keys());
|
|
14479
|
+
for (const pageNumber of initializedPageNumbers) {
|
|
14480
|
+
if (heapPagesRange.isInRange(pageNumber)) {
|
|
14466
14481
|
throw new IncorrectSbrkIndex();
|
|
14467
14482
|
}
|
|
14468
14483
|
}
|