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

DepositFailed in benchmarks #921

Open
cuteolaf opened this issue Jun 6, 2023 · 8 comments
Open

DepositFailed in benchmarks #921

cuteolaf opened this issue Jun 6, 2023 · 8 comments

Comments

@cuteolaf
Copy link

cuteolaf commented Jun 6, 2023

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

@cuteolaf
Copy link
Author

cuteolaf commented Jun 6, 2023

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

@xlc
Copy link
Member

xlc commented Jun 6, 2023

what's the error?

@cuteolaf
Copy link
Author

cuteolaf commented Jun 7, 2023

The required balance is not deposited.

@cuteolaf
Copy link
Author

cuteolaf commented Jun 7, 2023

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
...

@xlc
Copy link
Member

xlc commented Jun 7, 2023

what's the error you are getting from <T::RMultiCurrency as MultiCurrency<<T as frame_system::Config>::AccountId>>::deposit?

hint, don't ignore results.

@cuteolaf
Copy link
Author

cuteolaf commented Jun 7, 2023

DepositFailed

@xlc
Copy link
Member

xlc commented Jun 7, 2023

without looking at the code, my guess is that you have different ED configuration and the deposit amount in test is too low

@cuteolaf
Copy link
Author

cuteolaf commented Jun 8, 2023

I checked it and it's not the case.

@cuteolaf cuteolaf closed this as completed Jun 8, 2023
@cuteolaf cuteolaf reopened this Jun 8, 2023
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

No branches or pull requests

2 participants