@typeberry/jam 0.5.1-31343a9 → 0.5.1-45102d3
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-importer.mjs +8 -4
- package/bootstrap-importer.mjs.map +1 -1
- package/index.js +32 -19
- package/index.js.map +1 -1
- package/package.json +1 -1
package/bootstrap-importer.mjs
CHANGED
|
@@ -29070,6 +29070,7 @@ class Importer {
|
|
|
29070
29070
|
logger;
|
|
29071
29071
|
blocks;
|
|
29072
29072
|
states;
|
|
29073
|
+
options;
|
|
29073
29074
|
verifier;
|
|
29074
29075
|
stf;
|
|
29075
29076
|
// TODO [ToDr] we cannot assume state reference does not change.
|
|
@@ -29077,11 +29078,12 @@ class Importer {
|
|
|
29077
29078
|
// Hash of the block that we have the posterior state for in `state`.
|
|
29078
29079
|
currentHash;
|
|
29079
29080
|
metrics;
|
|
29080
|
-
constructor(spec, pvm, hasher, logger, blocks, states) {
|
|
29081
|
+
constructor(spec, pvm, hasher, logger, blocks, states, options = {}) {
|
|
29081
29082
|
this.hasher = hasher;
|
|
29082
29083
|
this.logger = logger;
|
|
29083
29084
|
this.blocks = blocks;
|
|
29084
29085
|
this.states = states;
|
|
29086
|
+
this.options = options;
|
|
29085
29087
|
this.metrics = createMetrics();
|
|
29086
29088
|
const currentBestHeaderHash = this.blocks.getBestHeaderHash();
|
|
29087
29089
|
const state = states.getState(currentBestHeaderHash);
|
|
@@ -29136,7 +29138,9 @@ class Importer {
|
|
|
29136
29138
|
logger.log `🧱 Attempting to import a new block`;
|
|
29137
29139
|
const timerVerify = measure("import:verify");
|
|
29138
29140
|
const verifyStart = now();
|
|
29139
|
-
const hash = await this.verifier.verifyBlock(block
|
|
29141
|
+
const hash = await this.verifier.verifyBlock(block, {
|
|
29142
|
+
skipParentAndStateRoot: this.options.initGenesisFromAncestry ?? false,
|
|
29143
|
+
});
|
|
29140
29144
|
const verifyDuration = now() - verifyStart;
|
|
29141
29145
|
logger.log `${timerVerify()}`;
|
|
29142
29146
|
if (hash.isError) {
|
|
@@ -29239,14 +29243,14 @@ function extractTimeSlot(block) {
|
|
|
29239
29243
|
const main_logger = Logger.new(import.meta.filename, "importer");
|
|
29240
29244
|
const keccakHasher = KeccakHasher.create();
|
|
29241
29245
|
const blake2b = Blake2b.createHasher();
|
|
29242
|
-
async function createImporter(config) {
|
|
29246
|
+
async function createImporter(config, options = {}) {
|
|
29243
29247
|
const chainSpec = config.chainSpec;
|
|
29244
29248
|
const db = config.openDatabase({ readonly: false });
|
|
29245
29249
|
const pvm = config.workerParams.pvm;
|
|
29246
29250
|
const blocks = db.getBlocksDb();
|
|
29247
29251
|
const states = db.getStatesDb();
|
|
29248
29252
|
const hasher = new TransitionHasher(await keccakHasher, await blake2b);
|
|
29249
|
-
const importer = new Importer(chainSpec, pvm, hasher, main_logger, blocks, states);
|
|
29253
|
+
const importer = new Importer(chainSpec, pvm, hasher, main_logger, blocks, states, options);
|
|
29250
29254
|
return {
|
|
29251
29255
|
importer,
|
|
29252
29256
|
db,
|