Skip to content

trace host function refactor - #7920

Open
pwang200 wants to merge 1 commit into
ripple/wasmi-host-functionsfrom
ripple/wasmi-host-functions-trace2
Open

trace host function refactor#7920
pwang200 wants to merge 1 commit into
ripple/wasmi-host-functionsfrom
ripple/wasmi-host-functions-trace2

Conversation

@pwang200

Copy link
Copy Markdown
Contributor

High Level Overview of Change

The five trace_* host functions now return nothing, charge a flat 30 gas instead of 500, and skip all work when the node's log level is below Trace.

This breaks the guest wasm ABI: trace, trace_num, trace_acct, trace_xfloat, and trace_amt change from -> i32 to no result. Fixtures are regenerated against a matching xrpl-wasm-stdlib branch; guests built against the old signatures will fail to instantiate.

API Impact

  • Public API: New feature (new methods and/or new fields)
  • Public API: Breaking change (in general, breaking changes should only impact the next api_version)
  • libxrpl change (any change that may affect libxrpl or dependents of libxrpl)
  • Peer protocol change (must be backward compatible or bump the peer protocol version)

The HostFunctions virtuals in include/xrpl/tx/wasm/HostFunc.h change return type and their base implementations become no-ops rather than returning Unimplemented.

Future Tasks

The fixture Cargo.toml files pin a scratch stdlib branch (renames_error_code_trace) and should be repointed once the rename and trace changes land on stdlib main, regenerating fixtures and re-verifying gas expectations.

@pwang200
pwang200 force-pushed the ripple/wasmi-host-functions-trace2 branch from 21a8698 to 260dfc5 Compare July 30, 2026 19:39
@pwang200
pwang200 requested a review from mvadari July 30, 2026 20:07
@codecov

codecov Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.47368% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/libxrpl/tx/wasm/HostFuncWrapper.cpp 88.7% 8 Missing ⚠️

📢 Thoughts on this report? Let us know!

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good. No issues to flag.

return returnResult(runtime, params, results, hf.trace(*msg, *data, *asHex != 0), index);
try
{
int index = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Let's use one of the stdint types. I have seen this through this file.

auto const msg = getDataString(runtime, params, index);
auto const data = getDataSlice(runtime, params, index);
auto const asHex = getDataInt32(runtime, params, index);
if (!msg || !data || !asHex || (*asHex != 0 && *asHex != 1) ||

@TimothyBanks TimothyBanks Jul 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it be anymore efficient to change the check to something like this:

auto const msg = getDataString(runtime, params, index);
if (!msg)
{
  return nullptr;
}
auto const data = getDataSlice(runtime, params, index);
if (!data)
{
  return nullptr;
}
// etc

This would apply to all functions in this file.

try
{
int index = 0;
WasmRuntimeWrapper& runtime = hf.getRT();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Maybe use auto here as well to maintain consistency with the rest of the function?

This would apply to all functions in this file.

}
hf.trace(*msg, *data, *asHex != 0);
}
catch (std::exception const& e)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is catching std::exception enough? Is it ok for other exceptions to bubble across the boundary?

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.

2 participants