-
Notifications
You must be signed in to change notification settings - Fork 16
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 missing redeemers in certificate delegation and deregistration #306
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-} | ||
|
||
{-# LANGUAGE DataKinds #-} | ||
{-# LANGUAGE FlexibleContexts #-} | ||
{-# LANGUAGE GADTs #-} | ||
|
@@ -37,6 +35,7 @@ module Cardano.CLI.Types.Errors.TxValidationError | |
) where | ||
|
||
import Cardano.Api | ||
import qualified Cardano.Api.Ledger as L | ||
import Cardano.Api.Shelley | ||
|
||
import Prelude | ||
|
@@ -247,30 +246,50 @@ validateTxCertificates era certsAndScriptWitnesses = cardanoEraConstraints era $ | |
reqWits = Map.fromList $ mapMaybe convert certsAndScriptWitnesses | ||
pure $ TxCertificates supported certs $ BuildTxWith reqWits | ||
where | ||
-- We get the stake credential witness for a certificate that requires it. | ||
-- NB: Only stake address deregistration and delegation requires | ||
-- witnessing (witness can be script or key) | ||
deriveStakeCredentialWitness | ||
:: Certificate era | ||
-> Maybe StakeCredential | ||
deriveStakeCredentialWitness _cert = Nothing | ||
-- case cert of | ||
-- -- TODO: Conway era | ||
-- -- StakeAddressDeregistrationCertificate sCred -> Just sCred | ||
-- -- StakeAddressPoolDelegationCertificate sCred _ -> Just sCred | ||
-- _ -> Nothing | ||
|
||
convert | ||
:: (Certificate era, Maybe (ScriptWitness WitCtxStake era)) | ||
-> Maybe (StakeCredential, Witness WitCtxStake era) | ||
convert (cert, mScriptWitnessFiles) = do | ||
sCred <- deriveStakeCredentialWitness cert | ||
case mScriptWitnessFiles of | ||
Just sWit -> do | ||
Just ( sCred | ||
, ScriptWitness ScriptWitnessForStakeAddr sWit | ||
) | ||
Nothing -> Just (sCred, KeyWitness KeyWitnessForStakeAddr) | ||
-- We get the stake credential witness for a certificate that requires it. | ||
-- NB: Only stake address deregistration and delegation requires | ||
-- witnessing (witness can be script or key) | ||
deriveStakeCredentialWitness | ||
:: Certificate era | ||
-> Maybe StakeCredential | ||
deriveStakeCredentialWitness = fmap fromShelleyStakeCredential . \case | ||
ShelleyRelatedCertificate stbEra shelleyCert -> shelleyToBabbageEraConstraints stbEra $ | ||
case shelleyCert of | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't we have this function in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are similar ones, but are not the same: https://github.com/input-output-hk/cardano-api/blob/151eff181cb1782f9db46dbea36d22e8d40f0545/cardano-api/internal/Cardano/Api/Certificate.hs#L670 Should we extract stake creds only for deregistration and delegation like the comment says here, or should we use stake credential witness for the cases when it's available? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can leave it as it for now. We should follow the specification and document it here |
||
L.RegTxCert _sCred -> Nothing -- not required | ||
L.UnRegTxCert sCred -> Just sCred | ||
L.DelegStakeTxCert sCred _ -> Just sCred | ||
L.RegPoolTxCert _ -> Nothing | ||
L.RetirePoolTxCert _ _ -> Nothing | ||
L.MirTxCert _ -> Nothing | ||
L.GenesisDelegTxCert{} -> Nothing | ||
|
||
ConwayCertificate cEra conwayCert -> conwayEraOnwardsConstraints cEra $ | ||
case conwayCert of | ||
L.RegPoolTxCert _ -> Nothing | ||
L.RetirePoolTxCert _ _ -> Nothing | ||
L.RegTxCert _ -> Nothing | ||
L.UnRegTxCert sCred -> Just sCred | ||
L.RegDepositTxCert _ _ -> Nothing | ||
L.UnRegDepositTxCert sCred _ -> Just sCred | ||
L.DelegTxCert sCred _ -> Just sCred | ||
L.RegDepositDelegTxCert sCred _ _ -> Just sCred | ||
L.AuthCommitteeHotKeyTxCert{} -> Nothing | ||
L.ResignCommitteeColdTxCert _ -> Nothing | ||
L.RegDRepTxCert{} -> Nothing | ||
L.UnRegDRepTxCert{} -> Nothing | ||
L.UpdateDRepTxCert{} -> Nothing | ||
|
||
convert | ||
:: (Certificate era, Maybe (ScriptWitness WitCtxStake era)) | ||
-> Maybe (StakeCredential, Witness WitCtxStake era) | ||
convert (cert, mScriptWitnessFiles) = do | ||
sCred <- deriveStakeCredentialWitness cert | ||
case mScriptWitnessFiles of | ||
Just sWit -> do | ||
Just ( sCred | ||
, ScriptWitness ScriptWitnessForStakeAddr sWit | ||
) | ||
Nothing -> Just (sCred, KeyWitness KeyWitnessForStakeAddr) | ||
|
||
newtype TxProtocolParametersValidationError | ||
= ProtocolParametersNotSupported AnyCardanoEra | ||
|
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.
👍