FuelLabs / sway

🌴 Empowering everyone to build reliable and efficient smart contracts.
https://docs.fuel.network/docs/sway/
Apache License 2.0
62.58k stars 5.37k forks source link

Too many arguments, cannot handle.: Immediate12TooLarge #6542

Closed cctdaniel closed 2 months ago

cctdaniel commented 2 months ago

Related Component

compiler

Problem

thread 'main' panicked at sway-core/src/asm_generation/fuel/functions.rs:121:30:
Too many arguments, cannot handle.: Immediate12TooLarge { val: 5300, span: Span { src (ptr): 0x600001564300, source_id: None, start: 0, end: 0, as_str(): "" } }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Steps

  1. git clone https://github.com/pyth-network/pyth-crosschain
  2. cd target_chains/fuel/contracts
  3. change fuel-toolchain.toml to forc 0.63.5 and fuel-core to 0.35.0
  4. forc deploy --testnet

Possible Solution(s)

No response

Notes

forc build works but forc deploy --testnet fails with the error

Installed components

latest  - Up to date
beta-5  - Up to date
nightly - Up to date
fuelup  - Up to date
cctdaniel commented 2 months ago

The compiler error "Too many arguments, cannot handle" has been resolved by refactoring the main.sw file. We moved some of the longer functions, particularly those within implementations, into separate internal functions. This approach reduced the complexity within the implementations and resolved the "Immediate12TooLarge" error.

The key changes included:

  1. Moving the execute_governance_instruction function out of the PythGovernance implementation.
  2. Creating separate internal functions for complex operations.
  3. Simplifying the structure of some longer functions.

These modifications allowed the contract to compile successfully without changing its core functionality. The issue can now be closed as the deployment error has been resolved.