Skip to content

Conversation

guptapratykshh
Copy link
Contributor

Description

Soroban contracts increasingly require 256-bit arithmetic compatibility with Solidity. This PR brings Solang’s Soroban backend to parity for 256-bit types, enabling broader contract portability and correctness.

Implementation -

  • Encoding/Decoding

    • Split 256-bit values into four 64-bit pieces: lo_lo (0–63), lo_hi (64–127), hi_lo (128–191), hi_hi (192–255)
    • Preserve signedness during shifts for int256
    • Reconstruct from host-provided 64-bit pieces
  • Host Functions

    • Declare and use new host functions:
      • U256: ObjToU256LoLo, ObjToU256LoHi, ObjToU256HiLo, ObjToU256HiHi, ObjFromU256Pieces
      • I256: ObjToI256LoLo, ObjToI256LoHi, ObjToI256HiLo, ObjToI256HiHi, ObjFromI256Pieces
    • Provide correct LLVM signatures:
      • ObjTo*: (i64) -> i64
      • ObjFrom*Pieces: (i64, i64, i64, i64) -> i64

Fixes #1831

Resolves: hyperledger-solang#1831
Signed-off-by: Pratyksh Gupta <pratykshgupta9999@gmail.com>
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

Successfully merging this pull request may close these issues.

Mentee Task 3: Add support for Uint/Int 256 for Stellar target
1 participant