AcalaNetwork / chopsticks

Create parallel reality of your Substrate network.
Apache License 2.0
133 stars 80 forks source link

Mismatch between configuration and runtime return for u32 storage item #605

Closed laurogripa closed 9 months ago

laurogripa commented 9 months ago

I'm trying to change the value of this storage item: https://github.com/paritytech/substrate/blob/308e6464204d855f18ad0bfd931148cdb2b5dfea/frame/society/src/lib.rs#L683-L685

This is my storage section in the configuration file:

  Society:
    $removePrefix:
      - Bids
      - Candidates
      - Members
      - MemberCount
    Bids:
      - who: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # Alice
        kind:
          Deposit: 1
        value: 299000000000000
    Candidates:
      -
        -
          - 5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty # Bob
        - round: 2
          kind:
            Deposit: 33333333000
          bid: 500000000000000
          tally:
            approvals: 1
            rejections: 0
          skepticStruck: false
    Members:
      -
        -
          - 5HGjWAeFDfFCWPsjFQdVV2Msvz2XtMktvgocEZcCj68kUMaw # Eve
        - rank: 0
          strikes: 5
          index: 0
      -
        -
          - 5CiPPseXPECbkjWCa6MnjNokrgYjMqmKndv2rSnekmSK2DjL # Ferdie
        - rank: 1
          strikes: 0
          index: 1
    MemberCount: 2

Everything works completely fine, except for the MemberCount, it's yielding 33554432 instead of 2. Seems like a binary conversion error, or am I doing something wrong? Any suggestions?

EDIT: adding screenshot to complement the information

image

ermalkaleci commented 9 months ago

try removing - MemberCount from $removePrefix. Maybe it's triggering some weird behaviour. $removePrefix: should be used to clear maps

laurogripa commented 9 months ago

@ermalkaleci unfortunately I've already tried that, same problem

ermalkaleci commented 9 months ago

seems like a bug encoding/decoding primitives

ermalkaleci commented 9 months ago

@laurogripa use encoded value for now until we fix it

Society:
    MemberCount: 0x02000000
laurogripa commented 9 months ago

@laurogripa use encoded value for now until we fix it

Society:
    MemberCount: 0x02000000

Perfect 👌 Thanks!

seems like a bug encoding/decoding primitives

If you point me to the files responsible for the encoding/decoding I can take a look. I would love to try and contribute to the codebase :)

xlc commented 9 months ago

https://github.com/AcalaNetwork/chopsticks/blob/a45e5d022e9091615094c02177e92ceca981210e/packages/core/src/utils/set-storage.ts#L14

this is the code converts the config to raw values. you can start with some tests to reproduce the issue