Files
rippled/include/xrpl
Mayukha Vadari 3106b79e4b Port the contract host functions to the Rust-declared wasm ABI
The 15 smart-contract host functions were registered through
`HostFuncWrapper.cpp` and `createWasmImport`, both of which upstream
deleted. They are now declared where every other host function is: one
`host_functions!` entry each in `crates/xrpl-host-functions`, which
generates the trait, the spec table and the wasmi registration, with a
body in the engine, a crossing in the cxx bridge, and a `HostContext`
method lowering it onto the wire.

They share the `host_lib` namespace with the escrow functions, whose host
leaves them `Unimplemented`. Wire order and gas are unchanged, so a guest
built against the old ABI still links, with two exceptions.

`emit_built_txn` and `emit_txn` gain an output region and write the TER
there as four little-endian bytes, returning the length. Their old
signature returned the TER as the call's result, which the engine reads
as a `HostError` when negative: every `tem`, `tef`, `ter` and `tel` code
would have stopped the run instead of reaching the contract.

`HostContext` decodes what the old wrappers decoded: the account region,
the typed value a `set_data_*` call carries, the serialized transaction
and the serialized event. A guest that writes those bytes wrongly gets
`InvalidParams`, so the deserializers' exceptions are caught at the call
rather than by `guarded`, which would report a node fault.

Every Rust site that enumerates the ABI is extended: the two literal
tables in `generated_abi.rs`, the import list and arity check in
`preflight.rs`, the per-function wasm in `budgets.rs`, and the three fake
hosts. `MockHostFunctions` gains the 15 methods and the matchers a
contract expectation needs.

Two `host_calls` tests cover the shapes that are new here: a typed value
decoded on its way to the host, and a TER crossing as bytes, including
the negative code that motivated the change.
2026-09-15 18:08:35 -04:00
..
2026-08-28 13:30:45 +01:00
2026-09-10 16:10:13 +01:00