Summary
The current invoke_host_function() API accepts all inputs as XDR-encoded bytes and returns outputs as encoded bytes. This made sense for the C++ stellar-core FFI boundary, but imposes unnecessary overhead on pure-Rust embedders that already have typed XDR objects — they pay for two redundant XDR round-trips per transaction (serialize typed inputs to bytes, then deserialize byte outputs back to typed).
Proposal
Add a parallel invoke_host_function_typed() that accepts and returns native Rust XDR types directly (HostFunction, SorobanResources, AccountId, etc.), along with:
- A typed result struct (
InvokeHostFunctionTypedResult) returning Result<ScVal, HostError>, post-execution Storage, Events, initial TTL/storage state, and restored key information — everything a Rust embedder needs to compute rent and ledger changes without re-encoding.
- A typed
get_ledger_changes_typed() that mirrors the existing get_ledger_changes() but returns Rc<LedgerKey> / Rc<LedgerEntry> instead of encoded byte vectors.
- Public type aliases (
TtlEntryMap, RestoredKeySet) so downstream consumers can work with these types directly.
The existing bytes-based API remains unchanged — this is purely additive.
Summary
The current
invoke_host_function()API accepts all inputs as XDR-encoded bytes and returns outputs as encoded bytes. This made sense for the C++ stellar-core FFI boundary, but imposes unnecessary overhead on pure-Rust embedders that already have typed XDR objects — they pay for two redundant XDR round-trips per transaction (serialize typed inputs to bytes, then deserialize byte outputs back to typed).Proposal
Add a parallel
invoke_host_function_typed()that accepts and returns native Rust XDR types directly (HostFunction,SorobanResources,AccountId, etc.), along with:InvokeHostFunctionTypedResult) returningResult<ScVal, HostError>, post-executionStorage,Events, initial TTL/storage state, and restored key information — everything a Rust embedder needs to compute rent and ledger changes without re-encoding.get_ledger_changes_typed()that mirrors the existingget_ledger_changes()but returnsRc<LedgerKey>/Rc<LedgerEntry>instead of encoded byte vectors.TtlEntryMap,RestoredKeySet) so downstream consumers can work with these types directly.The existing bytes-based API remains unchanged — this is purely additive.