Support JAM codec for bounded collections#914
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR decouples the bounded collections’ codec implementation from a hard dependency on scale-codec by making the codec used optional with feature flags and adding support for jam-codec. Key changes include re-exporting scale-codec as codec in primitive-types, updating dependencies and Cargo.toml files, and refactoring codec implementations across bounded collections using conditional compilation macros.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| primitive-types/impls/codec/src/lib.rs | Re-exports scale-codec as codec to enable optional codec selection. |
| primitive-types/impls/codec/Cargo.toml | Updates dependency references from codec to scale-codec. |
| bounded-collections/src/weak_bounded_vec.rs | Removes unconditional codec impls and adds a macro-based conditional implementation for scale-codec and jam-codec. |
| bounded-collections/src/bounded_vec.rs | Updates attribute derivations and refactors codec decoding via macros. |
| bounded-collections/src/bounded_btree_set.rs | Refactors codec implementations using macros for both codec libraries. |
| bounded-collections/src/bounded_btree_map.rs | Refactors codec implementations and removes deprecated helper structs for decoding. |
| bounded-collections/Cargo.toml | Updates dependency definitions and versions to support jam-codec. |
| bounded-collections/CHANGELOG.md | Adds a new changelog entry documenting the JAM codec support. |
| Cargo.toml | Updates root dependency from codec to scale-codec. |
Comments suppressed due to low confidence (1)
bounded-collections/src/bounded_btree_map.rs:429
- [nitpick] Consider renaming the macro to a more specific name (e.g., 'bounded_btree_map_codec_impl') to enhance clarity and prevent potential name conflicts in larger modules.
macro_rules! codec_impl {
bkchr
approved these changes
May 22, 2025
Member
bkchr
left a comment
There was a problem hiding this comment.
Besides the dependency that should be moved, it looks good.
arkpar
approved these changes
May 26, 2025
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.
Previously,
bounded-collectionswas tightly coupled toscale-codec, which posed limitations as our usage evolved.For now, in PolkaJam, we're relying on a temporary fork:
bounded-collections-nextwith these changes applied. However, our long-term goal is to havejam-codecsupported upstream.This PR introduces the following changes:
scale-codecas the default for backward compatibility).jam-codecandscale-codecshare an identical API (different in their implementations of integers compact encoding).