Skip to content

Conversation

@mvadari
Copy link
Collaborator

@mvadari mvadari commented Sep 11, 2025

High Level Overview of Change

This PR adds all the WAMR integration code and the host functions specified in XLS-102. It also adds tests for all of this.

Note for reviewers: 10k lines of this PR are just WASM-compiled test fixtures, and another 4k lines are WASM test fixture source code. So while this PR is still quite large, it's not as large as it seems on the surface.

Context of Change

This PR depends on #5790

It is part of an effort to split up #5600 into smaller, more managable-to-review PRs.

XLS-102: XRPLF/XRPL-Standards#303

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (non-breaking change that only restructures code)
  • Performance (increase or change in throughput and/or latency)
  • Tests (you added tests for code that already exists, or your new feature included in this PR)
  • Documentation update
  • Chore (no impact to binary, e.g. .gitignore, formatting, dropping support for older tooling)
  • Release

API Impact

N/A

Test Plan

Several tests are added to this PR.

@mvadari mvadari requested a review from a team as a code owner September 11, 2025 16:11
@codecov
Copy link

codecov bot commented Sep 11, 2025

Codecov Report

❌ Patch coverage is 92.41448% with 153 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.7%. Comparing base (334bcfa) to head (427b7ea).

Files with missing lines Patch % Lines
src/xrpld/app/wasm/detail/WamrVM.cpp 76.6% 86 Missing ⚠️
src/xrpld/app/wasm/detail/HostFuncWrapper.cpp 93.5% 56 Missing ⚠️
src/xrpld/app/wasm/HostFuncImpl.h 81.8% 4 Missing ⚠️
src/xrpld/app/wasm/detail/WasmVM.cpp 95.9% 4 Missing ⚠️
src/xrpld/app/wasm/detail/HostFuncImpl.cpp 99.7% 2 Missing ⚠️
src/libxrpl/basics/Number.cpp 95.2% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##           ripple/wamr   #5791     +/-   ##
=============================================
+ Coverage         78.2%   78.7%   +0.4%     
=============================================
  Files              816     825      +9     
  Lines            68948   70964   +2016     
  Branches          8354    8436     +82     
=============================================
+ Hits             53941   55819   +1878     
- Misses           15007   15145    +138     
Files with missing lines Coverage Δ
include/xrpl/basics/Number.h 100.0% <ø> (ø)
include/xrpl/protocol/IOUAmount.h 100.0% <ø> (ø)
include/xrpl/protocol/TER.h 100.0% <ø> (ø)
src/libxrpl/protocol/IOUAmount.cpp 90.1% <100.0%> (+0.1%) ⬆️
src/libxrpl/protocol/TER.cpp 100.0% <ø> (ø)
src/xrpld/app/wasm/HostFunc.h 100.0% <100.0%> (ø)
src/xrpld/app/wasm/ParamsHelper.h 100.0% <100.0%> (ø)
src/xrpld/app/wasm/WamrVM.h 100.0% <100.0%> (ø)
src/xrpld/app/wasm/WasmVM.h 100.0% <100.0%> (ø)
src/libxrpl/basics/Number.cpp 99.3% <95.2%> (-0.2%) ⬇️
... and 5 more

... and 5 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment on lines -3 to -8

# Require the rpc-reviewers team to review changes to the rpc code.
include/xrpl/protocol/ @xrplf/rpc-reviewers
src/libxrpl/protocol/ @xrplf/rpc-reviewers
src/xrpld/rpc/ @xrplf/rpc-reviewers
src/xrpld/app/misc/ @xrplf/rpc-reviewers
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this being removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change won't be merged. It's just so the group isn't pinged for all of our PRs not going into develop.

Comment on lines +644 to +645
auto const r = 2 * z / denom;
return r;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could be simply return 2 * z / denom;

Comment on lines +664 to +665
auto const r = lnX / ln10;
return r;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: same

@vvysokikh1 vvysokikh1 self-requested a review October 30, 2025 11:06
Comment on lines +55 to +57
--cacheIdx;
if (cacheIdx < 0 || cacheIdx >= MAX_CACHE)
return Unexpected(HostFunctionError::SLOT_OUT_RANGE);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a possibly integer underflow (UB). If the user passes minimal int, this will flip

Comment on lines +42 to +50
if (!isLedgerObjCached)
{
isLedgerObjCached = true;
currentLedgerObj = ctx.view().read(leKey);
}
if (currentLedgerObj)
return currentLedgerObj;
return Unexpected(HostFunctionError::LEDGER_OBJ_NOT_FOUND);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this whole function does not make a lot of sense as API.

if we are talking only in context of escrow, then in escrowFinish::preflight we already verified that sle can be found. In this case we can just pass the SLE into the WasmHostFunctionImpl constructor and consider it cached already. There will be no need for the bool variable to track it, no error code etc.

Even if we expand on this to consider other types of SLE, it would still make more sense to just cache this SLE?

Even in case we want to do it this way, it still is enough to read the object, then return it or the error depending on if it's nullptr or not. The bool variable here is completely obsolete

@vvysokikh1 vvysokikh1 self-requested a review November 4, 2025 12:27
@mvadari
Copy link
Collaborator Author

mvadari commented Dec 2, 2025

Closed in favor of #6075

@mvadari mvadari closed this Dec 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants