Response errors; not enough coins to fit the target during predicate call

GM, Frens :sunny:
In continuation of this topic , I was finally able to run local tests, and I immediately rewrote the testnet tests to beta4.

The testnet test crashes with the ProviderError("Response errors; not enough coins to fit the target") error

I tried to solve it by increasing the number of eths per predicate.

  let base_asset = wallet
            .get_asset_inputs_for_amount(AssetId::BASE, 1000)
            .await
            .unwrap();

and

 alice
         .transfer(
             predicate.address(),
             1000,
             AssetId::BASE,
             TxParameters::default().with_gas_price(1),
         )
         .await
         .unwrap();

Full cancel_order output


🏁 Cancel Order Test 🏁 

alice_address = 0x194c4d5d321ea3bc2e87109f4a86520ad60f924998f67007d487d3cc0acc45d2

USDC AssetId (asset0) = 0x8bf7951ea3222fe0bae9b811c2b142a1ff417361dcf7457855ed477d2d9a8550
UNI AssetId (asset1) = 0xae37bc0feb66e60a89e301d450bb4640aa9bd7cedd856e253e23989eae536e92
amount0 = 1000 USDC
amount1 = 300 UNI
Price = 300000000 UNI/USDC
Predicate root = Bech32Address { hrp: "fuel", hash: 30eca21483827cc70edeb56d562d25839e4ddf268f58b2ba4abb8a21f8f66a39 }

Alice transfers 1000 USDC to predicate

Alice balances = Ok(
    {
        "0000000000000000000000000000000000000000000000000000000000000000": 299997179,
        "8bf7951ea3222fe0bae9b811c2b142a1ff417361dcf7457855ed477d2d9a8550": 4000000000,
    },
)
Predicate balances = Ok(
    {
        "0000000000000000000000000000000000000000000000000000000000000000": 500002000,
        "8bf7951ea3222fe0bae9b811c2b142a1ff417361dcf7457855ed477d2d9a8550": 11000000000,
    },
)
thread 'testnet_tests::cancel_order_test::cancel_order_test' panicked at 'called `Result::unwrap()` on an `Err` value: ProviderError("Response errors; not enough coins to fit the target")', tests/testnet_tests/cancel_order_test.rs:121:10
stack backtrace:
   0: rust_begin_unwind
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/panicking.rs:67:14
   2: core::result::unwrap_failed
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/result.rs:1651:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/result.rs:1076:23
   4: tests::testnet_tests::cancel_order_test::cancel_order_test::{{closure}}
             at ./tests/testnet_tests/cancel_order_test.rs:119:5
   5: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/future/future.rs:125:9
   6: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/future/future.rs:125:9
   7: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::{{closure}}
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/current_thread/mod.rs:665:57
   8: tokio::runtime::coop::with_budget
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/coop.rs:107:5
   9: tokio::runtime::coop::budget
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/coop.rs:73:5
  10: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/current_thread/mod.rs:665:25
  11: tokio::runtime::scheduler::current_thread::Context::enter
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/current_thread/mod.rs:410:19
  12: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/current_thread/mod.rs:664:36
  13: tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}}
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/current_thread/mod.rs:743:68
  14: tokio::runtime::context::scoped::Scoped<T>::set
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/context/scoped.rs:40:9
  15: tokio::runtime::context::set_scheduler::{{closure}}
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/context.rs:176:26
  16: std::thread::local::LocalKey<T>::try_with
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/std/src/thread/local.rs:270:16
  17: std::thread::local::LocalKey<T>::with
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/std/src/thread/local.rs:246:9
  18: tokio::runtime::context::set_scheduler
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/context.rs:176:9
  19: tokio::runtime::scheduler::current_thread::CoreGuard::enter
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/current_thread/mod.rs:743:27
  20: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/current_thread/mod.rs:652:19
  21: tokio::runtime::scheduler::current_thread::CurrentThread::block_on::{{closure}}
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/current_thread/mod.rs:175:28
  22: tokio::runtime::context::runtime::enter_runtime
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/context/runtime.rs:65:16
  23: tokio::runtime::scheduler::current_thread::CurrentThread::block_on
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/current_thread/mod.rs:167:9
  24: tokio::runtime::runtime::Runtime::block_on
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/runtime.rs:347:47
  25: tests::testnet_tests::cancel_order_test::cancel_order_test
             at ./tests/testnet_tests/cancel_order_test.rs:131:5
  26: tests::testnet_tests::cancel_order_test::cancel_order_test::{{closure}}
             at ./tests/testnet_tests/cancel_order_test.rs:27:30
  27: core::ops::function::FnOnce::call_once
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/ops/function.rs:250:5
  28: core::ops::function::FnOnce::call_once
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
test testnet_tests::cancel_order_test::cancel_order_test ... FAILED

