Skip to content

Build cmd - Add options to disable automatic metadata-hash checks on votes and proposals included in the transaction. #1065

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ data TransactionBuildCmdArgs era = TransactionBuildCmdArgs
, mUpdateProposalFile :: !(Maybe (Featured ShelleyToBabbageEra era (Maybe UpdateProposalFile)))
, voteFiles :: ![(VoteFile In, Maybe CliVoteScriptRequirements)]
, proposalFiles :: ![(ProposalFile In, Maybe CliProposalScriptRequirements)]
, metadataChecksOnProposals :: !MetadataCheck
, metadataChecksOnVotes :: !MetadataCheck
, treasuryDonation :: !(Maybe TxTreasuryDonation)
, buildOutputOptions :: !TxBuildOutputOptions
}
Expand Down
19 changes: 19 additions & 0 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Cardano.CLI.EraBased.Commands.Transaction
import Cardano.CLI.EraBased.Options.Common
import Cardano.CLI.Parser
import Cardano.CLI.Types.Common
import Cardano.CLI.Types.Governance

import Data.Foldable
import Options.Applicative hiding (help, str)
Expand Down Expand Up @@ -200,6 +201,8 @@ pTransactionBuildCmd sbe envCli = do
<*> pFeatured (toCardanoEra sbe) (optional pUpdateProposalFile)
<*> pVoteFiles sbe AutoBalance
<*> pProposalFiles sbe AutoBalance
<*> pMetadataChecksOnProposals
<*> pMetadataChecksOnVotes
<*> pTreasuryDonation sbe
<*> pTxBuildOutputOptions

Expand Down Expand Up @@ -384,3 +387,19 @@ pTransactionId =
TransactionTxIdCmdArgs
<$> pInputTxOrTxBodyFile
<*> pTxIdOutputFormatJsonOrText

pMetadataChecksOnProposals :: Parser MetadataCheck
pMetadataChecksOnProposals =
Opt.flag EnableMetadataCheck DisableMetadataCheck $
mconcat
[ Opt.long "disable-metadata-checks-on-proposals"
Copy link
Contributor

Choose a reason for hiding this comment

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

Right so now we have a common prefix: disable-metadata-checks

Repeating this is going to add to our already verbose commands. I'll have another look tomorrow to suggest an alternative.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried to favor clarity over shortness with the flag names. The shortest I can come up with without loosing clarity is:

--disable-vote-metadata-check
--disable-proposal-metadata-check

Copy link
Contributor

@Jimbo4350 Jimbo4350 Feb 20, 2025

Choose a reason for hiding this comment

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

What we are looking for is the following:

[--update-proposal-file FILEPATH [--disable-proposal-metadata-check]]

, Opt.help "Disable automatic metadata-hash checks on proposals included in the transaction."
]

pMetadataChecksOnVotes :: Parser MetadataCheck
pMetadataChecksOnVotes =
Opt.flag EnableMetadataCheck DisableMetadataCheck $
mconcat
[ Opt.long "disable-metadata-checks-on-votes"
, Opt.help "Disable automatic metadata-hash checks on votes included in the transaction."
]
12 changes: 10 additions & 2 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import Cardano.CLI.Types.Errors.BootstrapWitnessError
import Cardano.CLI.Types.Errors.NodeEraMismatchError
import Cardano.CLI.Types.Errors.TxCmdError
import Cardano.CLI.Types.Errors.TxValidationError
import Cardano.CLI.Types.Governance
import Cardano.CLI.Types.Output (renderScriptCosts)
import Cardano.CLI.Types.TxFeature

Expand Down Expand Up @@ -147,6 +148,8 @@ runTransactionBuildCmd
, mUpdateProposalFile
, voteFiles
, proposalFiles
, metadataChecksOnProposals
, metadataChecksOnVotes
, treasuryDonation -- Maybe TxTreasuryDonation
, buildOutputOptions
} = do
Expand Down Expand Up @@ -209,14 +212,19 @@ runTransactionBuildCmd
(\w -> firstExceptT TxCmdVoteError $ ExceptT (readVotingProceduresFiles w voteFiles))
era'

forM_ votingProceduresAndMaybeScriptWits (checkVotingProcedureHashes eon . fst)
unless (metadataChecksOnVotes == DisableMetadataCheck) $
forM_ votingProceduresAndMaybeScriptWits (checkVotingProcedureHashes eon . fst)

-- unless disableMetadataChecksOnVotes $
-- forM_ votingProceduresAndMaybeScriptWits (checkVotingProcedureHashes eon . fst)

proposals <-
newExceptT $
first TxCmdProposalError
<$> readTxGovernanceActions eon proposalFiles

