fix: emit generic metas as a rain meta document, not a bare cbor map - #272
Open
thedavidmeister wants to merge 1 commit into
Open
fix: emit generic metas as a rain meta document, not a bare cbor map#272thedavidmeister wants to merge 1 commit into
thedavidmeister wants to merge 1 commit into
Conversation
generate_emit_meta_calldata built emitMeta calldata whose meta was item.cbor_encode() — the bare cbor map, no 0xff0a89c674ee7874 prefix. IMetaBoardV1_2.emitMeta reverts NotRainMetaV1 on exactly that, so every call this function generated was unsubmittable. Closes #192 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Warning Review limit reachedNext included review available in 18 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Closes #192.
The issue filed this "flagged, not adjudicated" — the sol half adjudicates it
#192 asks whether the bare-map framing might be deliberate for this API. It is
not, and the deciding fact is in this repo rather than only in the spec.
generate_emit_meta_calldatabuilds calldata forIMetaBoardV1_2.emitMeta(subject, meta). That entry point isLibIMetaBoardV1_2.emitMeta, whose whole body is:checkMetaUnhashedV1revertsNotRainMetaV1unless the first 8 bytes are0xff0a89c674ee7874(src/lib/LibMeta.sol), andIMetaBoardV1_2states it asa contract-level MUST: "
IMetaBoardV1_2contracts MUST revert any metadata thatdoes not start with the Rain metadata magic number."
So this was not a spec-vs-implementation ambiguity with two liveable answers.
Every calldata this function has ever produced reverts on any conforming
metaboard. There is no exemption to document — a "documented exemption" would
have documented a function that cannot be used for its stated purpose.
Two further in-repo oracles agree:
Store::store_content(crates/cli/src/meta/mod.rs) caches inner items onlyif bytes.starts_with(&KnownMagic::RainMetaDocumentV1.to_prefix_bytes())—this repo's own reader already discards unprefixed blobs, which is the spec
MUST generate_emit_meta_calldata emits meta bytes without the rain-meta-document-v1 magic prefix the metadata-v1 spec requires #192 quotes, implemented.
generate_dotrain_source_emit_tx_data, the sibling emit path, has alwaysprefixed.
Changes
crates/cli/src/metaboard.rsonly:generate_emit_meta_calldata's meta is nowcbor_encode_seq(&vec![meta], KnownMagic::RainMetaDocumentV1)instead ofmeta.cbor_encode(). A one-item cbor-seq under the magic — which is whathash(true)andgenerate_dotrain_source_emit_tx_dataalready build, so itintroduces no new framing.
test_generate_emit_meta_calldata_success's meta pin follows.test_emit_meta_bytes_are_a_rain_meta_document.What deliberately did NOT change: the subject
The subject stays
meta.hash(false)— keccak256 of the BARE cbor item. #192 isabout the meta bytes only, and the bare item hash is the key
Storeinsertsinner items under (
keccak256(meta_map.cbor_encode())instore_content), soit is the item's identity in this codebase rather than an arbitrary third
digest. That the subject and the emitted bytes are now over different preimages
looks like an inconsistency at a glance, so the docstring says it is on purpose;
that is the whole of the comment added.
Relation to #247 (
2026-08-25-issue-158)#247 touches the same module and no overlapping line. It changes only
generate_dotrain_source_emit_tx_data's subject (cbor item hash → contenthash) and leaves that path's meta bytes prefixed as they already were. This PR
changes only
generate_emit_meta_calldata's meta bytes and leaves itssubject alone. #247's body names the split itself: "the generic
generate_emit_meta_calldatastill keys onmeta.hash(false), which is adifferent question (#192)."
Both branch off the same
origin/main(45ca96c). Their metaboard.rs hunks aredisjoint — #247 rewrites the impl body of
generate_dotrain_source_emit_tx_dataand the tail of
test_generate_dotrain_source_emit_tx_data_success; this onerewrites the body of
generate_emit_meta_calldataand the head oftest_generate_emit_meta_calldata_success— so whichever merges second shouldmerge clean, and neither changes a value the other asserts.
Behaviour change
generate_emit_meta_calldataispuband re-exported at the crate root, sothis is wire-visible on a shipped library API: same input, different calldata,
8 bytes longer meta. Called out rather than buried. No in-org consumer exists —
gh search code "generate_emit_meta_calldata org:rainlanguage"returns thisrepo's own module and nothing else — and the previous output could not have been
successfully submitted anywhere, so no working caller can regress.
QA
metaboard::tests::test_emit_meta_bytes_are_a_rain_meta_document(new) and
metaboard::tests::test_generate_emit_meta_calldata_success(metapin rewritten) — each fails on base, verified by reverting only the impl hunk
in place (
let meta_bytes = meta.cbor_encode()?, tests untouched) andre-running: both FAILED, 8 passed / 2 failed. On the fixed tree
cargo test -p rain-metadata --lib metaboard::is 10 passed / 0 failed.crates/cli/src/metaboard.rslet meta_bytes = RainMetaDocumentV1Item::cbor_encode_seq(&vec![meta], crate::KnownMagic::RainMetaDocumentV1)?;→
let meta_bytes = meta.cbor_encode()?;(the original bug is the mutant) →killed by
test_emit_meta_bytes_are_a_rain_meta_document(
left: "a3004c7465737420", the bare cbor map header, vsright: "ff0a89c674ee7874") and bytest_generate_emit_meta_calldata_success(emitted meta 8 bytes short).KnownMagic::RainMetaDocumentV1→KnownMagic::DotrainSourceV1— prefixed but with the WRONG magic → killedby both (
left: "ffa15ef0fc437099"), so the new test pins the specificmagic and not merely "has some prefix".
in one file and the working tree is clean against it.
ff0a89c674ee7874asserted directly against the emittedbytes, not routed through
KnownMagic— the same constanttest/interface/MetaMagicNumberV1.t.solpins on the sol side, and the valuequoted in generate_emit_meta_calldata emits meta bytes without the rain-meta-document-v1 magic prefix the metadata-v1 spec requires #192 and in
rainprotocol/specsmetadata-v1.md. The new test alsoround-trips
cbor_decodeback to the original item and assertsemitted[8..] == meta.cbor_encode(), so the prefix is added and nothing elseis. The behavioural authority is
LibMeta.isRainMetaV1in this repo, which iswhat actually accepts or rejects the calldata.
rain-meta-document-v1 magic the spec requires, and (B) an explicit decision
between prefixing here too and documenting why this path is exempt. Covered A
by prefixing. Covered B by deciding, with the reason on the record: exempting
is not available, because
IMetaBoardV1_2.emitMeta— the only consumer ofthis calldata — reverts
NotRainMetaV1on unprefixed meta. generate_emit_meta_calldata emits meta bytes without the rain-meta-document-v1 magic prefix the metadata-v1 spec requires #192's own"possibly deliberate" hypotheses are both refuted: there is no wrapping
caller (no in-org consumer at all), and whether the subgraph checks the prefix
is moot since the event it indexes is never emitted. The subject question
generate_emit_meta_calldata emits meta bytes without the rain-meta-document-v1 magic prefix the metadata-v1 spec requires #192 does not ask is left alone and stated above.
CopyArtifactsor manifestcoupling is in play.
cargo fmt --all -- --checkandcargo clippy --workspace --all-targets -- -D warningsare both clean. Perthe task brief the wider suite is left to CI (~70 sibling agents on this box).
🤖 Generated with Claude Code
CI
rainix-rs / static / rs-staticfails on therustfmt-conditionalhook with"Failed to find targets" before it reads a single file. It fails the same way on
mainitself (45ca96c, 6fe2e2b, 9c65a23 allfailure) and on unrelated PRs,so it is a rainix hook bug and not this change. Every other lane is green.