Skip to content
Merged
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
5 changes: 5 additions & 0 deletions .changes/20261016_dijkstra_script_validity_flags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
project: cardano-cli
pr: 1474
kind:
- breaking
description: Remove --script-valid and --script-invalid from Dijkstra transaction build, build-raw and build-estimate in preparation for CIP-0167; retain both options for Conway.
49 changes: 27 additions & 22 deletions cardano-cli/src/Cardano/CLI/EraBased/Transaction/Option.hs
Original file line number Diff line number Diff line change
Expand Up @@ -144,25 +144,30 @@ pSignWitnessBackwardCompatible =
Opt.subparser $
Opt.command "sign-witness" assembleInfo <> Opt.internal

pScriptValidity :: Parser ScriptValidity
pScriptValidity =
asum
[ Opt.flag' ScriptValid $
mconcat
[ Opt.long "script-valid"
, Opt.help "Assertion that the script is valid. (default)"
]
, Opt.flag' ScriptInvalid $
mconcat
[ Opt.long "script-invalid"
, Opt.help $
mconcat
[ "Assertion that the script is invalid. "
, "If a transaction is submitted with such a script, "
, "the script will fail and the collateral will be taken."
]
]
]
pScriptValidity :: Exp.Era era -> Parser (Maybe ScriptValidity)
pScriptValidity era' = case era' of
-- CIP-0167 removes the author-supplied validity flag from standalone transactions:
-- https://github.com/cardano-foundation/CIPs/tree/master/CIP-0167
Exp.DijkstraEra -> pure Nothing

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would be good to have a comment that points at CIP-0167

Exp.ConwayEra ->
optional $
asum
[ Opt.flag' ScriptValid $
mconcat
[ Opt.long "script-valid"
, Opt.help "Assertion that the script is valid. (default)"
]
, Opt.flag' ScriptInvalid $
mconcat
[ Opt.long "script-invalid"
, Opt.help $
mconcat
[ "Assertion that the script is invalid. "
, "If a transaction is submitted with such a script, "
, "the script will fail and the collateral will be taken."
]
]
]