failures:

failures:
    testnet_tests::cancel_order_test::cancel_order_test

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 6 filtered out; finished in 3.40s

error: test failed, to rerun pass `-p spark_sdk --test tests`

 *  The terminal process "cargo 'test', '--package', 'spark_sdk', '--test', 'tests', '--', 'testnet_tests::cancel_order_test::cancel_order_test', '--exact', '--nocapture'" terminated with exit code: 101. 
 *  Terminal will be reused by tasks, press any key to close it. 

Full fulfill_order output

🏁 Fulfill Order Test 🏁 

admin_address = 0x5cd7a90ddc6e4c9ba59c08f9fcd5ec59f1ab9998088a28176f395803c7bd4534
alice_address = 0x194c4d5d321ea3bc2e87109f4a86520ad60f924998f67007d487d3cc0acc45d2
bob_address = 0x47010c8ecfeaa888954d7a536131fa962060e28552f3353c06954afdc558410e

USDC AssetId (asset0) = 0x8bf7951ea3222fe0bae9b811c2b142a1ff417361dcf7457855ed477d2d9a8550
UNI AssetId (asset1) = 0xae37bc0feb66e60a89e301d450bb4640aa9bd7cedd856e253e23989eae536e92
amount0 = 1000 USDC
amount1 = 300 UNI
Price = 300000000 UNI/USDC
Predicate root = Bech32Address { hrp: "fuel", hash: 507883308fc1fa2e56cf4bed9388f22867f452fef6e092d4cf3ab30f0a9e8f40 }

Alice transfers 1000 USDC to predicate

Alice balances = Ok(
    {
        "0000000000000000000000000000000000000000000000000000000000000000": 799996966,
        "8bf7951ea3222fe0bae9b811c2b142a1ff417361dcf7457855ed477d2d9a8550": 1000000000,
    },
)
Predicate balances = Ok(
    {
        "8bf7951ea3222fe0bae9b811c2b142a1ff417361dcf7457855ed477d2d9a8550": 3000000000,
    },
)
thread 'testnet_tests::fulfill_order_test::fulfill_order_test' panicked at 'called `Result::unwrap()` on an `Err` value: ProviderError("Response errors; not enough coins to fit the target")', tests/testnet_tests/fulfill_order_test.rs:145:6
stack backtrace:
   0: rust_begin_unwind
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/panicking.rs:67:14
   2: core::result::unwrap_failed
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/result.rs:1651:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/result.rs:1076:23
   4: tests::testnet_tests::fulfill_order_test::fulfill_order_test::{{closure}}
             at ./tests/testnet_tests/fulfill_order_test.rs:135:16
   5: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/future/future.rs:125:9
   6: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/future/future.rs:125:9
   7: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::{{closure}}
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/current_thread/mod.rs:665:57
   8: tokio::runtime::coop::with_budget
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/coop.rs:107:5
   9: tokio::runtime::coop::budget
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/coop.rs:73:5
  10: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/current_thread/mod.rs:665:25
  11: tokio::runtime::scheduler::current_thread::Context::enter
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/current_thread/mod.rs:410:19
  12: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/current_thread/mod.rs:664:36
  13: tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}}
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/current_thread/mod.rs:743:68
  14: tokio::runtime::context::scoped::Scoped<T>::set
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/context/scoped.rs:40:9
  15: tokio::runtime::context::set_scheduler::{{closure}}
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/context.rs:176:26
  16: std::thread::local::LocalKey<T>::try_with
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/std/src/thread/local.rs:270:16
  17: std::thread::local::LocalKey<T>::with
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/std/src/thread/local.rs:246:9
  18: tokio::runtime::context::set_scheduler
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/context.rs:176:9
  19: tokio::runtime::scheduler::current_thread::CoreGuard::enter
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/current_thread/mod.rs:743:27
  20: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/current_thread/mod.rs:652:19
  21: tokio::runtime::scheduler::current_thread::CurrentThread::block_on::{{closure}}
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/current_thread/mod.rs:175:28
  22: tokio::runtime::context::runtime::enter_runtime
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/context/runtime.rs:65:16
  23: tokio::runtime::scheduler::current_thread::CurrentThread::block_on
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/scheduler/current_thread/mod.rs:167:9
  24: tokio::runtime::runtime::Runtime::block_on
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.32.0/src/runtime/runtime.rs:347:47
  25: tests::testnet_tests::fulfill_order_test::fulfill_order_test
             at ./tests/testnet_tests/fulfill_order_test.rs:167:5
  26: tests::testnet_tests::fulfill_order_test::fulfill_order_test::{{closure}}
             at ./tests/testnet_tests/fulfill_order_test.rs:26:31
  27: core::ops::function::FnOnce::call_once
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/ops/function.rs:250:5
  28: core::ops::function::FnOnce::call_once
             at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
