Issues with Order Creation in Fuel Beta 5 - OutOfGas Error
Hello Fuel Community,
We recently upgraded our Spark Perps project to work with Fuel Beta 5 and redeployed all our contracts. Our local tests are running smoothly, and here are the outputs from these tests:
๐ Match orders test ๐
admin_address = 09c0b2d1a486c439a87bcba6b46a7a1a23f3897cc83a94521a96da5c23bc58db
bob_address = bdaad6a89e073e177895b3e5a9ccd15806749eda134a6438dae32fc5b6601f3f
chad_address = 95a7aa6cc32743f8706c40ef49a7423b47da763bb4bbc055b1f07254dc729036
๐ฎ ETH Price { confidence: 104000000, exponent: 8, price: 203313000000, publish_time: 4611686020127907021 }
๐ฎ USDC Price { confidence: 50000, exponent: 8, price: 99985000, publish_time: 4611686020127907020 }
๐ฎ BTC Price { confidence: 2158641006, exponent: 8, price: 3754119461006, publish_time: 4611686020127907021 }
==================== Step #0 ====================
๐ Contract: vault
๐ค Function: deposit_collateral
๐ Wallet: Bob
๐ฐ Amount: Amount: 1500.00 USDC
Markets state ๐ช
markets: ["ETH", "BTC"]
treasury_owed_realized_pnl 0
insurance_fund_owed_realized_pnl 0
market_prices []
mark_prices []
last_fundings_growth_global [0, 0]
market_twaps []
mark_twaps []
Trader ๐บ Bob bdaad6a89e073e177895b3e5a9ccd15806749eda134a6438dae32fc5b6601f3f
clearing_house.all_pending_funding_payment: 0
clearing_house.margin_requirement_for_liquidation: 0
clearing_house.pending_funding_payment: funding_growth_globals: [] | funding_payments: []
vault.get_account_value_and_total_collateral_value: (account_value: 1500000000, total_collateral_value: 1500000000)
perp market.get_total_trader_order_bases: [0, 0]
account_balance.owed_realized_pnl: 0, unrealized_pnl: 0
account_balance.margin_requirement: 0
account_balance.total_abs_position_value: 0
account_balance.total_position_value: [0, 0]
account_balance.account_balance: [
(
"asset: ETH (0000000000000000000000000000000000000000000000000000000000000000)",
"taker_position_size: 0",
"taker_open_notional: 0",
"last_tw_premium_growth_global: 0",
),
(
"asset: BTC (c9c5e1c5fa7d3e66e9939cc8c9bc216138ae70cdfb176e989806694911dab74e)",
"taker_position_size: 0",
"taker_open_notional: 0",
"last_tw_premium_growth_global: 0",
),
]
โฐ timestamp + 600
==================== Step #1 ====================
๐ Contract: clearing house
๐ค Function: create_market
๐ Wallet: Admin
๐ฐ Amount: name: BTC, im_ratio: 60000, mm_ratio: 50000
Markets state ๐ช
markets: ["ETH", "BTC"]
treasury_owed_realized_pnl 0
insurance_fund_owed_realized_pnl 0
market_prices [37541194610]
mark_prices [37541194610]
last_fundings_growth_global [0, 0]
market_twaps []
mark_twaps [
Twap {
base_token: 0xc9c5e1c5fa7d3e66e9939cc8c9bc216138ae70cdfb176e989806694911dab74e,
span: 3600,
current_twap: 37541194610,
last_update: 600,
},
]
โฐ timestamp + 600
==================== Step #2 ====================
๐ Contract: clearing house
๐ค Function: open_order (should fail)
๐ Wallet: Admin
๐ฐ Amount: LONG 0.000001 BTC
Markets state ๐ช
markets: ["ETH", "BTC"]
treasury_owed_realized_pnl 0
insurance_fund_owed_realized_pnl 0
market_prices [37541194610]
mark_prices [37541194610]
last_fundings_growth_global [0, 0]
market_twaps []
mark_twaps [
Twap {
base_token: 0xc9c5e1c5fa7d3e66e9939cc8c9bc216138ae70cdfb176e989806694911dab74e,
span: 3600,
current_twap: 37541194610,
last_update: 600,
},
]
Trader ๐บ Admin 09c0b2d1a486c439a87bcba6b46a7a1a23f3897cc83a94521a96da5c23bc58db
clearing_house.all_pending_funding_payment: 0
clearing_house.margin_requirement_for_liquidation: 0
clearing_house.pending_funding_payment: funding_growth_globals: [0] | funding_payments: [0]
vault.get_account_value_and_total_collateral_value: (account_value: 0, total_collateral_value: 0)
perp market.get_total_trader_order_bases: [0, 0]
account_balance.owed_realized_pnl: 0, unrealized_pnl: 0
account_balance.margin_requirement: 0
account_balance.total_abs_position_value: 0
account_balance.total_position_value: [0, 0]
account_balance.account_balance: [
(
"asset: ETH (0000000000000000000000000000000000000000000000000000000000000000)",
"taker_position_size: 0",
"taker_open_notional: 0",
"last_tw_premium_growth_global: 0",
),
(
"asset: BTC (c9c5e1c5fa7d3e66e9939cc8c9bc216138ae70cdfb176e989806694911dab74e)",
"taker_position_size: 0",
"taker_open_notional: 0",
"last_tw_premium_growth_global: 0",
),
]
โฐ timestamp + 600
==================== Step #3 ====================
๐ Contract: clearing house
๐ค Function: create_market
๐ Wallet: Admin
๐ฐ Amount: NAME: ETH, im_ratio: 60000, mm_ratio: 50000
Markets state ๐ช
markets: ["ETH", "BTC"]
treasury_owed_realized_pnl 0
insurance_fund_owed_realized_pnl 0
market_prices [2033130000, 37541194610]
mark_prices [2033130000, 37541194610]
last_fundings_growth_global [0, 0]
market_twaps []
mark_twaps [
Twap {
base_token: 0x0000000000000000000000000000000000000000000000000000000000000000,
span: 3600,
current_twap: 2033130000,
last_update: 1800,
},
Twap {
base_token: 0xc9c5e1c5fa7d3e66e9939cc8c9bc216138ae70cdfb176e989806694911dab74e,
span: 3600,
current_twap: 37541194610,
last_update: 600,
},
]
โฐ timestamp + 600
==================== Step #4 ====================
๐ Contract: clearing house
๐ค Function: open_order
๐ Wallet: Bob
๐ฐ Amount: LONG 0.5 BTC
Markets state ๐ช
markets: ["ETH", "BTC"]
treasury_owed_realized_pnl 0
insurance_fund_owed_realized_pnl 0
market_prices [2033130000, 37541194610]
mark_prices [2033130000, 37541194610]
last_fundings_growth_global [0, 0]
market_twaps []
mark_twaps [
Twap {
base_token: 0x0000000000000000000000000000000000000000000000000000000000000000,
span: 3600,
current_twap: 2033130000,
last_update: 1800,
},
Twap {
base_token: 0xc9c5e1c5fa7d3e66e9939cc8c9bc216138ae70cdfb176e989806694911dab74e,
span: 3600,
current_twap: 37541194610,
last_update: 600,
},
]
Trader ๐บ Bob bdaad6a89e073e177895b3e5a9ccd15806749eda134a6438dae32fc5b6601f3f
clearing_house.all_pending_funding_payment: 0
clearing_house.margin_requirement_for_liquidation: 0
clearing_house.pending_funding_payment: funding_growth_globals: [0, 0] | funding_payments: [0, 0]
vault.get_account_value_and_total_collateral_value: (account_value: 1500000000, total_collateral_value: 1500000000)
perp market.get_total_trader_order_bases: [0, 50000000]
account_balance.owed_realized_pnl: 0, unrealized_pnl: 0
account_balance.margin_requirement: 1126235838
account_balance.total_abs_position_value: 0
account_balance.total_position_value: [0, 0]
account_balance.account_balance: [
(
"asset: ETH (0000000000000000000000000000000000000000000000000000000000000000)",
"taker_position_size: 0",
"taker_open_notional: 0",
"last_tw_premium_growth_global: 0",
),
(
"asset: BTC (c9c5e1c5fa7d3e66e9939cc8c9bc216138ae70cdfb176e989806694911dab74e)",
"taker_position_size: 0",
"taker_open_notional: 0",
"last_tw_premium_growth_global: 0",
),
]
โฐ timestamp + 600
==================== Step #5 ====================
๐ Contract: clearing house
๐ค Function: open_order
๐ Wallet: Bob
๐ฐ Amount: -0.1 BTC
Markets state ๐ช
markets: ["ETH", "BTC"]
treasury_owed_realized_pnl 0
insurance_fund_owed_realized_pnl 0
market_prices [2033130000, 37541194610]
mark_prices [2033130000, 37541194610]
last_fundings_growth_global [0, 0]
market_twaps []
mark_twaps [
Twap {
base_token: 0x0000000000000000000000000000000000000000000000000000000000000000,
span: 3600,
current_twap: 2033130000,
last_update: 1800,
},
Twap {
base_token: 0xc9c5e1c5fa7d3e66e9939cc8c9bc216138ae70cdfb176e989806694911dab74e,
span: 3600,
current_twap: 37541194610,
last_update: 600,
},
]
Trader ๐บ Bob bdaad6a89e073e177895b3e5a9ccd15806749eda134a6438dae32fc5b6601f3f
clearing_house.all_pending_funding_payment: 0
clearing_house.margin_requirement_for_liquidation: 0
clearing_house.pending_funding_payment: funding_growth_globals: [0, 0] | funding_payments: [0, 0]
vault.get_account_value_and_total_collateral_value: (account_value: 1500000000, total_collateral_value: 1500000000)
perp market.get_total_trader_order_bases: [0, 40000000]
account_balance.owed_realized_pnl: 0, unrealized_pnl: 0
account_balance.margin_requirement: 900988670
account_balance.total_abs_position_value: 0
account_balance.total_position_value: [0, 0]
account_balance.account_balance: [
(
"asset: ETH (0000000000000000000000000000000000000000000000000000000000000000)",
"taker_position_size: 0",
"taker_open_notional: 0",
"last_tw_premium_growth_global: 0",
),
(
"asset: BTC (c9c5e1c5fa7d3e66e9939cc8c9bc216138ae70cdfb176e989806694911dab74e)",
"taker_position_size: 0",
"taker_open_notional: 0",
"last_tw_premium_growth_global: 0",
),
]
โฐ timestamp + 600
==================== Step #6 ====================
๐ Contract: vault
๐ค Function: withdraw_collateral
๐ Wallet: Bob
๐ฐ Amount: 900 USDC
Markets state ๐ช
markets: ["ETH", "BTC"]
treasury_owed_realized_pnl 0
insurance_fund_owed_realized_pnl 0
market_prices [2033130000, 37541194610]
mark_prices [2033130000, 37541194610]
last_fundings_growth_global [0, 0]
market_twaps []
mark_twaps [
Twap {
base_token: 0x0000000000000000000000000000000000000000000000000000000000000000,
span: 3600,
current_twap: 2033130000,
last_update: 1800,
},
Twap {
base_token: 0xc9c5e1c5fa7d3e66e9939cc8c9bc216138ae70cdfb176e989806694911dab74e,
span: 3600,
current_twap: 37541194610,
last_update: 600,
},
]
Trader ๐บ Bob bdaad6a89e073e177895b3e5a9ccd15806749eda134a6438dae32fc5b6601f3f
clearing_house.all_pending_funding_payment: 0
clearing_house.margin_requirement_for_liquidation: 0
clearing_house.pending_funding_payment: funding_growth_globals: [0, 0] | funding_payments: [0, 0]
vault.get_account_value_and_total_collateral_value: (account_value: 1500000000, total_collateral_value: 1500000000)
perp market.get_total_trader_order_bases: [0, 40000000]
account_balance.owed_realized_pnl: 0, unrealized_pnl: 0
account_balance.margin_requirement: 900988670
account_balance.total_abs_position_value: 0
account_balance.total_position_value: [0, 0]
account_balance.account_balance: [
(
"asset: ETH (0000000000000000000000000000000000000000000000000000000000000000)",
"taker_position_size: 0",
"taker_open_notional: 0",
"last_tw_premium_growth_global: 0",
),
(
"asset: BTC (c9c5e1c5fa7d3e66e9939cc8c9bc216138ae70cdfb176e989806694911dab74e)",
"taker_position_size: 0",
"taker_open_notional: 0",
"last_tw_premium_growth_global: 0",
),
]
โฐ timestamp + 600
==================== Step #7 ====================
๐ Contract: vault
๐ค Function: withdraw_collateral
๐ Wallet: Bob
๐ฐ Amount: 1 USDC
Markets state ๐ช
markets: ["ETH", "BTC"]
treasury_owed_realized_pnl 0
insurance_fund_owed_realized_pnl 0
market_prices [2033130000, 37541194610]
mark_prices [2033130000, 37541194610]
last_fundings_growth_global [0, 0]
market_twaps []
mark_twaps [
Twap {
base_token: 0x0000000000000000000000000000000000000000000000000000000000000000,
span: 3600,
current_twap: 2033130000,
last_update: 1800,
},
Twap {
base_token: 0xc9c5e1c5fa7d3e66e9939cc8c9bc216138ae70cdfb176e989806694911dab74e,
span: 3600,
current_twap: 37541194610,
last_update: 600,
},
]
Trader ๐บ Bob bdaad6a89e073e177895b3e5a9ccd15806749eda134a6438dae32fc5b6601f3f
clearing_house.all_pending_funding_payment: 0
clearing_house.margin_requirement_for_liquidation: 0
clearing_house.pending_funding_payment: funding_growth_globals: [0, 0] | funding_payments: [0, 0]
vault.get_account_value_and_total_collateral_value: (account_value: 1499000000, total_collateral_value: 1499000000)
perp market.get_total_trader_order_bases: [0, 40000000]
account_balance.owed_realized_pnl: 0, unrealized_pnl: 0
account_balance.margin_requirement: 900988670
account_balance.total_abs_position_value: 0
account_balance.total_position_value: [0, 0]
account_balance.account_balance: [
(
"asset: ETH (0000000000000000000000000000000000000000000000000000000000000000)",
"taker_position_size: 0",
"taker_open_notional: 0",
"last_tw_premium_growth_global: 0",
),
(
"asset: BTC (c9c5e1c5fa7d3e66e9939cc8c9bc216138ae70cdfb176e989806694911dab74e)",
"taker_position_size: 0",
"taker_open_notional: 0",
"last_tw_premium_growth_global: 0",
),
]
โฐ timestamp + 600
And this is the error weโre encountering:
๐ โจ Testnet spark open_order action ๐ ๐
btc_price = 37541194610
๐ Start_block: 3213744
thread 'testnet_actions::open_order::open_order_action' panicked at tests/testnet_actions/open_order.rs:81:10:
called `Result::unwrap()` on an `Err` value: RevertTransactionError { reason: "OutOfGas", revert_id: 0, receipts: [Panic { id: 0000000000000000000000000000000000000000000000000000000000000000, reason: PanicInstruction { reason: OutOfGas, instruction: CALL { target_struct: 0x10, fwd_coins: 0x11, asset_id_addr: 0x12, fwd_gas: 0xa } (bytes: 2d 41 14 8a) }, pc: 10352, is: 10336, contract_id: None }, ScriptResult { result: Panic, gas_used: 10000 }] }
stack backtrace:
0: rust_begin_unwind
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
1: core::panicking::panic_fmt
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
2: core::result::unwrap_failed
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:1653:5
3: core::result::Result<T,E>::unwrap
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:1077:23
4: integration_tests::testnet_actions::open_order::open_order_action::{{closure}}
at ./tests/testnet_actions/open_order.rs:77:5
5: <core::pin::Pin<P> as core::future::future::Future>::poll
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/future/future.rs:125:9
6: <core::pin::Pin<P> as core::future::future::Future>::poll
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/future/future.rs:125:9
7: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::{{closure}}
at /Users/lidia/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:665:57
8: tokio::runtime::coop::with_budget
at /Users/lidia/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/coop.rs:107:5
9: tokio::runtime::coop::budget
at /Users/lidia/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/coop.rs:73:5
10: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}
at /Users/lidia/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:665:25
11: tokio::runtime::scheduler::current_thread::Context::enter
at /Users/lidia/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:410:19
12: tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}
at /Users/lidia/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:664:36
13: tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}}
at /Users/lidia/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:743:68
14: tokio::runtime::context::scoped::Scoped<T>::set
at /Users/lidia/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/context/scoped.rs:40:9
15: tokio::runtime::context::set_scheduler::{{closure}}
at /Users/lidia/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/context.rs:176:26
16: std::thread::local::LocalKey<T>::try_with
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:270:16
17: std::thread::local::LocalKey<T>::with
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/thread/local.rs:246:9
18: tokio::runtime::context::set_scheduler
at /Users/lidia/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/context.rs:176:9
19: tokio::runtime::scheduler::current_thread::CoreGuard::enter
at /Users/lidia/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:743:27
20: tokio::runtime::scheduler::current_thread::CoreGuard::block_on
at /Users/lidia/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:652:19
21: tokio::runtime::scheduler::current_thread::CurrentThread::block_on::{{closure}}
at /Users/lidia/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:175:28
22: tokio::runtime::context::runtime::enter_runtime
at /Users/lidia/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/context/runtime.rs:65:16
23: tokio::runtime::scheduler::current_thread::CurrentThread::block_on
at /Users/lidia/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/scheduler/current_thread/mod.rs:167:9
24: tokio::runtime::runtime::Runtime::block_on
at /Users/lidia/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/runtime.rs:348:47
25: integration_tests::testnet_actions::open_order::open_order_action
at ./tests/testnet_actions/open_order.rs:102:9
26: integration_tests::testnet_actions::open_order::open_order_action::{{closure}}
at ./tests/testnet_actions/open_order.rs:19:29
27: core::ops::function::FnOnce::call_once
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
28: core::ops::function::FnOnce::call_once
at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
test testnet_actions::open_order::open_order_action ... FAILED
failures:
failures:
testnet_actions::open_order::open_order_action
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 12 filtered out; finished in 8.05s
error: test failed, to rerun pass `-p spark-perps --test integration_tests`
The code seems to fail at the .deposit_collateral(amount, usdc.asset_id)
call. Here is the deposit_collateral
function:
pub async fn deposit_collateral(
&self,
collateral_amount: u64,
collateral_asset_id: AssetId,
) -> Result<FuelCallResponse<()>, fuels::types::errors::Error> {
let call_params = CallParameters::default()
.with_amount(collateral_amount)
.with_asset_id(collateral_asset_id);
self.vault
.methods()
.deposit_collateral()
.with_tx_policies(
TxPolicies::default()
.with_gas_price(1)
.with_script_gas_limit(10000),
)
.call_params(call_params)?
.call()
.await
}
We followed the gas calculation recommendations found in this discussion:
https://rust.fuel.network/master/calling-contracts/cost-estimation.html?highlight=estimate_transaction_cost#estimating-contract-call-cost
, but error is the same
pub async fn deposit_collateral(
&self,
collateral_amount: u64,
collateral_asset_id: AssetId,
) -> Result<FuelCallResponse<()>, fuels::types::errors::Error> {
let call_params = CallParameters::default()
.with_amount(collateral_amount)
.with_asset_id(collateral_asset_id);
let transaction_cost = self.vault
.methods()
.deposit_collateral() // Build the ABI call
.estimate_transaction_cost(Some(0.0)) // Get estimated transaction cost
.await?;
p
self.vault
.methods()
.deposit_collateral()
.with_tx_policies(
TxPolicies::default()
.with_gas_price(1)
.with_script_gas_limit(transaction_cost.gas_used),
)
.call_params(call_params)?
.call()
.await
}
We are currently using Rust SDK version 0.54. Below is my toolchain setup:
Default host: aarch64-apple-darwin
fuelup home: /Users/lidia/.fuelup
installed toolchains
--------------------
latest-aarch64-apple-darwin (default)
nightly-2024-01-24-aarch64-apple-darwin
active toolchain
----------------
latest-aarch64-apple-darwin (default)
forc : 0.49.1
- forc-client
- forc-deploy : 0.49.1
- forc-run : 0.49.1
- forc-crypto : 0.49.1
- forc-doc : 0.49.1
- forc-explore : 0.28.1
- forc-fmt : 0.49.1
- forc-lsp : 0.49.1
- forc-tx : 0.49.1
- forc-wallet : 0.4.2
fuel-core : 0.22.0
fuel-core-keygen : 0.22.0
fuels versions
--------------
forc : 0.54.0
forc-wallet : 0.54.0
I am reaching out to the community for insights or suggestions on what might be causing the OutOfGas error and how to resolve it. Any help or guidance would be greatly appreciated.
Thank you!