Skip to content

Commit

Permalink
don't panic when Session.Validators storage doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
eldargab committed Sep 15, 2023
1 parent 22df36a commit e3979ff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@subsquid/substrate-data",
"comment": "don't panic when `Session.Validators` storage doesn't exist",
"type": "patch"
}
],
"packageName": "@subsquid/substrate-data"
}
2 changes: 2 additions & 0 deletions substrate/substrate-data/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export class Parser {
}

private async setValidators(blocks: RawBlock[]): Promise<void> {
blocks = blocks.filter(b => b.runtime!.hasStorageItem('Session.Validators'))

if (blocks.length == 0) return

let prev = this.prevValidators.get(blocks[0].height)
Expand Down
5 changes: 4 additions & 1 deletion substrate/substrate-data/src/parsing/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ class BlockParser {

@def
validator(): AccountId | undefined {
if (this.runtime.checkType(this.runtime.description.digestItem, DigestItem)) {
if (
this.runtime.hasStorageItem('Session.Validators') &&
this.runtime.checkType(this.runtime.description.digestItem, DigestItem)
) {
let digest = this.digest() as IDigestItem[]
let validators = assertNotNull(this.src.validators, 'validator data is not provided')
return getBlockValidator(digest, validators)
Expand Down

0 comments on commit e3979ff

Please sign in to comment.