Skip to content

feat(macros): make manifest topic drift a compile-time failure - #108

Open
mfw78 wants to merge 2 commits into
types/t2-manifest-valuesfrom
types/t3-topic-parity
Open

feat(macros): make manifest topic drift a compile-time failure#108
mfw78 wants to merge 2 commits into
types/t2-manifest-valuesfrom
types/t3-topic-parity

Conversation

@mfw78

@mfw78 mfw78 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

What

Makes the #[nexum_sdk::module] macro fail the build when a module's
module.toml event_signature does not match the topic-0 of the event
type named in the attribute.

Parity checking is opt-in per module and names both sides (manifest hash
and computed SIGNATURE_HASH) when they drift, so a mismatch is caught
mechanically instead of by a per-module hand-written test.

Adds a topic-parity fixture crate under modules/fixtures/ and wires it
into the CI wasm build matrix and the local justfile build/ci targets.

Why

The on-chain topic a module subscribes to was stated twice: once in code
via sol!/SIGNATURE_HASH, and once in module.toml as event_signature,
which is what the host actually filters on. Nothing kept the two in step.

ethflow-watcher had no guard at all, so a drift there would be silent:
the host subscribes to one topic, the guest decodes another, and the
module never sees the event. twap-monitor's hand-written parity test was
itself found to be a substring match that would have passed while the real
event_signature had drifted.

This closes the gap by construction at compile time rather than relying on
per-module tests, while keeping module.toml as the operator-auditable
admission surface.

Closes #49

Testing

  • cargo nextest run --workspace --all-features --no-fail-fast
  • cargo test --doc
  • CI wasm build matrix extended to build the new topic-parity fixture
    (cargo build --release --target wasm32-wasip2 -p topic-parity, alongside
    the other fixture crates)
  • justfile build-fixtures and ci targets updated to include
    -p topic-parity so the fixture is exercised locally the same way as CI

AI Assistance

Implementation by Claude (Fable 5), red-team review by Claude Opus 5, PR by Claude Sonnet 5.

mfw78 added 2 commits August 6, 2026 12:26
AI Assistance: Claude (Fable 5) used for implementation and tests
AI Assistance: Claude Opus 5 used for red-team review and the fixes.
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