Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata changed but version did not #2184

Closed
Slesarew opened this issue Jun 7, 2022 · 1 comment · Fixed by #2185
Closed

Metadata changed but version did not #2184

Slesarew opened this issue Jun 7, 2022 · 1 comment · Fixed by #2185

Comments

@Slesarew
Copy link

Slesarew commented Jun 7, 2022

Describe the bug

Today I've fetched Acala metadata through rpc call from public node and received different response then last Thursday. Apparently, some pallets changed. Yet, spec_version is still the same as before. This breaks Signer functionality and is unsafe.

Expected Behavior

Metadata should always be uniquely identified by spec_name and spec_version, any changes in metadata should be reflected with version bump.

There should be some mechanism to prevent this in future. I've reported similar bug in Polkadot and Kusama previously and those were fixed and covered with tests somehow, I do not know the details.

Current Behavior

CollateralCurrencyIds value is different in 2 places

Steps to Reproduce

  1. Fetch metadata from current block
  2. Fetch metadata from previous blocks
  3. Compare

I used to keep a log of metadata, but only for 3 networks and I do not do it anymore.

Additional context

  • Node version: 2064

Code to check metadata diff:

 let acala_meta_old = RuntimeMetadataV14::decode(&mut &acala_old[5..]).unwrap();    
 let acala_meta_new = RuntimeMetadataV14::decode(&mut &acala_new[5..]).unwrap();

 for pallet_old in acala_meta_old.pallets.iter() {
        let index = pallet_old.index;
        for pallet_new in acala_meta_new.pallets.iter() {
            if pallet_new.index == pallet_old.index {
                if pallet_new != pallet_old {
                    println!("pallet name new: {}", pallet_new.name);
                    println!("in new:\n{:?}", pallet_new);
                    println!("in old:\n{:?}", pallet_old);
                }
            }
        }
    }

Observed diff:

pallet name new: Honzon
in new:
PalletMetadata { name: "Honzon", storage: Some(PalletStorageMetadata { prefix: "Honzon", entries: [StorageEntryMetadata { name: "Authorization", modifier: Optional, ty: Map { hashers: [Twox64Concat, Blake2_128Concat], key: UntrackedSymbol { id: 537, marker: PhantomData }, value: UntrackedSymbol { id: 6, marker: PhantomData } }, default: [0], docs: [] }] }), calls: Some(PalletCallMetadata { ty: UntrackedSymbol { id: 308, marker: PhantomData } }), event: Some(PalletEventMetadata { ty: UntrackedSymbol { id: 150, marker: PhantomData } }), constants: [PalletConstantMetadata { name: "DepositPerAuthorization", ty: UntrackedSymbol { id: 6, marker: PhantomData }, value: [0, 192, 101, 67, 172, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], docs: [] }, PalletConstantMetadata { name: "CollateralCurrencyIds", ty: UntrackedSymbol { id: 59, marker: PhantomData }, value: [20, 0, 0, 0, 3, 0, 2, 3, 0, 0, 0, 0, 4, 13, 0, 0, 0], docs: [] }], error: Some(PalletErrorMetadata { ty: UntrackedSymbol { id: 538, marker: PhantomData } }), index: 102 }
in old:
PalletMetadata { name: "Honzon", storage: Some(PalletStorageMetadata { prefix: "Honzon", entries: [StorageEntryMetadata { name: "Authorization", modifier: Optional, ty: Map { hashers: [Twox64Concat, Blake2_128Concat], key: UntrackedSymbol { id: 537, marker: PhantomData }, value: UntrackedSymbol { id: 6, marker: PhantomData } }, default: [0], docs: [] }] }), calls: Some(PalletCallMetadata { ty: UntrackedSymbol { id: 308, marker: PhantomData } }), event: Some(PalletEventMetadata { ty: UntrackedSymbol { id: 150, marker: PhantomData } }), constants: [PalletConstantMetadata { name: "DepositPerAuthorization", ty: UntrackedSymbol { id: 6, marker: PhantomData }, value: [0, 192, 101, 67, 172, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], docs: [] }, PalletConstantMetadata { name: "CollateralCurrencyIds", ty: UntrackedSymbol { id: 59, marker: PhantomData }, value: [16, 0, 0, 0, 3, 0, 2, 4, 13, 0, 0, 0], docs: [] }], error: Some(PalletErrorMetadata { ty: UntrackedSymbol { id: 538, marker: PhantomData } }), index: 102 }
pallet name new: EmergencyShutdown
in new:
PalletMetadata { name: "EmergencyShutdown", storage: Some(PalletStorageMetadata { prefix: "EmergencyShutdown", entries: [StorageEntryMetadata { name: "IsShutdown", modifier: Default, ty: Plain(UntrackedSymbol { id: 126, marker: PhantomData }), default: [0], docs: [] }, StorageEntryMetadata { name: "CanRefund", modifier: Default, ty: Plain(UntrackedSymbol { id: 126, marker: PhantomData }), default: [0], docs: [] }] }), calls: Some(PalletCallMetadata { ty: UntrackedSymbol { id: 314, marker: PhantomData } }), event: Some(PalletEventMetadata { ty: UntrackedSymbol { id: 154, marker: PhantomData } }), constants: [PalletConstantMetadata { name: "CollateralCurrencyIds", ty: UntrackedSymbol { id: 59, marker: PhantomData }, value: [20, 0, 0, 0, 3, 0, 2, 3, 0, 0, 0, 0, 4, 13, 0, 0, 0], docs: [] }], error: Some(PalletErrorMetadata { ty: UntrackedSymbol { id: 542, marker: PhantomData } }), index: 105 }
in old:
PalletMetadata { name: "EmergencyShutdown", storage: Some(PalletStorageMetadata { prefix: "EmergencyShutdown", entries: [StorageEntryMetadata { name: "IsShutdown", modifier: Default, ty: Plain(UntrackedSymbol { id: 126, marker: PhantomData }), default: [0], docs: [] }, StorageEntryMetadata { name: "CanRefund", modifier: Default, ty: Plain(UntrackedSymbol { id: 126, marker: PhantomData }), default: [0], docs: [] }] }), calls: Some(PalletCallMetadata { ty: UntrackedSymbol { id: 314, marker: PhantomData } }), event: Some(PalletEventMetadata { ty: UntrackedSymbol { id: 154, marker: PhantomData } }), constants: [PalletConstantMetadata { name: "CollateralCurrencyIds", ty: UntrackedSymbol { id: 59, marker: PhantomData }, value: [16, 0, 0, 0, 3, 0, 2, 4, 13, 0, 0, 0], docs: [] }], error: Some(PalletErrorMetadata { ty: UntrackedSymbol { id: 542, marker: PhantomData } }), index: 105 }
@xlc
Copy link
Member

xlc commented Jun 8, 2022

Thanks for the report. We have incorrectly annotated a non constant as a constant and hence this issue. Will fix it in next runtime upgrade.

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 a pull request may close this issue.

2 participants