Commit Graph

15216 Commits

Author SHA1 Message Date
Mayukha Vadari
2641f0c819 Add the contract test fixtures and the first real-ledger host tests
`ContractLedger` is the contract counterpart of `WasmLedger`: a real
genesis ledger with a real `ContractHostFunctionsImpl` over it, built the
way `ContractCall::doApply` builds one. It carries no test framework, for
the reason `WasmLedger` carries none — the benchmarks need a ledger and a
host, not GTest's lifecycle — so it joins `xrpl.testkit.wasm`.

`ContractHost` owns the four things the host borrows, in the order it
needs them, and its `finalize()` does what the transactor does once a
contract returns: write the data cache and the events to the ledger, then
apply. Applying alone is not enough, because `ApplyContext` reaches a
sandbox rather than the ledger under it, so `finalize()` commits that too.

`ContractHostFixture` adds the framework and the value constructors a
data test compares against, including `valueWire`, which produces the
bytes a guest writes for a value: the inverse of what `HostContext`
decodes.

`WasmLedger::tracingJournal` is extracted so a derived fixture can build
a tracing host over the same sink.
2026-09-15 18:15:13 -04:00
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
Mayukha Vadari
ca331d2dba Merge upstream/ripple/smart-escrow into xrplf/smart-contracts
Upstream rewrote the wasm VM and host-function system (Rust `crates/`
bridged via cxx), collapsed `transactions.macro` onto `TxSettings`, and
moved invariant running from `ApplyContext` to `Transactor`. This merge
resolves those conflicts and the breaks that carried no conflict marker.

Conflict resolutions of note:
- transactions.macro: took upstream's 5-argument `TxSettings` form and
  re-expressed our `emitable` column as `TxSettings::emittance`, a new
  scoped `Emittance` enum in TxSettings.h. `Emitable.cpp` and the
  transaction code generator read the new member.
- sfields.macro: upstream claimed UINT32 75-80, so `sfParameterFlag`
  moves from 80 to 86. The amendment is not live, so no wire break.
- HostFunc.h: took upstream's version, which drops `floatRoot`, and
  re-added the 15 contract virtuals. `setDataNestedObjectField`'s
  parameters are renamed to `(account, key, nestedKey, value)` to match
  the implementation; the wire order is unchanged.
- WasmCommon.h: `SubmitTxnFailure` (-21) and `InvalidState` (-22) join
  upstream's enum and the Rust `host_errors!` table. `Success` is gone;
  the helpers that compared against it now return `expected<void, ...>`.
- Transactor.cpp: kept the emitted-transaction pass, now using
  `checkInvariants(result, fee, InvariantScope::ProtocolOnly)`.

Breaks with no conflict marker:
- `Emitable.cpp` used the 8-argument TRANSACTION macro.
- `STTx::getSeqValue` is gone; use `getSeqProxy().value()`.
- `NetworkOPsImp::subLock_` is now `streamLock_`, held with `scoped_lock`.
- The `LedgerEntryHelpers` namespace is now `ledger_entry_helpers`.
- `keylet::vault` takes a `SeqProxy`. The three contract `ledger_entry`
  parsers were copy-pasted from the vault one and returned vault keylets;
  they now build contract, contract source and contract data keylets from
  their own fields. `contract_hash` is added to jss.

