4

No custom data migration logic for this pallet. but the data retrieved by the chain state has changed. here is code logic.

#[derive(Copy, Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
pub enum MyEnum {
    A,
    B,
    C,
    D,
}



#[derive(Clone, Encode, Decode, Eq, Copy, PartialEq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
pub struct MyStruct<
    Balance: Encode + Decode + Clone + Debug + Eq + PartialEq,
    AccountId: Encode + Decode + Clone + Debug + Eq + PartialEq,
> {
    pub account: AccountId,

    pub cost: Balance,

    pub action: MyEnum,
}




#[pallet::storage]
#[pallet::getter(fn action_list)]
pub(super) type ActionListOf<T: Config> =
StorageMap<_, Blake2_128Concat, MyEnum, Vec<Option<MyStruct<BalanceOf<T>, T::AccountId>>>, ValueQuery>;

before the upgrade, the retrieved data of the chain state is as follows:

[
  [
    [
      B
    ]
    [
      {
        account: 5HgtRNQxpttSomysgAsGgYmohdMD8knPBt8HtR5EH3neLbvV
        fee: 100,000,000,000,000,0
        action: B
      }
    ]
  ]
]

After the upgrade, the retrieved data of the chain state is as follows:

[
  [
    [
      A
    ]
    [
      {
        account: 5HgtRNQxpttSomysgAsGgYmohdMD8knPBt8HtR5EH3neLbvV
        fee: 100,000,000,000,000,0
        action: B
      }
    ]
  ]
]

The key in the StorageMap has changed, how to fix this problem?

commit checklist QA:

  1. no update code for this pallet
  2. update system weight
1
  • And what changed in the runtime upgrade? Can this be reproduced?
    – bkchr
    Commented Apr 14, 2022 at 8:52

1 Answer 1

1

It's hard to determine what happened without inspecting the new runtime and knowing what steps you took from pre to post upgrade.

The first thing to verify is to look at was upgraded in the runtime and make sure the upgrade didn't corrupt this StorageMap inside the pallet itself. Then, are you sure there were no dispatchables called post upgrade that could have updated the key to A ? Steps that could help understand what happened here would be:

  1. Reproduce the new runtime
  2. Inspect it using sr-tool and compare against the runtime that gave the unexpected storage. If they're not the same, you can look where they differ and fix your runtime code.
  3. If they are the same, then update your runtime with the new blob and make no other extrinsics to the pallet (again, this could have been an issue but its hard to know based on your problem description).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.