Skip to content

Conversation

@JoeCap08055
Copy link
Collaborator

@JoeCap08055 JoeCap08055 commented Dec 10, 2025

Goal

The goal of this PR is to enable building a WASM runtime that can be used directly with Chopsticks to build blocks.
Chopsticks runs its own node code that does not include Frequency's custom host functions. While it is possible to instruct Chopsticks to ignore unresolved host function references when loading the WASM, there remains the problem that any runtime calls to the unresolved host function(s) will result in a WASM trap/abort.

This PR adds a new Cargo feature flag, no-host-functions, that causes the WASM runtime to be compiled without any compile-time OR runtime references to custom host functions, thereby enabling such a runtime to be used to produce blocks when running under Chopsticks.

Usage

In order to build a WASM runtime suitable for using with Chopsticks, see the README

Checklist

  • Updated Readme?

…nction references, suitable for using with Chopsticks
Copy link
Collaborator

@enddynayn enddynayn left a comment

Choose a reason for hiding this comment

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

Nice! 👍

Copy link
Collaborator

@aramikm aramikm left a comment

Choose a reason for hiding this comment

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

You need to bump the version for runtime since you are adding a new runtime

@codecov
Copy link

codecov bot commented Dec 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
common/primitives/src/offchain.rs 88.75% <ø> (ø)
pallets/msa/src/lib.rs 92.38% <100.00%> (+0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions bot added the metadata-changed Metadata has changed since the latest full release label Dec 10, 2025
@github-actions github-actions bot added metadata-changed Metadata has changed since the latest full release and removed metadata-changed Metadata has changed since the latest full release labels Dec 10, 2025
@github-actions github-actions bot removed the metadata-changed Metadata has changed since the latest full release label Dec 26, 2025
Comment on lines +270 to +273
// Block reindex_offchain if we've disabled custom host functions
#[cfg(feature = "no-custom-host-functions")]
RuntimeCall::Msa(pallet_msa::Call::reindex_offchain { .. }) => false,

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Keeping consistent with existing precedent: rather than remove this extrinsic from the pallet (which would cause metadata to be different), if custom host functions are disabled we simply filter the call.

@github-actions github-actions bot added the metadata-changed Metadata has changed since the latest full release label Dec 26, 2025
@github-actions github-actions bot removed the metadata-changed Metadata has changed since the latest full release label Dec 30, 2025
@github-actions github-actions bot added the metadata-changed Metadata has changed since the latest full release label Dec 30, 2025
@JoeCap08055 JoeCap08055 requested a review from demisx as a code owner January 2, 2026 15:41
@github-actions github-actions bot removed the metadata-changed Metadata has changed since the latest full release label Jan 2, 2026
- name: Set Up Cargo Deny
run: |
cargo install --force --locked cargo-deny@0.18.5
cargo install --force --locked cargo-deny@0.18.9
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Had to bump cargo-deny because the latest advisory DB was not parseable with 0.18.5. Selected the current latest, 0.18.9

{ id = "RUSTSEC-2025-0057", reason = "Remove when https://github.com/paritytech/polkadot-sdk/pull/8714 is merged into a stable release. (Should be in stable2509 tag)"},
{ id = "RUSTSEC-2025-0118", reason = "Remove when polkadot-sdk updates to a fixed wasmtime."}
{ id = "RUSTSEC-2025-0118", reason = "Remove when polkadot-sdk updates to a fixed wasmtime."},
{ id = "RUSTSEC-2025-0137", reason = "Transitive dependency polkadot-sdk => alloy-primitives => ruint; Fixed ruint >= 1.17.1. No dependency fixes upstream yet." }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added an exception. No fixes yet in the dependency path; probably not until polkadot-sdk@stable2603 at least.

@github-actions github-actions bot added the metadata-changed Metadata has changed since the latest full release label Jan 2, 2026
@github-actions github-actions bot added metadata-changed Metadata has changed since the latest full release and removed metadata-changed Metadata has changed since the latest full release labels Jan 2, 2026
Copy link
Collaborator

@aramikm aramikm left a comment

Choose a reason for hiding this comment

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

Looks great!

@JoeCap08055 JoeCap08055 merged commit 36bc001 into main Jan 5, 2026
35 checks passed
@JoeCap08055 JoeCap08055 deleted the feat/no-host-functions branch January 5, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

metadata-changed Metadata has changed since the latest full release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants