Skip to content

Stellar-xdr compilation fails due to missing try_size_hint methods in Arbitrary derive #27

@samjay8

Description

@samjay8

Title: fix: stellar-xdr compilation fails due to missing try_size_hint methods in Arbitrary derive

Labels: bug, backend, rust, dependencies, priority-high

Description:
The project fails to compile because the stellar-xdr
dependency generates hundreds of Rust compilation errors
related to missing try_size_hint methods while deriving
Arbitrary.

The errors originate from generated files inside the
stellar-xdr crate and appear to be caused by a dependency
or feature mismatch between stellar-xdr, arbitrary,
and the current Rust/Soroban ecosystem versions.

This completely blocks compilation of the contracts
workspace and prevents development, testing, and deployment.

Error:
error[E0599]: no function or associated item named
try_size_hint found for struct RestoreFootprintOp
in the current scope

Additional repeated errors:

  • OperationBody
  • Operation
  • HashIdPreimage
  • Memo
  • Transaction
  • TransactionEnvelope
  • SorobanTransactionData
  • InvokeHostFunctionResult
  • OperationResult
  • TransactionResult
  • Many other generated XDR types

Final compiler output:
error: could not compile stellar-xdr (lib)
due to 1836 previous errors

This is a critical issue because the entire smart contract
workspace cannot compile successfully.

Likely Cause:
The issue is most likely caused by one of the following:

  • Version incompatibility between:

    • stellar-xdr
    • soroban-sdk
    • arbitrary
    • Rust toolchain version
  • An incompatible arbitrary crate version that does not
    expose the expected try_size_hint API

  • Incorrect crate features being enabled for stellar-xdr

  • A transitive dependency conflict introduced during
    dependency updates

What Needs to Be Done:

Option A — Align Soroban/Stellar dependency versions (preferred):

  • Verify compatible versions for:
    • soroban-sdk
    • stellar-xdr
    • soroban-env-*
    • stellar-strkey
  • Use officially compatible versions from the Soroban SDK
    release documentation
  • Update Cargo.toml dependencies accordingly
  • Run:
    cargo update
  • Rebuild the workspace

Option B — Pin the arbitrary crate version:

  • Inspect dependency tree:
    cargo tree | grep arbitrary
  • Identify incompatible versions
  • Pin a compatible arbitrary version in Cargo.toml
  • Rebuild dependencies

Option C — Disable problematic crate features:

  • Inspect whether the arbitrary feature is enabled
    unnecessarily on stellar-xdr
  • Remove or disable:
    features = ["arbitrary"]
    if fuzzing/property testing is not required
  • Rebuild the workspace

Option D — Update Rust toolchain:

  • Verify the Rust version matches the Soroban-supported
    toolchain version
  • Run:
    rustup update
    rustup override set stable
  • Rebuild after toolchain alignment

Key Files:

  • Cargo.toml
  • Cargo.lock
  • apps/contracts/Cargo.toml
  • Any workspace dependency configuration files
  • .cargo/config.toml (if present)

Commands to Investigate:

  • cargo tree | grep arbitrary
  • cargo tree | grep stellar-xdr
  • cargo tree | grep soroban
  • rustc --version
  • cargo clean
  • cargo build

Acceptance Criteria:

  • cargo build completes successfully
  • stellar-xdr compiles without try_size_hint errors
  • No Arbitrary derive failures remain
  • Soroban contracts compile successfully
  • Dependency versions are aligned and documented
  • Existing tests continue to pass
  • No duplicate or conflicting dependency versions exist
    in the workspace

Branch: fix/stellar-xdr-arbitrary-compile-failure

Commit: fix(deps): resolve stellar-xdr Arbitrary derive compilation failure

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