test testnet_tests::fulfill_order_test::fulfill_order_test ... FAILED

failures:

failures:
    testnet_tests::fulfill_order_test::fulfill_order_test

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 6 filtered out; finished in 3.70s

error: test failed, to rerun pass `-p spark_sdk --test tests`

 *  The terminal process "cargo 'test', '--package', 'spark_sdk', '--test', 'tests', '--', 'testnet_tests::fulfill_order_test::fulfill_order_test', '--exact', '--nocapture'" terminated with exit code: 101. 
 *  Terminal will be reused by tasks, press any key to close it. 

How to reproduce

Before starting please create 2 beta-4 addresses (Admin and Alice) and mint some eth and save private keys

git clone https://github.com/compolabs/spark-rs.git  
cd spark-rs   
git checkout beta-4  
cd limit-order-predicate  && forc build  && cd ..
cd proxy-contract && forc build  && cd ..
echo "ADMIN=<ADMIN_PK>" >> .env
echo "ALICE=<ALICE_PK>" >> .env
cargo test --package spark_sdk --test tests -- 
#fulfill_order_test
cargo test --package spark_sdk --test tests -- testnet_tests::fulfill_order_test::fulfill_order_test --exact --nocapture
#cancel_order_test
cargo test --package spark_sdk --test tests -- testnet_tests::cancel_order_test::cancel_order_test --exact --nocapture 

Toolchain

Default host: aarch64-apple-darwin
fuelup home: /Users/alexey/.fuelup

installed toolchains
--------------------
beta-3-aarch64-apple-darwin
beta-4-rc.2-aarch64-apple-darwin
latest-aarch64-apple-darwin (default)
hotfix
my-custom-toolchain

active toolchain
-----------------
latest-aarch64-apple-darwin (default)
  forc : 0.44.1
    - forc-client
      - forc-deploy : 0.44.1
      - forc-run : 0.44.1
    - forc-doc : 0.44.1
    - forc-explore : 0.28.1
    - forc-fmt : 0.44.1
    - forc-index : 0.20.7
    - forc-lsp : 0.44.1
    - forc-tx : 0.44.1
    - forc-wallet : 0.3.0
  fuel-core : 0.20.4
  fuel-core-keygen : Error getting version string
  fuel-indexer : 0.20.7

fuels versions
---------------
forc : 0.45
forc-wallet : 0.45
2 Likes

Hello!
:thinking:
It seems that you should divide your coins a bit just to make sure you have at least two coins.

If our faucet only gives you one utxo, you can initiate a transfer with multiple outputs, all directing to your wallet. This will create more utxos for you.

Hi, cannot understand ho to do that, can you describe more?

But also I a bit confused because the same tests works well on local node

This is an issue related to the utxo.
I’m not the right person to deeply explain this but I’ll try:

The local node bootstraps the chain with multiple utxos, however the faucet doesn’t.

The workaround might be to get funds from the faucet, send a couple of txs to another wallet and then back again to your main wallet so you have multiples utxo.

However, the rust sdk team is preparing a release to fix this issue.

Let me know if this makes sense.

Can you share an issue link or target version of Rust SDK, to allow us to keep tracking solution?

The fix for predicated cost estimation was just released!

You can check the release here

1 Like

Hi, just updated rust SDK to 0.48.0, but error is the same

It seems that your Cargo.toml is still pointing at 0.47. After bumping it I got a “not enough coins could be found” error.

This is due to a bug in the ScriptCallHandler where it calculates the wrong amount of the base asset for covering tx fees. The reason why it works in the local tests is because the wallet is initialized with more than 1 coin.

So you could circumvent this for now by having bob hold more than 1 coin or by removing this input:

However, ScriptCallHandler is generally meant to be used with transaction that have some script code, where you want a convenient way to decode the response value.
If you just want a simple transfer transaction, you should go with something like this:

let tb = ScriptTransactionBuilder::prepare_transfer(inputs, outputs, TxParameters::default().with_gas_price(1));
let script = wallet.add_fee_resources(tb, 0).await?;

let tx_id = provider.send_transaction(script).await?;
let receipts = provider.get_receipts(&tx_id).await?;

Calling add_fee_resources modifies the inputs to cover tx fees. Usually you also need to provide it with the amount of base asset that your tx is already transferring but in your case it’s 0 since it’s only transferring the USDC, UNI asset.

2 Likes

Sorry, I just removed target and that works for me
Thanks a log <3

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.