Skip to content
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

Fix EscrowFinish fulfillment and condition parsing #512

Merged
merged 8 commits into from
Oct 16, 2024

Conversation

nkramer44
Copy link
Collaborator

@nkramer44 nkramer44 commented Dec 18, 2023

Fixes #513

As seen in transaction 138543329687544CDAFCD3AB0DCBFE9C4F8E710397747BA7155F19426F493C8D, sometimes EscrowFinish transactions can show up in validated ledger transaction sets with an invalid fulfillment or condition. We added a fulfillmentRawValue and conditionRawValue, and normalization functions to try to make fulfillment() equivalent to fulfillmentRawValue and condition() equivalent to conditionRawValue in #483. However, we missed a special case where the fulfillment or condition could be well formed in the first 32 bytes, but contain extra bytes afterward (in the case of 138543329687544CDAFCD3AB0DCBFE9C4F8E710397747BA7155F19426F493C8D, the fulfillment is duplicated), which causes an exception to be thrown by the normalization function.

This PR fixes this issue by checking that the parsed fulfillment or condition is equivalent to the fulfillment/condition raw value. If it is not equivalent, we will not set fulfillment or condition. If it is, we will.

…ent to the raw value when re-written before setting typed fields.
Copy link

codecov bot commented Dec 18, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.01%. Comparing base (be893dd) to head (de91349).
Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #512      +/-   ##
============================================
+ Coverage     92.00%   92.01%   +0.01%     
- Complexity     1833     1835       +2     
============================================
  Files           381      381              
  Lines          5090     5098       +8     
  Branches        431      433       +2     
============================================
+ Hits           4683     4691       +8     
  Misses          272      272              
  Partials        135      135              
Flag Coverage Δ
?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@sappenin sappenin left a comment

Choose a reason for hiding this comment

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

LGTM!

@nkramer44 nkramer44 merged commit f9020da into main Oct 16, 2024
21 checks passed
@nkramer44 nkramer44 deleted the nk/fix-escrow-fulfillments branch October 16, 2024 17:36
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.

LedgerResult Deserialization: Invalid but parseable EscrowFinish fulfillment
2 participants