@typeberry/jam 0.5.0-70ae055 → 0.5.0-7f94e30
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/bootstrap-generator.mjs +32 -23
- package/bootstrap-generator.mjs.map +1 -1
- package/bootstrap-importer.mjs +35 -26
- package/bootstrap-importer.mjs.map +1 -1
- package/index.js +35 -26
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -163000,12 +163000,15 @@ class Accumulate {
|
|
|
163000
163000
|
chainSpec;
|
|
163001
163001
|
blake2b;
|
|
163002
163002
|
state;
|
|
163003
|
-
|
|
163004
|
-
constructor(chainSpec, blake2b, state,
|
|
163003
|
+
options;
|
|
163004
|
+
constructor(chainSpec, blake2b, state, options) {
|
|
163005
163005
|
this.chainSpec = chainSpec;
|
|
163006
163006
|
this.blake2b = blake2b;
|
|
163007
163007
|
this.state = state;
|
|
163008
|
-
this.
|
|
163008
|
+
this.options = options;
|
|
163009
|
+
if (options.accumulateSequentially === true) {
|
|
163010
|
+
accumulate_logger.warn `⚠️ Parallel accumulation is disabled. Running in sequential mode.`;
|
|
163011
|
+
}
|
|
163009
163012
|
}
|
|
163010
163013
|
/**
|
|
163011
163014
|
* Returns an index that determines how many WorkReports can be processed before exceeding a given gasLimit.
|
|
@@ -163057,7 +163060,7 @@ class Accumulate {
|
|
|
163057
163060
|
serviceExternalities: partialState,
|
|
163058
163061
|
fetchExternalities,
|
|
163059
163062
|
};
|
|
163060
|
-
const executor = await PvmExecutor.createAccumulateExecutor(serviceId, code, externalities, this.chainSpec, this.pvm);
|
|
163063
|
+
const executor = await PvmExecutor.createAccumulateExecutor(serviceId, code, externalities, this.chainSpec, this.options.pvm);
|
|
163061
163064
|
const invocationArgs = encoder_Encoder.encodeObject(ARGS_CODEC, {
|
|
163062
163065
|
slot,
|
|
163063
163066
|
serviceId,
|
|
@@ -163274,6 +163277,9 @@ class Accumulate {
|
|
|
163274
163277
|
];
|
|
163275
163278
|
return resultEntry;
|
|
163276
163279
|
});
|
|
163280
|
+
if (this.options.accumulateSequentially === true) {
|
|
163281
|
+
await promise;
|
|
163282
|
+
}
|
|
163277
163283
|
resultPromises[serviceIndex] = promise;
|
|
163278
163284
|
}
|
|
163279
163285
|
return Promise.all(resultPromises).then((results) => new Map(results));
|
|
@@ -163505,6 +163511,7 @@ class DeferredTransfers {
|
|
|
163505
163511
|
|
|
163506
163512
|
|
|
163507
163513
|
|
|
163514
|
+
|
|
163508
163515
|
;// CONCATENATED MODULE: ./packages/jam/transition/authorization.ts
|
|
163509
163516
|
|
|
163510
163517
|
|
|
@@ -165940,22 +165947,23 @@ class Statistics {
|
|
|
165940
165947
|
const newPreImagesSize = current[authorIndex].preImagesSize + preImagesSize;
|
|
165941
165948
|
current[authorIndex].preImagesSize = numbers_tryAsU32(newPreImagesSize);
|
|
165942
165949
|
/**
|
|
165943
|
-
*
|
|
165944
|
-
* Kappa' is not needed because we can use validator indexes directly from guarantees extrinsic.
|
|
165945
|
-
* I asked a question to ensure it is true but I didn't get any response yet:
|
|
165946
|
-
* https://github.com/w3f/jamtestvectors/pull/28#discussion_r190723700
|
|
165950
|
+
* Update guarantees
|
|
165947
165951
|
*
|
|
165948
|
-
* https://graypaper.fluffylabs.dev/#/
|
|
165952
|
+
* https://graypaper.fluffylabs.dev/#/ab2cdbd/19ea0119f201?v=0.7.2
|
|
165949
165953
|
*/
|
|
165950
|
-
const
|
|
165951
|
-
for (const
|
|
165952
|
-
|
|
165953
|
-
|
|
165954
|
-
|
|
165955
|
-
|
|
165956
|
-
|
|
165957
|
-
|
|
165954
|
+
const validatorKeys = input.currentValidatorData.map((v) => v.ed25519);
|
|
165955
|
+
for (const reporter of input.reporters) {
|
|
165956
|
+
const index = validatorKeys.findIndex((x) => x.isEqualTo(reporter));
|
|
165957
|
+
if (index === -1) {
|
|
165958
|
+
/**
|
|
165959
|
+
* it should never happen because:
|
|
165960
|
+
* 1. the extrinsic is verified in reports transition
|
|
165961
|
+
* 2. we use current validators set from safrole
|
|
165962
|
+
*/
|
|
165963
|
+
continue;
|
|
165958
165964
|
}
|
|
165965
|
+
const newGuaranteesCount = current[index].guarantees + 1;
|
|
165966
|
+
current[index].guarantees = numbers_tryAsU32(newGuaranteesCount);
|
|
165959
165967
|
}
|
|
165960
165968
|
for (const { validatorIndex } of extrinsic.assurances) {
|
|
165961
165969
|
const newAssurancesCount = current[validatorIndex].assurances + 1;
|
|
@@ -166127,7 +166135,7 @@ class OnChain {
|
|
|
166127
166135
|
// chapter 13: https://graypaper.fluffylabs.dev/#/68eaa1f/18b60118b601?v=0.6.4
|
|
166128
166136
|
statistics;
|
|
166129
166137
|
isReadyForNextEpoch = Promise.resolve(false);
|
|
166130
|
-
constructor(chainSpec, state, hasher,
|
|
166138
|
+
constructor(chainSpec, state, hasher, options, headerChain) {
|
|
166131
166139
|
this.chainSpec = chainSpec;
|
|
166132
166140
|
this.state = state;
|
|
166133
166141
|
this.hasher = hasher;
|
|
@@ -166139,9 +166147,9 @@ class OnChain {
|
|
|
166139
166147
|
this.disputes = new Disputes(chainSpec, hasher.blake2b, state);
|
|
166140
166148
|
this.reports = new Reports(chainSpec, hasher.blake2b, state, headerChain);
|
|
166141
166149
|
this.assurances = new Assurances(chainSpec, state, hasher.blake2b);
|
|
166142
|
-
this.accumulate = new Accumulate(chainSpec, hasher.blake2b, state,
|
|
166150
|
+
this.accumulate = new Accumulate(chainSpec, hasher.blake2b, state, options);
|
|
166143
166151
|
this.accumulateOutput = new AccumulateOutput();
|
|
166144
|
-
this.deferredTransfers = new DeferredTransfers(chainSpec, hasher.blake2b, state, pvm);
|
|
166152
|
+
this.deferredTransfers = new DeferredTransfers(chainSpec, hasher.blake2b, state, options.pvm);
|
|
166145
166153
|
this.preimages = new Preimages(state, hasher.blake2b);
|
|
166146
166154
|
this.authorization = new Authorization(chainSpec, state);
|
|
166147
166155
|
}
|
|
@@ -166229,8 +166237,7 @@ class OnChain {
|
|
|
166229
166237
|
if (reportsResult.isError) {
|
|
166230
166238
|
return stfError(StfErrorKind.Reports, reportsResult);
|
|
166231
166239
|
}
|
|
166232
|
-
|
|
166233
|
-
const { reported: workPackages, reporters: _, stateUpdate: reportsUpdate, ...reportsRest } = reportsResult.ok;
|
|
166240
|
+
const { reported: workPackages, reporters, stateUpdate: reportsUpdate, ...reportsRest } = reportsResult.ok;
|
|
166234
166241
|
assertEmpty(reportsRest);
|
|
166235
166242
|
const { availabilityAssignment: reportsAvailAssignment, ...reportsUpdateRest } = reportsUpdate;
|
|
166236
166243
|
assertEmpty(reportsUpdateRest);
|
|
@@ -166244,7 +166251,7 @@ class OnChain {
|
|
|
166244
166251
|
}
|
|
166245
166252
|
const { preimages, ...preimagesRest } = preimagesResult.ok;
|
|
166246
166253
|
assertEmpty(preimagesRest);
|
|
166247
|
-
const timerAccumulate = measure(`import:accumulate (${PvmBackend[this.accumulate.pvm]})`);
|
|
166254
|
+
const timerAccumulate = measure(`import:accumulate (${PvmBackend[this.accumulate.options.pvm]})`);
|
|
166248
166255
|
// accumulate
|
|
166249
166256
|
const accumulateResult = await this.accumulate.transition({
|
|
166250
166257
|
slot: timeSlot,
|
|
@@ -166304,6 +166311,8 @@ class OnChain {
|
|
|
166304
166311
|
availableReports,
|
|
166305
166312
|
accumulationStatistics,
|
|
166306
166313
|
transferStatistics,
|
|
166314
|
+
reporters: reporters,
|
|
166315
|
+
currentValidatorData,
|
|
166307
166316
|
});
|
|
166308
166317
|
const { statistics, ...statisticsRest } = statisticsUpdate;
|
|
166309
166318
|
assertEmpty(statisticsRest);
|
|
@@ -166555,7 +166564,7 @@ class Importer {
|
|
|
166555
166564
|
throw new Error(`Unable to load best state from header hash: ${currentBestHeaderHash}.`);
|
|
166556
166565
|
}
|
|
166557
166566
|
this.verifier = new BlockVerifier(hasher, blocks);
|
|
166558
|
-
this.stf = new OnChain(spec, state, hasher, pvm, DbHeaderChain.new(blocks));
|
|
166567
|
+
this.stf = new OnChain(spec, state, hasher, { pvm, accumulateSequentially: false }, DbHeaderChain.new(blocks));
|
|
166559
166568
|
this.state = state;
|
|
166560
166569
|
this.currentHash = currentBestHeaderHash;
|
|
166561
166570
|
this.prepareForNextEpoch();
|
|
@@ -166708,11 +166717,11 @@ const blake2b = blake2b_Blake2b.createHasher();
|
|
|
166708
166717
|
async function createImporter(config) {
|
|
166709
166718
|
const chainSpec = config.chainSpec;
|
|
166710
166719
|
const db = config.openDatabase({ readonly: false });
|
|
166711
|
-
const
|
|
166720
|
+
const pvm = config.workerParams.pvm;
|
|
166712
166721
|
const blocks = db.getBlocksDb();
|
|
166713
166722
|
const states = db.getStatesDb();
|
|
166714
166723
|
const hasher = new hasher_TransitionHasher(await keccakHasher, await blake2b);
|
|
166715
|
-
const importer = new Importer(chainSpec,
|
|
166724
|
+
const importer = new Importer(chainSpec, pvm, hasher, main_logger, blocks, states);
|
|
166716
166725
|
return {
|
|
166717
166726
|
importer,
|
|
166718
166727
|
db,
|