Add Vector256 support to the locator#6131
Add Vector256 support to the locator#6131mvadari merged 18 commits intoXRPLF:ripple/wasmi-host-functionsfrom
Vector256 support to the locator#6131Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## ripple/wasmi-host-functions #6131 +/- ##
===========================================================
Coverage 79.8% 79.8%
===========================================================
Files 854 854
Lines 73730 73735 +5
Branches 8341 8341
===========================================================
+ Hits 58809 58813 +4
- Misses 14921 14922 +1
🚀 New features to boost your workflow:
|
|
Look good to me, but Olek should take a look. |
There was a problem hiding this comment.
Pull request overview
This PR extends the locator functionality in the WASM host functions to support STI_VECTOR256 type fields, enabling WASM smart contracts to access and navigate Vector256 fields (such as CredentialIDs) in transactions and ledger objects.
Key changes:
- Added
STI_VECTOR256as a non-leaf field type that can be indexed like arrays - Implemented Vector256 element access through the locator with proper index bounds checking
- Extended array length functions to support Vector256 fields
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/xrpld/app/wasm/detail/HostFuncImpl.cpp | Adds Vector256 support to getAnyFieldData, locateField, and array length functions; implements indexing into Vector256 fields using a thread_local temporary STUInt256 wrapper |
| src/test/app/HostFuncImpl_test.cpp | Adds comprehensive tests for Vector256 field access, including tests for retrieving Vector256 elements via locator, bounds checking, and error handling for non-leaf field access |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Locator for STVector256 | ||
| expectError( | ||
| {sfCredentialIDs.fieldCode}, HostFunctionError::NOT_LEAF_FIELD); |
There was a problem hiding this comment.
Consider adding a test case for attempting to nest further into a Vector256 element, similar to the test at lines 691-696 for nesting into non-array/object fields. For example, test a locator like {sfCredentialIDs.fieldCode, 0, sfAccount.fieldCode} which should return LOCATOR_MALFORMED since uint256 values (the elements of Vector256) are leaf nodes and cannot be nested into. This would verify that the Vector256 indexing correctly returns a leaf type that cannot be further navigated.
oleks-rip
left a comment
There was a problem hiding this comment.
Please put 319-324 into helper function, and use it in other places
|
I have concern about static variable, if someone later will call that function 2 times it will overwrite the value without any notice. Try this variants.patch patch with variants instead |
oleks-rip
left a comment
There was a problem hiding this comment.
Please add test with maximum allowed size for STI_VECTOR256
There's no maximum size, it depends on the field. |
High Level Overview of Change
Context of Change
Type of Change
.gitignore, formatting, dropping support for older tooling)API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)