feat(macros): make manifest topic drift a compile-time failure - #108
Open
mfw78 wants to merge 2 commits into
Open
feat(macros): make manifest topic drift a compile-time failure#108mfw78 wants to merge 2 commits into
mfw78 wants to merge 2 commits into
Conversation
AI Assistance: Claude (Fable 5) used for implementation and tests
AI Assistance: Claude Opus 5 used for red-team review and the fixes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Makes the
#[nexum_sdk::module]macro fail the build when a module'smodule.tomlevent_signaturedoes not match the topic-0 of the eventtype 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 caughtmechanically instead of by a per-module hand-written test.
Adds a
topic-parityfixture crate undermodules/fixtures/and wires itinto the CI wasm build matrix and the local
justfilebuild/ci targets.Why
The on-chain topic a module subscribes to was stated twice: once in code
via
sol!/SIGNATURE_HASH, and once inmodule.tomlasevent_signature,which is what the host actually filters on. Nothing kept the two in step.
ethflow-watcherhad 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 wasitself found to be a substring match that would have passed while the real
event_signaturehad drifted.This closes the gap by construction at compile time rather than relying on
per-module tests, while keeping
module.tomlas the operator-auditableadmission surface.
Closes #49
Testing
cargo nextest run --workspace --all-features --no-fail-fastcargo test --doctopic-parityfixture(
cargo build --release --target wasm32-wasip2 -p topic-parity, alongsidethe other fixture crates)
justfilebuild-fixturesandcitargets updated to include-p topic-parityso the fixture is exercised locally the same way as CIAI Assistance
Implementation by Claude (Fable 5), red-team review by Claude Opus 5, PR by Claude Sonnet 5.