@typeberry/jam 0.4.1-0a3acb2 → 0.4.1-8408216

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.
@@ -11811,7 +11811,7 @@ class BlockVerifier {
11811
11811
  this.hasher = hasher;
11812
11812
  this.blocks = blocks;
11813
11813
  }
11814
- async verifyBlock(block) {
11814
+ async verifyBlock(block, options = { skipParentAndStateRoot: false }) {
11815
11815
  const headerView = block.header.view();
11816
11816
  const headerHash = this.hasher.header(headerView);
11817
11817
  // check if current block is already imported
@@ -11823,7 +11823,7 @@ class BlockVerifier {
11823
11823
  // https://graypaper.fluffylabs.dev/#/cc517d7/0c9d000c9d00?v=0.6.5
11824
11824
  const parentHash = headerView.parentHeaderHash.materialize();
11825
11825
  // importing genesis block
11826
- if (!parentHash.isEqualTo(block_verifier_ZERO_HASH)) {
11826
+ if (!parentHash.isEqualTo(block_verifier_ZERO_HASH) && !options.skipParentAndStateRoot) {
11827
11827
  const parentBlock = this.blocks.getHeader(parentHash);
11828
11828
  if (parentBlock === null) {
11829
11829
  return Result.error(BlockVerifierError.ParentNotFound, () => `Parent ${parentHash.toString()} not found`);
@@ -11843,21 +11843,20 @@ class BlockVerifier {
11843
11843
  if (!extrinsicHash.isEqualTo(extrinsicMerkleCommitment.hash)) {
11844
11844
  return Result.error(BlockVerifierError.InvalidExtrinsic, () => `Invalid extrinsic hash: ${extrinsicHash.toString()}, expected ${extrinsicMerkleCommitment.hash.toString()}`);
11845
11845
  }
11846
- // Check if the state root is valid.
11847
- // https://graypaper.fluffylabs.dev/#/cc517d7/0c18010c1801?v=0.6.5
11848
- const stateRoot = headerView.priorStateRoot.materialize();
11849
- const posteriorStateRoot = this.blocks.getPostStateRoot(parentHash);
11850
- if (posteriorStateRoot === null) {
11851
- return Result.error(BlockVerifierError.StateRootNotFound, () => `Posterior state root ${parentHash.toString()} not found`);
11852
- }
11853
- if (!stateRoot.isEqualTo(posteriorStateRoot)) {
11854
- return Result.error(BlockVerifierError.InvalidStateRoot, () => `Invalid prior state root: ${stateRoot.toString()}, expected ${posteriorStateRoot.toString()} (ours)`);
11846
+ if (!options.skipParentAndStateRoot) {
11847
+ // Check if the state root is valid.
11848
+ // https://graypaper.fluffylabs.dev/#/ab2cdbd/0c73010c7301?v=0.7.2
11849
+ const stateRoot = headerView.priorStateRoot.materialize();
11850
+ const posteriorStateRoot = this.blocks.getPostStateRoot(parentHash);
11851
+ if (posteriorStateRoot === null) {
11852
+ return Result.error(BlockVerifierError.StateRootNotFound, () => `Posterior state root ${parentHash.toString()} not found`);
11853
+ }
11854
+ if (!stateRoot.isEqualTo(posteriorStateRoot)) {
11855
+ return Result.error(BlockVerifierError.InvalidStateRoot, () => `Invalid prior state root: ${stateRoot.toString()}, expected ${posteriorStateRoot.toString()} (ours)`);
11856
+ }
11855
11857
  }
11856
11858
  return Result.ok(headerHash.hash);
11857
11859
  }
11858
- hashHeader(block) {
11859
- return this.hasher.header(block.header.view());
11860
- }
11861
11860
  }
11862
11861
 
11863
11862
  ;// CONCATENATED MODULE: ./packages/jam/transition/disputes/disputes-error-code.ts