@typeberry/jam 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/README.md +3 -3
- package/bootstrap-generator.mjs +24 -39
- package/bootstrap-generator.mjs.map +1 -1
- package/bootstrap-importer.mjs +113 -104
- package/bootstrap-importer.mjs.map +1 -1
- package/bootstrap-network.mjs +146 -31
- package/bootstrap-network.mjs.map +1 -1
- package/index.js +289 -132
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -24295,7 +24295,8 @@ var __webpack_exports__ = {};
|
|
|
24295
24295
|
__nccwpck_require__.d(__webpack_exports__, {
|
|
24296
24296
|
uB: () => (/* reexport */ Command),
|
|
24297
24297
|
_$: () => (/* reexport */ HELP),
|
|
24298
|
-
Zy: () => (/* reexport */ parseArgs)
|
|
24298
|
+
Zy: () => (/* reexport */ parseArgs),
|
|
24299
|
+
P3: () => (/* reexport */ parseSharedOptions)
|
|
24299
24300
|
});
|
|
24300
24301
|
|
|
24301
24302
|
;// CONCATENATED MODULE: ./packages/core/utils/compatibility.ts
|
|
@@ -24304,44 +24305,40 @@ var GpVersion;
|
|
|
24304
24305
|
GpVersion["V0_6_7"] = "0.6.7";
|
|
24305
24306
|
GpVersion["V0_7_0"] = "0.7.0";
|
|
24306
24307
|
GpVersion["V0_7_1"] = "0.7.1";
|
|
24307
|
-
GpVersion["V0_7_2"] = "0.7.2
|
|
24308
|
+
GpVersion["V0_7_2"] = "0.7.2";
|
|
24308
24309
|
})(GpVersion || (GpVersion = {}));
|
|
24309
24310
|
var TestSuite;
|
|
24310
24311
|
(function (TestSuite) {
|
|
24311
24312
|
TestSuite["W3F_DAVXY"] = "w3f-davxy";
|
|
24312
24313
|
TestSuite["JAMDUNA"] = "jamduna";
|
|
24313
24314
|
})(TestSuite || (TestSuite = {}));
|
|
24315
|
+
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1, GpVersion.V0_7_2];
|
|
24314
24316
|
const DEFAULT_SUITE = TestSuite.W3F_DAVXY;
|
|
24315
|
-
const DEFAULT_VERSION = GpVersion.
|
|
24317
|
+
const DEFAULT_VERSION = GpVersion.V0_7_2;
|
|
24316
24318
|
const env = typeof process === "undefined" ? {} : process.env;
|
|
24317
24319
|
let CURRENT_VERSION = parseCurrentVersion(env.GP_VERSION) ?? DEFAULT_VERSION;
|
|
24318
24320
|
let CURRENT_SUITE = parseCurrentSuite(env.TEST_SUITE) ?? DEFAULT_SUITE;
|
|
24319
|
-
const ALL_VERSIONS_IN_ORDER = [GpVersion.V0_6_7, GpVersion.V0_7_0, GpVersion.V0_7_1, GpVersion.V0_7_2];
|
|
24320
24321
|
function parseCurrentVersion(env) {
|
|
24321
24322
|
if (env === undefined) {
|
|
24322
24323
|
return undefined;
|
|
24323
24324
|
}
|
|
24324
|
-
|
|
24325
|
-
|
|
24326
|
-
|
|
24327
|
-
|
|
24328
|
-
case GpVersion.V0_7_2:
|
|
24329
|
-
return env;
|
|
24330
|
-
default:
|
|
24331
|
-
throw new Error(`Configured environment variable GP_VERSION is unknown: '${env}'. Use one of: ${ALL_VERSIONS_IN_ORDER}`);
|
|
24325
|
+
for (const v of Object.values(GpVersion)) {
|
|
24326
|
+
if (env === v) {
|
|
24327
|
+
return v;
|
|
24328
|
+
}
|
|
24332
24329
|
}
|
|
24330
|
+
throw new Error(`Configured environment variable GP_VERSION is unknown: '${env}'. Use one of: ${ALL_VERSIONS_IN_ORDER}`);
|
|
24333
24331
|
}
|
|
24334
24332
|
function parseCurrentSuite(env) {
|
|
24335
24333
|
if (env === undefined) {
|
|
24336
24334
|
return undefined;
|
|
24337
24335
|
}
|
|
24338
|
-
|
|
24339
|
-
|
|
24340
|
-
|
|
24341
|
-
|
|
24342
|
-
default:
|
|
24343
|
-
throw new Error(`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`);
|
|
24336
|
+
for (const s of Object.values(TestSuite)) {
|
|
24337
|
+
if (env === s) {
|
|
24338
|
+
return s;
|
|
24339
|
+
}
|
|
24344
24340
|
}
|
|
24341
|
+
throw new Error(`Configured environment variable TEST_SUITE is unknown: '${env}'. Use one of: ${Object.values(TestSuite)}`);
|
|
24345
24342
|
}
|
|
24346
24343
|
class Compatibility {
|
|
24347
24344
|
static override(version) {
|
|
@@ -24502,6 +24499,13 @@ class WithDebug {
|
|
|
24502
24499
|
return debug_inspect(this);
|
|
24503
24500
|
}
|
|
24504
24501
|
}
|
|
24502
|
+
function lazyInspect(obj) {
|
|
24503
|
+
return {
|
|
24504
|
+
toString() {
|
|
24505
|
+
return debug_inspect(obj);
|
|
24506
|
+
},
|
|
24507
|
+
};
|
|
24508
|
+
}
|
|
24505
24509
|
|
|
24506
24510
|
;// CONCATENATED MODULE: ./packages/core/utils/dev.ts
|
|
24507
24511
|
const dev_env = typeof process === "undefined" ? {} : process.env;
|
|
@@ -31593,7 +31597,7 @@ const DEV_CONFIG = "dev";
|
|
|
31593
31597
|
const DEFAULT_CONFIG = "default";
|
|
31594
31598
|
const NODE_DEFAULTS = {
|
|
31595
31599
|
name: isBrowser() ? "browser" : external_node_os_default().hostname(),
|
|
31596
|
-
config: DEFAULT_CONFIG,
|
|
31600
|
+
config: [DEFAULT_CONFIG],
|
|
31597
31601
|
pvm: PvmBackend.BuiltIn,
|
|
31598
31602
|
};
|
|
31599
31603
|
/** Chain spec chooser. */
|
|
@@ -31646,25 +31650,137 @@ class NodeConfiguration {
|
|
|
31646
31650
|
this.authorship = authorship;
|
|
31647
31651
|
}
|
|
31648
31652
|
}
|
|
31649
|
-
function loadConfig(
|
|
31650
|
-
|
|
31651
|
-
|
|
31652
|
-
|
|
31653
|
-
|
|
31654
|
-
|
|
31655
|
-
|
|
31656
|
-
|
|
31653
|
+
function loadConfig(config, withRelPath) {
|
|
31654
|
+
logger.log `🔧 Loading config`;
|
|
31655
|
+
let mergedJson = {};
|
|
31656
|
+
for (const entry of config) {
|
|
31657
|
+
logger.log `🔧 Applying '${entry}'`;
|
|
31658
|
+
if (entry === DEV_CONFIG) {
|
|
31659
|
+
mergedJson = structuredClone(configs.dev); // clone to avoid mutating the original config. not doing a merge since dev and default should theoretically replace all properties.
|
|
31660
|
+
continue;
|
|
31661
|
+
}
|
|
31662
|
+
if (entry === DEFAULT_CONFIG) {
|
|
31663
|
+
mergedJson = structuredClone(configs.default);
|
|
31664
|
+
continue;
|
|
31665
|
+
}
|
|
31666
|
+
// try to parse as JSON
|
|
31667
|
+
try {
|
|
31668
|
+
const parsed = JSON.parse(entry);
|
|
31669
|
+
deepMerge(mergedJson, parsed);
|
|
31670
|
+
continue;
|
|
31671
|
+
}
|
|
31672
|
+
catch { }
|
|
31673
|
+
// if not, try to load as file
|
|
31674
|
+
if (entry.indexOf("=") === -1 && entry.endsWith(".json")) {
|
|
31675
|
+
try {
|
|
31676
|
+
const configFile = external_node_fs_default().readFileSync(withRelPath(entry), "utf8");
|
|
31677
|
+
const parsed = JSON.parse(configFile);
|
|
31678
|
+
deepMerge(mergedJson, parsed);
|
|
31679
|
+
}
|
|
31680
|
+
catch (e) {
|
|
31681
|
+
throw new Error(`Unable to load config from ${entry}: ${e}`);
|
|
31682
|
+
}
|
|
31683
|
+
}
|
|
31684
|
+
else {
|
|
31685
|
+
// finally try to process as a pseudo-jq query
|
|
31686
|
+
try {
|
|
31687
|
+
processQuery(mergedJson, entry, withRelPath);
|
|
31688
|
+
}
|
|
31689
|
+
catch (e) {
|
|
31690
|
+
throw new Error(`Error while processing '${entry}': ${e}`);
|
|
31691
|
+
}
|
|
31692
|
+
}
|
|
31657
31693
|
}
|
|
31658
31694
|
try {
|
|
31659
|
-
|
|
31660
|
-
|
|
31661
|
-
|
|
31662
|
-
return parseFromJson(parsed, NodeConfiguration.fromJson);
|
|
31695
|
+
const parsed = parseFromJson(mergedJson, NodeConfiguration.fromJson);
|
|
31696
|
+
logger.log `🔧 Config ready`;
|
|
31697
|
+
return parsed;
|
|
31663
31698
|
}
|
|
31664
31699
|
catch (e) {
|
|
31665
|
-
throw new Error(`Unable to
|
|
31700
|
+
throw new Error(`Unable to parse config: ${e}`);
|
|
31701
|
+
}
|
|
31702
|
+
}
|
|
31703
|
+
function deepMerge(target, source) {
|
|
31704
|
+
if (!isJsonObject(source)) {
|
|
31705
|
+
throw new Error(`Expected object, got ${source}`);
|
|
31706
|
+
}
|
|
31707
|
+
for (const key in source) {
|
|
31708
|
+
if (isJsonObject(source[key])) {
|
|
31709
|
+
if (!isJsonObject(target[key])) {
|
|
31710
|
+
target[key] = {};
|
|
31711
|
+
}
|
|
31712
|
+
deepMerge(target[key], source[key]);
|
|
31713
|
+
}
|
|
31714
|
+
else {
|
|
31715
|
+
target[key] = source[key];
|
|
31716
|
+
}
|
|
31666
31717
|
}
|
|
31667
31718
|
}
|
|
31719
|
+
/**
|
|
31720
|
+
* Caution: updates input directly.
|
|
31721
|
+
* Processes a pseudo-jq query. Syntax:
|
|
31722
|
+
* .path.to.value = { ... } - updates value with the specified object by replacement
|
|
31723
|
+
* .path.to.value += { ... } - updates value with the specified object by merging
|
|
31724
|
+
* .path.to.value = file.json - updates value with the contents of file.json
|
|
31725
|
+
* .path.to.value += file.json - merges the contents of file.json onto value
|
|
31726
|
+
*/
|
|
31727
|
+
function processQuery(input, query, withRelPath) {
|
|
31728
|
+
const queryParts = query.split("=");
|
|
31729
|
+
if (queryParts.length === 2) {
|
|
31730
|
+
let [path, value] = queryParts.map((part) => part.trim());
|
|
31731
|
+
let merge = false;
|
|
31732
|
+
// detect += syntax
|
|
31733
|
+
if (path.endsWith("+")) {
|
|
31734
|
+
merge = true;
|
|
31735
|
+
path = path.slice(0, -1);
|
|
31736
|
+
}
|
|
31737
|
+
let parsedValue;
|
|
31738
|
+
if (value.endsWith(".json")) {
|
|
31739
|
+
try {
|
|
31740
|
+
const configFile = external_node_fs_default().readFileSync(withRelPath(value), "utf8");
|
|
31741
|
+
const parsed = JSON.parse(configFile);
|
|
31742
|
+
parsedValue = parsed;
|
|
31743
|
+
}
|
|
31744
|
+
catch (e) {
|
|
31745
|
+
throw new Error(`Unable to load config from ${value}: ${e}`);
|
|
31746
|
+
}
|
|
31747
|
+
}
|
|
31748
|
+
else {
|
|
31749
|
+
try {
|
|
31750
|
+
parsedValue = JSON.parse(value);
|
|
31751
|
+
}
|
|
31752
|
+
catch (e) {
|
|
31753
|
+
throw new Error(`Unrecognized syntax '${value}': ${e}`);
|
|
31754
|
+
}
|
|
31755
|
+
}
|
|
31756
|
+
let pathParts = path.split(".");
|
|
31757
|
+
// allow leading dot in path
|
|
31758
|
+
if (pathParts[0] === "") {
|
|
31759
|
+
pathParts = pathParts.slice(1);
|
|
31760
|
+
}
|
|
31761
|
+
let target = input;
|
|
31762
|
+
for (let i = 0; i < pathParts.length; i++) {
|
|
31763
|
+
const part = pathParts[i];
|
|
31764
|
+
if (!isJsonObject(target[part])) {
|
|
31765
|
+
target[part] = {};
|
|
31766
|
+
}
|
|
31767
|
+
if (i === pathParts.length - 1) {
|
|
31768
|
+
if (merge) {
|
|
31769
|
+
deepMerge(target[part], parsedValue);
|
|
31770
|
+
}
|
|
31771
|
+
else {
|
|
31772
|
+
target[part] = parsedValue;
|
|
31773
|
+
}
|
|
31774
|
+
return;
|
|
31775
|
+
}
|
|
31776
|
+
target = target[part];
|
|
31777
|
+
}
|
|
31778
|
+
}
|
|
31779
|
+
throw new Error("Unrecognized syntax.");
|
|
31780
|
+
}
|
|
31781
|
+
function isJsonObject(value) {
|
|
31782
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
31783
|
+
}
|
|
31668
31784
|
|
|
31669
31785
|
;// CONCATENATED MODULE: ./packages/jam/config-node/index.ts
|
|
31670
31786
|
|
|
@@ -33218,7 +33334,7 @@ function hashComparator(a, b) {
|
|
|
33218
33334
|
|
|
33219
33335
|
;// CONCATENATED MODULE: ./packages/core/pvm-interpreter/ops/math-consts.ts
|
|
33220
33336
|
const MAX_VALUE = 4294967295;
|
|
33221
|
-
const math_consts_MAX_VALUE_U64 =
|
|
33337
|
+
const math_consts_MAX_VALUE_U64 = 2n ** 63n;
|
|
33222
33338
|
const MIN_VALUE = -(2 ** 31);
|
|
33223
33339
|
const MAX_SHIFT_U32 = 32;
|
|
33224
33340
|
const MAX_SHIFT_U64 = 64n;
|
|
@@ -34003,26 +34119,6 @@ class InMemoryStateView {
|
|
|
34003
34119
|
|
|
34004
34120
|
|
|
34005
34121
|
|
|
34006
|
-
/** Dictionary entry of services that auto-accumulate every block. */
|
|
34007
|
-
class AutoAccumulate {
|
|
34008
|
-
service;
|
|
34009
|
-
gasLimit;
|
|
34010
|
-
static Codec = descriptors_codec.Class(AutoAccumulate, {
|
|
34011
|
-
service: descriptors_codec.u32.asOpaque(),
|
|
34012
|
-
gasLimit: descriptors_codec.u64.asOpaque(),
|
|
34013
|
-
});
|
|
34014
|
-
static create({ service, gasLimit }) {
|
|
34015
|
-
return new AutoAccumulate(service, gasLimit);
|
|
34016
|
-
}
|
|
34017
|
-
constructor(
|
|
34018
|
-
/** Service id that auto-accumulates. */
|
|
34019
|
-
service,
|
|
34020
|
-
/** Gas limit for auto-accumulation. */
|
|
34021
|
-
gasLimit) {
|
|
34022
|
-
this.service = service;
|
|
34023
|
-
this.gasLimit = gasLimit;
|
|
34024
|
-
}
|
|
34025
|
-
}
|
|
34026
34122
|
/**
|
|
34027
34123
|
* https://graypaper.fluffylabs.dev/#/ab2cdbd/114402114402?v=0.7.2
|
|
34028
34124
|
*/
|
|
@@ -34040,7 +34136,9 @@ class PrivilegedServices {
|
|
|
34040
34136
|
registrar: Compatibility.isGreaterOrEqual(GpVersion.V0_7_1)
|
|
34041
34137
|
? descriptors_codec.u32.asOpaque()
|
|
34042
34138
|
: ignoreValueWithDefault(tryAsServiceId(2 ** 32 - 1)),
|
|
34043
|
-
autoAccumulateServices:
|
|
34139
|
+
autoAccumulateServices: descriptors_codec.dictionary(descriptors_codec.u32.asOpaque(), descriptors_codec.u64.asOpaque(), {
|
|
34140
|
+
sortKeys: (a, b) => a - b,
|
|
34141
|
+
}),
|
|
34044
34142
|
});
|
|
34045
34143
|
static create(a) {
|
|
34046
34144
|
return new PrivilegedServices(a.manager, a.delegator, a.registrar, a.assigners, a.autoAccumulateServices);
|
|
@@ -34673,7 +34771,7 @@ class in_memory_state_InMemoryState extends WithDebug {
|
|
|
34673
34771
|
assigners: tryAsPerCore(new Array(spec.coresCount).fill(tryAsServiceId(0)), spec),
|
|
34674
34772
|
delegator: tryAsServiceId(0),
|
|
34675
34773
|
registrar: tryAsServiceId(MAX_VALUE),
|
|
34676
|
-
autoAccumulateServices:
|
|
34774
|
+
autoAccumulateServices: new Map(),
|
|
34677
34775
|
}),
|
|
34678
34776
|
accumulationOutputLog: SortedArray.fromArray(accumulationOutputComparator, []),
|
|
34679
34777
|
services: new Map(),
|
|
@@ -39395,7 +39493,7 @@ class AccumulateExternalities {
|
|
|
39395
39493
|
updatedState;
|
|
39396
39494
|
currentServiceId;
|
|
39397
39495
|
currentTimeslot;
|
|
39398
|
-
checkpointedState
|
|
39496
|
+
checkpointedState;
|
|
39399
39497
|
/** `x_i`: next service id we are going to create. */
|
|
39400
39498
|
nextNewServiceId;
|
|
39401
39499
|
constructor(chainSpec, blake2b, updatedState,
|
|
@@ -39406,13 +39504,14 @@ class AccumulateExternalities {
|
|
|
39406
39504
|
this.updatedState = updatedState;
|
|
39407
39505
|
this.currentServiceId = currentServiceId;
|
|
39408
39506
|
this.currentTimeslot = currentTimeslot;
|
|
39507
|
+
this.checkpointedState = AccumulationStateUpdate.copyFrom(updatedState.stateUpdate);
|
|
39409
39508
|
this.nextNewServiceId = this.getNextAvailableServiceId(nextNewServiceIdCandidate);
|
|
39410
39509
|
const service = this.updatedState.getServiceInfo(this.currentServiceId);
|
|
39411
39510
|
if (service === null) {
|
|
39412
39511
|
throw new Error(`Invalid state initialization. Service info missing for ${this.currentServiceId}.`);
|
|
39413
39512
|
}
|
|
39414
39513
|
}
|
|
39415
|
-
/** Return the underlying state update and checkpointed state
|
|
39514
|
+
/** Return the underlying state update and checkpointed state. */
|
|
39416
39515
|
getStateUpdates() {
|
|
39417
39516
|
return [this.updatedState.stateUpdate, this.checkpointedState];
|
|
39418
39517
|
}
|
|
@@ -39779,7 +39878,7 @@ class AccumulateExternalities {
|
|
|
39779
39878
|
assigners: authorizers,
|
|
39780
39879
|
delegator: delegator,
|
|
39781
39880
|
registrar: registrar ?? tryAsServiceId(0),
|
|
39782
|
-
autoAccumulateServices: autoAccumulate
|
|
39881
|
+
autoAccumulateServices: autoAccumulate,
|
|
39783
39882
|
});
|
|
39784
39883
|
return result_Result.ok(result_OK);
|
|
39785
39884
|
}
|
|
@@ -39803,9 +39902,7 @@ class AccumulateExternalities {
|
|
|
39803
39902
|
isAlreadyChanged: currentAssigner !== original.assigners[index],
|
|
39804
39903
|
}));
|
|
39805
39904
|
const newManager = isManager ? manager : current.manager;
|
|
39806
|
-
const newAutoAccumulateServices = isManager
|
|
39807
|
-
? autoAccumulate.map(([service, gasLimit]) => AutoAccumulate.create({ service, gasLimit }))
|
|
39808
|
-
: current.autoAccumulateServices;
|
|
39905
|
+
const newAutoAccumulateServices = isManager ? autoAccumulate : current.autoAccumulateServices;
|
|
39809
39906
|
// finally update the privileges
|
|
39810
39907
|
this.updatedState.stateUpdate.privilegedServices = PrivilegedServices.create({
|
|
39811
39908
|
manager: newManager,
|
|
@@ -40437,17 +40534,16 @@ class FetchExternalities {
|
|
|
40437
40534
|
|
|
40438
40535
|
|
|
40439
40536
|
|
|
40537
|
+
|
|
40440
40538
|
class AccumulateDataItem {
|
|
40441
40539
|
operands;
|
|
40442
40540
|
reportsLength;
|
|
40443
|
-
|
|
40444
|
-
constructor(operands, reportsLength, gasCost) {
|
|
40541
|
+
constructor(operands, reportsLength) {
|
|
40445
40542
|
this.operands = operands;
|
|
40446
40543
|
this.reportsLength = reportsLength;
|
|
40447
|
-
this.gasCost = gasCost;
|
|
40448
40544
|
}
|
|
40449
40545
|
static empty() {
|
|
40450
|
-
return new AccumulateDataItem([], numbers_tryAsU32(0)
|
|
40546
|
+
return new AccumulateDataItem([], numbers_tryAsU32(0));
|
|
40451
40547
|
}
|
|
40452
40548
|
}
|
|
40453
40549
|
/**
|
|
@@ -40457,23 +40553,43 @@ class AccumulateDataItem {
|
|
|
40457
40553
|
* - gas cost and reports length for each service (statistics)
|
|
40458
40554
|
*/
|
|
40459
40555
|
class AccumulateData {
|
|
40556
|
+
autoAccumulateServicesByServiceId;
|
|
40460
40557
|
reportsDataByServiceId;
|
|
40461
40558
|
transfersByServiceId;
|
|
40462
|
-
autoAccumulateServicesByServiceId;
|
|
40463
40559
|
serviceIds;
|
|
40464
|
-
|
|
40465
|
-
|
|
40560
|
+
gasLimitByServiceId;
|
|
40561
|
+
constructor(reports, transfers, autoAccumulateServicesByServiceId) {
|
|
40466
40562
|
this.autoAccumulateServicesByServiceId = autoAccumulateServicesByServiceId;
|
|
40467
|
-
const
|
|
40563
|
+
const serviceIdsFromAutoAccumulate = new Set(autoAccumulateServicesByServiceId.keys());
|
|
40564
|
+
const { reportsDataByServiceId, serviceIds: serviceIdsFromReports, gasLimitByServiceId: reportsGasLimitByServiceId, } = this.transformReports(reports);
|
|
40468
40565
|
this.reportsDataByServiceId = reportsDataByServiceId;
|
|
40469
|
-
const { transfersByServiceId, serviceIds: serviceIdsFromTransfers } = this.transformTransfers(transfers);
|
|
40566
|
+
const { transfersByServiceId, serviceIds: serviceIdsFromTransfers, gasLimitByServiceId: transfersGasLimitByServiceId, } = this.transformTransfers(transfers);
|
|
40470
40567
|
this.transfersByServiceId = transfersByServiceId;
|
|
40471
40568
|
/**
|
|
40472
40569
|
* Merge service ids from reports, auto-accumulate services and transfers.
|
|
40473
40570
|
*
|
|
40474
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
40571
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/173803174b03?v=0.7.2
|
|
40475
40572
|
*/
|
|
40476
40573
|
this.serviceIds = this.mergeServiceIds(serviceIdsFromReports, serviceIdsFromAutoAccumulate, serviceIdsFromTransfers);
|
|
40574
|
+
/**
|
|
40575
|
+
* Merge gas limits from reports, auto-accumulate services and transfers.
|
|
40576
|
+
*
|
|
40577
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/182001183701?v=0.7.2
|
|
40578
|
+
*/
|
|
40579
|
+
this.gasLimitByServiceId = this.mergeGasLimitByServiceId(this.serviceIds, autoAccumulateServicesByServiceId, reportsGasLimitByServiceId, transfersGasLimitByServiceId);
|
|
40580
|
+
}
|
|
40581
|
+
/**
|
|
40582
|
+
* Calculate the gas limit implied by the selected deferred-transfers, work-reports and gas-privileges.
|
|
40583
|
+
*
|
|
40584
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/182001183701?v=0.7.2
|
|
40585
|
+
*/
|
|
40586
|
+
mergeGasLimitByServiceId(serviceIds, ...gasLimitByServiceIdMaps) {
|
|
40587
|
+
const gasByServiceId = new Map();
|
|
40588
|
+
for (const serviceId of serviceIds) {
|
|
40589
|
+
const { overflow, value } = sumU64(...gasLimitByServiceIdMaps.map((map) => map.get(serviceId) ?? tryAsServiceGas(0)));
|
|
40590
|
+
gasByServiceId.set(serviceId, tryAsServiceGas(overflow ? math_consts_MAX_VALUE_U64 : value));
|
|
40591
|
+
}
|
|
40592
|
+
return gasByServiceId;
|
|
40477
40593
|
}
|
|
40478
40594
|
/** Merge two sets of service ids */
|
|
40479
40595
|
mergeServiceIds(...sources) {
|
|
@@ -40485,50 +40601,60 @@ class AccumulateData {
|
|
|
40485
40601
|
}
|
|
40486
40602
|
return Array.from(merged);
|
|
40487
40603
|
}
|
|
40604
|
+
/**
|
|
40605
|
+
* Transform the list of pending transfers into:
|
|
40606
|
+
* - map: transfers by service id
|
|
40607
|
+
* - map: gas limit by service id
|
|
40608
|
+
* - set: service ids
|
|
40609
|
+
*/
|
|
40488
40610
|
transformTransfers(transfersToTransform) {
|
|
40489
40611
|
const transfersByServiceId = new Map();
|
|
40490
40612
|
const serviceIds = new Set();
|
|
40613
|
+
const gasLimitByServiceId = new Map();
|
|
40491
40614
|
for (const transfer of transfersToTransform) {
|
|
40492
40615
|
const serviceId = transfer.destination;
|
|
40493
40616
|
const transfers = transfersByServiceId.get(serviceId) ?? [];
|
|
40617
|
+
const gas = gasLimitByServiceId.get(serviceId) ?? tryAsServiceGas(0n);
|
|
40618
|
+
const { value, overflow } = sumU64(gas, transfer.gas);
|
|
40619
|
+
gasLimitByServiceId.set(serviceId, tryAsServiceGas(overflow ? math_consts_MAX_VALUE_U64 : value));
|
|
40494
40620
|
transfers.push(transfer);
|
|
40495
40621
|
transfersByServiceId.set(serviceId, transfers);
|
|
40496
40622
|
serviceIds.add(serviceId);
|
|
40497
40623
|
}
|
|
40498
|
-
return { transfersByServiceId, serviceIds };
|
|
40499
|
-
}
|
|
40500
|
-
/** Transform the list of auto-accumulate services into a map by service id. */
|
|
40501
|
-
transformAutoAccumulateServices(autoAccumulateServices) {
|
|
40502
|
-
const serviceIds = new Set();
|
|
40503
|
-
const autoAccumulateServicesByServiceId = new Map();
|
|
40504
|
-
for (const autoAccumulate of autoAccumulateServices) {
|
|
40505
|
-
autoAccumulateServicesByServiceId.set(autoAccumulate.service, autoAccumulate);
|
|
40506
|
-
serviceIds.add(autoAccumulate.service);
|
|
40507
|
-
}
|
|
40508
|
-
return { autoAccumulateServicesByServiceId, serviceIds };
|
|
40624
|
+
return { transfersByServiceId, serviceIds, gasLimitByServiceId };
|
|
40509
40625
|
}
|
|
40510
40626
|
/**
|
|
40511
40627
|
* A function that transform reports into a list of operands and data needed for statistics (gas cost and reports length).
|
|
40512
40628
|
*/
|
|
40629
|
+
/**
|
|
40630
|
+
* Transform the list of reports into:
|
|
40631
|
+
* - map: AccumulateDataItem by service id
|
|
40632
|
+
* - map: gas limit by service id
|
|
40633
|
+
* - set: service ids
|
|
40634
|
+
*/
|
|
40513
40635
|
transformReports(reports) {
|
|
40514
40636
|
const reportsDataByServiceId = new Map();
|
|
40637
|
+
const gasLimitByServiceId = new Map();
|
|
40515
40638
|
const serviceIds = new Set();
|
|
40516
40639
|
for (const report of reports) {
|
|
40517
40640
|
for (const result of report.results) {
|
|
40518
40641
|
const serviceId = result.serviceId;
|
|
40519
40642
|
serviceIds.add(serviceId);
|
|
40520
40643
|
const item = reportsDataByServiceId.get(serviceId) ?? AccumulateDataItem.empty();
|
|
40644
|
+
const gas = gasLimitByServiceId.get(serviceId) ?? tryAsServiceGas(0n);
|
|
40645
|
+
const { value, overflow } = sumU64(gas, result.gas);
|
|
40646
|
+
const newGas = tryAsServiceGas(overflow ? math_consts_MAX_VALUE_U64 : value);
|
|
40647
|
+
gasLimitByServiceId.set(serviceId, newGas);
|
|
40521
40648
|
/**
|
|
40522
40649
|
* We count the report results and gas cost for each service to update service statistics.
|
|
40523
40650
|
*
|
|
40524
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
40651
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/180504182604?v=0.7.2
|
|
40525
40652
|
*/
|
|
40526
40653
|
item.reportsLength = numbers_tryAsU32(item.reportsLength + 1);
|
|
40527
|
-
item.gasCost = tryAsServiceGas(item.gasCost + result.gas);
|
|
40528
40654
|
/**
|
|
40529
40655
|
* Transform report into an operand
|
|
40530
40656
|
*
|
|
40531
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
40657
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/185901181402?v=0.7.2
|
|
40532
40658
|
*/
|
|
40533
40659
|
item.operands.push(Operand.new({
|
|
40534
40660
|
gas: result.gas, // g
|
|
@@ -40542,19 +40668,7 @@ class AccumulateData {
|
|
|
40542
40668
|
reportsDataByServiceId.set(serviceId, item);
|
|
40543
40669
|
}
|
|
40544
40670
|
}
|
|
40545
|
-
|
|
40546
|
-
* Add initial gas cost - it is `U(f_s, 0)` from this formula:
|
|
40547
|
-
*
|
|
40548
|
-
* https://graypaper.fluffylabs.dev/#/68eaa1f/17b00217b002?v=0.6.4
|
|
40549
|
-
*/
|
|
40550
|
-
for (const serviceId of serviceIds) {
|
|
40551
|
-
const item = reportsDataByServiceId.get(serviceId) ?? null;
|
|
40552
|
-
const autoAccumulateService = this.autoAccumulateServicesByServiceId.get(serviceId) ?? null;
|
|
40553
|
-
if (item !== null && autoAccumulateService !== null) {
|
|
40554
|
-
item.gasCost = tryAsServiceGas(item.gasCost + autoAccumulateService.gasLimit);
|
|
40555
|
-
}
|
|
40556
|
-
}
|
|
40557
|
-
return { reportsDataByServiceId, serviceIds };
|
|
40671
|
+
return { reportsDataByServiceId, serviceIds, gasLimitByServiceId };
|
|
40558
40672
|
}
|
|
40559
40673
|
/** Returns the list of operands for a given service id */
|
|
40560
40674
|
getOperands(serviceId) {
|
|
@@ -40568,14 +40682,14 @@ class AccumulateData {
|
|
|
40568
40682
|
getReportsLength(serviceId) {
|
|
40569
40683
|
return this.reportsDataByServiceId.get(serviceId)?.reportsLength ?? numbers_tryAsU32(0);
|
|
40570
40684
|
}
|
|
40571
|
-
/** Returns the gas
|
|
40572
|
-
|
|
40573
|
-
return this.
|
|
40685
|
+
/** Returns the gas limit for a given service id */
|
|
40686
|
+
getGasLimit(serviceId) {
|
|
40687
|
+
return this.gasLimitByServiceId.get(serviceId) ?? tryAsServiceGas(0n);
|
|
40574
40688
|
}
|
|
40575
40689
|
/**
|
|
40576
40690
|
* Returns a list of service ids that should be accumulated.
|
|
40577
40691
|
*
|
|
40578
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
40692
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/173803174a03?v=0.7.2
|
|
40579
40693
|
*/
|
|
40580
40694
|
getServiceIds() {
|
|
40581
40695
|
return this.serviceIds;
|
|
@@ -45763,7 +45877,7 @@ class Bless {
|
|
|
45763
45877
|
* `z`: array of key-value pairs serviceId -> gas that auto-accumulate every block
|
|
45764
45878
|
* https://graypaper.fluffylabs.dev/#/7e6ff6a/368100368100?v=0.6.7
|
|
45765
45879
|
*/
|
|
45766
|
-
const
|
|
45880
|
+
const autoAccumulate = new Map();
|
|
45767
45881
|
const result = safe_alloc_uint8array_safeAllocUint8Array(tryAsExactBytes(serviceIdAndGasCodec.sizeHint));
|
|
45768
45882
|
const decoder = decoder_Decoder.fromBlob(result);
|
|
45769
45883
|
let memIndex = sourceStart;
|
|
@@ -45776,7 +45890,7 @@ class Bless {
|
|
|
45776
45890
|
return PvmExecution.Panic;
|
|
45777
45891
|
}
|
|
45778
45892
|
const { serviceId, gas } = decoder.object(serviceIdAndGasCodec);
|
|
45779
|
-
|
|
45893
|
+
autoAccumulate.set(serviceId, gas);
|
|
45780
45894
|
// we allow the index to go beyond `MEMORY_SIZE` (i.e. 2**32) and have the next `loadInto` fail with page fault.
|
|
45781
45895
|
memIndex = numbers_tryAsU64(memIndex + numbers_tryAsU64(decoder.bytesRead()));
|
|
45782
45896
|
}
|
|
@@ -45785,26 +45899,26 @@ class Bless {
|
|
|
45785
45899
|
const authorizersDecoder = decoder_Decoder.fromBlob(res);
|
|
45786
45900
|
const memoryReadResult = memory.loadInto(res, authorization);
|
|
45787
45901
|
if (memoryReadResult.isError) {
|
|
45788
|
-
logger_logger.trace `BLESS(${manager}, ${delegator}, ${registrar}, ${
|
|
45902
|
+
logger_logger.trace `BLESS(${manager}, ${delegator}, ${registrar}, ${lazyInspect(autoAccumulate)}) <- PANIC`;
|
|
45789
45903
|
return PvmExecution.Panic;
|
|
45790
45904
|
}
|
|
45791
45905
|
// `a`
|
|
45792
45906
|
const authorizers = tryAsPerCore(authorizersDecoder.sequenceFixLen(descriptors_codec.u32.asOpaque(), this.chainSpec.coresCount), this.chainSpec);
|
|
45793
|
-
const updateResult = this.partialState.updatePrivilegedServices(manager, authorizers, delegator, registrar,
|
|
45907
|
+
const updateResult = this.partialState.updatePrivilegedServices(manager, authorizers, delegator, registrar, autoAccumulate);
|
|
45794
45908
|
if (updateResult.isOk) {
|
|
45795
|
-
logger_logger.trace `BLESS(${manager}, ${authorizers}, ${delegator}, ${registrar}, ${
|
|
45909
|
+
logger_logger.trace `BLESS(${manager}, ${authorizers}, ${delegator}, ${registrar}, ${lazyInspect(autoAccumulate)}) <- OK`;
|
|
45796
45910
|
regs.set(bless_IN_OUT_REG, HostCallResult.OK);
|
|
45797
45911
|
return;
|
|
45798
45912
|
}
|
|
45799
45913
|
const e = updateResult.error;
|
|
45800
45914
|
// NOTE: `UpdatePrivilegesError.UnprivilegedService` won't happen in 0.7.1+
|
|
45801
45915
|
if (e === UpdatePrivilegesError.UnprivilegedService) {
|
|
45802
|
-
logger_logger.trace `BLESS(${manager}, ${authorizers}, ${delegator}, ${registrar}, ${
|
|
45916
|
+
logger_logger.trace `BLESS(${manager}, ${authorizers}, ${delegator}, ${registrar}, ${lazyInspect(autoAccumulate)}) <- HUH`;
|
|
45803
45917
|
regs.set(bless_IN_OUT_REG, HostCallResult.HUH);
|
|
45804
45918
|
return;
|
|
45805
45919
|
}
|
|
45806
45920
|
if (e === UpdatePrivilegesError.InvalidServiceId) {
|
|
45807
|
-
logger_logger.trace `BLESS(${manager}, ${authorizers}, ${delegator}, ${registrar}, ${
|
|
45921
|
+
logger_logger.trace `BLESS(${manager}, ${authorizers}, ${delegator}, ${registrar}, ${lazyInspect(autoAccumulate)}) <- WHO`;
|
|
45808
45922
|
regs.set(bless_IN_OUT_REG, HostCallResult.WHO);
|
|
45809
45923
|
return;
|
|
45810
45924
|
}
|
|
@@ -47104,6 +47218,7 @@ class PvmExecutor {
|
|
|
47104
47218
|
|
|
47105
47219
|
|
|
47106
47220
|
|
|
47221
|
+
|
|
47107
47222
|
const ACCUMULATION_ERROR = "duplicate service created";
|
|
47108
47223
|
var PvmInvocationError;
|
|
47109
47224
|
(function (PvmInvocationError) {
|
|
@@ -47272,7 +47387,7 @@ class Accumulate {
|
|
|
47272
47387
|
const { gasCost, state: stateAfterParallelAcc, ...rest } = await this.accumulateInParallel(accumulateData, slot, entropy, statistics, stateUpdate);
|
|
47273
47388
|
assertEmpty(rest);
|
|
47274
47389
|
// NOTE [ToDr] recursive invocation
|
|
47275
|
-
const { accumulatedReports, gasCost: seqGasCost, state, ...seqRest } = await this.accumulateSequentiallyLegacy(tryAsServiceGas(gasLimit - gasCost), reportsToAccumulateSequentially, slot, entropy, statistics, stateAfterParallelAcc,
|
|
47390
|
+
const { accumulatedReports, gasCost: seqGasCost, state, ...seqRest } = await this.accumulateSequentiallyLegacy(tryAsServiceGas(gasLimit - gasCost), reportsToAccumulateSequentially, slot, entropy, statistics, stateAfterParallelAcc, new Map());
|
|
47276
47391
|
assertEmpty(seqRest);
|
|
47277
47392
|
return {
|
|
47278
47393
|
accumulatedReports: numbers_tryAsU32(i + accumulatedReports),
|
|
@@ -47304,8 +47419,15 @@ class Accumulate {
|
|
|
47304
47419
|
const { gasCost, state: stateAfterParallelAcc, ...rest } = await this.accumulateInParallel(accumulateData, slot, entropy, statistics, stateUpdate);
|
|
47305
47420
|
const newTransfers = stateAfterParallelAcc.takeTransfers();
|
|
47306
47421
|
assertEmpty(rest);
|
|
47422
|
+
/**
|
|
47423
|
+
* Gas limit from transfers is added to the next round of accumulation
|
|
47424
|
+
*
|
|
47425
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/172b02172b02?v=0.7.2
|
|
47426
|
+
*/
|
|
47427
|
+
const transfersGas = transfers.map((t) => t.gas);
|
|
47428
|
+
const { value: newGasLimit, overflow } = sumU64(tryAsServiceGas(gasLimit - gasCost), ...transfersGas);
|
|
47307
47429
|
// NOTE [ToDr] recursive invocation
|
|
47308
|
-
const { accumulatedReports, gasCost: seqGasCost, state, ...seqRest } = await this.accumulateSequentially(tryAsServiceGas(
|
|
47430
|
+
const { accumulatedReports, gasCost: seqGasCost, state, ...seqRest } = await this.accumulateSequentially(tryAsServiceGas(overflow ? math_consts_MAX_VALUE_U64 : newGasLimit), reportsToAccumulateSequentially, newTransfers, slot, entropy, statistics, stateAfterParallelAcc, new Map());
|
|
47309
47431
|
assertEmpty(seqRest);
|
|
47310
47432
|
return {
|
|
47311
47433
|
accumulatedReports: numbers_tryAsU32(i + accumulatedReports),
|
|
@@ -47331,14 +47453,16 @@ class Accumulate {
|
|
|
47331
47453
|
for (const serviceId of serviceIds) {
|
|
47332
47454
|
const checkpoint = AccumulationStateUpdate.copyFrom(currentState);
|
|
47333
47455
|
const operands = accumulateData.getOperands(serviceId);
|
|
47334
|
-
const { consumedGas, stateUpdate } = await this.accumulateSingleService(serviceId, accumulateData.getTransfers(serviceId), operands, accumulateData.
|
|
47456
|
+
const { consumedGas, stateUpdate } = await this.accumulateSingleService(serviceId, accumulateData.getTransfers(serviceId), operands, accumulateData.getGasLimit(serviceId), slot, entropy, currentState);
|
|
47335
47457
|
gasCost = tryAsServiceGas(gasCost + consumedGas);
|
|
47336
47458
|
// https://graypaper.fluffylabs.dev/#/ab2cdbd/193b05193b05?v=0.7.2
|
|
47337
47459
|
const serviceStatistics = statistics.get(serviceId) ?? { count: numbers_tryAsU32(0), gasUsed: tryAsServiceGas(0) };
|
|
47338
47460
|
const count = accumulateData.getReportsLength(serviceId);
|
|
47339
47461
|
// [0.7.1]: do not update statistics, if the service only had incoming transfers
|
|
47340
47462
|
if ((Compatibility.isLessThan(GpVersion.V0_7_2) && count > 0) ||
|
|
47341
|
-
(Compatibility.isGreaterOrEqual(GpVersion.V0_7_2)
|
|
47463
|
+
((Compatibility.isGreaterOrEqual(GpVersion.V0_7_2) ||
|
|
47464
|
+
(Compatibility.isSuite(TestSuite.W3F_DAVXY) && Compatibility.is(GpVersion.V0_7_1))) &&
|
|
47465
|
+
(count > 0 || consumedGas > 0n))) {
|
|
47342
47466
|
serviceStatistics.count = numbers_tryAsU32(serviceStatistics.count + count);
|
|
47343
47467
|
serviceStatistics.gasUsed = tryAsServiceGas(serviceStatistics.gasUsed + consumedGas);
|
|
47344
47468
|
statistics.set(serviceId, serviceStatistics);
|
|
@@ -47351,7 +47475,7 @@ class Accumulate {
|
|
|
47351
47475
|
// Since serviceIds already contains newV, this service gets accumulated twice.
|
|
47352
47476
|
// To avoid double-counting, we skip stats and gas cost tracking here.
|
|
47353
47477
|
// We need this accumulation to get the correct `delegator`
|
|
47354
|
-
const { stateUpdate } = await this.accumulateSingleService(newV, [], accumulateData.getOperands(newV), accumulateData.
|
|
47478
|
+
const { stateUpdate } = await this.accumulateSingleService(newV, [], accumulateData.getOperands(newV), accumulateData.getGasLimit(newV), slot, entropy, checkpoint);
|
|
47355
47479
|
const correctV = stateUpdate?.privilegedServices?.delegator ?? this.state.privilegedServices.delegator;
|
|
47356
47480
|
currentState.privilegedServices = PrivilegedServices.create({
|
|
47357
47481
|
...currentState.privilegedServices,
|
|
@@ -47417,7 +47541,7 @@ class Accumulate {
|
|
|
47417
47541
|
*/
|
|
47418
47542
|
getGasLimit() {
|
|
47419
47543
|
const calculatedGasLimit = GAS_TO_INVOKE_WORK_REPORT * BigInt(this.chainSpec.coresCount) +
|
|
47420
|
-
this.state.privilegedServices.autoAccumulateServices.reduce((acc,
|
|
47544
|
+
Array.from(this.state.privilegedServices.autoAccumulateServices.values()).reduce((acc, gasLimit) => acc + gasLimit, 0n);
|
|
47421
47545
|
const gasLimit = tryAsServiceGas(this.chainSpec.maxBlockGas > calculatedGasLimit ? this.chainSpec.maxBlockGas : calculatedGasLimit);
|
|
47422
47546
|
return tryAsServiceGas(gasLimit);
|
|
47423
47547
|
}
|
|
@@ -47570,9 +47694,8 @@ class DeferredTransfers {
|
|
|
47570
47694
|
consumedGas = (await executor.run(args, tryAsGas(gas))).consumedGas;
|
|
47571
47695
|
}
|
|
47572
47696
|
transferStatistics.set(serviceId, { count: numbers_tryAsU32(transfers.length), gasUsed: tryAsServiceGas(consumedGas) });
|
|
47573
|
-
const [updatedState
|
|
47697
|
+
const [updatedState] = partialState.getStateUpdates();
|
|
47574
47698
|
currentStateUpdate = updatedState;
|
|
47575
|
-
debug_check `${checkpointedState === null} On transfer cannot invoke checkpoint.`;
|
|
47576
47699
|
}
|
|
47577
47700
|
return result_Result.ok({
|
|
47578
47701
|
// NOTE: we return only services, since it's impossible to update
|
|
@@ -48889,7 +49012,6 @@ class Statistics {
|
|
|
48889
49012
|
|
|
48890
49013
|
|
|
48891
49014
|
|
|
48892
|
-
|
|
48893
49015
|
class DbHeaderChain {
|
|
48894
49016
|
blocks;
|
|
48895
49017
|
constructor(blocks) {
|
|
@@ -48960,7 +49082,7 @@ class OnChain {
|
|
|
48960
49082
|
// chapter 13: https://graypaper.fluffylabs.dev/#/68eaa1f/18b60118b601?v=0.6.4
|
|
48961
49083
|
statistics;
|
|
48962
49084
|
isReadyForNextEpoch = Promise.resolve(false);
|
|
48963
|
-
constructor(chainSpec, state, blocks, hasher, pvm
|
|
49085
|
+
constructor(chainSpec, state, blocks, hasher, pvm) {
|
|
48964
49086
|
this.chainSpec = chainSpec;
|
|
48965
49087
|
this.state = state;
|
|
48966
49088
|
this.hasher = hasher;
|
|
@@ -52697,7 +52819,15 @@ Usage:
|
|
|
52697
52819
|
Options:
|
|
52698
52820
|
--name Override node name. Affects networking key and db location.
|
|
52699
52821
|
[default: ${NODE_DEFAULTS.name}]
|
|
52700
|
-
--config
|
|
52822
|
+
--config Configuration directives. If specified more than once, they are evaluated and merged from left to right.
|
|
52823
|
+
A configuration directive can be a path to a config file, an inline JSON object, a pseudo-jq query or one of predefined configs ['${DEV_CONFIG}', '${DEFAULT_CONFIG}'].
|
|
52824
|
+
Pseudo-jq queries are a way to modify the config using a subset of jq syntax.
|
|
52825
|
+
Example: --config=dev --config=.chain_spec+={"bootnodes": []} -- will modify only the bootnodes property of the chain spec (merge).
|
|
52826
|
+
Example: --config=dev --config=.chain_spec={"bootnodes": []} -- will replace the entire chain spec property with the provided JSON object.
|
|
52827
|
+
Example: --config=dev --config=.chain_spec+=bootnodes.json -- you may also use JSON files in your queries. This one will merge the contents of bootnodes.json onto the chain spec.
|
|
52828
|
+
Example: --config=dev --config={"chain_spec": { "bootnodes": [] }} -- will merge the provided JSON object onto the "dev" config.
|
|
52829
|
+
Example: --config=dev --config=bootnodes.json -- will merge the contents of bootnodes.json onto the "dev" config.
|
|
52830
|
+
Example: --config=custom-config.json -- will use the contents of custom-config.json as the config.
|
|
52701
52831
|
[default: ${NODE_DEFAULTS.config}]
|
|
52702
52832
|
--pvm PVM Backend, one of: [${PvmBackendNames.join(", ")}].
|
|
52703
52833
|
[default: ${PvmBackendNames[NODE_DEFAULTS.pvm]}]
|
|
@@ -52716,9 +52846,9 @@ var Command;
|
|
|
52716
52846
|
/** Run as a Fuzz Target. */
|
|
52717
52847
|
Command["FuzzTarget"] = "fuzz-target";
|
|
52718
52848
|
})(Command || (Command = {}));
|
|
52719
|
-
function parseSharedOptions(args,
|
|
52849
|
+
function parseSharedOptions(args, defaultConfig = NODE_DEFAULTS.config) {
|
|
52720
52850
|
const { name } = parseStringOption(args, "name", (v) => v, NODE_DEFAULTS.name);
|
|
52721
|
-
const { config } =
|
|
52851
|
+
const { config } = parseValueOptionAsArray(args, "config", "string", (v) => (v === "" ? null : v), defaultConfig);
|
|
52722
52852
|
const { pvm } = parseStringOption(args, "pvm", (v) => {
|
|
52723
52853
|
const pvm = PvmBackendNames.indexOf(v);
|
|
52724
52854
|
if (pvm >= 0) {
|
|
@@ -52728,7 +52858,7 @@ function parseSharedOptions(args, withRelPath, defaultConfig = NODE_DEFAULTS.con
|
|
|
52728
52858
|
}, NODE_DEFAULTS.pvm);
|
|
52729
52859
|
return {
|
|
52730
52860
|
nodeName: name,
|
|
52731
|
-
|
|
52861
|
+
config,
|
|
52732
52862
|
pvm,
|
|
52733
52863
|
};
|
|
52734
52864
|
}
|
|
@@ -52741,12 +52871,12 @@ function parseArgs(input, withRelPath) {
|
|
|
52741
52871
|
}
|
|
52742
52872
|
switch (command) {
|
|
52743
52873
|
case Command.Run: {
|
|
52744
|
-
const data = parseSharedOptions(args
|
|
52874
|
+
const data = parseSharedOptions(args);
|
|
52745
52875
|
assertNoMoreArgs(args);
|
|
52746
52876
|
return { command: Command.Run, args: data };
|
|
52747
52877
|
}
|
|
52748
52878
|
case Command.Dev: {
|
|
52749
|
-
const data = parseSharedOptions(args,
|
|
52879
|
+
const data = parseSharedOptions(args, [DEV_CONFIG]);
|
|
52750
52880
|
const index = args._.shift();
|
|
52751
52881
|
if (index === undefined) {
|
|
52752
52882
|
throw new Error("Missing dev-validator index.");
|
|
@@ -52759,7 +52889,7 @@ function parseArgs(input, withRelPath) {
|
|
|
52759
52889
|
return { command: Command.Dev, args: { ...data, index: numIndex } };
|
|
52760
52890
|
}
|
|
52761
52891
|
case Command.FuzzTarget: {
|
|
52762
|
-
const data = parseSharedOptions(args
|
|
52892
|
+
const data = parseSharedOptions(args);
|
|
52763
52893
|
const { version } = parseValueOption(args, "version", "number", parseFuzzVersion, 1);
|
|
52764
52894
|
const socket = args._.shift() ?? null;
|
|
52765
52895
|
assertNoMoreArgs(args);
|
|
@@ -52773,7 +52903,7 @@ function parseArgs(input, withRelPath) {
|
|
|
52773
52903
|
};
|
|
52774
52904
|
}
|
|
52775
52905
|
case Command.Import: {
|
|
52776
|
-
const data = parseSharedOptions(args
|
|
52906
|
+
const data = parseSharedOptions(args);
|
|
52777
52907
|
const files = args._.map((f) => withRelPath(f));
|
|
52778
52908
|
args._ = [];
|
|
52779
52909
|
assertNoMoreArgs(args);
|
|
@@ -52786,7 +52916,7 @@ function parseArgs(input, withRelPath) {
|
|
|
52786
52916
|
};
|
|
52787
52917
|
}
|
|
52788
52918
|
case Command.Export: {
|
|
52789
|
-
const data = parseSharedOptions(args
|
|
52919
|
+
const data = parseSharedOptions(args);
|
|
52790
52920
|
const output = args._.shift();
|
|
52791
52921
|
if (output === undefined) {
|
|
52792
52922
|
throw new Error("Missing output directory.");
|
|
@@ -52810,6 +52940,29 @@ function parseArgs(input, withRelPath) {
|
|
|
52810
52940
|
function parseStringOption(args, option, parser, defaultValue) {
|
|
52811
52941
|
return parseValueOption(args, option, "string", parser, defaultValue);
|
|
52812
52942
|
}
|
|
52943
|
+
function parseValueOptionAsArray(args, option, typeOfX, parser, defaultValue) {
|
|
52944
|
+
if (args[option] === undefined) {
|
|
52945
|
+
return {
|
|
52946
|
+
[option]: defaultValue,
|
|
52947
|
+
};
|
|
52948
|
+
}
|
|
52949
|
+
const vals = Array.isArray(args[option]) ? args[option] : [args[option]];
|
|
52950
|
+
delete args[option];
|
|
52951
|
+
const parsedVals = vals.reduce((result, val) => {
|
|
52952
|
+
const valType = typeof val;
|
|
52953
|
+
if (valType !== typeOfX) {
|
|
52954
|
+
throw new Error(`Option '--${option}' requires an argument of type: ${typeOfX}, got: ${valType}.`);
|
|
52955
|
+
}
|
|
52956
|
+
const parsed = parser(val);
|
|
52957
|
+
if (parsed !== null) {
|
|
52958
|
+
result.push(parsed);
|
|
52959
|
+
}
|
|
52960
|
+
return result;
|
|
52961
|
+
}, []);
|
|
52962
|
+
return {
|
|
52963
|
+
[option]: parsedVals.length > 0 ? parsedVals : defaultValue,
|
|
52964
|
+
};
|
|
52965
|
+
}
|
|
52813
52966
|
function parseValueOption(args, option, typeOfX, parser, defaultValue) {
|
|
52814
52967
|
const val = args[option];
|
|
52815
52968
|
if (val === undefined) {
|
|
@@ -52817,6 +52970,9 @@ function parseValueOption(args, option, typeOfX, parser, defaultValue) {
|
|
|
52817
52970
|
[option]: defaultValue,
|
|
52818
52971
|
};
|
|
52819
52972
|
}
|
|
52973
|
+
if (Array.isArray(val)) {
|
|
52974
|
+
throw new Error(`Option '--${option}' has been specified more than once. Only one value was expected.`);
|
|
52975
|
+
}
|
|
52820
52976
|
delete args[option];
|
|
52821
52977
|
const valType = typeof val;
|
|
52822
52978
|
if (valType !== typeOfX) {
|
|
@@ -52890,9 +53046,9 @@ running.catch((e) => {
|
|
|
52890
53046
|
console.error(`${e}`);
|
|
52891
53047
|
process.exit(-1);
|
|
52892
53048
|
});
|
|
52893
|
-
async function prepareConfigFile(args, blake2b) {
|
|
53049
|
+
async function prepareConfigFile(args, blake2b, withRelPath) {
|
|
52894
53050
|
const { nodeName: defaultNodeName } = args.args;
|
|
52895
|
-
const nodeConfig = loadConfig(args.args.
|
|
53051
|
+
const nodeConfig = loadConfig(args.args.config, withRelPath);
|
|
52896
53052
|
const nodeName = args.command === Command.Dev ? devNodeName(defaultNodeName, args.args.index) : defaultNodeName;
|
|
52897
53053
|
const devPortShift = args.command === Command.Dev ? args.args.index : 0;
|
|
52898
53054
|
const devBootnodes = args.command === Command.Dev
|
|
@@ -52920,7 +53076,7 @@ async function prepareConfigFile(args, blake2b) {
|
|
|
52920
53076
|
}
|
|
52921
53077
|
async function startNode(args, withRelPath) {
|
|
52922
53078
|
const blake2b = await blake2b_Blake2b.createHasher();
|
|
52923
|
-
const jamNodeConfig = await prepareConfigFile(args, blake2b);
|
|
53079
|
+
const jamNodeConfig = await prepareConfigFile(args, blake2b, withRelPath);
|
|
52924
53080
|
// Start fuzz-target
|
|
52925
53081
|
if (args.command === Command.FuzzTarget) {
|
|
52926
53082
|
const version = args.args.version;
|
|
@@ -52960,6 +53116,7 @@ function devNetworkingSeed(blake2b, name) {
|
|
|
52960
53116
|
var __webpack_exports__Command = __webpack_exports__.uB;
|
|
52961
53117
|
var __webpack_exports__HELP = __webpack_exports__._$;
|
|
52962
53118
|
var __webpack_exports__parseArgs = __webpack_exports__.Zy;
|
|
52963
|
-
|
|
53119
|
+
var __webpack_exports__parseSharedOptions = __webpack_exports__.P3;
|
|
53120
|
+
export { __webpack_exports__Command as Command, __webpack_exports__HELP as HELP, __webpack_exports__parseArgs as parseArgs, __webpack_exports__parseSharedOptions as parseSharedOptions };
|
|
52964
53121
|
|
|
52965
53122
|
//# sourceMappingURL=index.js.map
|