Skip to content

Conversation

@oleks-rip
Copy link
Collaborator

High Level Overview of Change

Check and reject slices if they are non-canonical (which is possible if craft binary manually) but still represent valid number.

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

@oleks-rip oleks-rip requested a review from a team as a code owner January 23, 2026 21:08
@oleks-rip oleks-rip changed the base branch from develop to ripple/wasmi-host-functions January 23, 2026 21:08
@oleks-rip oleks-rip requested a review from mvadari January 23, 2026 21:09
}

void
testFloatNonCanonical()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we combine testFloatNonIOU and testFloatNonCanonical into something like testFloatSpecialCases?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved

void
testFloatNonCanonical()
{
testcase("float Xrp+Mpt");
Copy link
Collaborator

Choose a reason for hiding this comment

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

wrong name

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

renamed

mvadari
mvadari previously approved these changes Jan 23, 2026
@codecov
Copy link

codecov bot commented Jan 23, 2026

Codecov Report

❌ Patch coverage is 95.55556% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.9%. Comparing base (977caea) to head (d9f6039).
⚠️ Report is 1 commits behind head on ripple/wasmi-host-functions.

Files with missing lines Patch % Lines
src/xrpld/app/wasm/detail/HostFuncImplFloat.cpp 95.6% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                     Coverage Diff                     @@
##           ripple/wasmi-host-functions   #6277   +/-   ##
===========================================================
  Coverage                         79.9%   79.9%           
===========================================================
  Files                              854     854           
  Lines                            73782   73799   +17     
  Branches                          8301    8301           
===========================================================
+ Hits                             58918   58935   +17     
  Misses                           14864   14864           
Files with missing lines Coverage Δ
src/xrpld/app/wasm/HostFuncImpl.h 84.6% <ø> (ø)
src/xrpld/app/wasm/detail/HostFuncImplFloat.cpp 98.3% <95.6%> (-0.8%) ⬇️

... and 1 file 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.

std::string
floatToString(Slice const& data)
{
detail::FloatState rm(0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does this do?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Floats has global state for rounding and mantissa length. FloatState restore that state on return / exception

Copy link
Collaborator

Choose a reason for hiding this comment

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

If it's restored, why does it need to be instantiated here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We save current state of the Numbers during initialization, switch to our state and restore state on exit, so every float host-functions doesn't change system settings for floats. Isn't it obvious?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Discussed offline.
It's done in the other functions, the other functions just take a mode param to signify the rounding mode used in the math. These two functions don't need a rounding mode since there is no computation done, so we can just use the regular rounding mode.

{
try
{
detail::FloatState rm(0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does this do?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the same here

@oleks-rip oleks-rip requested a review from mvadari January 27, 2026 18:21
@oleks-rip oleks-rip merged commit c1c1b4e into XRPLF:ripple/wasmi-host-functions Jan 27, 2026
22 of 24 checks passed
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