@typeberry/jam 0.3.0 → 0.3.1-27dfdd9

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.js CHANGED
@@ -31617,7 +31617,7 @@ const DEFAULT_CONFIG = "default";
31617
31617
  const NODE_DEFAULTS = {
31618
31618
  name: isBrowser() ? "browser" : external_node_os_default().hostname(),
31619
31619
  config: [DEFAULT_CONFIG],
31620
- pvm: PvmBackend.BuiltIn,
31620
+ pvm: PvmBackend.Ananas,
31621
31621
  };
31622
31622
  /** Chain spec chooser. */
31623
31623
  var KnownChainSpec;
@@ -36587,15 +36587,19 @@ class InMemorySerializedStates {
36587
36587
  async updateAndSetState(header, state, update) {
36588
36588
  const blake2b = this.blake2b;
36589
36589
  const updatedValues = serializeStateUpdate(this.spec, blake2b, update);
36590
- const { values, leafs } = updateLeafs(state.backend.leafs, blake2b, updatedValues);
36590
+ // make sure to clone the leafs before writing, since the collection is re-used.
36591
+ const newLeafs = SortedSet.fromSortedArray(leafComparator, state.backend.leafs.array);
36592
+ const { values, leafs } = updateLeafs(newLeafs, blake2b, updatedValues);
36593
+ // make sure to reset the cache and re-create leafsdb lookup
36594
+ state.updateBackend(LeafDb.fromLeaves(leafs, state.backend.db));
36591
36595
  // insert values to the db
36592
36596
  // valuesdb can be shared between all states because it's just
36593
36597
  // <valuehash> -> <value> mapping and existence is managed by trie leafs.
36594
36598
  for (const val of values) {
36595
36599
  this.valuesDb.set(val[0], val[1]);
36596
36600
  }
36597
- // make sure to clone the leafs before writing, since the collection is re-used.
36598
- this.db.set(header, SortedSet.fromSortedArray(leafComparator, leafs.slice()));
36601
+ // store new set of leaves
36602
+ this.db.set(header, leafs);
36599
36603
  return result_Result.ok(result_OK);
36600
36604
  }
36601
36605
  getState(header) {
@@ -36884,7 +36888,12 @@ class LmdbStates {
36884
36888
  async updateAndSetState(headerHash, state, update) {
36885
36889
  const updatedValues = serializeStateUpdate(this.spec, this.blake2b, update);
36886
36890
  // and finally we insert new values and store leaves in the DB.
36887
- return await this.updateAndCommit(headerHash, state.backend.leafs, updatedValues);
36891
+ const res = await this.updateAndCommit(headerHash, state.backend.leafs, updatedValues);
36892
+ if (res.isOk) {
36893
+ // update the internal backend with new leaves.
36894
+ state.updateBackend(LeafDb.fromLeaves(state.backend.leafs, state.backend.db));
36895
+ }
36896
+ return res;
36888
36897
  }
36889
36898
  async getStateRoot(state) {
36890
36899
  return state.backend.getStateRoot(this.blake2b);
@@ -49690,13 +49699,6 @@ class Importer {
49690
49699
  logger.error `🧱 Unable to update state: ${result_resultToString(updateResult)}`;
49691
49700
  return importerError(ImporterErrorKind.Update, updateResult);
49692
49701
  }
49693
- const newState = this.states.getState(headerHash);
49694
- if (newState === null) {
49695
- throw new Error("Freshly updated state not in the DB?");
49696
- }
49697
- // TODO [ToDr] This is a temporary measure. We should rather read
49698
- // the state of a parent block to support forks and create a fresh STF.
49699
- this.state.updateBackend(newState.backend);
49700
49702
  this.prepareForNextEpoch();
49701
49703
  this.currentHash = headerHash;
49702
49704
  logger.log `${timerState()}`;
@@ -49705,7 +49707,7 @@ class Importer {
49705
49707
  const writeBlocks = this.blocks.insertBlock(new hash_WithHash(headerHash, block));
49706
49708
  // Computation of the state root may happen asynchronously,
49707
49709
  // but we still need to wait for it before next block can be imported
49708
- const stateRoot = await this.states.getStateRoot(newState);
49710
+ const stateRoot = await this.states.getStateRoot(this.state);
49709
49711
  logger.log `🧱 Storing post-state-root for ${headerHash}: ${stateRoot}.`;
49710
49712
  const writeStateRoot = this.blocks.setPostStateRoot(headerHash, stateRoot);
49711
49713
  await Promise.all([writeBlocks, writeStateRoot]);
@@ -52419,7 +52421,7 @@ function initializeExtensions(api) {
52419
52421
  }
52420
52422
 
52421
52423
  ;// CONCATENATED MODULE: ./packages/jam/node/package.json
52422
- const package_namespaceObject = {"rE":"0.3.0"};
52424
+ const package_namespaceObject = {"rE":"0.3.1"};
52423
52425
  ;// CONCATENATED MODULE: ./packages/workers/block-generator/generator.ts
52424
52426
 
52425
52427
 
@@ -53053,7 +53055,7 @@ function readJsonBlock(file, chainSpec) {
53053
53055
  var minimist = __nccwpck_require__(8595);
53054
53056
  var minimist_default = /*#__PURE__*/__nccwpck_require__.n(minimist);
53055
53057
  ;// CONCATENATED MODULE: ./bin/jam/package.json
53056
- const jam_package_namespaceObject = {"rE":"0.3.0"};
53058
+ const jam_package_namespaceObject = {"rE":"0.3.1"};
53057
53059
  ;// CONCATENATED MODULE: ./bin/jam/args.ts
53058
53060
 
53059
53061