paritytech / paritytech/parity-scale-codec

More `codec` edge cases

Open
#555 1 comment 1 reaction 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

https://github.com/paritytech/parity-scale-codec/issues/507 covers one but there are two more:

  • Two codec attributes can be applied to the same variant with no warning,
  • meanwhile a variant can have no codec attribute and there is no warning.

For example:

enum Foo {
    #[codec(index = 0)]
    #[codec(index = 1)]
    A,
    B,
}

This kind of bug can happen due to a copy/paste mistake or a mistake when resolving a merge conflict (as it did to me). When there are many attributes this kind of mistake can be hard to spot. In my case it resulted in the decoded value being different from the original value before encoding, which made for a fun debugging session.

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

Start by reviewing the linked issue 507 and reproducing the enum example with duplicate and missing codec attributes. The work is done when both invalid cases produce warnings and the existing codec behavior remains covered by appropriate tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.