Skip to content

Fix pseudo-account ID calculation#5447

Merged
bthomee merged 2 commits intodevelopfrom
Bronek/vault_pseudoaccount_fix
May 23, 2025
Merged

Fix pseudo-account ID calculation#5447
bthomee merged 2 commits intodevelopfrom
Bronek/vault_pseudoaccount_fix

Conversation

@Bronek
Copy link
Copy Markdown
Collaborator

@Bronek Bronek commented May 23, 2025

High Level Overview of Change

Before #5224, pseudo-account ID was calculated using prefix expressed in std::uint16_t. #5224 included refactoring to move the pseudo-account ID calculation to View.cpp, so this calculation can be reused in VaultCreate. This refactoring had accidentally changed the prefix type to int (derived from auto i = 0) which in turn changed the length of the first input to sha512Half from 2 bytes to 4, altering the calculation result.

This resulted in a different ID of the pseudo-account calculated from the function after the refactoring, breaking the ledger. This impacts AMMCreate, even when SingleAssetVault amendment is not active.

Context of Change

In #5224 I accidentally altered the calculation of pseudo-account ID, even when SingleAssetVault amendment is not active. This is obviously breaking the ledger, unintentionally making #5224 a "breaking change". This fix brings back the old calculation.

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)

Before #5224, pseudoaccount ID was calculated using prefix expressed in
std::uint16_t. The refactoring to move the pseudoaccount ID calculation to
View.cpp had accidentally changed the prefix type to int (derived from
`auto i = 0`) which in turn changed the length of the input to
`sha512Half` from 2 bytes to 4, altering the result.

This resulted in a different ID of the pseudoaccount calculated from the
function after the refactoring, breaking the ledger. This impacts
AMMCreate, even when SingleAssetVault amendment is not active.
@Bronek Bronek added this to the 2.5.0 (Q2 2025) milestone May 23, 2025
@Bronek Bronek added the Bug label May 23, 2025
@Bronek Bronek added the Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. label May 23, 2025
@bthomee bthomee enabled auto-merge (squash) May 23, 2025 13:34
@codecov
Copy link
Copy Markdown

codecov bot commented May 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.5%. Comparing base (7713ff8) to head (b455152).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           develop   #5447   +/-   ##
=======================================
  Coverage     78.5%   78.5%           
=======================================
  Files          813     813           
  Lines        70085   70086    +1     
  Branches      8282    8279    -3     
=======================================
+ Hits         55033   55043   +10     
+ Misses       15052   15043    -9     
Files with missing lines Coverage Δ
src/xrpld/ledger/detail/View.cpp 91.1% <100.0%> (ø)

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

@bthomee bthomee merged commit 40ce8a8 into develop May 23, 2025
4 checks passed
@bthomee bthomee deleted the Bronek/vault_pseudoaccount_fix branch May 23, 2025 14:05
This was referenced Jun 12, 2025
@legleux legleux mentioned this pull request Jun 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants