Skip to content

Commit

Permalink
Merge pull request #716 from IntersectMBO/mkoura/reference_script_siz…
Browse files Browse the repository at this point in the history
…e_default

Provide a default value for `calculate-min-fee --reference-script-size`
  • Loading branch information
mkoura authored Apr 11, 2024
2 parents 0758a14 + 835512e commit 222a332
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ data TransactionCalculateMinFeeCmdArgs = TransactionCalculateMinFeeCmdArgs
, txShelleyWitnessCount :: !TxShelleyWitnessCount
, txByronWitnessCount :: !TxByronWitnessCount
-- | The total size in bytes of the transaction reference scripts.
, referenceScriptSize :: !Int
, referenceScriptSize :: !ReferenceScriptSize
} deriving Show

data TransactionCalculateMinValueCmdArgs era = TransactionCalculateMinValueCmdArgs
Expand Down
9 changes: 5 additions & 4 deletions cardano-cli/src/Cardano/CLI/EraBased/Options/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3308,12 +3308,13 @@ pNetworkIdForTestnetData envCli = asum $ mconcat
pure <$> maybeToList (envCliNetworkId envCli)
]

pReferenceScriptSize :: Parser Int
pReferenceScriptSize :: Parser ReferenceScriptSize
pReferenceScriptSize =
Opt.option auto $ mconcat
fmap ReferenceScriptSize $ Opt.option Opt.auto $ mconcat
[ Opt.long "reference-script-size"
, Opt.metavar "INT"
, Opt.help "Total size in bytes of transaction reference scripts"
, Opt.metavar "NATURAL"
, Opt.help "Total size in bytes of transaction reference scripts (default is 0)."
, Opt.value 0
]

--------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ runTransactionCalculateMinFeeCmd
, protocolParamsFile = protocolParamsFile
, txShelleyWitnessCount = TxShelleyWitnessCount nShelleyKeyWitnesses
, txByronWitnessCount = TxByronWitnessCount nByronKeyWitnesses
, referenceScriptSize
, referenceScriptSize = ReferenceScriptSize sReferenceScript
} = do

txbodyFile <- liftIO $ fileOrPipe txbodyFilePath
Expand All @@ -1040,7 +1040,7 @@ runTransactionCalculateMinFeeCmd

lpparams <- getLedgerPParams sbe pparams

let shelleyfee = evaluateTransactionFee sbe lpparams txbody nShelleyKeyWitW32 0 referenceScriptSize
let shelleyfee = evaluateTransactionFee sbe lpparams txbody nShelleyKeyWitW32 0 sReferenceScript

let byronfee = calculateByronWitnessFees (protocolParamTxFeePerByte pparams) nByronKeyWitnesses

Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Legacy/Commands/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ data LegacyTransactionCmds
ProtocolParamsFile
TxShelleyWitnessCount
TxByronWitnessCount
Int
ReferenceScriptSize
-- ^ The total size in bytes of the transaction reference scripts.
| TransactionCalculateMinValueCmd
(EraInEon ShelleyBasedEra)
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Legacy/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ runLegacyTransactionCalculateMinFeeCmd :: ()
-> ProtocolParamsFile
-> TxShelleyWitnessCount
-> TxByronWitnessCount
-> Int
-> ReferenceScriptSize
-> ExceptT TxCmdError IO ()
runLegacyTransactionCalculateMinFeeCmd
txbodyFile
Expand Down
5 changes: 5 additions & 0 deletions cardano-cli/src/Cardano/CLI/Types/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ module Cardano.CLI.Types.Common
, ProtocolParamsFile(..)
, QueryOutputFormat(..)
, ReferenceScriptAnyEra (..)
, ReferenceScriptSize (..)
, RequiredSigner (..)
, ScriptDataOrFile (..)
, ScriptDatumOrFile (..)
Expand Down Expand Up @@ -506,6 +507,10 @@ newtype TxByronWitnessCount
= TxByronWitnessCount Int
deriving Show

newtype ReferenceScriptSize
= ReferenceScriptSize Int
deriving Show

newtype BlockId
= BlockId String -- Probably not a String
deriving Show
Expand Down
18 changes: 9 additions & 9 deletions cardano-cli/test/cardano-cli-golden/files/golden/help.cli
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ Usage: cardano-cli shelley transaction calculate-min-fee --tx-body-file FILE
--protocol-params-file FILE
--witness-count NATURAL
[--byron-witness-count NATURAL]
--reference-script-size INT
[--reference-script-size NATURAL]
[ --mainnet
| --testnet-magic NATURAL
]
Expand Down Expand Up @@ -2331,7 +2331,7 @@ Usage: cardano-cli allegra transaction calculate-min-fee --tx-body-file FILE
--protocol-params-file FILE
--witness-count NATURAL
[--byron-witness-count NATURAL]
--reference-script-size INT
[--reference-script-size NATURAL]
[ --mainnet
| --testnet-magic NATURAL
]
Expand Down Expand Up @@ -3507,7 +3507,7 @@ Usage: cardano-cli mary transaction calculate-min-fee --tx-body-file FILE
--protocol-params-file FILE
--witness-count NATURAL
[--byron-witness-count NATURAL]
--reference-script-size INT
[--reference-script-size NATURAL]
[ --mainnet
| --testnet-magic NATURAL
]
Expand Down Expand Up @@ -4700,7 +4700,7 @@ Usage: cardano-cli alonzo transaction calculate-min-fee --tx-body-file FILE
--protocol-params-file FILE
--witness-count NATURAL
[--byron-witness-count NATURAL]
--reference-script-size INT
[--reference-script-size NATURAL]
[ --mainnet
| --testnet-magic NATURAL
]
Expand Down Expand Up @@ -5918,7 +5918,7 @@ Usage: cardano-cli babbage transaction calculate-min-fee --tx-body-file FILE
--protocol-params-file FILE
--witness-count NATURAL
[--byron-witness-count NATURAL]
--reference-script-size INT
[--reference-script-size NATURAL]
[ --mainnet
| --testnet-magic NATURAL
]
Expand Down Expand Up @@ -7587,7 +7587,7 @@ Usage: cardano-cli conway transaction calculate-min-fee --tx-body-file FILE
--protocol-params-file FILE
--witness-count NATURAL
[--byron-witness-count NATURAL]
--reference-script-size INT
[--reference-script-size NATURAL]
[ --mainnet
| --testnet-magic NATURAL
]
Expand Down Expand Up @@ -8802,7 +8802,7 @@ Usage: cardano-cli latest transaction calculate-min-fee --tx-body-file FILE
--protocol-params-file FILE
--witness-count NATURAL
[--byron-witness-count NATURAL]
--reference-script-size INT
[--reference-script-size NATURAL]
[ --mainnet
| --testnet-magic NATURAL
]
Expand Down Expand Up @@ -9839,7 +9839,7 @@ Usage: cardano-cli legacy transaction calculate-min-fee --tx-body-file FILE
--protocol-params-file FILE
--witness-count NATURAL
[--byron-witness-count NATURAL]
--reference-script-size INT
[--reference-script-size NATURAL]
[ --mainnet
| --testnet-magic NATURAL
]
Expand Down Expand Up @@ -11059,7 +11059,7 @@ Usage: cardano-cli transaction calculate-min-fee --tx-body-file FILE
--protocol-params-file FILE
--witness-count NATURAL
[--byron-witness-count NATURAL]
--reference-script-size INT
[--reference-script-size NATURAL]
[ --mainnet
| --testnet-magic NATURAL
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Usage: cardano-cli allegra transaction calculate-min-fee --tx-body-file FILE
--protocol-params-file FILE
--witness-count NATURAL
[--byron-witness-count NATURAL]
--reference-script-size INT
[--reference-script-size NATURAL]
[ --mainnet
| --testnet-magic NATURAL
]
Expand All @@ -18,8 +18,9 @@ Available options:
--witness-count NATURAL The number of Shelley key witnesses.
--byron-witness-count NATURAL
The number of Byron key witnesses (default is 0).
--reference-script-size INT
--reference-script-size NATURAL
Total size in bytes of transaction reference scripts
(default is 0).
--mainnet DEPRECATED. This argument has no effect.
--testnet-magic NATURAL DEPRECATED. This argument has no effect.
--tx-in-count NATURAL DEPRECATED. This argument has no effect.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Usage: cardano-cli alonzo transaction calculate-min-fee --tx-body-file FILE
--protocol-params-file FILE
--witness-count NATURAL
[--byron-witness-count NATURAL]
--reference-script-size INT
[--reference-script-size NATURAL]
[ --mainnet
| --testnet-magic NATURAL
]
Expand All @@ -18,8 +18,9 @@ Available options:
--witness-count NATURAL The number of Shelley key witnesses.
--byron-witness-count NATURAL
The number of Byron key witnesses (default is 0).
--reference-script-size INT
--reference-script-size NATURAL
Total size in bytes of transaction reference scripts
(default is 0).
--mainnet DEPRECATED. This argument has no effect.
--testnet-magic NATURAL DEPRECATED. This argument has no effect.
--tx-in-count NATURAL DEPRECATED. This argument has no effect.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Usage: cardano-cli babbage transaction calculate-min-fee --tx-body-file FILE
--protocol-params-file FILE
--witness-count NATURAL
[--byron-witness-count NATURAL]
--reference-script-size INT
[--reference-script-size NATURAL]
[ --mainnet
| --testnet-magic NATURAL
]
Expand All @@ -18,8 +18,9 @@ Available options:
--witness-count NATURAL The number of Shelley key witnesses.
--byron-witness-count NATURAL
The number of Byron key witnesses (default is 0).
--reference-script-size INT
--reference-script-size NATURAL
Total size in bytes of transaction reference scripts
(default is 0).
--mainnet DEPRECATED. This argument has no effect.
--testnet-magic NATURAL DEPRECATED. This argument has no effect.
--tx-in-count NATURAL DEPRECATED. This argument has no effect.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Usage: cardano-cli conway transaction calculate-min-fee --tx-body-file FILE
--protocol-params-file FILE
--witness-count NATURAL
[--byron-witness-count NATURAL]
--reference-script-size INT
[--reference-script-size NATURAL]
[ --mainnet
| --testnet-magic NATURAL
]
Expand All @@ -18,8 +18,9 @@ Available options:
--witness-count NATURAL The number of Shelley key witnesses.
--byron-witness-count NATURAL
The number of Byron key witnesses (default is 0).
--reference-script-size INT
--reference-script-size NATURAL
Total size in bytes of transaction reference scripts
(default is 0).
--mainnet DEPRECATED. This argument has no effect.
--testnet-magic NATURAL DEPRECATED. This argument has no effect.
--tx-in-count NATURAL DEPRECATED. This argument has no effect.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Usage: cardano-cli latest transaction calculate-min-fee --tx-body-file FILE
--protocol-params-file FILE
--witness-count NATURAL
[--byron-witness-count NATURAL]
--reference-script-size INT
[--reference-script-size NATURAL]
[ --mainnet
| --testnet-magic NATURAL
]
Expand All @@ -18,8 +18,9 @@ Available options:
--witness-count NATURAL The number of Shelley key witnesses.
--byron-witness-count NATURAL
The number of Byron key witnesses (default is 0).
--reference-script-size INT
--reference-script-size NATURAL
Total size in bytes of transaction reference scripts
(default is 0).
--mainnet DEPRECATED. This argument has no effect.
--testnet-magic NATURAL DEPRECATED. This argument has no effect.
--tx-in-count NATURAL DEPRECATED. This argument has no effect.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Usage: cardano-cli legacy transaction calculate-min-fee --tx-body-file FILE
--protocol-params-file FILE
--witness-count NATURAL
[--byron-witness-count NATURAL]
--reference-script-size INT
[--reference-script-size NATURAL]
[ --mainnet
| --testnet-magic NATURAL
]
Expand All @@ -18,8 +18,9 @@ Available options:
--witness-count NATURAL The number of Shelley key witnesses.
--byron-witness-count NATURAL
The number of Byron key witnesses (default is 0).
--reference-script-size INT
--reference-script-size NATURAL
Total size in bytes of transaction reference scripts
(default is 0).
--mainnet DEPRECATED. This argument has no effect.
--testnet-magic NATURAL DEPRECATED. This argument has no effect.
--tx-in-count NATURAL DEPRECATED. This argument has no effect.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Usage: cardano-cli mary transaction calculate-min-fee --tx-body-file FILE
--protocol-params-file FILE
--witness-count NATURAL
[--byron-witness-count NATURAL]
--reference-script-size INT
[--reference-script-size NATURAL]
[ --mainnet
| --testnet-magic NATURAL
]
Expand All @@ -18,8 +18,9 @@ Available options:
--witness-count NATURAL The number of Shelley key witnesses.
--byron-witness-count NATURAL
The number of Byron key witnesses (default is 0).
--reference-script-size INT
--reference-script-size NATURAL
Total size in bytes of transaction reference scripts
(default is 0).
--mainnet DEPRECATED. This argument has no effect.
--testnet-magic NATURAL DEPRECATED. This argument has no effect.
--tx-in-count NATURAL DEPRECATED. This argument has no effect.
Expand Down
Loading

0 comments on commit 222a332

Please sign in to comment.