8000 add more keylet host functions, helper macros by mvadari · Pull Request #5522 · XRPLF/rippled · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

add more keylet host functions, helper macros #5522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: ripple/smart-escrow
Choose a base branch
from

Conversation

mvadari
Copy link
Collaborator
@mvadari mvadari commented Jul 1, 2025

High Level Overview of Change

Context of Change

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

  • 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)

@@ -51,6 +51,10 @@ setData(
return ssz;
}

#pragma push_macro("EXTRACT_ARG_UINT32")
#undef EXTRACT_ARG_UINT32
#define EXTRACT_ARG_UINT32(i) (params->data[i].of.i32)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This macro doesn't save any space, don't see any good reason for it to be introduced.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Easier to understand what's going on with it IMO

@@ -68,6 +72,42 @@ getData(InstanceWrapper const* rt, int32_t src, int32_t ssz)
return data;
}

#pragma push_macro("EXTRACT_ARG_BLOB")
#undef EXTRACT_ARG_BLOB
#define EXTRACT_ARG_BLOB(i) \
Copy link
Collaborator
@oleks-rip oleks-rip Jul 2, 2025

Choose a reason for hiding this comment

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

These macroses (EXTRACT...) doesn't use any specific macro functionality, so they must be functions

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Used as macros because of error handling - otherwise you have to have special error handling for that. I'd ideally prefer a templated function version, but I can't get that to work properly - I plan on updating to that when I get it working (which would be in a separate PR).

@@ -23,6 +23,46 @@

namespace ripple {

#pragma push_macro("ACCOUNT_PARAM")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Better to revert this full change, it will make much more difficult to debug.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this makes this file much easier to read/reason about - before, I had to do all this analysis myself

@mvadari mvadari marked this pull request as ready for review July 2, 2025 16:06
@mvadari mvadari requested a review from a team as a code owner July 2, 2025 16:06
@mvadari mvadari removed the request for review from a team July 2, 2025 16:06
@@ -51,6 +51,10 @@ setData(
return ssz;
}

#pragma push_macro("EXTRACT_ARG_UINT32")
Copy link
Collaborator
@oleks-rip oleks-rip Jul 2, 2025

Choose a reason for hiding this comment

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

You don't need to push and pop macros inside cpp file, just #undef will be fine

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's done in other cpp files in the repo, would rather stick with the norms

// function wrappers
#pragma push_macro("KEYLET_WRAPPER")
#undef KEYLET_WRAPPER
#define KEYLET_WRAPPER(FUNC, i, ...) \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use macro only for name concatenation, and make the body as another general function / template

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Needed for the function name

Copy link
codecov bot commented Jul 2, 2025

Codecov Report

Attention: Patch coverage is 4.18605% with 206 lines in your changes missing coverage. Please review.

Project coverage is 78.5%. Comparing base (ece3a8d) to head (58a959d).
Report is 1 commits behind head on ripple/smart-escrow.

Files with missing lines Patch % Lines
src/xrpld/app/misc/WasmHostFuncWrapper.cpp 0.0% 120 Missing ⚠️
src/xrpld/app/misc/WasmHostFuncImpl.cpp 0.0% 65 Missing ⚠️
src/xrpld/app/misc/WasmHostFunc.h 0.0% 21 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                  Coverage Diff                  @@
##           ripple/smart-escrow   #5522     +/-   ##
=====================================================
- Coverage                 78.7%   78.5%   -0.2%     
=====================================================
  Files                      825     825             
  Lines                    73098   73311    +213     
  Branches                  8548    8684    +136     
=====================================================
+ Hits                     57553   57584     +31     
- Misses                   15545   15727    +182     
Files with missing lines Coverage Δ
src/xrpld/app/misc/WasmHostFuncImpl.h 100.0% <ø> (ø)
src/xrpld/app/misc/WasmVM.cpp 97.1% <100.0%> (+0.4%) ⬆️
src/xrpld/app/misc/WasmHostFunc.h 3.9% <0.0%> (-1.4%) ⬇️
src/xrpld/app/misc/WasmHostFuncImpl.cpp 26.2% <0.0%> (-6.1%) ⬇️
src/xrpld/app/misc/WasmHostFuncWrapper.cpp 34.8% <0.0%> (-13.9%) ⬇️

... and 7 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mvadari
Copy link
Collaborator Author
mvadari commented Jul 3, 2025

This PR will be greatly simplified by #5534 so going to wait on that (whatever its end form becomes)

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
0