-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat: add WASM host functions #5791
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
Closed
Closed
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
dbc9dd5
Add WAMR integration code
mvadari 8341864
add host functions
mvadari bfc048e
add tests
mvadari 51a9f10
CODEOWNERS
mvadari f03c3aa
misc host function files
mvadari b1d70db
limits
mvadari 129aa4b
bring out IOUAmount.h
mvadari 2de8488
add temBAD_WASM
mvadari a15d65f
update tests
mvadari bf32dc2
add fixtures files
mvadari 1b6312a
rearrange files
mvadari ba52d34
test: improve codecov in `HostFuncWrapper.cpp` (#5730)
mvadari ebd90c4
chore: remove unneeded float stuff (#5729)
mvadari cfe57c1
Merge branch 'ripple/wamr' into ripple/wamr-host-functions
mvadari 1c646db
Merge remote-tracking branch 'upstream/ripple/wamr' into wamr-host-fu…
mvadari edfed06
fix merge issues
mvadari 6be8f21
Latests HF perf test (#5789)
oleks-rip 9f58751
Merge branch 'ripple/wamr' into ripple/wamr-host-functions
mvadari b69b4a0
Merge branch 'ripple/wamr' into ripple/wamr-host-functions
mvadari eaba76f
Merge branch 'ripple/wamr' into ripple/wamr-host-functions
mvadari 57fc1df
switch from wasm32-unknown-unknown to wasm32v1-none (#5814)
mvadari 8dea76b
Merge branch 'ripple/wamr' into ripple/wamr-host-functions
mvadari cb62248
Merge branch 'ripple/wamr' into ripple/wamr-host-functions
mvadari da2b945
fix: remove `get_ledger_account_hash` and `get_ledger_tx_hash` host f…
mvadari c10a5f9
Merge branch 'ripple/wamr' into ripple/wamr-host-functions
mvadari c507880
Merge branch 'ripple/wamr' into ripple/wamr-host-functions
mvadari f34b05f
Merge branch 'ripple/wamr' into ripple/wamr-host-functions
mvadari 1c5683e
Merge branch 'ripple/wamr' into ripple/wamr-host-functions
mvadari 286dc63
Merge branch 'ripple/wamr' into ripple/wamr-host-functions
mvadari 101f285
return size from updateData
mvadari 29f5430
fix bug
mvadari 0c65a38
fix tests
mvadari 4021a7e
Wamr and HF security review fixes (#5965)
oleks-rip 3ffdcf8
allow 0-value trace amounts
mvadari 106dea4
update fixtures to use the latest version of stdlib
mvadari 0bc1a11
Merge branch 'wamr' into wamr-host-functions
mvadari 7bf6878
fix imports
mvadari 427b7ea
run rename script
mvadari File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,2 @@ | ||
| # Allow anyone to review any change by default. | ||
| * | ||
|
|
||
| # 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -604,6 +604,48 @@ power(Number const& f, unsigned n) | |
| return r; | ||
| } | ||
|
|
||
| // Continued fraction approximation of ln(x) | ||
| static Number | ||
| ln(Number const& x, unsigned iterations = 50) | ||
| { | ||
| if (x <= 0) | ||
| throw std::runtime_error("Not positive value"); | ||
|
|
||
| Number const z = (x - 1) / (x + 1); | ||
| Number const zz = z * z; | ||
| Number denom = Number(1, -10); | ||
|
|
||
| // Construct the fraction from the bottom up | ||
| for (int i = iterations; i > 0; --i) | ||
| { | ||
| Number k(2 * i - 1); | ||
| denom = k - (i * i * zz / denom); | ||
| } | ||
|
|
||
| auto const r = 2 * z / denom; | ||
| return r; | ||
|
Comment on lines
+625
to
+626
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: could be simply |
||
| } | ||
|
|
||
| Number | ||
| lg(Number const& x) | ||
| { | ||
| static Number const ln10 = ln(Number(10)); | ||
|
|
||
| if (x <= Number(10)) | ||
| { | ||
| auto const r = ln(x) / ln10; | ||
| return r; | ||
| } | ||
|
|
||
| // ln(x) = ln(normX * 10^norm) = ln(normX) + norm * ln(10) | ||
| int diffExp = 15 + x.exponent(); | ||
| Number const normalX = x / Number(1, diffExp); // (1 <= normalX < 10) | ||
| auto const lnX = ln(normalX) + diffExp * ln10; | ||
|
|
||
| auto const r = lnX / ln10; | ||
| return r; | ||
|
Comment on lines
+645
to
+646
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: same |
||
| } | ||
|
|
||
| // Returns f^(1/d) | ||
| // Uses Newton–Raphson iterations until the result stops changing | ||
| // to find the non-negative root of the polynomial g(x) = x^d - f | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.