DepositFailed in benchmarks
deposit method of orml-currencies is not working in benchmarks
pub fn create_funded_user<T: Config>(
seed: &'static str,
n: u32,
balance_factor: u32,
) -> T::AccountId {
let user = account(seed, n, 0);
let balance: BalanceOf<T> = balance_factor.into();
assert_ok!(<T::MultiCurrency as MultiCurrency<
<T as frame_system::Config>::AccountId,
>>::deposit(CurrencyId::Native, &user, balance,));
user
}
Reference: https://github.com/ImbueNetwork/imbue/blob/0744ca52a89b2d2a17ba379c43663c3882df2592/pallets/proposals/src/test_utils.rs#L117-L128
I see this post on Stack Exchange, but it has been closed for some reason.
https://substrate.stackexchange.com/questions/2942/how-to-fix-depositfailed-on-orml-currencies-while-benchmarking
what's the error?
The required balance is not deposited.
fn create_account_id<T: Config>(suri: &'static str, n: u32) -> T::AccountId {
let user = account(suri, n, SEED);
let _ = <T::RMultiCurrency as MultiCurrency<<T as frame_system::Config>::AccountId>>::deposit(
CurrencyId::Native,
&user,
1_000_000u32.into(),
);
assert_eq!(
<T::RMultiCurrency as MultiCurrency<<T as frame_system::Config>::AccountId>>::free_balance(
CurrencyId::Native,
&user
),
1_000_000u32.into()
);
user
}
assert_eq!(...) succeeds for cargo test --release and cargo test --release --features runtime-benchmarks
but fails when running the benchmark command to generate weights.
when I run ./target/release/imbue benchmark pallet --pallet pallet-grants --extrinsics '*' --execution wasm --wasm-execution compiled --steps 50 --repeat 20, I find that assert_eq! fails with the error
...
left = 0, right = 1000000
...
what's the error you are getting from <T::RMultiCurrency as MultiCurrency<<T as frame_system::Config>::AccountId>>::deposit?
hint, don't ignore results.
DepositFailed
without looking at the code, my guess is that you have different ED configuration and the deposit amount in test is too low
I checked it and it's not the case.