forM_ proposals (checkProposalHashes eon . fst)
unless (metadataChecksOnProposals == DisableMetadataCheck) $
forM_ proposals (checkProposalHashes eon . fst)

-- Extract return addresses from proposals and check that the return address in each proposal is registered

Expand Down
3 changes: 3 additions & 0 deletions cardano-cli/src/Cardano/CLI/Types/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ data VoteDelegationTarget
| VoteDelegationTargetOfAbstain
| VoteDelegationTargetOfNoConfidence
deriving (Eq, Show)

data MetadataCheck = EnableMetadataCheck | DisableMetadataCheck
deriving (Eq, Show)
6 changes: 6 additions & 0 deletions cardano-cli/test/cardano-cli-golden/files/golden/help.cli
Original file line number Diff line number Diff line change
Expand Up @@ -6435,6 +6435,8 @@ Usage: cardano-cli babbage transaction build
| --metadata-cbor-file FILEPATH
]
[--update-proposal-file FILEPATH]
[--disable-metadata-checks-on-proposals]
[--disable-metadata-checks-on-votes]
( --out-file FILEPATH
| --calculate-plutus-script-cost FILEPATH
)
Expand Down Expand Up @@ -8489,6 +8491,8 @@ Usage: cardano-cli conway transaction build
| --proposal-reference-tx-in-redeemer-value JSON_VALUE
)
]]
[--disable-metadata-checks-on-proposals]
[--disable-metadata-checks-on-votes]
[--treasury-donation LOVELACE]
( --out-file FILEPATH
| --calculate-plutus-script-cost FILEPATH
Expand Down Expand Up @@ -10577,6 +10581,8 @@ Usage: cardano-cli latest transaction build
| --proposal-reference-tx-in-redeemer-value JSON_VALUE
)
]]
[--disable-metadata-checks-on-proposals]
[--disable-metadata-checks-on-votes]
[--treasury-donation LOVELACE]
( --out-file FILEPATH
| --calculate-plutus-script-cost FILEPATH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ Usage: cardano-cli babbage transaction build
| --metadata-cbor-file FILEPATH
]
[--update-proposal-file FILEPATH]
[--disable-metadata-checks-on-proposals]
[--disable-metadata-checks-on-votes]
( --out-file FILEPATH
| --calculate-plutus-script-cost FILEPATH
)
Expand Down Expand Up @@ -391,6 +393,12 @@ Available options:
Filepath of the metadata, in raw CBOR format.
--update-proposal-file FILEPATH
Filepath of the update proposal.
--disable-metadata-checks-on-proposals
Disable automatic metadata-hash checks on proposals
included in the transaction.
--disable-metadata-checks-on-votes
Disable automatic metadata-hash checks on votes
included in the transaction.
--out-file FILEPATH Output filepath of the JSON TxBody.
--calculate-plutus-script-cost FILEPATH
Where to write the script cost information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ Usage: cardano-cli conway transaction build
| --proposal-reference-tx-in-redeemer-value JSON_VALUE
)
]]
[--disable-metadata-checks-on-proposals]
[--disable-metadata-checks-on-votes]
[--treasury-donation LOVELACE]
( --out-file FILEPATH
| --calculate-plutus-script-cost FILEPATH
Expand Down Expand Up @@ -470,6 +472,12 @@ Available options:
The script redeemer value. There is no schema:
(almost) any JSON value is supported, including
top-level strings and numbers.
--disable-metadata-checks-on-proposals
Disable automatic metadata-hash checks on proposals
included in the transaction.
--disable-metadata-checks-on-votes
Disable automatic metadata-hash checks on votes
included in the transaction.
--treasury-donation LOVELACE
The donation to the treasury to perform.
--out-file FILEPATH Output filepath of the JSON TxBody.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ Usage: cardano-cli latest transaction build
| --proposal-reference-tx-in-redeemer-value JSON_VALUE
)
]]
[--disable-metadata-checks-on-proposals]
[--disable-metadata-checks-on-votes]
[--treasury-donation LOVELACE]
( --out-file FILEPATH
| --calculate-plutus-script-cost FILEPATH
Expand Down Expand Up @@ -470,6 +472,12 @@ Available options:
The script redeemer value. There is no schema:
(almost) any JSON value is supported, including
top-level strings and numbers.
--disable-metadata-checks-on-proposals
Disable automatic metadata-hash checks on proposals
included in the transaction.
--disable-metadata-checks-on-votes
Disable automatic metadata-hash checks on votes
included in the transaction.
--treasury-donation LOVELACE
The donation to the treasury to perform.
--out-file FILEPATH Output filepath of the JSON TxBody.
Expand Down
Loading