@typeberry/lib 0.2.0-5746fdc → 0.2.0-79dc2d4
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 +154 -59
- package/index.d.ts +189 -81
- package/index.js +154 -59
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -11,44 +11,40 @@ var GpVersion;
|
|
|
11
11
|
GpVersion["V0_6_7"] = "0.6.7";
|
|
12
12
|
GpVersion["V0_7_0"] = "0.7.0";
|
|
13
13
|
GpVersion["V0_7_1"] = "0.7.1";
|
|
14
|
-
GpVersion["V0_7_2"] = "0.7.2
|
|
14
|
+
GpVersion["V0_7_2"] = "0.7.2";
|
|
15
15
|
})(GpVersion || (GpVersion = {}));
|
|
16
16
|
var TestSuite;
|
|
17
17
|
(function (TestSuite) {
|
|
18
18
|
TestSuite["W3F_DAVXY"] = "w3f-davxy";
|
|
19
19
|
TestSuite["JAMDUNA"] = "jamduna";
|
|
20
20
|
})(TestSuite || (TestSuite = {}));
|
|
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 DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
22
|
-
const DEFAULT_VERSION = GpVersion.
|
|
23
|
+
const DEFAULT_VERSION = GpVersion.V0_7_2;
|
|
23
24
|
const env$1 = typeof process === "undefined" ? {} : process.env;
|
|
24
25
|
let CURRENT_VERSION = parseCurrentVersion(env$1.GP_VERSION) ?? DEFAULT_VERSION;
|
|
25
26
|
let CURRENT_SUITE = parseCurrentSuite(env$1.TEST_SUITE) ?? DEFAULT_SUITE;
|
|
26
|
-
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1, GpVersion.V0_7_2];
|
|
27
27
|
function parseCurrentVersion(env) {
|
|
28
28
|
if (env === undefined) {
|
|
29
29
|
return undefined;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
case GpVersion.V0_7_2:
|
|
36
|
-
return env;
|
|
37
|
-
default:
|
|
38
|
-
throw new Error(`Configured environment variable GP_VERSION is unknown: '${env}'. Use one of: ${ALL_VERSIONS_IN_ORDER}`);
|
|
31
|
+
for (const v of Object.values(GpVersion)) {
|
|
32
|
+
if (env === v) {
|
|
33
|
+
return v;
|
|
34
|
+
}
|
|
39
35
|
}
|
|
36
|
+
throw new Error(`Configured environment variable GP_VERSION is unknown: '${env}'. Use one of: ${ALL_VERSIONS_IN_ORDER}`);
|
|
40
37
|
}
|
|
41
38
|
function parseCurrentSuite(env) {
|
|
42
39
|
if (env === undefined) {
|
|
43
40
|
return undefined;
|
|
44
41
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
default:
|
|
50
|
-
throw new Error(`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`);
|
|
42
|
+
for (const s of Object.values(TestSuite)) {
|
|
43
|
+
if (env === s) {
|
|
44
|
+
return s;
|
|
45
|
+
}
|
|
51
46
|
}
|
|
47
|
+
throw new Error(`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`);
|
|
52
48
|
}
|
|
53
49
|
class Compatibility {
|
|
54
50
|
static override(version) {
|
|
@@ -208,6 +204,13 @@ class WithDebug {
|
|
|
208
204
|
return inspect(this);
|
|
209
205
|
}
|
|
210
206
|
}
|
|
207
|
+
function lazyInspect(obj) {
|
|
208
|
+
return {
|
|
209
|
+
toString() {
|
|
210
|
+
return inspect(obj);
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
}
|
|
211
214
|
|
|
212
215
|
const env = typeof process === "undefined" ? {} : process.env;
|
|
213
216
|
/**
|
|
@@ -602,6 +605,7 @@ var index$u = /*#__PURE__*/Object.freeze({
|
|
|
602
605
|
deepEqual: deepEqual,
|
|
603
606
|
inspect: inspect,
|
|
604
607
|
isBrowser: isBrowser,
|
|
608
|
+
lazyInspect: lazyInspect,
|
|
605
609
|
measure: measure,
|
|
606
610
|
resultToString: resultToString,
|
|
607
611
|
safeAllocUint8Array: safeAllocUint8Array,
|
|
@@ -7744,7 +7748,7 @@ const DEV_CONFIG = "dev";
|
|
|
7744
7748
|
const DEFAULT_CONFIG = "default";
|
|
7745
7749
|
const NODE_DEFAULTS = {
|
|
7746
7750
|
name: isBrowser() ? "browser" : os.hostname(),
|
|
7747
|
-
config: DEFAULT_CONFIG,
|
|
7751
|
+
config: [DEFAULT_CONFIG],
|
|
7748
7752
|
pvm: PvmBackend.BuiltIn,
|
|
7749
7753
|
};
|
|
7750
7754
|
/** Chain spec chooser. */
|
|
@@ -7797,25 +7801,137 @@ class NodeConfiguration {
|
|
|
7797
7801
|
this.authorship = authorship;
|
|
7798
7802
|
}
|
|
7799
7803
|
}
|
|
7800
|
-
function loadConfig(
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
|
|
7804
|
+
function loadConfig(config, withRelPath) {
|
|
7805
|
+
logger$5.log `🔧 Loading config`;
|
|
7806
|
+
let mergedJson = {};
|
|
7807
|
+
for (const entry of config) {
|
|
7808
|
+
logger$5.log `🔧 Applying '${entry}'`;
|
|
7809
|
+
if (entry === DEV_CONFIG) {
|
|
7810
|
+
mergedJson = structuredClone(configs.dev); // clone to avoid mutating the original config. not doing a merge since dev and default should theoretically replace all properties.
|
|
7811
|
+
continue;
|
|
7812
|
+
}
|
|
7813
|
+
if (entry === DEFAULT_CONFIG) {
|
|
7814
|
+
mergedJson = structuredClone(configs.default);
|
|
7815
|
+
continue;
|
|
7816
|
+
}
|
|
7817
|
+
// try to parse as JSON
|
|
7818
|
+
try {
|
|
7819
|
+
const parsed = JSON.parse(entry);
|
|
7820
|
+
deepMerge(mergedJson, parsed);
|
|
7821
|
+
continue;
|
|
7822
|
+
}
|
|
7823
|
+
catch { }
|
|
7824
|
+
// if not, try to load as file
|
|
7825
|
+
if (entry.indexOf("=") === -1 && entry.endsWith(".json")) {
|
|
7826
|
+
try {
|
|
7827
|
+
const configFile = fs.readFileSync(withRelPath(entry), "utf8");
|
|
7828
|
+
const parsed = JSON.parse(configFile);
|
|
7829
|
+
deepMerge(mergedJson, parsed);
|
|
7830
|
+
}
|
|
7831
|
+
catch (e) {
|
|
7832
|
+
throw new Error(`Unable to load config from ${entry}: ${e}`);
|
|
7833
|
+
}
|
|
7834
|
+
}
|
|
7835
|
+
else {
|
|
7836
|
+
// finally try to process as a pseudo-jq query
|
|
7837
|
+
try {
|
|
7838
|
+
processQuery(mergedJson, entry, withRelPath);
|
|
7839
|
+
}
|
|
7840
|
+
catch (e) {
|
|
7841
|
+
throw new Error(`Error while processing '${entry}': ${e}`);
|
|
7842
|
+
}
|
|
7843
|
+
}
|
|
7808
7844
|
}
|
|
7809
7845
|
try {
|
|
7810
|
-
|
|
7811
|
-
|
|
7812
|
-
|
|
7813
|
-
return parseFromJson(parsed, NodeConfiguration.fromJson);
|
|
7846
|
+
const parsed = parseFromJson(mergedJson, NodeConfiguration.fromJson);
|
|
7847
|
+
logger$5.log `🔧 Config ready`;
|
|
7848
|
+
return parsed;
|
|
7814
7849
|
}
|
|
7815
7850
|
catch (e) {
|
|
7816
|
-
throw new Error(`Unable to
|
|
7851
|
+
throw new Error(`Unable to parse config: ${e}`);
|
|
7817
7852
|
}
|
|
7818
7853
|
}
|
|
7854
|
+
function deepMerge(target, source) {
|
|
7855
|
+
if (!isJsonObject(source)) {
|
|
7856
|
+
throw new Error(`Expected object, got ${source}`);
|
|
7857
|
+
}
|
|
7858
|
+
for (const key in source) {
|
|
7859
|
+
if (isJsonObject(source[key])) {
|
|
7860
|
+
if (!isJsonObject(target[key])) {
|
|
7861
|
+
target[key] = {};
|
|
7862
|
+
}
|
|
7863
|
+
deepMerge(target[key], source[key]);
|
|
7864
|
+
}
|
|
7865
|
+
else {
|
|
7866
|
+
target[key] = source[key];
|
|
7867
|
+
}
|
|
7868
|
+
}
|
|
7869
|
+
}
|
|
7870
|
+
/**
|
|
7871
|
+
* Caution: updates input directly.
|
|
7872
|
+
* Processes a pseudo-jq query. Syntax:
|
|
7873
|
+
* .path.to.value = { ... } - updates value with the specified object by replacement
|
|
7874
|
+
* .path.to.value += { ... } - updates value with the specified object by merging
|
|
7875
|
+
* .path.to.value = file.json - updates value with the contents of file.json
|
|
7876
|
+
* .path.to.value += file.json - merges the contents of file.json onto value
|
|
7877
|
+
*/
|
|
7878
|
+
function processQuery(input, query, withRelPath) {
|
|
7879
|
+
const queryParts = query.split("=");
|
|
7880
|
+
if (queryParts.length === 2) {
|
|
7881
|
+
let [path, value] = queryParts.map((part) => part.trim());
|
|
7882
|
+
let merge = false;
|
|
7883
|
+
// detect += syntax
|
|
7884
|
+
if (path.endsWith("+")) {
|
|
7885
|
+
merge = true;
|
|
7886
|
+
path = path.slice(0, -1);
|
|
7887
|
+
}
|
|
7888
|
+
let parsedValue;
|
|
7889
|
+
if (value.endsWith(".json")) {
|
|
7890
|
+
try {
|
|
7891
|
+
const configFile = fs.readFileSync(withRelPath(value), "utf8");
|
|
7892
|
+
const parsed = JSON.parse(configFile);
|
|
7893
|
+
parsedValue = parsed;
|
|
7894
|
+
}
|
|
7895
|
+
catch (e) {
|
|
7896
|
+
throw new Error(`Unable to load config from ${value}: ${e}`);
|
|
7897
|
+
}
|
|
7898
|
+
}
|
|
7899
|
+
else {
|
|
7900
|
+
try {
|
|
7901
|
+
parsedValue = JSON.parse(value);
|
|
7902
|
+
}
|
|
7903
|
+
catch (e) {
|
|
7904
|
+
throw new Error(`Unrecognized syntax '${value}': ${e}`);
|
|
7905
|
+
}
|
|
7906
|
+
}
|
|
7907
|
+
let pathParts = path.split(".");
|
|
7908
|
+
// allow leading dot in path
|
|
7909
|
+
if (pathParts[0] === "") {
|
|
7910
|
+
pathParts = pathParts.slice(1);
|
|
7911
|
+
}
|
|
7912
|
+
let target = input;
|
|
7913
|
+
for (let i = 0; i < pathParts.length; i++) {
|
|
7914
|
+
const part = pathParts[i];
|
|
7915
|
+
if (!isJsonObject(target[part])) {
|
|
7916
|
+
target[part] = {};
|
|
7917
|
+
}
|
|
7918
|
+
if (i === pathParts.length - 1) {
|
|
7919
|
+
if (merge) {
|
|
7920
|
+
deepMerge(target[part], parsedValue);
|
|
7921
|
+
}
|
|
7922
|
+
else {
|
|
7923
|
+
target[part] = parsedValue;
|
|
7924
|
+
}
|
|
7925
|
+
return;
|
|
7926
|
+
}
|
|
7927
|
+
target = target[part];
|
|
7928
|
+
}
|
|
7929
|
+
}
|
|
7930
|
+
throw new Error("Unrecognized syntax.");
|
|
7931
|
+
}
|
|
7932
|
+
function isJsonObject(value) {
|
|
7933
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7934
|
+
}
|
|
7819
7935
|
|
|
7820
7936
|
var index$h = /*#__PURE__*/Object.freeze({
|
|
7821
7937
|
__proto__: null,
|
|
@@ -8958,26 +9074,6 @@ class InMemoryStateView {
|
|
|
8958
9074
|
}
|
|
8959
9075
|
}
|
|
8960
9076
|
|
|
8961
|
-
/** Dictionary entry of services that auto-accumulate every block. */
|
|
8962
|
-
class AutoAccumulate {
|
|
8963
|
-
service;
|
|
8964
|
-
gasLimit;
|
|
8965
|
-
static Codec = codec$1.Class(AutoAccumulate, {
|
|
8966
|
-
service: codec$1.u32.asOpaque(),
|
|
8967
|
-
gasLimit: codec$1.u64.asOpaque(),
|
|
8968
|
-
});
|
|
8969
|
-
static create({ service, gasLimit }) {
|
|
8970
|
-
return new AutoAccumulate(service, gasLimit);
|
|
8971
|
-
}
|
|
8972
|
-
constructor(
|
|
8973
|
-
/** Service id that auto-accumulates. */
|
|
8974
|
-
service,
|
|
8975
|
-
/** Gas limit for auto-accumulation. */
|
|
8976
|
-
gasLimit) {
|
|
8977
|
-
this.service = service;
|
|
8978
|
-
this.gasLimit = gasLimit;
|
|
8979
|
-
}
|
|
8980
|
-
}
|
|
8981
9077
|
/**
|
|
8982
9078
|
* https://graypaper.fluffylabs.dev/#/ab2cdbd/114402114402?v=0.7.2
|
|
8983
9079
|
*/
|
|
@@ -8995,7 +9091,9 @@ class PrivilegedServices {
|
|
|
8995
9091
|
registrar: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
|
|
8996
9092
|
? codec$1.u32.asOpaque()
|
|
8997
9093
|
: ignoreValueWithDefault(tryAsServiceId(2 ** 32 - 1)),
|
|
8998
|
-
autoAccumulateServices:
|
|
9094
|
+
autoAccumulateServices: codec$1.dictionary(codec$1.u32.asOpaque(), codec$1.u64.asOpaque(), {
|
|
9095
|
+
sortKeys: (a, b) => a - b,
|
|
9096
|
+
}),
|
|
8999
9097
|
});
|
|
9000
9098
|
static create(a) {
|
|
9001
9099
|
return new PrivilegedServices(a.manager, a.delegator, a.registrar, a.assigners, a.autoAccumulateServices);
|
|
@@ -9600,7 +9698,7 @@ class InMemoryState extends WithDebug {
|
|
|
9600
9698
|
assigners: tryAsPerCore(new Array(spec.coresCount).fill(tryAsServiceId(0)), spec),
|
|
9601
9699
|
delegator: tryAsServiceId(0),
|
|
9602
9700
|
registrar: tryAsServiceId(MAX_VALUE),
|
|
9603
|
-
autoAccumulateServices:
|
|
9701
|
+
autoAccumulateServices: new Map(),
|
|
9604
9702
|
}),
|
|
9605
9703
|
accumulationOutputLog: SortedArray.fromArray(accumulationOutputComparator, []),
|
|
9606
9704
|
services: new Map(),
|
|
@@ -9623,7 +9721,6 @@ var index$g = /*#__PURE__*/Object.freeze({
|
|
|
9623
9721
|
__proto__: null,
|
|
9624
9722
|
AUTHORIZATION_QUEUE_SIZE: AUTHORIZATION_QUEUE_SIZE,
|
|
9625
9723
|
AccumulationOutput: AccumulationOutput,
|
|
9626
|
-
AutoAccumulate: AutoAccumulate,
|
|
9627
9724
|
AvailabilityAssignment: AvailabilityAssignment,
|
|
9628
9725
|
BASE_SERVICE_BALANCE: BASE_SERVICE_BALANCE,
|
|
9629
9726
|
BlockState: BlockState,
|
|
@@ -17606,6 +17703,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
17606
17703
|
instructionArgumentTypeMap: instructionArgumentTypeMap,
|
|
17607
17704
|
interpreter: index$5,
|
|
17608
17705
|
isBrowser: isBrowser,
|
|
17706
|
+
lazyInspect: lazyInspect,
|
|
17609
17707
|
measure: measure,
|
|
17610
17708
|
numbers: index$r,
|
|
17611
17709
|
resultToString: resultToString,
|
|
@@ -18012,10 +18110,7 @@ const fullStateDumpFromJson = (spec) => json.object({
|
|
|
18012
18110
|
chi_a: json.array("number"),
|
|
18013
18111
|
chi_v: "number",
|
|
18014
18112
|
chi_r: json.optional("number"),
|
|
18015
|
-
chi_g: json.nullable(json.
|
|
18016
|
-
service: "number",
|
|
18017
|
-
gasLimit: json.fromNumber((v) => tryAsServiceGas(v)),
|
|
18018
|
-
})),
|
|
18113
|
+
chi_g: json.nullable(json.map("number", json.fromNumber((v) => tryAsServiceGas(v)))),
|
|
18019
18114
|
},
|
|
18020
18115
|
pi: JsonStatisticsData.fromJson,
|
|
18021
18116
|
omega: json.array(json.array(notYetAccumulatedFromJson)),
|
|
@@ -18056,7 +18151,7 @@ const fullStateDumpFromJson = (spec) => json.object({
|
|
|
18056
18151
|
assigners: chi.chi_a,
|
|
18057
18152
|
delegator: chi.chi_v,
|
|
18058
18153
|
registrar: chi.chi_r ?? tryAsServiceId(2 ** 32 - 1),
|
|
18059
|
-
autoAccumulateServices: chi.chi_g ??
|
|
18154
|
+
autoAccumulateServices: chi.chi_g ?? new Map(),
|
|
18060
18155
|
}),
|
|
18061
18156
|
statistics: JsonStatisticsData.toStatisticsData(spec, pi),
|
|
18062
18157
|
accumulationQueue: omega,
|
package/index.d.ts
CHANGED
|
@@ -2,7 +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",
|
|
5
|
-
V0_7_2 = "0.7.2
|
|
5
|
+
V0_7_2 = "0.7.2",
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
declare enum TestSuite {
|
|
@@ -10,43 +10,39 @@ declare enum TestSuite {
|
|
|
10
10
|
JAMDUNA = "jamduna",
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
declare const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1, GpVersion.V0_7_2];
|
|
14
|
+
|
|
13
15
|
declare const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
14
|
-
declare const DEFAULT_VERSION = GpVersion.
|
|
16
|
+
declare const DEFAULT_VERSION = GpVersion.V0_7_2;
|
|
15
17
|
declare let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
|
|
16
18
|
declare let CURRENT_SUITE = parseCurrentSuite(env.TEST_SUITE) ?? DEFAULT_SUITE;
|
|
17
19
|
|
|
18
|
-
declare const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1, GpVersion.V0_7_2];
|
|
19
|
-
|
|
20
20
|
declare function parseCurrentVersion(env?: string): GpVersion | undefined {
|
|
21
21
|
if (env === undefined) {
|
|
22
22
|
return undefined;
|
|
23
23
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
);
|
|
24
|
+
for (const v of Object.values(GpVersion)) {
|
|
25
|
+
if (env === v) {
|
|
26
|
+
return v;
|
|
27
|
+
}
|
|
34
28
|
}
|
|
29
|
+
throw new Error(
|
|
30
|
+
`Configured environment variable GP_VERSION is unknown: '${env}'. Use one of: ${ALL_VERSIONS_IN_ORDER}`,
|
|
31
|
+
);
|
|
35
32
|
}
|
|
36
33
|
|
|
37
34
|
declare function parseCurrentSuite(env?: string): TestSuite | undefined {
|
|
38
35
|
if (env === undefined) {
|
|
39
36
|
return undefined;
|
|
40
37
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
default:
|
|
46
|
-
throw new Error(
|
|
47
|
-
`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`,
|
|
48
|
-
);
|
|
38
|
+
for (const s of Object.values(TestSuite)) {
|
|
39
|
+
if (env === s) {
|
|
40
|
+
return s;
|
|
41
|
+
}
|
|
49
42
|
}
|
|
43
|
+
throw new Error(
|
|
44
|
+
`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`,
|
|
45
|
+
);
|
|
50
46
|
}
|
|
51
47
|
|
|
52
48
|
declare class Compatibility {
|
|
@@ -242,6 +238,14 @@ declare abstract class WithDebug {
|
|
|
242
238
|
}
|
|
243
239
|
}
|
|
244
240
|
|
|
241
|
+
declare function lazyInspect<T>(obj: T) {
|
|
242
|
+
return {
|
|
243
|
+
toString() {
|
|
244
|
+
return inspect(obj);
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
245
249
|
/**
|
|
246
250
|
* The function will produce relative path resolver that is adjusted
|
|
247
251
|
* for package location within the workspace.
|
|
@@ -769,6 +773,7 @@ declare const index$u_inspect: typeof inspect;
|
|
|
769
773
|
declare const index$u_isBrowser: typeof isBrowser;
|
|
770
774
|
declare const index$u_isResult: typeof isResult;
|
|
771
775
|
declare const index$u_isTaggedError: typeof isTaggedError;
|
|
776
|
+
declare const index$u_lazyInspect: typeof lazyInspect;
|
|
772
777
|
declare const index$u_maybeTaggedErrorToString: typeof maybeTaggedErrorToString;
|
|
773
778
|
declare const index$u_measure: typeof measure;
|
|
774
779
|
declare const index$u_oomWarningPrinted: typeof oomWarningPrinted;
|
|
@@ -780,7 +785,7 @@ declare const index$u_seeThrough: typeof seeThrough;
|
|
|
780
785
|
declare const index$u_trimStack: typeof trimStack;
|
|
781
786
|
declare const index$u_workspacePathFix: typeof workspacePathFix;
|
|
782
787
|
declare namespace index$u {
|
|
783
|
-
export { index$u_ALL_VERSIONS_IN_ORDER as ALL_VERSIONS_IN_ORDER, index$u_CURRENT_SUITE as CURRENT_SUITE, index$u_CURRENT_VERSION as CURRENT_VERSION, index$u_Compatibility as Compatibility, index$u_DEFAULT_SUITE as DEFAULT_SUITE, index$u_DEFAULT_VERSION as DEFAULT_VERSION, index$u_ErrorsCollector as ErrorsCollector, index$u_GpVersion as GpVersion, MAX_LENGTH$1 as MAX_LENGTH, Result$2 as Result, index$u_RichTaggedError as RichTaggedError, index$u_TEST_COMPARE_USING as TEST_COMPARE_USING, index$u_TestSuite as TestSuite, index$u_WithDebug as WithDebug, index$u___OPAQUE_TYPE__ as __OPAQUE_TYPE__, index$u_asOpaqueType as asOpaqueType, index$u_assertEmpty as assertEmpty, index$u_assertNever as assertNever, index$u_callCompareFunction as callCompareFunction, index$u_check as check, index$u_deepEqual as deepEqual, index$u_getAllKeysSorted as getAllKeysSorted, index$u_inspect as inspect, index$u_isBrowser as isBrowser, index$u_isResult as isResult, index$u_isTaggedError as isTaggedError, index$u_maybeTaggedErrorToString as maybeTaggedErrorToString, index$u_measure as measure, index$u_oomWarningPrinted as oomWarningPrinted, index$u_parseCurrentSuite as parseCurrentSuite, index$u_parseCurrentVersion as parseCurrentVersion, index$u_resultToString as resultToString, index$u_safeAllocUint8Array as safeAllocUint8Array, index$u_seeThrough as seeThrough, index$u_trimStack as trimStack, index$u_workspacePathFix as workspacePathFix };
|
|
788
|
+
export { index$u_ALL_VERSIONS_IN_ORDER as ALL_VERSIONS_IN_ORDER, index$u_CURRENT_SUITE as CURRENT_SUITE, index$u_CURRENT_VERSION as CURRENT_VERSION, index$u_Compatibility as Compatibility, index$u_DEFAULT_SUITE as DEFAULT_SUITE, index$u_DEFAULT_VERSION as DEFAULT_VERSION, index$u_ErrorsCollector as ErrorsCollector, index$u_GpVersion as GpVersion, MAX_LENGTH$1 as MAX_LENGTH, Result$2 as Result, index$u_RichTaggedError as RichTaggedError, index$u_TEST_COMPARE_USING as TEST_COMPARE_USING, index$u_TestSuite as TestSuite, index$u_WithDebug as WithDebug, index$u___OPAQUE_TYPE__ as __OPAQUE_TYPE__, index$u_asOpaqueType as asOpaqueType, index$u_assertEmpty as assertEmpty, index$u_assertNever as assertNever, index$u_callCompareFunction as callCompareFunction, index$u_check as check, index$u_deepEqual as deepEqual, index$u_getAllKeysSorted as getAllKeysSorted, index$u_inspect as inspect, index$u_isBrowser as isBrowser, index$u_isResult as isResult, index$u_isTaggedError as isTaggedError, index$u_lazyInspect as lazyInspect, index$u_maybeTaggedErrorToString as maybeTaggedErrorToString, index$u_measure as measure, index$u_oomWarningPrinted as oomWarningPrinted, index$u_parseCurrentSuite as parseCurrentSuite, index$u_parseCurrentVersion as parseCurrentVersion, index$u_resultToString as resultToString, index$u_safeAllocUint8Array as safeAllocUint8Array, index$u_seeThrough as seeThrough, index$u_trimStack as trimStack, index$u_workspacePathFix as workspacePathFix };
|
|
784
789
|
export type { index$u_DeepEqualOptions as DeepEqualOptions, index$u_EnumMapping as EnumMapping, index$u_ErrorResult as ErrorResult, index$u_OK as OK, index$u_OkResult as OkResult, index$u_Opaque as Opaque, index$u_StringLiteral as StringLiteral, index$u_TaggedError as TaggedError, index$u_TokenOf as TokenOf, index$u_Uninstantiable as Uninstantiable, index$u_WithOpaque as WithOpaque };
|
|
785
790
|
}
|
|
786
791
|
|
|
@@ -8168,7 +8173,7 @@ declare const DEFAULT_CONFIG = "default";
|
|
|
8168
8173
|
|
|
8169
8174
|
declare const NODE_DEFAULTS = {
|
|
8170
8175
|
name: isBrowser() ? "browser" : os.hostname(),
|
|
8171
|
-
config: DEFAULT_CONFIG,
|
|
8176
|
+
config: [DEFAULT_CONFIG],
|
|
8172
8177
|
pvm: PvmBackend.BuiltIn,
|
|
8173
8178
|
};
|
|
8174
8179
|
|
|
@@ -8222,52 +8227,173 @@ declare class NodeConfiguration {
|
|
|
8222
8227
|
) {}
|
|
8223
8228
|
}
|
|
8224
8229
|
|
|
8225
|
-
declare function loadConfig(
|
|
8226
|
-
|
|
8227
|
-
|
|
8228
|
-
|
|
8229
|
-
|
|
8230
|
+
declare function loadConfig(config: string[], withRelPath: (p: string) => string): NodeConfiguration {
|
|
8231
|
+
logger.log`🔧 Loading config`;
|
|
8232
|
+
let mergedJson: AnyJsonObject = {};
|
|
8233
|
+
|
|
8234
|
+
for (const entry of config) {
|
|
8235
|
+
logger.log`🔧 Applying '${entry}'`;
|
|
8236
|
+
|
|
8237
|
+
if (entry === DEV_CONFIG) {
|
|
8238
|
+
mergedJson = structuredClone(configs.dev); // clone to avoid mutating the original config. not doing a merge since dev and default should theoretically replace all properties.
|
|
8239
|
+
continue;
|
|
8240
|
+
}
|
|
8230
8241
|
|
|
8231
|
-
|
|
8232
|
-
|
|
8233
|
-
|
|
8242
|
+
if (entry === DEFAULT_CONFIG) {
|
|
8243
|
+
mergedJson = structuredClone(configs.default);
|
|
8244
|
+
continue;
|
|
8245
|
+
}
|
|
8246
|
+
|
|
8247
|
+
// try to parse as JSON
|
|
8248
|
+
try {
|
|
8249
|
+
const parsed = JSON.parse(entry);
|
|
8250
|
+
deepMerge(mergedJson, parsed);
|
|
8251
|
+
continue;
|
|
8252
|
+
} catch {}
|
|
8253
|
+
|
|
8254
|
+
// if not, try to load as file
|
|
8255
|
+
if (entry.indexOf("=") === -1 && entry.endsWith(".json")) {
|
|
8256
|
+
try {
|
|
8257
|
+
const configFile = fs.readFileSync(withRelPath(entry), "utf8");
|
|
8258
|
+
const parsed = JSON.parse(configFile);
|
|
8259
|
+
deepMerge(mergedJson, parsed);
|
|
8260
|
+
} catch (e) {
|
|
8261
|
+
throw new Error(`Unable to load config from ${entry}: ${e}`);
|
|
8262
|
+
}
|
|
8263
|
+
} else {
|
|
8264
|
+
// finally try to process as a pseudo-jq query
|
|
8265
|
+
try {
|
|
8266
|
+
processQuery(mergedJson, entry, withRelPath);
|
|
8267
|
+
} catch (e) {
|
|
8268
|
+
throw new Error(`Error while processing '${entry}': ${e}`);
|
|
8269
|
+
}
|
|
8270
|
+
}
|
|
8234
8271
|
}
|
|
8235
8272
|
|
|
8236
8273
|
try {
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
|
|
8240
|
-
return parseFromJson(parsed, NodeConfiguration.fromJson);
|
|
8274
|
+
const parsed = parseFromJson(mergedJson, NodeConfiguration.fromJson);
|
|
8275
|
+
logger.log`🔧 Config ready`;
|
|
8276
|
+
return parsed;
|
|
8241
8277
|
} catch (e) {
|
|
8242
|
-
throw new Error(`Unable to
|
|
8278
|
+
throw new Error(`Unable to parse config: ${e}`);
|
|
8243
8279
|
}
|
|
8244
8280
|
}
|
|
8245
8281
|
|
|
8282
|
+
declare function deepMerge(target: AnyJsonObject, source: JsonValue): void {
|
|
8283
|
+
if (!isJsonObject(source)) {
|
|
8284
|
+
throw new Error(`Expected object, got ${source}`);
|
|
8285
|
+
}
|
|
8286
|
+
for (const key in source) {
|
|
8287
|
+
if (isJsonObject(source[key])) {
|
|
8288
|
+
if (!isJsonObject(target[key])) {
|
|
8289
|
+
target[key] = {};
|
|
8290
|
+
}
|
|
8291
|
+
deepMerge(target[key], source[key]);
|
|
8292
|
+
} else {
|
|
8293
|
+
target[key] = source[key];
|
|
8294
|
+
}
|
|
8295
|
+
}
|
|
8296
|
+
}
|
|
8297
|
+
|
|
8298
|
+
/**
|
|
8299
|
+
* Caution: updates input directly.
|
|
8300
|
+
* Processes a pseudo-jq query. Syntax:
|
|
8301
|
+
* .path.to.value = { ... } - updates value with the specified object by replacement
|
|
8302
|
+
* .path.to.value += { ... } - updates value with the specified object by merging
|
|
8303
|
+
* .path.to.value = file.json - updates value with the contents of file.json
|
|
8304
|
+
* .path.to.value += file.json - merges the contents of file.json onto value
|
|
8305
|
+
*/
|
|
8306
|
+
declare function processQuery(input: AnyJsonObject, query: string, withRelPath: (p: string) => string): void {
|
|
8307
|
+
const queryParts = query.split("=");
|
|
8308
|
+
|
|
8309
|
+
if (queryParts.length === 2) {
|
|
8310
|
+
let [path, value] = queryParts.map((part) => part.trim());
|
|
8311
|
+
let merge = false;
|
|
8312
|
+
|
|
8313
|
+
// detect += syntax
|
|
8314
|
+
if (path.endsWith("+")) {
|
|
8315
|
+
merge = true;
|
|
8316
|
+
path = path.slice(0, -1);
|
|
8317
|
+
}
|
|
8318
|
+
|
|
8319
|
+
let parsedValue: JsonValue;
|
|
8320
|
+
if (value.endsWith(".json")) {
|
|
8321
|
+
try {
|
|
8322
|
+
const configFile = fs.readFileSync(withRelPath(value), "utf8");
|
|
8323
|
+
const parsed = JSON.parse(configFile);
|
|
8324
|
+
parsedValue = parsed;
|
|
8325
|
+
} catch (e) {
|
|
8326
|
+
throw new Error(`Unable to load config from ${value}: ${e}`);
|
|
8327
|
+
}
|
|
8328
|
+
} else {
|
|
8329
|
+
try {
|
|
8330
|
+
parsedValue = JSON.parse(value);
|
|
8331
|
+
} catch (e) {
|
|
8332
|
+
throw new Error(`Unrecognized syntax '${value}': ${e}`);
|
|
8333
|
+
}
|
|
8334
|
+
}
|
|
8335
|
+
|
|
8336
|
+
let pathParts = path.split(".");
|
|
8337
|
+
|
|
8338
|
+
// allow leading dot in path
|
|
8339
|
+
if (pathParts[0] === "") {
|
|
8340
|
+
pathParts = pathParts.slice(1);
|
|
8341
|
+
}
|
|
8342
|
+
|
|
8343
|
+
let target = input;
|
|
8344
|
+
for (let i = 0; i < pathParts.length; i++) {
|
|
8345
|
+
const part = pathParts[i];
|
|
8346
|
+
if (!isJsonObject(target[part])) {
|
|
8347
|
+
target[part] = {};
|
|
8348
|
+
}
|
|
8349
|
+
if (i === pathParts.length - 1) {
|
|
8350
|
+
if (merge) {
|
|
8351
|
+
deepMerge(target[part], parsedValue);
|
|
8352
|
+
} else {
|
|
8353
|
+
target[part] = parsedValue;
|
|
8354
|
+
}
|
|
8355
|
+
return;
|
|
8356
|
+
}
|
|
8357
|
+
target = target[part];
|
|
8358
|
+
}
|
|
8359
|
+
}
|
|
8360
|
+
|
|
8361
|
+
throw new Error("Unrecognized syntax.");
|
|
8362
|
+
}
|
|
8363
|
+
|
|
8364
|
+
type JsonValue = string | number | boolean | null | AnyJsonObject | JsonArray;
|
|
8365
|
+
|
|
8366
|
+
interface AnyJsonObject {
|
|
8367
|
+
[key: string]: JsonValue;
|
|
8368
|
+
}
|
|
8369
|
+
|
|
8370
|
+
interface JsonArray extends Array<JsonValue> {}
|
|
8371
|
+
|
|
8372
|
+
declare function isJsonObject(value: JsonValue): value is AnyJsonObject {
|
|
8373
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8374
|
+
}
|
|
8375
|
+
|
|
8376
|
+
type index$h_AnyJsonObject = AnyJsonObject;
|
|
8246
8377
|
declare const index$h_DEFAULT_CONFIG: typeof DEFAULT_CONFIG;
|
|
8247
8378
|
declare const index$h_DEV_CONFIG: typeof DEV_CONFIG;
|
|
8248
8379
|
type index$h_JipChainSpec = JipChainSpec;
|
|
8249
8380
|
declare const index$h_JipChainSpec: typeof JipChainSpec;
|
|
8381
|
+
type index$h_JsonArray = JsonArray;
|
|
8382
|
+
type index$h_JsonValue = JsonValue;
|
|
8250
8383
|
type index$h_KnownChainSpec = KnownChainSpec;
|
|
8251
8384
|
declare const index$h_KnownChainSpec: typeof KnownChainSpec;
|
|
8252
8385
|
declare const index$h_NODE_DEFAULTS: typeof NODE_DEFAULTS;
|
|
8253
8386
|
type index$h_NodeConfiguration = NodeConfiguration;
|
|
8254
8387
|
declare const index$h_NodeConfiguration: typeof NodeConfiguration;
|
|
8388
|
+
declare const index$h_deepMerge: typeof deepMerge;
|
|
8389
|
+
declare const index$h_isJsonObject: typeof isJsonObject;
|
|
8255
8390
|
declare const index$h_knownChainSpecFromJson: typeof knownChainSpecFromJson;
|
|
8256
8391
|
declare const index$h_loadConfig: typeof loadConfig;
|
|
8257
8392
|
declare const index$h_parseBootnode: typeof parseBootnode;
|
|
8393
|
+
declare const index$h_processQuery: typeof processQuery;
|
|
8258
8394
|
declare namespace index$h {
|
|
8259
|
-
export {
|
|
8260
|
-
|
|
8261
|
-
index$h_DEV_CONFIG as DEV_CONFIG,
|
|
8262
|
-
index$h_JipChainSpec as JipChainSpec,
|
|
8263
|
-
index$h_KnownChainSpec as KnownChainSpec,
|
|
8264
|
-
index$h_NODE_DEFAULTS as NODE_DEFAULTS,
|
|
8265
|
-
index$h_NodeConfiguration as NodeConfiguration,
|
|
8266
|
-
index$h_knownChainSpecFromJson as knownChainSpecFromJson,
|
|
8267
|
-
index$h_loadConfig as loadConfig,
|
|
8268
|
-
logger$2 as logger,
|
|
8269
|
-
index$h_parseBootnode as parseBootnode,
|
|
8270
|
-
};
|
|
8395
|
+
export { index$h_DEFAULT_CONFIG as DEFAULT_CONFIG, index$h_DEV_CONFIG as DEV_CONFIG, index$h_JipChainSpec as JipChainSpec, index$h_KnownChainSpec as KnownChainSpec, index$h_NODE_DEFAULTS as NODE_DEFAULTS, index$h_NodeConfiguration as NodeConfiguration, index$h_deepMerge as deepMerge, index$h_isJsonObject as isJsonObject, index$h_knownChainSpecFromJson as knownChainSpecFromJson, index$h_loadConfig as loadConfig, logger$2 as logger, index$h_parseBootnode as parseBootnode, index$h_processQuery as processQuery };
|
|
8396
|
+
export type { index$h_AnyJsonObject as AnyJsonObject, index$h_JsonArray as JsonArray, index$h_JsonValue as JsonValue };
|
|
8271
8397
|
}
|
|
8272
8398
|
|
|
8273
8399
|
/**
|
|
@@ -9992,25 +10118,6 @@ declare class LookupHistoryItem {
|
|
|
9992
10118
|
}
|
|
9993
10119
|
}
|
|
9994
10120
|
|
|
9995
|
-
/** Dictionary entry of services that auto-accumulate every block. */
|
|
9996
|
-
declare class AutoAccumulate {
|
|
9997
|
-
static Codec = codec.Class(AutoAccumulate, {
|
|
9998
|
-
service: codec.u32.asOpaque<ServiceId>(),
|
|
9999
|
-
gasLimit: codec.u64.asOpaque<ServiceGas>(),
|
|
10000
|
-
});
|
|
10001
|
-
|
|
10002
|
-
static create({ service, gasLimit }: CodecRecord<AutoAccumulate>) {
|
|
10003
|
-
return new AutoAccumulate(service, gasLimit);
|
|
10004
|
-
}
|
|
10005
|
-
|
|
10006
|
-
private constructor(
|
|
10007
|
-
/** Service id that auto-accumulates. */
|
|
10008
|
-
readonly service: ServiceId,
|
|
10009
|
-
/** Gas limit for auto-accumulation. */
|
|
10010
|
-
readonly gasLimit: ServiceGas,
|
|
10011
|
-
) {}
|
|
10012
|
-
}
|
|
10013
|
-
|
|
10014
10121
|
/**
|
|
10015
10122
|
* https://graypaper.fluffylabs.dev/#/ab2cdbd/114402114402?v=0.7.2
|
|
10016
10123
|
*/
|
|
@@ -10023,7 +10130,9 @@ declare class PrivilegedServices {
|
|
|
10023
10130
|
registrar: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
|
|
10024
10131
|
? codec.u32.asOpaque<ServiceId>()
|
|
10025
10132
|
: ignoreValueWithDefault(tryAsServiceId(2 ** 32 - 1)),
|
|
10026
|
-
autoAccumulateServices:
|
|
10133
|
+
autoAccumulateServices: codec.dictionary(codec.u32.asOpaque<ServiceId>(), codec.u64.asOpaque<ServiceGas>(), {
|
|
10134
|
+
sortKeys: (a, b) => a - b,
|
|
10135
|
+
}),
|
|
10027
10136
|
});
|
|
10028
10137
|
|
|
10029
10138
|
static create(a: CodecRecord<PrivilegedServices>) {
|
|
@@ -10048,7 +10157,7 @@ declare class PrivilegedServices {
|
|
|
10048
10157
|
/** `χ_A`: Manages authorization queue one for each core. */
|
|
10049
10158
|
readonly assigners: PerCore<ServiceId>,
|
|
10050
10159
|
/** `χ_Z`: Dictionary of services that auto-accumulate every block with their gas limit. */
|
|
10051
|
-
readonly autoAccumulateServices:
|
|
10160
|
+
readonly autoAccumulateServices: Map<ServiceId, ServiceGas>,
|
|
10052
10161
|
) {}
|
|
10053
10162
|
}
|
|
10054
10163
|
|
|
@@ -11365,7 +11474,7 @@ declare class InMemoryState extends WithDebug implements State, WithStateView, E
|
|
|
11365
11474
|
assigners: tryAsPerCore(new Array(spec.coresCount).fill(tryAsServiceId(0)), spec),
|
|
11366
11475
|
delegator: tryAsServiceId(0),
|
|
11367
11476
|
registrar: tryAsServiceId(MAX_VALUE),
|
|
11368
|
-
autoAccumulateServices:
|
|
11477
|
+
autoAccumulateServices: new Map(),
|
|
11369
11478
|
}),
|
|
11370
11479
|
accumulationOutputLog: SortedArray.fromArray(accumulationOutputComparator, []),
|
|
11371
11480
|
services: new Map(),
|
|
@@ -11421,8 +11530,6 @@ type index$e_AccumulationQueue = AccumulationQueue;
|
|
|
11421
11530
|
type index$e_AccumulationQueueView = AccumulationQueueView;
|
|
11422
11531
|
type index$e_AuthorizationPool = AuthorizationPool;
|
|
11423
11532
|
type index$e_AuthorizationQueue = AuthorizationQueue;
|
|
11424
|
-
type index$e_AutoAccumulate = AutoAccumulate;
|
|
11425
|
-
declare const index$e_AutoAccumulate: typeof AutoAccumulate;
|
|
11426
11533
|
type index$e_AvailabilityAssignment = AvailabilityAssignment;
|
|
11427
11534
|
declare const index$e_AvailabilityAssignment: typeof AvailabilityAssignment;
|
|
11428
11535
|
type index$e_AvailabilityAssignmentsView = AvailabilityAssignmentsView;
|
|
@@ -11531,7 +11638,7 @@ declare const index$e_validatorsDataCodec: typeof validatorsDataCodec;
|
|
|
11531
11638
|
declare const index$e_workReportsSortedSetCodec: typeof workReportsSortedSetCodec;
|
|
11532
11639
|
declare const index$e_zeroSizeHint: typeof zeroSizeHint;
|
|
11533
11640
|
declare namespace index$e {
|
|
11534
|
-
export { index$e_AccumulationOutput as AccumulationOutput, index$
|
|
11641
|
+
export { index$e_AccumulationOutput as AccumulationOutput, index$e_AvailabilityAssignment as AvailabilityAssignment, index$e_BASE_SERVICE_BALANCE as BASE_SERVICE_BALANCE, index$e_BlockState as BlockState, index$e_CoreStatistics as CoreStatistics, index$e_DisputesRecords as DisputesRecords, index$e_ELECTIVE_BYTE_BALANCE as ELECTIVE_BYTE_BALANCE, index$e_ELECTIVE_ITEM_BALANCE as ELECTIVE_ITEM_BALANCE, index$e_InMemoryService as InMemoryService, index$e_InMemoryState as InMemoryState, index$e_LookupHistoryItem as LookupHistoryItem, index$e_MAX_LOOKUP_HISTORY_SLOTS as MAX_LOOKUP_HISTORY_SLOTS, index$e_NotYetAccumulatedReport as NotYetAccumulatedReport, index$e_PreimageItem as PreimageItem, index$e_PrivilegedServices as PrivilegedServices, index$e_RecentBlocks as RecentBlocks, index$e_SafroleData as SafroleData, index$e_SafroleSealingKeysData as SafroleSealingKeysData, index$e_SafroleSealingKeysKind as SafroleSealingKeysKind, index$e_ServiceAccountInfo as ServiceAccountInfo, index$e_ServiceStatistics as ServiceStatistics, index$e_StatisticsData as StatisticsData, index$e_StorageItem as StorageItem, index$e_UpdateError as UpdateError, index$e_UpdatePreimage as UpdatePreimage, index$e_UpdatePreimageKind as UpdatePreimageKind, index$e_UpdateService as UpdateService, index$e_UpdateServiceKind as UpdateServiceKind, index$e_UpdateStorage as UpdateStorage, index$e_UpdateStorageKind as UpdateStorageKind, index$e_ValidatorData as ValidatorData, index$e_ValidatorStatistics as ValidatorStatistics, index$e_accumulationOutputComparator as accumulationOutputComparator, index$e_accumulationQueueCodec as accumulationQueueCodec, index$e_authPoolsCodec as authPoolsCodec, index$e_authQueuesCodec as authQueuesCodec, index$e_availabilityAssignmentsCodec as availabilityAssignmentsCodec, index$e_codecBandersnatchKey as codecBandersnatchKey, index$e_codecPerCore as codecPerCore, index$e_codecServiceId as codecServiceId, index$e_codecVarGas as codecVarGas, index$e_codecVarU16 as codecVarU16, index$e_codecWithVersion as codecWithVersion, index$e_hashComparator as hashComparator, index$e_ignoreValueWithDefault as ignoreValueWithDefault, index$e_recentlyAccumulatedCodec as recentlyAccumulatedCodec, index$e_serviceDataCodec as serviceDataCodec, index$e_serviceEntriesCodec as serviceEntriesCodec, index$e_sortedSetCodec as sortedSetCodec, index$e_tryAsLookupHistorySlots as tryAsLookupHistorySlots, index$e_tryAsPerCore as tryAsPerCore, index$e_validatorsDataCodec as validatorsDataCodec, index$e_workReportsSortedSetCodec as workReportsSortedSetCodec, index$e_zeroSizeHint as zeroSizeHint };
|
|
11535
11642
|
export type { index$e_AUTHORIZATION_QUEUE_SIZE as AUTHORIZATION_QUEUE_SIZE, index$e_AccumulationQueue as AccumulationQueue, index$e_AccumulationQueueView as AccumulationQueueView, index$e_AuthorizationPool as AuthorizationPool, index$e_AuthorizationQueue as AuthorizationQueue, index$e_AvailabilityAssignmentsView as AvailabilityAssignmentsView, index$e_BlocksState as BlocksState, index$e_ENTROPY_ENTRIES as ENTROPY_ENTRIES, index$e_EnumerableState as EnumerableState, index$e_FieldNames as FieldNames, index$e_InMemoryStateFields as InMemoryStateFields, index$e_LookupHistorySlots as LookupHistorySlots, index$e_MAX_AUTH_POOL_SIZE as MAX_AUTH_POOL_SIZE, index$e_MAX_RECENT_HISTORY as MAX_RECENT_HISTORY, index$e_PerCore as PerCore, index$e_RecentBlocksView as RecentBlocksView, index$e_RecentlyAccumulated as RecentlyAccumulated, index$e_RecentlyAccumulatedView as RecentlyAccumulatedView, index$e_SafroleDataView as SafroleDataView, index$e_SafroleSealingKeys as SafroleSealingKeys, index$e_Service as Service, index$e_ServiceAccountInfoView as ServiceAccountInfoView, index$e_ServiceData as ServiceData, index$e_ServiceEntries as ServiceEntries, index$e_ServicesUpdate as ServicesUpdate, index$e_State as State, index$e_StateView as StateView, index$e_StatisticsDataView as StatisticsDataView, index$e_StorageKey as StorageKey, index$e_VALIDATOR_META_BYTES as VALIDATOR_META_BYTES, index$e_ValidatorDataView as ValidatorDataView, index$e_WithStateView as WithStateView };
|
|
11536
11643
|
}
|
|
11537
11644
|
|
|
@@ -14307,7 +14414,7 @@ interface PartialState {
|
|
|
14307
14414
|
a: PerCore<ServiceId>,
|
|
14308
14415
|
v: ServiceId | null,
|
|
14309
14416
|
r: ServiceId | null,
|
|
14310
|
-
z:
|
|
14417
|
+
z: Map<ServiceId, ServiceGas>,
|
|
14311
14418
|
): Result$2<OK, UpdatePrivilegesError>;
|
|
14312
14419
|
|
|
14313
14420
|
/** Yield accumulation trie result hash. */
|
|
@@ -19541,6 +19648,7 @@ declare const index$3_inspect: typeof inspect;
|
|
|
19541
19648
|
declare const index$3_instructionArgumentTypeMap: typeof instructionArgumentTypeMap;
|
|
19542
19649
|
declare const index$3_isBrowser: typeof isBrowser;
|
|
19543
19650
|
declare const index$3_isTaggedError: typeof isTaggedError;
|
|
19651
|
+
declare const index$3_lazyInspect: typeof lazyInspect;
|
|
19544
19652
|
declare const index$3_maybeTaggedErrorToString: typeof maybeTaggedErrorToString;
|
|
19545
19653
|
declare const index$3_measure: typeof measure;
|
|
19546
19654
|
declare const index$3_preimageLenAsU32: typeof preimageLenAsU32;
|
|
@@ -19552,7 +19660,7 @@ declare const index$3_tryAsMachineId: typeof tryAsMachineId;
|
|
|
19552
19660
|
declare const index$3_tryAsProgramCounter: typeof tryAsProgramCounter;
|
|
19553
19661
|
declare const index$3_writeServiceIdAsLeBytes: typeof writeServiceIdAsLeBytes;
|
|
19554
19662
|
declare namespace index$3 {
|
|
19555
|
-
export { index$3_AccumulationStateUpdate as AccumulationStateUpdate, index$3_ArgsDecoder as ArgsDecoder, index$3_ArgumentType as ArgumentType, index$3_BasicBlocks as BasicBlocks, index$3_CURRENT_SERVICE_ID as CURRENT_SERVICE_ID, index$3_EjectError as EjectError, index$3_ExtendedWitdthImmediateDecoder as ExtendedWitdthImmediateDecoder, index$3_ForgetPreimageError as ForgetPreimageError, index$3_HostCallMemory as HostCallMemory, index$3_HostCallRegisters as HostCallRegisters, index$3_HostCallResult as HostCallResult, index$3_ImmediateDecoder as ImmediateDecoder, index$3_MAX_U32 as MAX_U32, index$3_MAX_U32_BIG_INT as MAX_U32_BIG_INT, index$3_MachineInstance as MachineInstance, index$3_Mask as Mask, index$3_MemoryOperation as MemoryOperation, index$3_MemorySegment as MemorySegment, NO_OF_REGISTERS$1 as NO_OF_REGISTERS, index$3_NewServiceError as NewServiceError, index$3_NibblesDecoder as NibblesDecoder, index$3_PagesError as PagesError, index$3_PartiallyUpdatedState as PartiallyUpdatedState, index$3_PeekPokeError as PeekPokeError, index$3_PendingTransfer as PendingTransfer, index$3_PreimageStatusKind as PreimageStatusKind, index$3_Program as Program, index$3_ProgramDecoder as ProgramDecoder, index$3_ProvidePreimageError as ProvidePreimageError, DebuggerAdapter as Pvm, index$3_Registers as Registers, index$3_RequestPreimageError as RequestPreimageError, Result$2 as Result, index$3_RichTaggedError as RichTaggedError, index$3_SERVICE_ID_BYTES as SERVICE_ID_BYTES, index$3_SpiMemory as SpiMemory, index$3_SpiProgram as SpiProgram, index$3_TransferError as TransferError, index$3_UpdatePrivilegesError as UpdatePrivilegesError, index$3_WithDebug as WithDebug, index$3_ZeroVoidError as ZeroVoidError, index$3___OPAQUE_TYPE__ as __OPAQUE_TYPE__, index$3_asOpaqueType as asOpaqueType, index$3_assertEmpty as assertEmpty, index$3_assertNever as assertNever, index$l as block, index$s as bytes, index$3_check as check, index$3_clampU64ToU32 as clampU64ToU32, index$3_createResults as createResults, index$3_decodeStandardProgram as decodeStandardProgram, index$3_deepCloneMapWithArray as deepCloneMapWithArray, index$3_emptyRegistersBuffer as emptyRegistersBuffer, index$3_extractCodeAndMetadata as extractCodeAndMetadata, index$3_getServiceId as getServiceId, index$3_getServiceIdOrCurrent as getServiceIdOrCurrent, index$p as hash, index$3_inspect as inspect, index$3_instructionArgumentTypeMap as instructionArgumentTypeMap, index$6 as interpreter, index$3_isBrowser as isBrowser, index$3_isTaggedError as isTaggedError, index$3_maybeTaggedErrorToString as maybeTaggedErrorToString, index$3_measure as measure, index$r as numbers, index$3_preimageLenAsU32 as preimageLenAsU32, index$3_resultToString as resultToString, index$3_seeThrough as seeThrough, index$3_slotsToPreimageStatus as slotsToPreimageStatus, index$3_toMemoryOperation as toMemoryOperation, index$3_tryAsMachineId as tryAsMachineId, index$3_tryAsProgramCounter as tryAsProgramCounter, index$3_writeServiceIdAsLeBytes as writeServiceIdAsLeBytes };
|
|
19663
|
+
export { index$3_AccumulationStateUpdate as AccumulationStateUpdate, index$3_ArgsDecoder as ArgsDecoder, index$3_ArgumentType as ArgumentType, index$3_BasicBlocks as BasicBlocks, index$3_CURRENT_SERVICE_ID as CURRENT_SERVICE_ID, index$3_EjectError as EjectError, index$3_ExtendedWitdthImmediateDecoder as ExtendedWitdthImmediateDecoder, index$3_ForgetPreimageError as ForgetPreimageError, index$3_HostCallMemory as HostCallMemory, index$3_HostCallRegisters as HostCallRegisters, index$3_HostCallResult as HostCallResult, index$3_ImmediateDecoder as ImmediateDecoder, index$3_MAX_U32 as MAX_U32, index$3_MAX_U32_BIG_INT as MAX_U32_BIG_INT, index$3_MachineInstance as MachineInstance, index$3_Mask as Mask, index$3_MemoryOperation as MemoryOperation, index$3_MemorySegment as MemorySegment, NO_OF_REGISTERS$1 as NO_OF_REGISTERS, index$3_NewServiceError as NewServiceError, index$3_NibblesDecoder as NibblesDecoder, index$3_PagesError as PagesError, index$3_PartiallyUpdatedState as PartiallyUpdatedState, index$3_PeekPokeError as PeekPokeError, index$3_PendingTransfer as PendingTransfer, index$3_PreimageStatusKind as PreimageStatusKind, index$3_Program as Program, index$3_ProgramDecoder as ProgramDecoder, index$3_ProvidePreimageError as ProvidePreimageError, DebuggerAdapter as Pvm, index$3_Registers as Registers, index$3_RequestPreimageError as RequestPreimageError, Result$2 as Result, index$3_RichTaggedError as RichTaggedError, index$3_SERVICE_ID_BYTES as SERVICE_ID_BYTES, index$3_SpiMemory as SpiMemory, index$3_SpiProgram as SpiProgram, index$3_TransferError as TransferError, index$3_UpdatePrivilegesError as UpdatePrivilegesError, index$3_WithDebug as WithDebug, index$3_ZeroVoidError as ZeroVoidError, index$3___OPAQUE_TYPE__ as __OPAQUE_TYPE__, index$3_asOpaqueType as asOpaqueType, index$3_assertEmpty as assertEmpty, index$3_assertNever as assertNever, index$l as block, index$s as bytes, index$3_check as check, index$3_clampU64ToU32 as clampU64ToU32, index$3_createResults as createResults, index$3_decodeStandardProgram as decodeStandardProgram, index$3_deepCloneMapWithArray as deepCloneMapWithArray, index$3_emptyRegistersBuffer as emptyRegistersBuffer, index$3_extractCodeAndMetadata as extractCodeAndMetadata, index$3_getServiceId as getServiceId, index$3_getServiceIdOrCurrent as getServiceIdOrCurrent, index$p as hash, index$3_inspect as inspect, index$3_instructionArgumentTypeMap as instructionArgumentTypeMap, index$6 as interpreter, index$3_isBrowser as isBrowser, index$3_isTaggedError as isTaggedError, index$3_lazyInspect as lazyInspect, index$3_maybeTaggedErrorToString as maybeTaggedErrorToString, index$3_measure as measure, index$r as numbers, index$3_preimageLenAsU32 as preimageLenAsU32, index$3_resultToString as resultToString, index$3_seeThrough as seeThrough, index$3_slotsToPreimageStatus as slotsToPreimageStatus, index$3_toMemoryOperation as toMemoryOperation, index$3_tryAsMachineId as tryAsMachineId, index$3_tryAsProgramCounter as tryAsProgramCounter, index$3_writeServiceIdAsLeBytes as writeServiceIdAsLeBytes };
|
|
19556
19664
|
export type { index$3_Args as Args, index$3_EnumMapping as EnumMapping, index$3_ErrorResult as ErrorResult, index$3_InsufficientFundsError as InsufficientFundsError, index$3_MachineId as MachineId, index$3_MachineResult as MachineResult, index$3_MachineStatus as MachineStatus, index$3_NoMachineError as NoMachineError, index$3_OK as OK, index$3_OkResult as OkResult, index$3_Opaque as Opaque, index$3_PartialState as PartialState, index$3_PreimageStatus as PreimageStatus, index$3_ProgramCounter as ProgramCounter, index$3_RefineExternalities as RefineExternalities, index$3_SegmentExportError as SegmentExportError, index$3_ServiceStateUpdate as ServiceStateUpdate, index$3_StateSlice as StateSlice, index$3_StringLiteral as StringLiteral, index$3_TRANSFER_MEMO_BYTES as TRANSFER_MEMO_BYTES, index$3_TaggedError as TaggedError, index$3_TokenOf as TokenOf, index$3_Uninstantiable as Uninstantiable, index$3_UnprivilegedError as UnprivilegedError, index$3_WithOpaque as WithOpaque };
|
|
19557
19665
|
}
|
|
19558
19666
|
|
|
@@ -20146,10 +20254,10 @@ declare const fullStateDumpFromJson = (spec: ChainSpec) =>
|
|
|
20146
20254
|
chi_v: "number",
|
|
20147
20255
|
chi_r: json.optional("number"),
|
|
20148
20256
|
chi_g: json.nullable(
|
|
20149
|
-
json.
|
|
20150
|
-
|
|
20151
|
-
|
|
20152
|
-
|
|
20257
|
+
json.map(
|
|
20258
|
+
"number",
|
|
20259
|
+
json.fromNumber((v) => tryAsServiceGas(v)),
|
|
20260
|
+
),
|
|
20153
20261
|
),
|
|
20154
20262
|
},
|
|
20155
20263
|
pi: JsonStatisticsData.fromJson,
|
|
@@ -20216,7 +20324,7 @@ declare const fullStateDumpFromJson = (spec: ChainSpec) =>
|
|
|
20216
20324
|
assigners: chi.chi_a,
|
|
20217
20325
|
delegator: chi.chi_v,
|
|
20218
20326
|
registrar: chi.chi_r ?? tryAsServiceId(2 ** 32 - 1),
|
|
20219
|
-
autoAccumulateServices: chi.chi_g ??
|
|
20327
|
+
autoAccumulateServices: chi.chi_g ?? new Map(),
|
|
20220
20328
|
}),
|
|
20221
20329
|
statistics: JsonStatisticsData.toStatisticsData(spec, pi),
|
|
20222
20330
|
accumulationQueue: omega,
|
package/index.js
CHANGED
|
@@ -8,44 +8,40 @@ var GpVersion;
|
|
|
8
8
|
GpVersion["V0_6_7"] = "0.6.7";
|
|
9
9
|
GpVersion["V0_7_0"] = "0.7.0";
|
|
10
10
|
GpVersion["V0_7_1"] = "0.7.1";
|
|
11
|
-
GpVersion["V0_7_2"] = "0.7.2
|
|
11
|
+
GpVersion["V0_7_2"] = "0.7.2";
|
|
12
12
|
})(GpVersion || (GpVersion = {}));
|
|
13
13
|
var TestSuite;
|
|
14
14
|
(function (TestSuite) {
|
|
15
15
|
TestSuite["W3F_DAVXY"] = "w3f-davxy";
|
|
16
16
|
TestSuite["JAMDUNA"] = "jamduna";
|
|
17
17
|
})(TestSuite || (TestSuite = {}));
|
|
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 DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
19
|
-
const DEFAULT_VERSION = GpVersion.
|
|
20
|
+
const DEFAULT_VERSION = GpVersion.V0_7_2;
|
|
20
21
|
const env$1 = typeof process === "undefined" ? {} : process.env;
|
|
21
22
|
let CURRENT_VERSION = parseCurrentVersion(env$1.GP_VERSION) ?? DEFAULT_VERSION;
|
|
22
23
|
let CURRENT_SUITE = parseCurrentSuite(env$1.TEST_SUITE) ?? DEFAULT_SUITE;
|
|
23
|
-
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1, GpVersion.V0_7_2];
|
|
24
24
|
function parseCurrentVersion(env) {
|
|
25
25
|
if (env === undefined) {
|
|
26
26
|
return undefined;
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
case GpVersion.V0_7_2:
|
|
33
|
-
return env;
|
|
34
|
-
default:
|
|
35
|
-
throw new Error(`Configured environment variable GP_VERSION is unknown: '${env}'. Use one of: ${ALL_VERSIONS_IN_ORDER}`);
|
|
28
|
+
for (const v of Object.values(GpVersion)) {
|
|
29
|
+
if (env === v) {
|
|
30
|
+
return v;
|
|
31
|
+
}
|
|
36
32
|
}
|
|
33
|
+
throw new Error(`Configured environment variable GP_VERSION is unknown: '${env}'. Use one of: ${ALL_VERSIONS_IN_ORDER}`);
|
|
37
34
|
}
|
|
38
35
|
function parseCurrentSuite(env) {
|
|
39
36
|
if (env === undefined) {
|
|
40
37
|
return undefined;
|
|
41
38
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
default:
|
|
47
|
-
throw new Error(`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`);
|
|
39
|
+
for (const s of Object.values(TestSuite)) {
|
|
40
|
+
if (env === s) {
|
|
41
|
+
return s;
|
|
42
|
+
}
|
|
48
43
|
}
|
|
44
|
+
throw new Error(`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`);
|
|
49
45
|
}
|
|
50
46
|
class Compatibility {
|
|
51
47
|
static override(version) {
|
|
@@ -205,6 +201,13 @@ class WithDebug {
|
|
|
205
201
|
return inspect(this);
|
|
206
202
|
}
|
|
207
203
|
}
|
|
204
|
+
function lazyInspect(obj) {
|
|
205
|
+
return {
|
|
206
|
+
toString() {
|
|
207
|
+
return inspect(obj);
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
}
|
|
208
211
|
|
|
209
212
|
const env = typeof process === "undefined" ? {} : process.env;
|
|
210
213
|
/**
|
|
@@ -599,6 +602,7 @@ var index$u = /*#__PURE__*/Object.freeze({
|
|
|
599
602
|
deepEqual: deepEqual,
|
|
600
603
|
inspect: inspect,
|
|
601
604
|
isBrowser: isBrowser,
|
|
605
|
+
lazyInspect: lazyInspect,
|
|
602
606
|
measure: measure,
|
|
603
607
|
resultToString: resultToString,
|
|
604
608
|
safeAllocUint8Array: safeAllocUint8Array,
|
|
@@ -7741,7 +7745,7 @@ const DEV_CONFIG = "dev";
|
|
|
7741
7745
|
const DEFAULT_CONFIG = "default";
|
|
7742
7746
|
const NODE_DEFAULTS = {
|
|
7743
7747
|
name: isBrowser() ? "browser" : os.hostname(),
|
|
7744
|
-
config: DEFAULT_CONFIG,
|
|
7748
|
+
config: [DEFAULT_CONFIG],
|
|
7745
7749
|
pvm: PvmBackend.BuiltIn,
|
|
7746
7750
|
};
|
|
7747
7751
|
/** Chain spec chooser. */
|
|
@@ -7794,25 +7798,137 @@ class NodeConfiguration {
|
|
|
7794
7798
|
this.authorship = authorship;
|
|
7795
7799
|
}
|
|
7796
7800
|
}
|
|
7797
|
-
function loadConfig(
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
|
|
7801
|
+
function loadConfig(config, withRelPath) {
|
|
7802
|
+
logger$5.log `🔧 Loading config`;
|
|
7803
|
+
let mergedJson = {};
|
|
7804
|
+
for (const entry of config) {
|
|
7805
|
+
logger$5.log `🔧 Applying '${entry}'`;
|
|
7806
|
+
if (entry === DEV_CONFIG) {
|
|
7807
|
+
mergedJson = structuredClone(configs.dev); // clone to avoid mutating the original config. not doing a merge since dev and default should theoretically replace all properties.
|
|
7808
|
+
continue;
|
|
7809
|
+
}
|
|
7810
|
+
if (entry === DEFAULT_CONFIG) {
|
|
7811
|
+
mergedJson = structuredClone(configs.default);
|
|
7812
|
+
continue;
|
|
7813
|
+
}
|
|
7814
|
+
// try to parse as JSON
|
|
7815
|
+
try {
|
|
7816
|
+
const parsed = JSON.parse(entry);
|
|
7817
|
+
deepMerge(mergedJson, parsed);
|
|
7818
|
+
continue;
|
|
7819
|
+
}
|
|
7820
|
+
catch { }
|
|
7821
|
+
// if not, try to load as file
|
|
7822
|
+
if (entry.indexOf("=") === -1 && entry.endsWith(".json")) {
|
|
7823
|
+
try {
|
|
7824
|
+
const configFile = fs.readFileSync(withRelPath(entry), "utf8");
|
|
7825
|
+
const parsed = JSON.parse(configFile);
|
|
7826
|
+
deepMerge(mergedJson, parsed);
|
|
7827
|
+
}
|
|
7828
|
+
catch (e) {
|
|
7829
|
+
throw new Error(`Unable to load config from ${entry}: ${e}`);
|
|
7830
|
+
}
|
|
7831
|
+
}
|
|
7832
|
+
else {
|
|
7833
|
+
// finally try to process as a pseudo-jq query
|
|
7834
|
+
try {
|
|
7835
|
+
processQuery(mergedJson, entry, withRelPath);
|
|
7836
|
+
}
|
|
7837
|
+
catch (e) {
|
|
7838
|
+
throw new Error(`Error while processing '${entry}': ${e}`);
|
|
7839
|
+
}
|
|
7840
|
+
}
|
|
7805
7841
|
}
|
|
7806
7842
|
try {
|
|
7807
|
-
|
|
7808
|
-
|
|
7809
|
-
|
|
7810
|
-
return parseFromJson(parsed, NodeConfiguration.fromJson);
|
|
7843
|
+
const parsed = parseFromJson(mergedJson, NodeConfiguration.fromJson);
|
|
7844
|
+
logger$5.log `🔧 Config ready`;
|
|
7845
|
+
return parsed;
|
|
7811
7846
|
}
|
|
7812
7847
|
catch (e) {
|
|
7813
|
-
throw new Error(`Unable to
|
|
7848
|
+
throw new Error(`Unable to parse config: ${e}`);
|
|
7814
7849
|
}
|
|
7815
7850
|
}
|
|
7851
|
+
function deepMerge(target, source) {
|
|
7852
|
+
if (!isJsonObject(source)) {
|
|
7853
|
+
throw new Error(`Expected object, got ${source}`);
|
|
7854
|
+
}
|
|
7855
|
+
for (const key in source) {
|
|
7856
|
+
if (isJsonObject(source[key])) {
|
|
7857
|
+
if (!isJsonObject(target[key])) {
|
|
7858
|
+
target[key] = {};
|
|
7859
|
+
}
|
|
7860
|
+
deepMerge(target[key], source[key]);
|
|
7861
|
+
}
|
|
7862
|
+
else {
|
|
7863
|
+
target[key] = source[key];
|
|
7864
|
+
}
|
|
7865
|
+
}
|
|
7866
|
+
}
|
|
7867
|
+
/**
|
|
7868
|
+
* Caution: updates input directly.
|
|
7869
|
+
* Processes a pseudo-jq query. Syntax:
|
|
7870
|
+
* .path.to.value = { ... } - updates value with the specified object by replacement
|
|
7871
|
+
* .path.to.value += { ... } - updates value with the specified object by merging
|
|
7872
|
+
* .path.to.value = file.json - updates value with the contents of file.json
|
|
7873
|
+
* .path.to.value += file.json - merges the contents of file.json onto value
|
|
7874
|
+
*/
|
|
7875
|
+
function processQuery(input, query, withRelPath) {
|
|
7876
|
+
const queryParts = query.split("=");
|
|
7877
|
+
if (queryParts.length === 2) {
|
|
7878
|
+
let [path, value] = queryParts.map((part) => part.trim());
|
|
7879
|
+
let merge = false;
|
|
7880
|
+
// detect += syntax
|
|
7881
|
+
if (path.endsWith("+")) {
|
|
7882
|
+
merge = true;
|
|
7883
|
+
path = path.slice(0, -1);
|
|
7884
|
+
}
|
|
7885
|
+
let parsedValue;
|
|
7886
|
+
if (value.endsWith(".json")) {
|
|
7887
|
+
try {
|
|
7888
|
+
const configFile = fs.readFileSync(withRelPath(value), "utf8");
|
|
7889
|
+
const parsed = JSON.parse(configFile);
|
|
7890
|
+
parsedValue = parsed;
|
|
7891
|
+
}
|
|
7892
|
+
catch (e) {
|
|
7893
|
+
throw new Error(`Unable to load config from ${value}: ${e}`);
|
|
7894
|
+
}
|
|
7895
|
+
}
|
|
7896
|
+
else {
|
|
7897
|
+
try {
|
|
7898
|
+
parsedValue = JSON.parse(value);
|
|
7899
|
+
}
|
|
7900
|
+
catch (e) {
|
|
7901
|
+
throw new Error(`Unrecognized syntax '${value}': ${e}`);
|
|
7902
|
+
}
|
|
7903
|
+
}
|
|
7904
|
+
let pathParts = path.split(".");
|
|
7905
|
+
// allow leading dot in path
|
|
7906
|
+
if (pathParts[0] === "") {
|
|
7907
|
+
pathParts = pathParts.slice(1);
|
|
7908
|
+
}
|
|
7909
|
+
let target = input;
|
|
7910
|
+
for (let i = 0; i < pathParts.length; i++) {
|
|
7911
|
+
const part = pathParts[i];
|
|
7912
|
+
if (!isJsonObject(target[part])) {
|
|
7913
|
+
target[part] = {};
|
|
7914
|
+
}
|
|
7915
|
+
if (i === pathParts.length - 1) {
|
|
7916
|
+
if (merge) {
|
|
7917
|
+
deepMerge(target[part], parsedValue);
|
|
7918
|
+
}
|
|
7919
|
+
else {
|
|
7920
|
+
target[part] = parsedValue;
|
|
7921
|
+
}
|
|
7922
|
+
return;
|
|
7923
|
+
}
|
|
7924
|
+
target = target[part];
|
|
7925
|
+
}
|
|
7926
|
+
}
|
|
7927
|
+
throw new Error("Unrecognized syntax.");
|
|
7928
|
+
}
|
|
7929
|
+
function isJsonObject(value) {
|
|
7930
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7931
|
+
}
|
|
7816
7932
|
|
|
7817
7933
|
var index$h = /*#__PURE__*/Object.freeze({
|
|
7818
7934
|
__proto__: null,
|
|
@@ -8955,26 +9071,6 @@ class InMemoryStateView {
|
|
|
8955
9071
|
}
|
|
8956
9072
|
}
|
|
8957
9073
|
|
|
8958
|
-
/** Dictionary entry of services that auto-accumulate every block. */
|
|
8959
|
-
class AutoAccumulate {
|
|
8960
|
-
service;
|
|
8961
|
-
gasLimit;
|
|
8962
|
-
static Codec = codec$1.Class(AutoAccumulate, {
|
|
8963
|
-
service: codec$1.u32.asOpaque(),
|
|
8964
|
-
gasLimit: codec$1.u64.asOpaque(),
|
|
8965
|
-
});
|
|
8966
|
-
static create({ service, gasLimit }) {
|
|
8967
|
-
return new AutoAccumulate(service, gasLimit);
|
|
8968
|
-
}
|
|
8969
|
-
constructor(
|
|
8970
|
-
/** Service id that auto-accumulates. */
|
|
8971
|
-
service,
|
|
8972
|
-
/** Gas limit for auto-accumulation. */
|
|
8973
|
-
gasLimit) {
|
|
8974
|
-
this.service = service;
|
|
8975
|
-
this.gasLimit = gasLimit;
|
|
8976
|
-
}
|
|
8977
|
-
}
|
|
8978
9074
|
/**
|
|
8979
9075
|
* https://graypaper.fluffylabs.dev/#/ab2cdbd/114402114402?v=0.7.2
|
|
8980
9076
|
*/
|
|
@@ -8992,7 +9088,9 @@ class PrivilegedServices {
|
|
|
8992
9088
|
registrar: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
|
|
8993
9089
|
? codec$1.u32.asOpaque()
|
|
8994
9090
|
: ignoreValueWithDefault(tryAsServiceId(2 ** 32 - 1)),
|
|
8995
|
-
autoAccumulateServices:
|
|
9091
|
+
autoAccumulateServices: codec$1.dictionary(codec$1.u32.asOpaque(), codec$1.u64.asOpaque(), {
|
|
9092
|
+
sortKeys: (a, b) => a - b,
|
|
9093
|
+
}),
|
|
8996
9094
|
});
|
|
8997
9095
|
static create(a) {
|
|
8998
9096
|
return new PrivilegedServices(a.manager, a.delegator, a.registrar, a.assigners, a.autoAccumulateServices);
|
|
@@ -9597,7 +9695,7 @@ class InMemoryState extends WithDebug {
|
|
|
9597
9695
|
assigners: tryAsPerCore(new Array(spec.coresCount).fill(tryAsServiceId(0)), spec),
|
|
9598
9696
|
delegator: tryAsServiceId(0),
|
|
9599
9697
|
registrar: tryAsServiceId(MAX_VALUE),
|
|
9600
|
-
autoAccumulateServices:
|
|
9698
|
+
autoAccumulateServices: new Map(),
|
|
9601
9699
|
}),
|
|
9602
9700
|
accumulationOutputLog: SortedArray.fromArray(accumulationOutputComparator, []),
|
|
9603
9701
|
services: new Map(),
|
|
@@ -9620,7 +9718,6 @@ var index$g = /*#__PURE__*/Object.freeze({
|
|
|
9620
9718
|
__proto__: null,
|
|
9621
9719
|
AUTHORIZATION_QUEUE_SIZE: AUTHORIZATION_QUEUE_SIZE,
|
|
9622
9720
|
AccumulationOutput: AccumulationOutput,
|
|
9623
|
-
AutoAccumulate: AutoAccumulate,
|
|
9624
9721
|
AvailabilityAssignment: AvailabilityAssignment,
|
|
9625
9722
|
BASE_SERVICE_BALANCE: BASE_SERVICE_BALANCE,
|
|
9626
9723
|
BlockState: BlockState,
|
|
@@ -17603,6 +17700,7 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
17603
17700
|
instructionArgumentTypeMap: instructionArgumentTypeMap,
|
|
17604
17701
|
interpreter: index$5,
|
|
17605
17702
|
isBrowser: isBrowser,
|
|
17703
|
+
lazyInspect: lazyInspect,
|
|
17606
17704
|
measure: measure,
|
|
17607
17705
|
numbers: index$r,
|
|
17608
17706
|
resultToString: resultToString,
|
|
@@ -18009,10 +18107,7 @@ const fullStateDumpFromJson = (spec) => json.object({
|
|
|
18009
18107
|
chi_a: json.array("number"),
|
|
18010
18108
|
chi_v: "number",
|
|
18011
18109
|
chi_r: json.optional("number"),
|
|
18012
|
-
chi_g: json.nullable(json.
|
|
18013
|
-
service: "number",
|
|
18014
|
-
gasLimit: json.fromNumber((v) => tryAsServiceGas(v)),
|
|
18015
|
-
})),
|
|
18110
|
+
chi_g: json.nullable(json.map("number", json.fromNumber((v) => tryAsServiceGas(v)))),
|
|
18016
18111
|
},
|
|
18017
18112
|
pi: JsonStatisticsData.fromJson,
|
|
18018
18113
|
omega: json.array(json.array(notYetAccumulatedFromJson)),
|
|
@@ -18053,7 +18148,7 @@ const fullStateDumpFromJson = (spec) => json.object({
|
|
|
18053
18148
|
assigners: chi.chi_a,
|
|
18054
18149
|
delegator: chi.chi_v,
|
|
18055
18150
|
registrar: chi.chi_r ?? tryAsServiceId(2 ** 32 - 1),
|
|
18056
|
-
autoAccumulateServices: chi.chi_g ??
|
|
18151
|
+
autoAccumulateServices: chi.chi_g ?? new Map(),
|
|
18057
18152
|
}),
|
|
18058
18153
|
statistics: JsonStatisticsData.toStatisticsData(spec, pi),
|
|
18059
18154
|
accumulationQueue: omega,
|