pTransactionBuildCmd
:: forall era. Exp.IsEra era => EnvCli -> Maybe (Parser (TransactionCmds era))
Expand Down Expand Up @@ -195,7 +200,7 @@ pTransactionBuildCmd envCli = do
<*> pNetworkId envCli
<*> pSocketPath envCli
)
<*> optional pScriptValidity
<*> pScriptValidity (Exp.useEra @era)
<*> optional pWitnessOverride
<*> some (pTxInForEra (Exp.useEra @era) AutoBalance)
<*> many pReadOnlyReferenceTxIn
Expand Down Expand Up @@ -256,7 +261,7 @@ pTransactionBuildEstimateCmd _envCli = do
pCmd = do
fmap TransactionBuildEstimateCmd $
TransactionBuildEstimateCmdArgs Exp.useEra
<$> optional pScriptValidity
<$> pScriptValidity (Exp.useEra @era)
<*> pNumberOfShelleyKeyWitnesses
<*> optional pNumberOfByronKeyWitnesses
<*> pProtocolParamsFile
Expand Down Expand Up @@ -305,7 +310,7 @@ pTransactionBuildRaw :: forall era. Exp.IsEra era => Parser (TransactionCmds era
pTransactionBuildRaw =
fmap TransactionBuildRawCmd $
TransactionBuildRawCmdArgs Exp.useEra
<$> optional pScriptValidity
<$> pScriptValidity (Exp.useEra @era)
<*> some (pTxInForEra (Exp.useEra @era) ManualBalance)
<*> many pReadOnlyReferenceTxIn
<*> many pTxInCollateral
Expand Down
15 changes: 2 additions & 13 deletions cardano-cli/test/cardano-cli-golden/files/golden/help.cli
Original file line number Diff line number Diff line change
Expand Up @@ -5491,11 +5491,7 @@ Usage: cardano-cli dijkstra transaction

Transaction commands.

Usage: cardano-cli dijkstra transaction build-raw
[ --script-valid
| --script-invalid
]
(--tx-in TX_IN
Usage: cardano-cli dijkstra transaction build-raw (--tx-in TX_IN
[ --spending-tx-in-reference TX_IN
( --spending-plutus-script-v2
| --spending-plutus-script-v3
Expand Down Expand Up @@ -5671,9 +5667,6 @@ Usage: cardano-cli dijkstra transaction build
| --testnet-magic NATURAL
)
--socket-path SOCKET_PATH
[ --script-valid
| --script-invalid
]
[--witness-override WORD]
(--tx-in TX_IN
[ --spending-tx-in-reference TX_IN
Expand Down Expand Up @@ -5827,11 +5820,7 @@ Usage: cardano-cli dijkstra transaction build

Please note the order[93;22;23;24m of some cmd options is crucial. If used incorrectly may produce undesired tx body. See nested [] notation above for details.[0;22;23;24m

Usage: cardano-cli dijkstra transaction build-estimate
[ --script-valid
| --script-invalid
]
--shelley-key-witnesses INT
Usage: cardano-cli dijkstra transaction build-estimate --shelley-key-witnesses INT
[--byron-key-witnesses Int]
--protocol-params-file FILEPATH
--total-utxo-value VALUE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
Usage: cardano-cli dijkstra transaction build-estimate
[ --script-valid
| --script-invalid
]
--shelley-key-witnesses INT
Usage: cardano-cli dijkstra transaction build-estimate --shelley-key-witnesses INT
[--byron-key-witnesses Int]
--protocol-params-file FILEPATH
--total-utxo-value VALUE
Expand Down Expand Up @@ -176,10 +172,6 @@ Usage: cardano-cli dijkstra transaction build-estimate
Please note the order[93;22;23;24m of some cmd options is crucial. If used incorrectly may produce undesired tx body. See nested [] notation above for details.[0;22;23;24m

Available options:
--script-valid Assertion that the script is valid. (default)
--script-invalid Assertion that the script is invalid. If a
transaction is submitted with such a script, the
script will fail and the collateral will be taken.
--shelley-key-witnesses INT
Specify the number of Shelley key witnesses the
transaction requires.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
Usage: cardano-cli dijkstra transaction build-raw
[ --script-valid
| --script-invalid
]
(--tx-in TX_IN
Usage: cardano-cli dijkstra transaction build-raw (--tx-in TX_IN
[ --spending-tx-in-reference TX_IN
( --spending-plutus-script-v2
| --spending-plutus-script-v3
Expand Down Expand Up @@ -172,10 +168,6 @@ Usage: cardano-cli dijkstra transaction build-raw
Please note the order[93;22;23;24m of some cmd options is crucial. If used incorrectly may produce undesired tx body. See nested [] notation above for details.[0;22;23;24m

Available options:
--script-valid Assertion that the script is valid. (default)
--script-invalid Assertion that the script is invalid. If a
transaction is submitted with such a script, the
script will fail and the collateral will be taken.
--tx-in TX_IN TxId#TxIx
--spending-tx-in-reference TX_IN
TxId#TxIx - Specify a reference input. The reference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ Usage: cardano-cli dijkstra transaction build
| --testnet-magic NATURAL
)
--socket-path SOCKET_PATH
[ --script-valid
| --script-invalid
]
[--witness-override WORD]
(--tx-in TX_IN
[ --spending-tx-in-reference TX_IN
Expand Down Expand Up @@ -175,10 +172,6 @@ Available options:
CARDANO_NODE_SOCKET_PATH environment variable. The
argument is optional if CARDANO_NODE_SOCKET_PATH is
defined and mandatory otherwise.
--script-valid Assertion that the script is valid. (default)
--script-invalid Assertion that the script is invalid. If a
transaction is submitted with such a script, the
script will fail and the collateral will be taken.
--witness-override WORD Specify and override the number of witnesses the
transaction requires.
--tx-in TX_IN TxId#TxIx
Expand Down
16 changes: 16 additions & 0 deletions cardano-cli/test/cardano-cli-test/Test/Cli/Transaction/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Test.Cli.Transaction.Build where
import Cardano.Api
import Cardano.Api.Ledger (hashToBytes)

import Control.Monad (forM_)
import Data.Aeson qualified as Aeson
import Data.ByteString.Base16 qualified as Base16
import Data.List (isInfixOf)
Expand All @@ -29,6 +30,21 @@ import Hedgehog.Range qualified as Range
inputDir :: FilePath
inputDir = "test/cardano-cli-test/files/input/shelley/transaction"

-- | Script validity is no longer supplied by the transaction author in Dijkstra.
hprop_transaction_script_validity_era_gating :: Property
hprop_transaction_script_validity_era_gating =
watchdogProp . propertyOnce $ do
forM_ ["build", "build-raw", "build-estimate"] $ \command -> do
forM_ ["--script-valid", "--script-invalid"] $ \flag -> do
(exitCode, _, stderr) <-
execDetailCardanoCLI ["dijkstra", "transaction", command, flag]
exitCode === ExitFailure 1
H.assertWith stderr (("Invalid option `" ++ flag ++ "'") `isInfixOf`)
forM_ ["conway", "latest"] $ \era -> do
help <- execCardanoCLI [era, "transaction", command, "--help"]
forM_ ["--script-valid", "--script-invalid"] $ \flag ->
H.assertWith help (flag `isInfixOf`)

-- | This is a test of https://github.com/IntersectMBO/cardano-cli/issues/662
-- Execute me with:
-- @cabal test cardano-cli-test --test-options '-p "/conway transaction build one voter many votes/"'@
Expand Down
Loading