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 handling of custom fees in token create transaction builder #9632

Merged
merged 4 commits into from Nov 9, 2023

Conversation

MrValioBg
Copy link
Contributor

@MrValioBg MrValioBg commented Nov 2, 2023

Description:

This PR fixes the builder logic for adding customFees to the TransactionBuilder. As well as improves code readability in CreateSyntheticTxnFactory.

In the TokenCreateWrapper we initialize the fixedFees, fractionalFees & royaltyFees in the constructor to List.of(); So its not possible for them to be null. Also customFees method in TokenCreateTransactionBody directly overrides the Collection rather than adding the elements of the newly passed ones to it.

This PR addresses those issues.

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

Signed-off-by: Valentin Valkanov <valentin.valkanov@limechain.tech>
Signed-off-by: Valentin Valkanov <valentin.valkanov@limechain.tech>
Signed-off-by: Valentin Valkanov <valentin.valkanov@limechain.tech>
Copy link

github-actions bot commented Nov 2, 2023

Node: Unit Test Results

    2 271 files      2 271 suites   1h 26m 10s ⏱️
118 338 tests 118 304 ✔️ 34 💤 0
126 599 runs  126 565 ✔️ 34 💤 0

Results for commit 61ecab2f.

♻️ This comment has been updated with latest results.

Copy link

codecov bot commented Nov 2, 2023

Codecov Report

Attention: 27 lines in your changes are missing coverage. Please review.

Comparison is base (824d007) 0.00% compared to head (ec63071) 65.29%.

❗ Current head ec63071 differs from pull request most recent head 61ecab2. Consider uploading reports for the commit 61ecab2 to get more accurate results

Additional details and impacted files
@@              Coverage Diff               @@
##             develop    #9632       +/-   ##
==============================================
+ Coverage           0   65.29%   +65.29%     
- Complexity         0    29689    +29689     
==============================================
  Files              0     3260     +3260     
  Lines              0   124577   +124577     
  Branches           0    12916    +12916     
==============================================
+ Hits               0    81345    +81345     
- Misses             0    40158    +40158     
- Partials           0     3074     +3074     
Files Coverage Δ
...exec/systemcontracts/hts/create/CreateDecoder.java 0.98% <0.00%> (ø)
...ontracts/hts/create/CreateSyntheticTxnFactory.java 0.00% <0.00%> (ø)

... and 3258 files with indirect coverage changes

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

Copy link

github-actions bot commented Nov 2, 2023

Node: E2E Test Results

    1 files      1 suites   22m 25s ⏱️
310 tests 310 ✔️ 0 💤 0
332 runs  332 ✔️ 0 💤 0

Results for commit 61ecab2f.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Nov 2, 2023

Node: Integration Test Results

280 tests   280 ✔️  32m 50s ⏱️
    5 suites      0 💤
    5 files        0

Results for commit 61ecab2f.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Nov 3, 2023

Node: HAPI Test Results

1 242 tests   802 ✔️  1h 16m 53s ⏱️
   165 suites  440 💤
   165 files        0

Results for commit 61ecab2f.

♻️ This comment has been updated with latest results.

@mustafauzunn mustafauzunn added the Limechain Work planned for the LimeChain team label Nov 3, 2023
@MrValioBg MrValioBg marked this pull request as ready for review November 6, 2023 09:47
Copy link
Collaborator

@tinker-michaelj tinker-michaelj left a comment

Choose a reason for hiding this comment

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

I'm not certain I understand the point of the change; can you add a unit test that fails on develop and passes here to clarify?

@MrValioBg
Copy link
Contributor Author

MrValioBg commented Nov 8, 2023

Hey @tinker-michaelj

I was working on 9398, the tests were failing, producing a SUCCESS status instead of the expected INVALID_CUSTOM_FEE_COLLECTOR. Upon investigating the workflow, I discovered an issue with the way custom fees are added in the transaction builder for the create token operation, which I have addressed in this PR.

The if checks in CreateSyntheticTxnFactory that I removed were redundantly checking if specific fees are null - these fees are initialized in the constructor of TokenCreateWrapper as List.of(), so they are never null.

Additionally, the way we were adding the fees was incorrect. The customFees(List) method in TokenCreateTransactionBody simply assigns/overrides the local field for customFees in the TokenCreateTransactionBody.

Consequently, the following issue occurred:

  • Since the null checks are redundant and the Fees Collections are never null, we always end up passing every if check.
  • Furthermore, because txnBodyBuilder.customFees() overrides the custom fees in TokenCreateTransactionBody, all fees were being replaced by the royalty fees, as they are the last if check to be processed.

This issue became apparent when I noticed that the CustomFees in TokenCreateTransactionBody were always zero, which was due to the absence of royalty fees, resulting in the collection being overridden with an empty list.

I have not enabled any tests in this PR since after this fix the tests still fails, but now due to the missing child record logic.

Copy link
Collaborator

@tinker-michaelj tinker-michaelj left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the explanation @MrValioBg !

@MrValioBg MrValioBg merged commit 91e3209 into develop Nov 9, 2023
10 of 11 checks passed
@MrValioBg MrValioBg deleted the fix-custom-fee-builder-for-create-token branch November 9, 2023 08:29
ilko-iliev-lime pushed a commit that referenced this pull request Nov 10, 2023
Signed-off-by: Valentin Valkanov <valentin.valkanov@limechain.tech>
nickpoorman pushed a commit that referenced this pull request Nov 22, 2023
Signed-off-by: Valentin Valkanov <valentin.valkanov@limechain.tech>
Signed-off-by: Nick Poorman <nick@swirldslabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Limechain Work planned for the LimeChain team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants