paritytech / paritytech/parity-scale-codec

Allow for more than 256 variant enum: encode variant with compact encoding for integer.

Open
#305 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
287
Forks
103
Avg merge
6d 13h
Merged PRs (30d)
1

Description

As proposed by Gav: we should allow for enum with more than 256 variants, and we can do encoding of the variant index using compact encoding of integers. This way this is not breaking for enum with 0-63 variants.

For the transition we can follow this:

  • having 2 new attributes when deriving encode/decode for enum:
    • compact_variant_index (or a better name)
    • u8_variant_index
  • then we can deprecate the derivation of encode/decode on enum without any attribute
  • then we can force to use one of the 2 attributes
  • then we can make the default being compact_variant_index.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue does not name files or tests. Start by locating the enum Encode/Decode derivation and the existing compact integer encoding, then trace how variant indexes are encoded. Done means supporting enums with more than 256 variants while preserving compatibility for enums with 0–63 variants and implementing the proposed attribute transition.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.