Skip to content

Fix/per block runtime decoding - #7

Merged
nol4lej merged 3 commits into
mainfrom
fix/per-block-runtime-decoding
Oct 5, 2026
Merged

nol4lej merged 3 commits into
mainfrom
fix/per-block-runtime-decoding

Conversation

@nol4lej

@nol4lej nol4lej commented Oct 5, 2026

Copy link
Copy Markdown
Member

Summary

Release 0.7.1, with no API changes.

  • Fix: each block is decoded with its own runtime's metadata. getDynamicBuilder(blockHash?) and getExtrinsicDecoder(blockHash?) fetch the metadata of the runtime a block executed under, over RPC, once per spec_version. queryBlockEvents passes its hash. Before, the metadata cached at connect decoded every block, so at spec 17 every earlier shield misdecoded, and a long-lived session misdecoded blocks after an upgrade. Without a hash, behaviour is unchanged.
  • Fix: the shield commitment is validated on every path. assertShieldParams requires a 32-byte hex commitment. The pallet call now refuses what the precompile calldata already refused.
  • Refactor: SubstrateClient is split by responsibility.
    • runtimeDecoders: metadata and decoders per runtime. Each decoder is built on first use, and a failed fetch is retried instead of cached.
    • eventRecords: System.Events → EventRecord.
    • blockInfo: block time from timestamp.set and author from the digest.
    • getBlock is split into resolveBlockHash and readTimestamp.
    • The connected runtime's metadata is now fetched once for both decoders, instead of once by each.
    • The public API is unchanged: extractAuthorFromLogs and the DynamicBuilder / ExtrinsicDecoder types are still exported from SubstrateClient.

Test plan

  • pnpm run check: 899 passed
    • per-runtime cache
    • concurrent first fetch downloads metadata once
    • retry after a failed fetch
    • unknown block is not cached
    • only the requested decoder is built
    • timestamp fallback edge cases
    • commitment validation
  • pnpm audit: no known vulnerabilities
  • pnpm pack --dry-run
  • Against a spec 17 dev node: every extrinsic and the events of every block decode with the block hash. The indexer and privacy-explorer read shields correctly.

@nol4lej
nol4lej merged commit 851d66c into main Oct 5, 2026
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant