Skip to content

fix(soroban): handle DynamicBytes in ABI spec, codec, and LLVM type system#1904

Open
aryanbaranwal001 wants to merge 2 commits into
hyperledger-solang:mainfrom
aryanbaranwal001:fix/soroban-dynamic-bytes-support
Open

fix(soroban): handle DynamicBytes in ABI spec, codec, and LLVM type system#1904
aryanbaranwal001 wants to merge 2 commits into
hyperledger-solang:mainfrom
aryanbaranwal001:fix/soroban-dynamic-bytes-support

Conversation

@aryanbaranwal001

@aryanbaranwal001 aryanbaranwal001 commented May 13, 2026

Copy link
Copy Markdown

Description

Any solidity contract on soroban using bytes as a function parameter or return type would panic at compile time. This was caused by three independent gaps in the DynamicBytes emit path.

The following contract now compiles to a valid WASM binary:

// SPDX-License-Identifier: Apache-2.0
contract BytesWriteStub {
    bytes public data;

    function set_data(bytes memory d) public {
        data = d;
    }
}

Key Changes

  • codegen/encoding/soroban_encoding.rs : added DynamicBytes arm to soroban_decode_arg and soroban_encode_arg, same as String and Address.

  • emit/soroban/mod.rs: added DynamicBytes arm to emit_function_spec_entry for both inputs and outputs.

  • emit/binary.rs: extended the Soroban guard in var_ty_uses_pointer_storage() to cover DynamicBytes, on soroban bytes is i64 handle, not a ptr, so its LLVM alloca must be i64 not ptr

Tests

  • Added one test in soroban_testcases/dynamic_bytes.rs: covering set_data call with empty bytes then with b"hello", reads back via the auto generated data() getter, and asserts equality. Verifying all three fixed gaps.

… and codec

Signed-off-by: Aryan Baranwal <aryanbaranwal131214@gmail.com>
Signed-off-by: Aryan Baranwal <aryanbaranwal131214@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.

1 participant