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

Check if stake addresses in proposals are registered onchain #963

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

CarlosLopezDeLara
Copy link
Contributor

@CarlosLopezDeLara CarlosLopezDeLara commented Nov 7, 2024

Changelog

- description: |
    `transaction build` now checks and fails if stake addresses used for deposit return or treasury withdrawals in proposals are NOT registered on-chain. 
# uncomment types applicable to the change:
  type:
   - feature        # introduces a new feature
  # - breaking       # the API has changed in a breaking way
  # - compatible     # the API has changed but is non-breaking
  # - optimisation   # measurable performance improvements
  # - refactoring    # QoL changes
  # - bugfix         # fixes a defect
  # - test           # fixes/modifies tests
  # - maintenance    # not directly related to the code
  # - release        # related to a new release preparation
  # - documentation  # change in code docs, haddocks...

Context

Resolves #900

How to trust this PR

Tested locally with a Treasury Withdrawal action where neither the deposit return or funds receiving stake addresses are registered:

cardano-cli conway governance action create-treasury-withdrawal \
--testnet \
--governance-action-deposit 50000000000 \
--deposit-return-stake-verification-key-file example/utxo-keys/stake4.vkey \
--anchor-url https://tinyurl.com/3wrwb2as \
--anchor-data-hash 52e69500a92d80f2126c836a4903dc582006709f004cf7a28ed648f732dff8d2 \
--funds-receiving-stake-verification-key-file example/utxo-keys/stake5.vkey \
--transfer 50000000000 \
--constitution-script-hash fa24fb305126805cf2164c161d852a0e7330cf988f1fe558cf7d4a64 \
--out-file example/transactions/pparams-glt.action

cardano-cli conway transaction build \
--proposal-script-file guardrailscriptV2/guardrail-script.plutus \
--tx-in-collateral 90f53aca87f96e0e8660b7dbb71e79845e946a13966cdab382627e73a49dd602#3 \
--proposal-redeemer-value '{}' \
--tx-in 8e1885bb321b50bc0fba00784385e4edfc6a1fe15a6c6d0f1cbc4559dcc67f25#0 \
--change-address addr_test1qr32awchqmdy7l4qlwv5dn7gj2zkhrpzgh7rjapn23ve3a7l4827fjh037jakg39ez4465ywcwcmjq5hvm7r57g7f5fs4dqm47 \
--proposal-file example/transactions/pparams-glt.action \
--out-file example/transactions/pparams-cm-tx.raw

Command failed: transaction build  Error: One or more stake addresses in proposals is not registered: fromList [StakeCredentialByKey "139622a9b18cba6e408a8778be3c35e2e0182b0a3bde695de8d1579e",StakeCredentialByKey "a75e7935011d9228c89ea8ba4587ee0c13663c58500e360be8efe6ce"]

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details.
  • Self-reviewed the diff

@CarlosLopezDeLara CarlosLopezDeLara changed the title Check if stake address in proposals are registered onchain Check if stake addresses in proposals are registered onchain Nov 7, 2024
@CarlosLopezDeLara CarlosLopezDeLara marked this pull request as ready for review November 7, 2024 17:50
[ stakeCred
| (proposal, _) <- proposals
, let (_, _, govAction) = fromProposalProcedure eon proposal
, TreasuryWithdrawal withdrawalsList _ <- [govAction] -- Match on TreasuryWithdrawal action
Copy link
Contributor

Choose a reason for hiding this comment

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

As I said during the pair programming session, I don't like pattern matching in list comprehensions generally speaking. But in this case, it would be way more verbose to do differently, so I'm fine with this version.

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.

[FR] - Proactive protection against GovAction deposit losses
2 participants