The 15 contract host functions still register through the deleted C++
wrapper layer, so contract bytecode does not run yet. Porting them to the
Rust-declared ABI is the next commit.
2026-09-15 15:37:08 -04:00
Mayukha Vadari
824997df60 feat: Add sponsorship, loanBroker, and loan keylet host functions (#8195) 2026-09-15 12:40:32 -04:00
Sergey Kuznetsov
becfa96f64 Merge pull request #8212 from kuznetsss/Merge_develop
chore: Merge develop, fix pre-commit, update docs
2026-09-14 14:54:22 +01:00
Sergey Kuznetsov
2841b795f6 Merge ripple/smart-escrow 2026-09-14 13:58:32 +01:00
Timothy Banks
ba968988fe Merge pull request #8201 from XRPLF/timothybanks/port-smart-escrow-tests
fix: Port smart escrow tests to new design
2026-09-11 09:30:10 -04:00
TimothyBanks
d6757ce1a5 chore: Address code review comments 2026-09-10 13:07:34 -04:00
Sergey Kuznetsov
b68a2276f5 Comment test to make clang-tidy happy 2026-09-10 17:52:50 +01:00
Sergey Kuznetsov
4eac5dbd3b Fix coverage flags. Update AGENTS.md. Add crates/README.md 2026-09-10 16:28:50 +01:00
Sergey Kuznetsov
97b272be23 Merge develop 2026-09-10 16:10:13 +01:00
TimothyBanks
09c4e35c51 chore: Address code review comments 2026-09-10 09:40:55 -04:00
Sergey Kuznetsov
9403736199 ci: Exclude Rust unit tests from code coverage (#8203) 2026-09-10 11:38:25 +00:00
Sergey Kuznetsov
646c7ed494 refactor: Generate code to register host functions in wasm vm (#8206) 2026-09-10 11:27:40 +01:00
Mayukha Vadari
028783661d feat: Apply .macro changes from ripple/smart-escrow (#8157)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-09-09 20:05:58 +00:00
TimothyBanks
e1b1a010f5 fix: Address review comments 2026-09-09 11:53:38 -04:00
TimothyBanks
2d7e92ffc5 fix: Address review comments 2026-09-09 11:45:50 -04:00
TimothyBanks
c9b365315f fix: Port remaining escrow wasm tests 2026-09-09 10:41:34 -04:00
TimothyBanks
c1133a7443 fix: Port remaining escrow wasm tests 2026-09-09 10:04:37 -04:00
Vito Tumas
21890d9daf feat: Register featureLendingProtocolV1_2 amendment (#8185)
Co-authored-by: Bart <bthomee@users.noreply.github.com>
2026-09-09 10:01:32 +00:00
TimothyBanks
dd09ec2c2f fix: Port smart escrow tests to new design 2026-09-08 21:34:23 -04:00
Sergey Kuznetsov
060957ed39 ci: Add nightly Rust toolchain to the CI image (#8182)
Co-authored-by: Bart <bthomee@users.noreply.github.com>
2026-09-09 01:24:28 +00:00
TimothyBanks
a4d1bd1a55 fix: Port smart escrow tests to new design 2026-09-08 20:58:16 -04:00
Ayaz Salikhov
1381483c7a build: Fix test installation on debian:11 due to EOL (#8200) 2026-09-08 22:49:16 +00:00
TimothyBanks
4aa695f7d9 chore: Merge upstream branch 2026-09-08 15:54:17 -04:00
TimothyBanks
c9f7e39822 Merge branch 'ripple/se/wasmi-tests' into ripple/se/fees 2026-09-08 14:33:44 -04:00
TimothyBanks
9867cc295e chore: Merge upstream branch 2026-09-08 14:27:33 -04:00
Timothy Banks
0ba8b306e3 Merge pull request #8189 from XRPLF/timothybanks/upgrade-to-wasmi-2
chore: Upgrade to Wasmi 2.0
2026-09-08 10:34:47 -04:00
TimothyBanks
daecad43c9 chore: Upgrade to Wasmi 2.0 2026-09-08 09:58:32 -04:00
Timothy Banks
e9074726cd Merge pull request #8114 from XRPLF/timothybanks/port-wat-based-tests
feat: Port wat based wasm tests to new wasm design
2026-09-08 09:31:01 -04:00
dependabot[bot]
3e4bdf2782 ci: [DEPENDABOT] bump actions/deploy-pages from 5.0.0 to 5.0.1 in the github-actions group across 1 directory (#8180)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-09-07 16:07:56 +00:00
Mayukha Vadari
e3c8996e44 feat: Add fixCleanup3_5_0 amendment placeholder (#8174) 2026-09-05 00:06:14 +00:00
TimothyBanks
4208f14a91 fix: Add additional vm benchmarks 2026-09-03 20:47:09 -04:00
yinyiqian1
d5bfe94f15 feat: Support key rotation in MPTokenIssuanceSet (#7915) 2026-09-03 21:13:06 +00:00
Bart
2ad4def35f chore: Bump version to 3.4.0-rc1 (#8171)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
3.4.0-rc1
2026-09-03 20:07:24 +00:00
Mayukha Vadari
f7f50caa6e docs: Backfill API-CHANGELOG.md for 3.1.1 through 3.3.0 (#8159) 2026-09-03 19:48:15 +00:00
Ayaz Salikhov
3e54e7d00b fix: Don't use github.workspace as it slow downs gcovr (#8173) 2026-09-03 19:20:38 +00:00
Valentin Balaschenko
827b50f169 fix: Flaky online delete tests, and cover the health checks added in #5531 (#8137) 2026-09-03 18:56:30 +00:00
Mayukha Vadari
58a59c37ed fix: Add signature prefixes for sfCounterpartySignature and sfSponsorSignature (#8162) 2026-09-03 17:19:07 +00:00
Ayaz Salikhov
986065c16f build: Verify glibc version was determined in debian package (#8170) 2026-09-03 16:54:54 +00:00
Denis Angell
37cb4cdbe3 fix: Recycle the escrow reserve in EscrowCancel and EscrowFinish (#8142) 2026-09-03 16:27:45 +00:00
TimothyBanks
491b930ebb chore: Make Calibration type a non singleton 2026-09-03 12:08:40 -04:00
Bart
2ddf6ee148 ci: Update pre-commit SHA (#8169)
Co-authored-by: Bart <11445373+bthomee@users.noreply.github.com>
2026-09-03 14:52:42 +00:00
Pratik Mankawde
8ce4f71427 docs: Use consistent heading levels in PR template (#8155) 2026-09-03 14:48:32 +00:00
Bart
6e1eb88e6e ci: Update prepare-runner SHA (#8168)
Co-authored-by: Bart <11445373+bthomee@users.noreply.github.com>
2026-09-03 11:52:08 +00:00
TimothyBanks
422b8d0a43 chore: Address review comments 2026-09-02 18:49:20 -04:00
Ayaz Salikhov
49cdc105de fix: Correct and simplify Linux packaging (#8165) 2026-09-02 21:18:13 +00:00
TimothyBanks
a1ea8d3a6e chore: Address review comments 2026-09-02 17:03:47 -04:00
Chenna Keshava B S
636d2d4851 fix: Reinforce the priority of AMMClawback in case of insufficient reserves (#7796)
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-09-02 20:48:53 +00:00
Kassaking7
7d7275847d fix: PermissionedDEX (CreateOffer/Payment) never deletes expired credentials (#6827) 2026-09-02 19:38:01 +00:00