Skip to content

KoraContract Wasm exceeds Soroban's 128 KiB on-chain contract-size cap — not deployable until split #2

Description

@iam-mercy

Summary

The compiled KoraContract Wasm is ~1.7× larger than Soroban's on-chain
contract-size limit
and cannot be uploaded to any live Stellar network
(testnet, mainnet, or a stock local/standalone network). This blocks every
form of live deployment and integration testing against a real contract
instance until the contract is split into smaller pieces.

This is not an SDK or build-tooling problem — it persists after the
soroban-sdk 21.7.7 → 28.0.0-rc.1 bump, the switch to wasm32v1-none, and a
wasm-opt -Oz --mvp-features pass (see PR that references this issue).

Numbers

Measured on soroban-sdk = "=28.0.0-rc.1", built with
stellar contract build --optimize=false (spec-shaking applied) then
wasm-opt -Oz --mvp-features:

Artifact Size
stellar contract build raw (wasm32v1-none, opt-level="z" + LTO + strip) 253,600 B
after wasm-opt -Oz --mvp-features 219,161 B
Soroban contract_max_size_bytes (live, from stellar network settings --network testnet) 131,072 B (128 KiB)
Over the cap by 88,089 B — 67%

Section breakdown of the optimized Wasm:

  Code (section 10)     140,822 B
  contractspecv0         57,023 B   <- mandatory, cannot be stripped
  Data (section 11)      14,744 B
  exports + type/func/etc ~6,500 B
  contractenvmetav0 / contractmetav0  ~260 B
  --------------------------------------
  total                 219,161 B     vs cap 131,072 B

Related live network limits (protocol 28 testnet):

contract_max_size_bytes : 131072    # hard cap on an uploadable Wasm
tx_max_size_bytes       : 132096    # hard cap on one transaction envelope

The upload transaction (Wasm + envelope overhead ≈ 292 KB) also exceeds
tx_max_size_bytes, so the RPC rejects it before execution:

sendTransaction -> errorResultXdr -> {"fee_charged":"0","result":"tx_malformed"}

(stellar contract deploy surfaces this as error: transaction submission failed: TxSorobanInvalid.)

Why the usual levers don't help

  • wasm-opt -Oz / stellar contract build --optimize both land at ~219 KB —
    within ~70 B of each other. They cannot close an 88 KB gap.
  • contractspecv0 (57 KB) is required for the contract to be usable and is
    already spec-shaken down from 84 KB.
  • The bulk is the code section (141 KB): KoraContract is a single
    ~12,000-line impl block exporting hundreds of functions (pet registry,
    medical records, vaccinations, insurance, disputes, governance, breeding,
    grooming, nutrition, emergency contacts, custody chain, statistics, …).

What needs to happen

Split KoraContract into multiple independently-deployable Soroban contracts,
each under 128 KiB, coordinated via cross-contract calls or a registry/router
contract. This is an architecture change for the kora-app roadmap — out of
scope
for the SDK-28 bump PR.

Impact on downstream work

Until this is resolved there is no way to run a real KoraContract instance on
a live network. Downstream integration (e.g. kora-backend's contract-gateway)
must be scoped around this — mocked/unit-tested against the contract client,
with no live end-to-end deployment.

Acceptance

  • KoraContract decomposed into deployable units, each < 131072 B
    optimized
  • Each unit uploads and deploys to testnet
  • deploy-testnet job re-enabled in .github/workflows/stellar-contracts.yml
  • CI Report contract Wasm size step passes without the over-cap warning

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions