-
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
Balance temporarily increases when spending rewards #1955
Comments
…ending withdrawals + fix it This was trickier than I originally thought because crafting a generator of pending transactions which is somewhat meaningful and can have withdrawals turned out to be a bit complex. The property originally failed (without the fix) and clearly showed the bug described in #1955. The fix is relatively straightforward and is about adding the reward amount only if there are no pending withdrawal
…ending withdrawals + fix it This was trickier than I originally thought because crafting a generator of pending transactions which is somewhat meaningful and can have withdrawals turned out to be a bit complex. The property originally failed (without the fix) and clearly showed the bug described in #1955. The fix is relatively straightforward and is about adding the reward amount only if there are no pending withdrawal
1954: Fix reported amount on incoming transactions carrying withdrawals r=KtorZ a=KtorZ # Issue Number <!-- Put here a reference to the issue this PR relates to and which requirements it tackles --> #1952 # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> - d1c5618 📍 **modify scenario spending rewards to send money to _another_ wallet and assess right amount** We didn't quite catch a bug here because we were only looking at one side of the coin by sending the transaction to ourselves (so, we couldn't really assess the amount on an _incoming_ transaction, from a different perspective. That is now done properly such that 1 lovelace is send to another wallet (and, which should be the amount reported by this wallet). The outgoing amount however should contain any output sent to _another_ wallet, as well as fees. - 6932d1d 📍 **revise 'amount' calculation in the primitive model** Such that we only count withdrawals in outgoing transactions. In principle, withdrawals should be necessarily ours on a transaction.. but it's not excluded that a transaction may contain multiple withdrawals from different wallets (especially in the context of multisig). Beside, withdrawals should be completely out of the picture for _incoming_ transactions. - aa9fdf9 📍 **add test showing oddities on total balance + rewards when there are pending withdrawals + fix it** This was trickier than I originally thought because crafting a generator of pending transactions which is somewhat meaningful and can have withdrawals turned out to be a bit complex. The property originally failed (without the fix) and clearly showed the bug described in #1955. The fix is relatively straightforward and is about adding the reward amount only if there are no pending withdrawal - 5867d38 📍 **fix SlotNo generator in database arbitrary instances** This one was wrongly changed to browse the entire Word32 space instead of staying within small bounds as originally. There are many things in tests and other generators derived from the slot number value, and too big values can really do bad things here. - 8d1eadb 📍 **prevent users from creating two withdrawals simultaneously on the same wallet** Rewards ought to be spent fully, therefore, making two concurrent withdrawals has no sense since only one transaction will eventually be validated. # Comments <!-- Additional comments or screenshots to attach if any --> <!-- Don't forget to: ✓ Self-review your changes to make sure nothing unexpected slipped through ✓ Assign yourself to the PR ✓ Assign one or several reviewer(s) ✓ Once created, link this PR to its corresponding ticket ✓ Assign the PR to a corresponding milestone ✓ Acknowledge any changes required to the Wiki --> Co-authored-by: KtorZ <[email protected]>
…ending withdrawals + fix it This was trickier than I originally thought because crafting a generator of pending transactions which is somewhat meaningful and can have withdrawals turned out to be a bit complex. The property originally failed (without the fix) and clearly showed the bug described in #1955. The fix is relatively straightforward and is about adding the reward amount only if there are no pending withdrawal
1954: Fix reported amount on incoming transactions carrying withdrawals r=KtorZ a=KtorZ # Issue Number <!-- Put here a reference to the issue this PR relates to and which requirements it tackles --> #1952 # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> - d1c5618 📍 **modify scenario spending rewards to send money to _another_ wallet and assess right amount** We didn't quite catch a bug here because we were only looking at one side of the coin by sending the transaction to ourselves (so, we couldn't really assess the amount on an _incoming_ transaction, from a different perspective. That is now done properly such that 1 lovelace is send to another wallet (and, which should be the amount reported by this wallet). The outgoing amount however should contain any output sent to _another_ wallet, as well as fees. - 6932d1d 📍 **revise 'amount' calculation in the primitive model** Such that we only count withdrawals in outgoing transactions. In principle, withdrawals should be necessarily ours on a transaction.. but it's not excluded that a transaction may contain multiple withdrawals from different wallets (especially in the context of multisig). Beside, withdrawals should be completely out of the picture for _incoming_ transactions. - aa9fdf9 📍 **add test showing oddities on total balance + rewards when there are pending withdrawals + fix it** This was trickier than I originally thought because crafting a generator of pending transactions which is somewhat meaningful and can have withdrawals turned out to be a bit complex. The property originally failed (without the fix) and clearly showed the bug described in #1955. The fix is relatively straightforward and is about adding the reward amount only if there are no pending withdrawal - 5867d38 📍 **fix SlotNo generator in database arbitrary instances** This one was wrongly changed to browse the entire Word32 space instead of staying within small bounds as originally. There are many things in tests and other generators derived from the slot number value, and too big values can really do bad things here. - 8d1eadb 📍 **prevent users from creating two withdrawals simultaneously on the same wallet** Rewards ought to be spent fully, therefore, making two concurrent withdrawals has no sense since only one transaction will eventually be validated. # Comments <!-- Additional comments or screenshots to attach if any --> <!-- Don't forget to: ✓ Self-review your changes to make sure nothing unexpected slipped through ✓ Assign yourself to the PR ✓ Assign one or several reviewer(s) ✓ Once created, link this PR to its corresponding ticket ✓ Assign the PR to a corresponding milestone ✓ Acknowledge any changes required to the Wiki --> Co-authored-by: KtorZ <[email protected]>
…ending withdrawals + fix it This was trickier than I originally thought because crafting a generator of pending transactions which is somewhat meaningful and can have withdrawals turned out to be a bit complex. The property originally failed (without the fix) and clearly showed the bug described in #1955. The fix is relatively straightforward and is about adding the reward amount only if there are no pending withdrawal
1954: Fix reported amount on incoming transactions carrying withdrawals r=KtorZ a=KtorZ # Issue Number <!-- Put here a reference to the issue this PR relates to and which requirements it tackles --> #1952 # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> - d1c5618 📍 **modify scenario spending rewards to send money to _another_ wallet and assess right amount** We didn't quite catch a bug here because we were only looking at one side of the coin by sending the transaction to ourselves (so, we couldn't really assess the amount on an _incoming_ transaction, from a different perspective. That is now done properly such that 1 lovelace is send to another wallet (and, which should be the amount reported by this wallet). The outgoing amount however should contain any output sent to _another_ wallet, as well as fees. - 6932d1d 📍 **revise 'amount' calculation in the primitive model** Such that we only count withdrawals in outgoing transactions. In principle, withdrawals should be necessarily ours on a transaction.. but it's not excluded that a transaction may contain multiple withdrawals from different wallets (especially in the context of multisig). Beside, withdrawals should be completely out of the picture for _incoming_ transactions. - aa9fdf9 📍 **add test showing oddities on total balance + rewards when there are pending withdrawals + fix it** This was trickier than I originally thought because crafting a generator of pending transactions which is somewhat meaningful and can have withdrawals turned out to be a bit complex. The property originally failed (without the fix) and clearly showed the bug described in #1955. The fix is relatively straightforward and is about adding the reward amount only if there are no pending withdrawal - 5867d38 📍 **fix SlotNo generator in database arbitrary instances** This one was wrongly changed to browse the entire Word32 space instead of staying within small bounds as originally. There are many things in tests and other generators derived from the slot number value, and too big values can really do bad things here. - 8d1eadb 📍 **prevent users from creating two withdrawals simultaneously on the same wallet** Rewards ought to be spent fully, therefore, making two concurrent withdrawals has no sense since only one transaction will eventually be validated. # Comments <!-- Additional comments or screenshots to attach if any --> <!-- Don't forget to: ✓ Self-review your changes to make sure nothing unexpected slipped through ✓ Assign yourself to the PR ✓ Assign one or several reviewer(s) ✓ Once created, link this PR to its corresponding ticket ✓ Assign the PR to a corresponding milestone ✓ Acknowledge any changes required to the Wiki --> Co-authored-by: KtorZ <[email protected]>
I have tried to test it also on MC4 with earned rewards.
Is it possible? |
That sounds like:
So I think that is currently possible for short periods of time. |
It is possible indeed. The reward balance update and the block processing happens concurrently in two separate workers. They're invoked roughly at the same time but possibly with a visible delay. As a result there could be a point in time where there's no more pending withdrawal, but the balance hasn't been updated to We could "force" our cached balance to zero after processing a withdrawal (within the same database transaction) to prevent this. |
Shall we return it ticket to "in progress"? |
Oui. |
Moved to; https://jira.iohk.io/browse/ADP-611 |
Context
Steps to Reproduce
Expected behavior
Actual behavior
Resolution
QA
https://github.com/input-output-hk/cardano-wallet/blob/905277f370093ab43c9246ee6d7c32df7114fe1d/lib/core/test/unit/Cardano/Wallet/Primitive/ModelSpec.hs#L233-L255
The text was updated successfully, but these errors were encountered: