hardening: add static assertion for WASM mavros stub type layout

Open Beginner friendly
#341 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
rust, wasm
Domain
backend

Research direction

Start in provekit/common/src/mavros.rs, where the WASM stub types for WitnessLayout and ConstraintsLayout are defined, and compare them with the native mavros_vm types. Add the requested native-target compile-time layout checks or a postcard roundtrip test; done means layout divergence is caught clearly while WASM remains unsupported.

Written by the indexing model from the issue text.

Description

Context

From PR #246 review: the WASM stub types for WitnessLayout and ConstraintsLayout in provekit/common/src/mavros.rs must exactly mirror the real mavros_vm types for postcard serialization compatibility. Currently enforced only by a comment.

If mavros_vm adds a field, the stubs silently diverge and deserialization fails with a confusing error instead of the clean "Mavros prover is not supported on WASM" message.

Proposed Fix

Add a compile-time size assertion on native targets:

#[cfg(not(target_arch = "wasm32"))]
const _: () = {
    assert!(std::mem::size_of::<mavros_vm::WitnessLayout>() == 5 * std::mem::size_of::<usize>());
    assert!(std::mem::size_of::<mavros_vm::ConstraintsLayout>() == 3 * std::mem::size_of::<usize>());
};

Or a test that roundtrips both real and stub types through postcard to verify wire compatibility.

Dominant language
Noir
Stars
138
Forks
47
Avg merge
1d 34m
Merged PRs (30d)
6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from worldfnd/provekit

All issues in worldfnd/provekit

Similar issues

More Backend & API Design issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.