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

Logic changes to join/quitStakePools #4468

Merged

Conversation

paweljakubas
Copy link
Contributor

@paweljakubas paweljakubas commented Feb 23, 2024

  • Legacy joinStakePools automatically sets Abstain in Conway
  • check withdrawals and quitting (quitStakePools) with joinStakePools

Comments

In order to run

just conway-integration-tests-cabal-match STAKE_POOLS_

Issue Number

ADP-3261

@paweljakubas paweljakubas self-assigned this Feb 23, 2024
@paweljakubas paweljakubas force-pushed the paweljakubas/adp-3261/voting-delegation-withdrawals branch from d9683d3 to 72983cb Compare February 27, 2024 15:49
@paweljakubas paweljakubas marked this pull request as ready for review February 27, 2024 15:52
@paweljakubas paweljakubas force-pushed the paweljakubas/adp-3261/voting-delegation-withdrawals branch from 88be4b1 to 30818cd Compare February 28, 2024 15:18
Copy link
Contributor

@HeinrichApfelmus HeinrichApfelmus left a comment

Choose a reason for hiding this comment

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

Thank you! The integration tests look good to me, especially concerning the use of getTransaction.

That said, in the future, I would like to invest some effort into making the tests easier to understand and maintain — at the moment, separating test intent from programmatic details is hard. This would involve: Not using the Link module, exceptions instead of checking for 202 explicitly, encapsulating getTransaction. But for the purpose of testing functionality, this is good enough for now.

I would like to refactor the changes to the program logic, especially relating to the inConway boolean. For that purpose, @paweljakubas , could you split the pull request into two pull requests:

  1. A pull request that only contains the changes to the program logic.
  2. A pull request that uses pull request 1 as base and only contains the tests.

Thanks!

@paweljakubas paweljakubas force-pushed the paweljakubas/adp-3261/voting-delegation-withdrawals branch from b6cdfaa to bc7b294 Compare February 29, 2024 13:36
@paweljakubas paweljakubas changed the title Voting testing with delegation plus withdrawals Logic changes to join/quitStakePools Feb 29, 2024
@paweljakubas
Copy link
Contributor Author

@HeinrichApfelmus I slimmed down PR and not it contains logic changes to legacy join/quit+integration tests adjustment that are equired. Plus some small other logic changes

@@ -767,7 +767,7 @@ mkUnsignedTransaction networkId stakeCred ctx selection = do
, "either xpub or script when there is delegation"
, "action"
]
let certs = L.nub $ votingCerts <> delegCerts
let certs = L.nub $ delegCerts <> votingCerts
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one is needed as Registration cert needs to be FIRST...Otherwise node can protest

Copy link
Contributor

@HeinrichApfelmus HeinrichApfelmus Feb 29, 2024

Choose a reason for hiding this comment

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

I don't quite understand what's going on, because I would expect both votingCerts and delegCerts to contain the initial registration certificate. 🤔 That's actually my main reason for starting the refactoring.

Copy link
Contributor Author

@paweljakubas paweljakubas Feb 29, 2024

Choose a reason for hiding this comment

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

hmmm....I found one case where this was crucial and got node error....but it was without your refactoring (ie., before I rebased aginst your PR). Anyway, it does not change the picture if we have votingCerts <> delegCerts or delegCerts <> votingCerts.

Copy link
Contributor

Choose a reason for hiding this comment

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

I found one case where this was crucial and got node error.

Yes, I believe you — I just don't understand why, and that makes me suspicious that there could be another logic bug in the code. 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

Found it:

joinStakePoolDelegationAction must return Tx.VoteRegisteringKey instead of Tx.Vote in the voting action in order to for the second definition of certs to work when the key is not registered yet. I have fixed it.

Left _ -> pure False
Right _ -> pure True

(action,_) <- WD.joinStakePoolDelegationAction @s
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 Shouldn't the voting certificate also be part of the transaction that we select coins for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

So this endpoint is used by Daedalus for hardware wallet support.

If we want voting supported there, we should ensure the certificate is accounted for in the coin-selection, yes, but also that it is returned in the response. And then Daedalus would need to be updated to add that certificate to the tx.

Copy link
Contributor

Choose a reason for hiding this comment

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

And then Daedalus would need to be updated to add that certificate to the tx.

Dang. We can select the coins for it, but we don't assemble the transaction — it looks like Daedalus can't even vote to abstain in the presence of a hardware wallet.

Copy link
Contributor

@HeinrichApfelmus HeinrichApfelmus left a comment

Choose a reason for hiding this comment

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

@paweljakubas Thanks for splitting!

Could you rebase the logic on #4477 ? I have added additional comments — I would like to obtain a strict separation between IO (reading data from mutable sources) and pure functions (performing computation on that data).

lib/wallet/src/Cardano/Wallet.hs Outdated Show resolved Hide resolved
lib/wallet/src/Cardano/Wallet/Delegation.hs Outdated Show resolved Hide resolved
lib/wallet/src/Cardano/Wallet/Delegation.hs Outdated Show resolved Hide resolved
:: WalletDelegation
-> Withdrawal
-> Coin
-> Bool
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
-> Bool

Isn't this piece of information contained in the WalletDelegation argument? 🤔

voting = case last_ of
   Voting{}  True
   DelegatingVoting{}  True
   _  False

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably, but let's leave it like this for now — the argument is localized to the Cardano.Wallet.Delegation module now.

@paweljakubas paweljakubas force-pushed the paweljakubas/adp-3261/voting-delegation-withdrawals branch from a772cbd to bcdbdf5 Compare March 1, 2024 12:50
@paweljakubas
Copy link
Contributor Author

one more commit soon

@HeinrichApfelmus HeinrichApfelmus force-pushed the paweljakubas/adp-3261/voting-delegation-withdrawals branch from eaacc57 to 49468a1 Compare March 1, 2024 16:32
Copy link
Contributor

@HeinrichApfelmus HeinrichApfelmus left a comment

Choose a reason for hiding this comment

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

I have applied my review suggestions — I'm happy now. 😊 Good to merge.

<!--
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] Voting/revoting after delegation
- [x] Delegation/re-delegation after voting
- [x] Delegation/quitting after voting
- [x] Delegation together with voting
- [x] Quitting after voting
- [x] Withdrawals after voting
- [x] Withdrawals before voting

### Comments

<!-- Additional comments, links, or screenshots to attach, if any. -->

### Issue Number
adp-3261

<!-- 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. -->
@paweljakubas paweljakubas added this pull request to the merge queue Mar 1, 2024
Merged via the queue into master with commit 241100c Mar 1, 2024
3 checks passed
@paweljakubas paweljakubas deleted the paweljakubas/adp-3261/voting-delegation-withdrawals branch March 1, 2024 18:35
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.

3 participants