Internal Compiler Error When Compiling Perp Contract: ‘delta_balance’ Variable Resolution Issue
Hello Fuel Community,
I’ve hit a roadblock in the development of my perpetual contract and am seeking insights or assistance from the community. During compilation, I encountered an internal compiler error related to the inability to resolve a variable named ‘delta_balance’. The error message is as follows:
____
error: Internal compiler error: Unable to resolve variable 'delta_balance'.
Please file an issue on the repository and include the code that triggered this error.
____
Aborting due to 1 error.
Error: Failed to compile vault
This issue arises when I attempt to call the following function in my contract:
#[payable, storage(read, write)]
fn deposit_collateral(token: AssetId){
reentrancy_guard();
require_not_paused();
if (token != SETTLEMENT_TOKEN) {
require(is_allowed_collateral(token), Error::InvalidAsset);
let config = storage.collateral_configurations.get(token).read();
// V_GTDC: greater than deposit cap
require(this_balance(token) <= config.deposit_cap, "V_GTDC");
}
let caller = msg_sender_address();
modify_balance(caller, token, I64::from(msg_amount()));
}
The code for the contract is currently in a private repository. If you’re able to assist and would like access to review the code more thoroughly, please reach out to me here or directly on Telegram at @defi_defiler.
Repository link: https://github.com/compolabs/spark-perps
Branch: multi-collateral
Additionally, here are the details of my current toolchain setup:
Default host: aarch64-apple-darwin
fuelup home: /Users/alexey/.fuelup
installed toolchains
--------------------
latest-aarch64-apple-darwin (default)
latest-2023-11-15-aarch64-apple-darwin
my-custom-toolchain
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 appreciate any guidance or suggestions on how to resolve this issue or if anyone has faced something similar. Your expertise and advice would be invaluable in helping me move forward with my project.
Thank you in advance for your time and help.
This draft includes a concise description of the problem, the error message, a snippet of the code where the issue occurs, a call for assistance, and detailed information about your toolchain environment. It’s structured to provide the community with enough context to offer informed help or advice.