@typeberry/jam 0.0.5-d373345 → 0.0.5-f91bac5
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/importer/index.js +15 -43
- package/importer/index.js.map +1 -1
- package/index.js +634 -7747
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/bootstrap-bandersnatch.mjs +0 -162
- package/bootstrap-bandersnatch.mjs.map +0 -1
package/importer/index.js
CHANGED
|
@@ -3561,7 +3561,6 @@ var __webpack_exports__ = {};
|
|
|
3561
3561
|
|
|
3562
3562
|
// EXPORTS
|
|
3563
3563
|
__nccwpck_require__.d(__webpack_exports__, {
|
|
3564
|
-
F: () => (/* binding */ createImporter),
|
|
3565
3564
|
i: () => (/* binding */ main)
|
|
3566
3565
|
});
|
|
3567
3566
|
|
|
@@ -24438,8 +24437,7 @@ function verifyRefineContexts(minLookupSlot, contexts, recentBlocksPartialUpdate
|
|
|
24438
24437
|
*
|
|
24439
24438
|
* https://graypaper.fluffylabs.dev/#/5f542d7/155c01155f01
|
|
24440
24439
|
*/
|
|
24441
|
-
const isInChain = recentBlocks.has(context.lookupAnchor) ||
|
|
24442
|
-
headerChain.isAncestor(context.lookupAnchorSlot, context.lookupAnchor, context.anchor);
|
|
24440
|
+
const isInChain = recentBlocks.has(context.lookupAnchor) || headerChain.isAncestor(context.lookupAnchor);
|
|
24443
24441
|
if (!isInChain) {
|
|
24444
24442
|
if (process.env.SKIP_LOOKUP_ANCHOR_CHECK !== undefined) {
|
|
24445
24443
|
verify_contextual_logger.warn(`Lookup anchor check for ${context.lookupAnchor} would fail, but override is active.`);
|
|
@@ -25147,25 +25145,11 @@ class DbHeaderChain {
|
|
|
25147
25145
|
constructor(blocks) {
|
|
25148
25146
|
this.blocks = blocks;
|
|
25149
25147
|
}
|
|
25150
|
-
isAncestor(
|
|
25151
|
-
|
|
25152
|
-
|
|
25153
|
-
|
|
25154
|
-
|
|
25155
|
-
return true;
|
|
25156
|
-
}
|
|
25157
|
-
const current = this.blocks.getHeader(currentHash);
|
|
25158
|
-
// fail if we don't find a parent (unlikely?)
|
|
25159
|
-
if (current === null) {
|
|
25160
|
-
return false;
|
|
25161
|
-
}
|
|
25162
|
-
// fail if we went pass that time slot index
|
|
25163
|
-
if (current.timeSlotIndex.materialize() < pastHeaderSlot) {
|
|
25164
|
-
return false;
|
|
25165
|
-
}
|
|
25166
|
-
// move one block up
|
|
25167
|
-
currentHash = current.parentHeaderHash.materialize();
|
|
25168
|
-
}
|
|
25148
|
+
isAncestor(header) {
|
|
25149
|
+
// TODO [ToDr] This works only for simple forks scenario. We rather
|
|
25150
|
+
// should make sure that the `header` we are checking is a descendant
|
|
25151
|
+
// of the current header (i.e. there is a direct path when going by parent).
|
|
25152
|
+
return this.blocks.getHeader(header) !== null;
|
|
25169
25153
|
}
|
|
25170
25154
|
}
|
|
25171
25155
|
const OFFENDERS_ERROR = "offenders not matching header";
|
|
@@ -25652,7 +25636,7 @@ function importerStateMachine() {
|
|
|
25652
25636
|
return new machine_StateMachine("importer", initialized, [initialized, ready, finished]);
|
|
25653
25637
|
}
|
|
25654
25638
|
const state_machine_logger = Logger.new(import.meta.filename, "importer");
|
|
25655
|
-
const
|
|
25639
|
+
const importBlockCodec = descriptors_codec.custom({
|
|
25656
25640
|
name: "Result<StateRootHash, string>",
|
|
25657
25641
|
sizeHint: { bytes: 1, isExact: false },
|
|
25658
25642
|
}, (e, x) => {
|
|
@@ -25720,7 +25704,7 @@ class MainReady extends State {
|
|
|
25720
25704
|
async importBlock(port, block) {
|
|
25721
25705
|
const res = await port.sendRequest("importBlock", block, [block.buffer]);
|
|
25722
25706
|
if (res instanceof Uint8Array) {
|
|
25723
|
-
return decoder_Decoder.decodeObject(
|
|
25707
|
+
return decoder_Decoder.decodeObject(importBlockCodec, res);
|
|
25724
25708
|
}
|
|
25725
25709
|
return result_Result.error("Invalid worker response.");
|
|
25726
25710
|
}
|
|
@@ -25768,9 +25752,6 @@ class ImporterReady extends State {
|
|
|
25768
25752
|
this.importer = importer;
|
|
25769
25753
|
this.onImporter.emit();
|
|
25770
25754
|
}
|
|
25771
|
-
setConfig(config) {
|
|
25772
|
-
this.data = config;
|
|
25773
|
-
}
|
|
25774
25755
|
getConfig() {
|
|
25775
25756
|
if (this.data === null) {
|
|
25776
25757
|
throw new Error("Did not receive chain spec config!");
|
|
@@ -25847,7 +25828,7 @@ class ImporterReady extends State {
|
|
|
25847
25828
|
state_machine_logger.error(`${e instanceof Error ? e.stack : ""}`);
|
|
25848
25829
|
response = result_Result.error(`${e}`);
|
|
25849
25830
|
}
|
|
25850
|
-
const encoded = encoder_Encoder.encodeObject(
|
|
25831
|
+
const encoded = encoder_Encoder.encodeObject(importBlockCodec, response);
|
|
25851
25832
|
return {
|
|
25852
25833
|
response: encoded.raw,
|
|
25853
25834
|
};
|
|
@@ -25896,18 +25877,6 @@ if (!external_node_worker_threads_namespaceObject.isMainThread) {
|
|
|
25896
25877
|
channel.then((channel) => main(channel)).catch((e) => importer_logger.error(e));
|
|
25897
25878
|
}
|
|
25898
25879
|
const keccakHasher = KeccakHasher.create();
|
|
25899
|
-
async function createImporter(config) {
|
|
25900
|
-
const lmdb = new LmdbRoot(config.dbPath);
|
|
25901
|
-
const blocks = new LmdbBlocks(config.chainSpec, lmdb);
|
|
25902
|
-
const states = new LmdbStates(config.chainSpec, lmdb);
|
|
25903
|
-
const hasher = new TransitionHasher(config.chainSpec, await keccakHasher, new allocator_SimpleAllocator());
|
|
25904
|
-
const importer = new Importer(config.chainSpec, hasher, importer_logger, blocks, states);
|
|
25905
|
-
return {
|
|
25906
|
-
lmdb,
|
|
25907
|
-
blocks,
|
|
25908
|
-
importer,
|
|
25909
|
-
};
|
|
25910
|
-
}
|
|
25911
25880
|
/**
|
|
25912
25881
|
* The `BlockImporter` listens to `block` signals, where it expects
|
|
25913
25882
|
* RAW undecoded block objects (typically coming from the network).
|
|
@@ -25921,7 +25890,11 @@ async function main(channel) {
|
|
|
25921
25890
|
const ready = await channel.waitForState("ready(importer)");
|
|
25922
25891
|
const finished = await ready.doUntil("finished", async (worker, port) => {
|
|
25923
25892
|
const config = worker.getConfig();
|
|
25924
|
-
const
|
|
25893
|
+
const lmdb = new LmdbRoot(config.dbPath);
|
|
25894
|
+
const blocks = new LmdbBlocks(config.chainSpec, lmdb);
|
|
25895
|
+
const states = new LmdbStates(config.chainSpec, lmdb);
|
|
25896
|
+
const hasher = new TransitionHasher(config.chainSpec, await keccakHasher, new allocator_SimpleAllocator());
|
|
25897
|
+
const importer = new Importer(config.chainSpec, hasher, importer_logger, blocks, states);
|
|
25925
25898
|
// TODO [ToDr] this is shit, since we have circular dependency.
|
|
25926
25899
|
worker.setImporter(importer);
|
|
25927
25900
|
importer_logger.info("📥 Importer waiting for blocks.");
|
|
@@ -25982,8 +25955,7 @@ async function main(channel) {
|
|
|
25982
25955
|
finished.currentState().close(channel);
|
|
25983
25956
|
}
|
|
25984
25957
|
|
|
25985
|
-
var __webpack_exports__createImporter = __webpack_exports__.F;
|
|
25986
25958
|
var __webpack_exports__main = __webpack_exports__.i;
|
|
25987
|
-
export {
|
|
25959
|
+
export { __webpack_exports__main as main };
|
|
25988
25960
|
|
|
25989
25961
|
//# sourceMappingURL=index.js.map
|