Skip to content

Add Vector256 support to the locator#6131

Merged
mvadari merged 18 commits intoXRPLF:ripple/wasmi-host-functionsfrom
mvadari:vector256
Jan 16, 2026
Merged

Add Vector256 support to the locator#6131
mvadari merged 18 commits intoXRPLF:ripple/wasmi-host-functionsfrom
mvadari:vector256

Conversation

@mvadari
Copy link
Copy Markdown
Collaborator

@mvadari mvadari commented Dec 10, 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)

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.8%. Comparing base (209a1a6) to head (ccf1a83).
⚠️ Report is 1 commits behind head on ripple/wasmi-host-functions.

Additional details and impacted files

Impacted file tree graph

@@                     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     
Files with missing lines Coverage Δ
src/xrpld/app/wasm/detail/HostFuncImplGetter.cpp 100.0% <100.0%> (ø)

... 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.

@pwang200
Copy link
Copy Markdown
Collaborator

Look good to me, but Olek should take a look.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_VECTOR256 as 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.

Comment on lines +687 to +689
// Locator for STVector256
expectError(
{sfCredentialIDs.fieldCode}, HostFunctionError::NOT_LEAF_FIELD);
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

@oleks-rip oleks-rip left a comment

Choose a reason for hiding this comment

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

Please put 319-324 into helper function, and use it in other places

Comment thread src/xrpld/app/wasm/detail/HostFuncImpl.cpp Outdated
@mvadari mvadari requested a review from oleks-rip January 6, 2026 20:21
@oleks-rip
Copy link
Copy Markdown
Collaborator

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

Comment thread src/test/app/HostFuncImpl_test.cpp Outdated
Comment thread src/test/app/HostFuncImpl_test.cpp Outdated
Comment thread src/xrpld/app/wasm/detail/HostFuncImpl.cpp Outdated
Comment thread src/xrpld/app/wasm/detail/HostFuncImpl.cpp Outdated
Comment thread src/xrpld/app/wasm/detail/HostFuncImpl.cpp Outdated
@mvadari mvadari requested a review from oleks-rip January 7, 2026 21:49
Comment thread src/xrpld/app/wasm/detail/HostFuncImpl.cpp Outdated
@mvadari mvadari requested a review from oleks-rip January 12, 2026 20:22
Copy link
Copy Markdown
Collaborator

@oleks-rip oleks-rip left a comment

Choose a reason for hiding this comment

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

Please add test with maximum allowed size for STI_VECTOR256

@mvadari
Copy link
Copy Markdown
Collaborator Author

mvadari commented Jan 13, 2026

Please add test with maximum allowed size for STI_VECTOR256

There's no maximum size, it depends on the field.

@mvadari mvadari requested a review from oleks-rip January 14, 2026 17:42
Comment thread src/test/app/HostFuncImpl_test.cpp Outdated
Comment thread src/test/app/HostFuncImpl_test.cpp
@mvadari mvadari merged commit 9a9a7aa into XRPLF:ripple/wasmi-host-functions Jan 16, 2026
25 checks passed
@mvadari mvadari deleted the vector256 branch February 4, 2026 22:34
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.

4 participants