1

When integrating pallet-contracts v10 storage migration in pub type Migrations

use pallet_contracts::migration::{v10, v11, v12};
pub type Migrations = (
    v10::Migration<Runtime>,
)

I get an error about trait bounds not satisfied

= note: the following trait bounds were not satisfied: (pallet_contracts::migration::v10::Migration<Runtime>,): OnRuntimeUpgrade

First I thought this was a [duplicate][1] but my Cargo.toml [try-runtime] section already included the pallet-contracts/try-runtime clause.

The first in a series of similar errors is:

  error[E0599]: the function or associated item `execute_block` exists for struct `Executive<Runtime, Block<Header<u32, BlakeTwo256>, ...>, ..., ..., ..., ...>`, but its trait bounds were not satisfied
     --> /home/simson/nodle/chain/runtimes/eden/src/lib.rs:237:15
      |
  237 |             Executive::execute_block(block)
      |                        ^^^^^^^^^^^^^ function or associated item cannot be called due to unsatisfied trait bounds
      |
      = note: the full type name has been written to '/home/simson/nodle/chain/target/release/wbuild/runtime-eden/target/wasm32-unknown-unknown/release/deps/runtime_eden-709135493b42bf5f.long-type-12564475873963747691.txt'
      = note: the following trait bounds were not satisfied:
              `(pallet_contracts::migration::v10::Migration<Runtime>,): OnRuntimeUpgrade`


The long type from the file above:

frame_executive::Executive<Runtime,

sp_runtime::generic::Block<sp_runtime::generic::Header<u32, 

polkadot_primitives::BlakeTwo256>, sp_runtime::generic::UncheckedExtrinsic<MultiAddress<sp_runtime::AccountId32, ()>, 

RuntimeCall, 
MultiSignature, 
(CheckSpecVersion<Runtime>, 
CheckTxVersion<Runtime>, 
CheckGenesis<Runtime>, 
CheckEra<Runtime>, 
CheckNonce<Runtime>, 
CheckWeight<Runtime>, 
ChargeTransactionPayment<Runtime>, 
ChargeSponsor<Runtime>)>>, 
ChainContext<Runtime>, 
Runtime,
(frame_system::Pallet<Runtime>, 
pallet_timestamp::Pallet<Runtime>, 
pallet_balances::Pallet<Runtime>, 
pallet_transaction_payment::Pallet<Runtime>, 
pallet_insecure_randomness_collective_flip::Pallet<Runtime>, 
pallet_scheduler::Pallet<Runtime>, 
pallet_reserve::Pallet<Runtime, Instance1>, 
pallet_reserve::Pallet<Runtime, Instance2>, 
pallet_reserve::Pallet<Runtime, Instance3>, 
pallet_grants::Pallet<Runtime>, 
pallet_mandate::Pallet<Runtime>, 
pallet_collective::Pallet<Runtime, Instance1>, 
pallet_membership::Pallet<Runtime, Instance3>, 
pallet_collator_selection::Pallet<Runtime>, 
pallet_authorship::Pallet<Runtime>, 
pallet_session::Pallet<Runtime>, 
pallet_aura::Pallet<Runtime>, 
cumulus_pallet_aura_ext::Pallet<Runtime>, 
cumulus_pallet_parachain_system::Pallet<Runtime>, 
parachain_info::Pallet<Runtime>, 
cumulus_pallet_xcm::Pallet<Runtime>, 
cumulus_pallet_dmp_queue::Pallet<Runtime>, 
cumulus_pallet_xcmp_queue::Pallet<Runtime>, 
pallet_xcm::Pallet<Runtime>, 
orml_xtokens::Pallet<Runtime>, 
pallet_utility::Pallet<Runtime>, 
pallet_multisig::Pallet<Runtime>, 
pallet_uniques::Pallet<Runtime>, 
pallet_preimage::Pallet<Runtime>, 
pallet_nodle_uniques::Pallet<Runtime>, 
pallet_sponsorship::Pallet<Runtime>, 
pallet_identity::Pallet<Runtime>, 
pallet_allocations::Pallet<Runtime>, 
pallet_membership::Pallet<Runtime, Instance2>, 
pallet_reserve::Pallet<Runtime, Instance4>, 
pallet_contracts::Pallet<Runtime>), 
(pallet_contracts::migration::v10::Migration<Runtime>,)>

What is the compiler trying to tell me here? What flag could be missing?

update:

const TEST_ALL_STEPS: bool = cfg!(feature = "try-runtime");

pub type Migrations = (pallet_contracts::Migration<Runtime,TEST_ALL_STEPS>);

will not work as my migration is from 9 to 12

3

2 Answers 2

2

These are multi-blocks migrations. You don't need to add all of them to the Executive.

You should add pallet_contracts::Migration to the Executive and configure:

impl pallet_contracts::Config {
    type Migrations = (
        pallet_contracts::migration::v10::Migration<Runtime>,
        pallet_contracts::migration::v11::Migration<Runtime>,
        pallet_contracts::migration::v12::Migration<Runtime>
    );
    ..
}

Please check the documentation at https://github.com/paritytech/polkadot-sdk/blob/4ac2db8095e55a68f9b3d843d4e4689759fcc9d5/substrate/frame/contracts/src/migration.rs#L18-L58.

1
  • but it does not make try runtime happy see my update above
    – Simson
    Nov 16 at 22:40
0

With some inspiration from this answer but added the parts missing to solve the problem

Integration of pallet_contracts multi-step mitigation is slightly different from integration of migrations intended to be executed in one block. Two steps are needed.

First in the block implementing impl pallet_contracts::Config for Runtime the step migrations should be added.

impl pallet_contracts::Config for Runtime {
    type Migrations = (
        pallet_contracts::migration::v10::Migration<Runtime>,
        pallet_contracts::migration::v11::Migration<Runtime>,
        pallet_contracts::migration::v12::Migration<Runtime>,
    );
}

Second in the pallet_contracts::Migration<Runtime, TEST_ALL_STEPS> must be integrated in pub type Executive

const TEST_ALL_STEPS: bool = cfg!(feature = "try-runtime");

pub type Executive = frame_executive::Executive<
    Runtime,
    Block,
    frame_system::ChainContext<Runtime>,
    Runtime,
    AllPalletsWithSystem,
    (   pallet_contracts::Migration<Runtime, TEST_ALL_STEPS>,)
>;

Your Answer

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

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