Skip to content

Add support for ext_trie_blake2_256_verify_proof host functions#2221

Open
x3c41a wants to merge 1 commit intosmol-dot:mainfrom
x3c41a:ndk/add-verify-proof-host-functions
Open

Add support for ext_trie_blake2_256_verify_proof host functions#2221
x3c41a wants to merge 1 commit intosmol-dot:mainfrom
x3c41a:ndk/add-verify-proof-host-functions

Conversation

@x3c41a
Copy link
Copy Markdown
Contributor

@x3c41a x3c41a commented Mar 20, 2026

Summary

Implemented ext_trie_blake2_256_verify_proof_version_1 and _version_2 host functions

Uses the existing proof_decode module to decode and verify the Merkle proof, look up the key, and compare against the expected value. Handles state version V1 where values >= 33 bytes are stored as blake2b hashes.

Motivation

Chopsticks uses smoldot for WASM execution and fails on runtimes that call these host functions (e.g. Polkadot Bulletin Chain's pallet-transaction-storage).

Reference issue - paritytech/polkadot-bulletin-chain#341

Implement ext_trie_blake2_256_verify_proof_version_1 and _version_2
which were previously stubbed with host_fn_not_implemented!(). These
host functions are needed by runtimes that perform Merkle proof
verification, such as Polkadot Bulletin Chain's pallet-transaction-storage.

The implementation uses smoldot's existing proof_decode module to decode
and verify the proof, then looks up the key and compares against the
expected value. For state version V1 (version_2 only), hashed storage
values (>= 33 bytes) are handled by comparing blake2b hashes.
@x3c41a x3c41a force-pushed the ndk/add-verify-proof-host-functions branch from e74b774 to 8b546d7 Compare March 20, 2026 13:16
Copy link
Copy Markdown
Contributor

@tomaka tomaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you!
If you've tried that it works, then it's good to go.


### Added

- Add support for the `ext_trie_blake2_256_verify_proof_version_1` and `ext_trie_blake2_256_verify_proof_version_2` host functions. These are used by runtimes that perform Merkle proof verification (e.g. Polkadot Bulletin Chain's `pallet-transaction-storage`).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Add support for the `ext_trie_blake2_256_verify_proof_version_1` and `ext_trie_blake2_256_verify_proof_version_2` host functions. These are used by runtimes that perform Merkle proof verification (e.g. Polkadot Bulletin Chain's `pallet-transaction-storage`).
- Add support for the `ext_trie_blake2_256_verify_proof_version_1` and `ext_trie_blake2_256_verify_proof_version_2` host functions. ([#2221](https://github.com/smol-dot/smoldot/pull/2221))

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.

2 participants