fix: make serde a non-optional dependency of pallas-primitives#779
Conversation
The crate gated `serde` behind the `json` feature, but used
`serde::{Serialize, Deserialize}` unconditionally across the era
models, so building with `default-features = false` failed to
compile. Since `pallas-codec` and `pallas-crypto` already depend on
serde unconditionally, gating it here gave no real benefit anyway.
The `json` feature now gates only `serde_json`. A CI job checks
pallas-primitives in isolation, since a workspace-wide
`--no-default-features` build unifies the feature back on.
Fixes #740
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR fixes and validates the issue where ChangesSerde Dependency and No-Default-Features Support
Possibly related PRs
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
Summary
pallas-primitivesdeclaredserdeas an optional dependency gated behind thejsonfeature, but the era models (lib.rs,plutus_data.rs,alonzo/model.rs,babbage/model.rs,conway/model.rs,conway/script_data.rs) useserde::{Serialize, Deserialize}and#[serde(...)]attributes unconditionally. Building the crate withdefault-features = falsetherefore failed withE0432: unresolved import \serde``.Rather than
#[cfg(feature = "json")]-gating ~90 derive/attribute sites, this makesserdea plain (non-optional) dependency:pallas-codecandpallas-cryptoalready depend onserdeunconditionally, so any consumer ofpallas-primitives— even withdefault-features = false— already compiles serde transitively. The "optional" gating provided no real benefit; it only broke the build.jsonfeature now gates onlyserde_json(theto_jsonAPI inframework.rs/alonzo/json.rs), which was already correctly#[cfg]-gated.Why CI didn't catch this
The existing
featuresjob runscargo check --workspace --no-default-features, but a workspace-wide build unifies features across members — other crates depend onpallas-primitiveswith default features, sojson(and serde) was always pulled back in. This PR adds anisolated-featuresjob runningcargo check -p pallas-primitives --no-default-features, which builds the crate on its own and would have caught the regression.Verification
cargo build -p pallas-primitives(default) — okcargo build -p pallas-primitives --no-default-features— ok (previously failed)cargo build --workspace— okcargo test -p pallas-primitives— okFixes #740
🤖 Generated with Claude Code
Summary by CodeRabbit