Skip to content

Remove compact encoding bound from BaseArithmetic - #12394

Open
rossbulat wants to merge 5 commits into
paritytech:masterfrom
rossbulat:rb/fix-arithmetic-compact-traits
Open

Remove compact encoding bound from BaseArithmetic#12394
rossbulat wants to merge 5 commits into
paritytech:masterfrom
rossbulat:rb/fix-arithmetic-compact-traits

Conversation

@rossbulat

Copy link
Copy Markdown
Contributor

Summary

Fixes #1144.

This removes the compact-encoding requirement from BaseArithmetic, allowing signed integer types to satisfy the general arithmetic traits. Compact encoding remains required on the unsigned arithmetic traits and at the specific call sites that actually compact-encode values.

Changes

  • Remove HasCompact from BaseArithmetic.
  • Add HasCompact to:
    • AtLeast8BitUnsigned
    • AtLeast16BitUnsigned
    • AtLeast32BitUnsigned
  • Add explicit compact bounds to call sites that rely on compact encoding:
    • pallet_timestamp::Config::Moment
    • pallet_indices::Config::AccountIndex
    • bp_runtime::Chain::Nonce
  • Require HasCompact<Type: DecodeWithMemTracking> where compact-decoded types participate in memory-tracked decoding.

Rationale

AtLeast32Bit is the signed-or-unsigned arithmetic trait, but it previously inherited HasCompact through BaseArithmetic. Since compact encoding is only implemented for unsigned integer types today, this prevented signed integers such as i128 from implementing AtLeast32Bit.

The compact-encoding requirement belongs on unsigned-specific traits and concrete compact-encoding use sites, not on the shared base arithmetic trait.

Validation

SKIP_WASM_BUILD=1 \
SKIP_PALLET_REVIVE_FIXTURES=1 \
cargo check --workspace

git diff --check

@rossbulat
rossbulat requested a review from a team as a code owner June 16, 2026 14:57
@paritytech-review-bot
paritytech-review-bot Bot requested a review from a team June 16, 2026 14:58
@rossbulat

Copy link
Copy Markdown
Contributor Author

cc'ing @xlc for review as he opened the original issue.

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.

Not possible to implement AtLeast32Bit for signed number

1 participant