-
Notifications
You must be signed in to change notification settings - Fork 217
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
Handle reclaims in get transaction #3104
Handle reclaims in get transaction #3104
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Also adding a returned deposit check for quitting in the old workflow would be nice
I.e. here lib/core-integration/src/Test/Integration/Scenario/API/Shelley/StakePools.hs:395
-- Quit delegation altogether.
rq <- quitStakePool @n ctx (src, fixturePassphrase)
verify rq
-- pending tx for quitting pool is initially outgoing
-- because there is a fee for this tx
[ expectResponseCode HTTP.status202
, expectField (#status . #getApiT) (`shouldBe` Pending)
, expectField (#direction . #getApiT) (`shouldBe` Incoming)
]
reclaimIfAny :: Natural | ||
reclaimIfAny | ||
| tx ^. (#txMeta . #direction) == W.Outgoing = | ||
if totalIn < totalOut | ||
then totalOut - totalIn | ||
else 0 | ||
| otherwise = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looked odd to me at first, but I guess it is correct, as the ins, outs and withdrawals include both ours and foreign.
@paweljakubas I see an issue:
I've added checks to illustrate this to repective tests:
|
cd5f9db
to
29c2adf
Compare
@piotr-iohk @Anviking now all checks in tests added by Piotr passes. the problem was solved by:
|
29c2adf
to
e6d6643
Compare
lib/core/src/Cardano/Wallet.hs
Outdated
dir = if (txCtx ^. #txDelegationAction) == Just Quit then | ||
Incoming | ||
else | ||
Outgoing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything TxMeta
-related seems so complicated, and I don't grasp the full picture, but this change might interplay with the rollback logic
It seems a pending Quit
tx could be deleted on rollback. I'm not sure if it also stops the wallet from trying to re-submit it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I bet it is not going to destroy anything as for OLD tx workflow Incoming was for both Pending/InLedger. We had Outcoming -> Incoming for new tx workflow though. and now we have the transition/directions as for old tx workflow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair, the old tx workflow should also be able to produce pending incoming txs through this logic.
I still suspect this could be a problem, but unrelated to this PR.
@paweljakubas I'm getting issues (
in the wallet.log there is:
|
I see this also in integration tests when running
CLI Specifications, SHELLEY_CLI_TRANSACTIONS, TRANS_LIST_03 - Can order results I bet I need to make sure not to substract bigger natural from smaller one in |
@piotr-iohk indeed, my hypothesis was right. I needed one more check in reclaimIfAny. Now the test passes. Could you kindly confirm? |
lib/core/src/Cardano/Wallet.hs
Outdated
@@ -2142,9 +2143,13 @@ mkTxMetaWithoutSel blockHeader wState txCtx inps outs = | |||
w@WithdrawalSelf{} -> Coin.add (withdrawalToCoin w) | |||
WithdrawalExternal{} -> Prelude.id | |||
NoWithdrawal -> Prelude.id | |||
dir = if (txCtx ^. #txDelegationAction) == Just Quit then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic is called from submitTransaction
, where the user could submit any kind of (wallet-related) transaction.
Defining the direction this way might work for txs from constructTransaction
, but with balanceTransaction
it would quickly break.
What was the reason we can't use mkTxMeta
instead of constructTxMeta
? (which itself is duplicated with logic in Primitive.Model)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, we are not doing selection when submitting, we are decoding what is inside tx cbor to be sent. hence we do not use, mkTxMeta
. But, we can resign from dir
and compare amtInps
and amtOuts
to determine direction. Now it should survive balanceTransaction
step (or at least we will not deteriorate situation in the context what was before this PR). I have refactored constructTxMeta and found a bug in submitTransaction. And simplified the things. And locally it is green
---> see the last commit
fbf3708
to
fdf53da
Compare
bors r+ |
3104: Handle reclaims in get transaction r=paweljakubas a=paweljakubas <!-- Detail in a few bullet points the work accomplished in this PR. Before you submit, don't forget to: * Make sure the GitHub PR fields are correct: ✓ Set a good Title for your PR. ✓ Assign yourself to the PR. ✓ Assign one or more reviewer(s). ✓ Link to a Jira issue, and/or other GitHub issues or PRs. ✓ In the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages. * Don't waste reviewers' time: ✓ If it's a draft, select the Create Draft PR option. ✓ Self-review your changes to make sure nothing unexpected slipped through. * Try to make your intent clear: ✓ Write a good Description that explains what this PR is meant to do. ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding Jira ticket. ✓ Highlight what Testing you have done. ✓ Acknowledge any changes required to the Documentation. --> - [x] Update of `ApiTransaction` to include `depositTaken` and `depositReturned` - [x] adding of integration tests showing the case for joining/rejoining and quitting - [x] update core unit tests and swagger ### Comments <!-- Additional comments, links, or screenshots to attach, if any. --> ### Issue Number <!-- Reference the Jira/GitHub issue that this PR relates to, and which requirements it tackles. Note: Jira issues of the form ADP- will be auto-linked. --> Co-authored-by: Pawel Jakubas <[email protected]> Co-authored-by: Piotr Stachyra <[email protected]>
Build failed: #expected (hlint) |
bors r+ |
3104: Handle reclaims in get transaction r=paweljakubas a=paweljakubas <!-- Detail in a few bullet points the work accomplished in this PR. Before you submit, don't forget to: * Make sure the GitHub PR fields are correct: ✓ Set a good Title for your PR. ✓ Assign yourself to the PR. ✓ Assign one or more reviewer(s). ✓ Link to a Jira issue, and/or other GitHub issues or PRs. ✓ In the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages. * Don't waste reviewers' time: ✓ If it's a draft, select the Create Draft PR option. ✓ Self-review your changes to make sure nothing unexpected slipped through. * Try to make your intent clear: ✓ Write a good Description that explains what this PR is meant to do. ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding Jira ticket. ✓ Highlight what Testing you have done. ✓ Acknowledge any changes required to the Documentation. --> - [x] Update of `ApiTransaction` to include `depositTaken` and `depositReturned` - [x] adding of integration tests showing the case for joining/rejoining and quitting - [x] update core unit tests and swagger ### Comments <!-- Additional comments, links, or screenshots to attach, if any. --> ### Issue Number <!-- Reference the Jira/GitHub issue that this PR relates to, and which requirements it tackles. Note: Jira issues of the form ADP- will be auto-linked. --> Co-authored-by: Pawel Jakubas <[email protected]> Co-authored-by: Piotr Stachyra <[email protected]>
Build failed:
|
bors r+ |
3104: Handle reclaims in get transaction r=paweljakubas a=paweljakubas <!-- Detail in a few bullet points the work accomplished in this PR. Before you submit, don't forget to: * Make sure the GitHub PR fields are correct: ✓ Set a good Title for your PR. ✓ Assign yourself to the PR. ✓ Assign one or more reviewer(s). ✓ Link to a Jira issue, and/or other GitHub issues or PRs. ✓ In the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages. * Don't waste reviewers' time: ✓ If it's a draft, select the Create Draft PR option. ✓ Self-review your changes to make sure nothing unexpected slipped through. * Try to make your intent clear: ✓ Write a good Description that explains what this PR is meant to do. ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding Jira ticket. ✓ Highlight what Testing you have done. ✓ Acknowledge any changes required to the Documentation. --> - [x] Update of `ApiTransaction` to include `depositTaken` and `depositReturned` - [x] adding of integration tests showing the case for joining/rejoining and quitting - [x] update core unit tests and swagger ### Comments <!-- Additional comments, links, or screenshots to attach, if any. --> ### Issue Number adp-460 adp-1402 <!-- Reference the Jira/GitHub issue that this PR relates to, and which requirements it tackles. Note: Jira issues of the form ADP- will be auto-linked. --> Co-authored-by: Pawel Jakubas <[email protected]> Co-authored-by: Piotr Stachyra <[email protected]>
adp-1402 situation seems to be fixed also. 🎉 It would be nice to have a property/unit test for that (integration or e2e is not really viable because most lakely it'd cause race conditions), but as far as I understand there's no way currently to have an automated test, so manual check has to be enough. |
Build failed:
|
994c5a5
to
8489261
Compare
bors r+ |
3104: Handle reclaims in get transaction r=paweljakubas a=paweljakubas <!-- Detail in a few bullet points the work accomplished in this PR. Before you submit, don't forget to: * Make sure the GitHub PR fields are correct: ✓ Set a good Title for your PR. ✓ Assign yourself to the PR. ✓ Assign one or more reviewer(s). ✓ Link to a Jira issue, and/or other GitHub issues or PRs. ✓ In the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages. * Don't waste reviewers' time: ✓ If it's a draft, select the Create Draft PR option. ✓ Self-review your changes to make sure nothing unexpected slipped through. * Try to make your intent clear: ✓ Write a good Description that explains what this PR is meant to do. ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding Jira ticket. ✓ Highlight what Testing you have done. ✓ Acknowledge any changes required to the Documentation. --> - [x] Update of `ApiTransaction` to include `depositTaken` and `depositReturned` - [x] adding of integration tests showing the case for joining/rejoining and quitting - [x] update core unit tests and swagger ### Comments <!-- Additional comments, links, or screenshots to attach, if any. --> ### Issue Number adp-460 adp-1402 <!-- Reference the Jira/GitHub issue that this PR relates to, and which requirements it tackles. Note: Jira issues of the form ADP- will be auto-linked. --> Co-authored-by: Pawel Jakubas <[email protected]> Co-authored-by: Piotr Stachyra <[email protected]>
Timed out. |
bors retry |
3104: Handle reclaims in get transaction r=paweljakubas a=paweljakubas <!-- Detail in a few bullet points the work accomplished in this PR. Before you submit, don't forget to: * Make sure the GitHub PR fields are correct: ✓ Set a good Title for your PR. ✓ Assign yourself to the PR. ✓ Assign one or more reviewer(s). ✓ Link to a Jira issue, and/or other GitHub issues or PRs. ✓ In the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages. * Don't waste reviewers' time: ✓ If it's a draft, select the Create Draft PR option. ✓ Self-review your changes to make sure nothing unexpected slipped through. * Try to make your intent clear: ✓ Write a good Description that explains what this PR is meant to do. ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding Jira ticket. ✓ Highlight what Testing you have done. ✓ Acknowledge any changes required to the Documentation. --> - [x] Update of `ApiTransaction` to include `depositTaken` and `depositReturned` - [x] adding of integration tests showing the case for joining/rejoining and quitting - [x] update core unit tests and swagger ### Comments <!-- Additional comments, links, or screenshots to attach, if any. --> ### Issue Number adp-460 adp-1402 <!-- Reference the Jira/GitHub issue that this PR relates to, and which requirements it tackles. Note: Jira issues of the form ADP- will be auto-linked. --> Co-authored-by: Pawel Jakubas <[email protected]> Co-authored-by: Piotr Stachyra <[email protected]>
Timed out. |
8489261
to
9670f61
Compare
bors r+ |
3104: Handle reclaims in get transaction r=paweljakubas a=paweljakubas <!-- Detail in a few bullet points the work accomplished in this PR. Before you submit, don't forget to: * Make sure the GitHub PR fields are correct: ✓ Set a good Title for your PR. ✓ Assign yourself to the PR. ✓ Assign one or more reviewer(s). ✓ Link to a Jira issue, and/or other GitHub issues or PRs. ✓ In the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages. * Don't waste reviewers' time: ✓ If it's a draft, select the Create Draft PR option. ✓ Self-review your changes to make sure nothing unexpected slipped through. * Try to make your intent clear: ✓ Write a good Description that explains what this PR is meant to do. ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding Jira ticket. ✓ Highlight what Testing you have done. ✓ Acknowledge any changes required to the Documentation. --> - [x] Update of `ApiTransaction` to include `depositTaken` and `depositReturned` - [x] adding of integration tests showing the case for joining/rejoining and quitting - [x] update core unit tests and swagger ### Comments <!-- Additional comments, links, or screenshots to attach, if any. --> ### Issue Number adp-460 adp-1402 <!-- Reference the Jira/GitHub issue that this PR relates to, and which requirements it tackles. Note: Jira issues of the form ADP- will be auto-linked. --> Co-authored-by: Pawel Jakubas <[email protected]> Co-authored-by: Piotr Stachyra <[email protected]>
9670f61
to
d5721da
Compare
Canceled. |
…ter quit tx is in ledger.
d5721da
to
75c4ec3
Compare
ApiTransaction
to includedepositTaken
anddepositReturned
Comments
Issue Number
adp-460
adp-1402