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

Add budget raise cli arg to local-server #182

Open
wants to merge 2 commits 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
33 changes: 31 additions & 2 deletions local-cluster/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ import Plutip.Config (
WorkingDirectory (Fixed, Temporary),
ecEpochSize,
ecSlotLength,
ecRaiseExUnitsToMax,
ecMaxTxSize,
stdTxSize,
)
import Plutip.DistributeFunds (Lovelace)
import Plutip.Keys (KeyPair, mainnetAddress, saveKeyPair, showPkh)
Expand All @@ -43,10 +46,15 @@ main = do
case totalAmount config of
Left e -> error e
Right amt -> do
let ClusterConfig {numWallets, dirWallets, numUtxos, workDir, slotLength, epochSize} = config
let ClusterConfig {numWallets, dirWallets, numUtxos, workDir, slotLength, epochSize, maxTxSize, raiseUnitsToMax} = config
workingDir = maybe Temporary (`Fixed` False) workDir
-- todo: if needed pipe remaining extraConfig options from command line args
extraConf = def {ecSlotLength = slotLength, ecEpochSize = epochSize}
extraConf = def
{ ecSlotLength = slotLength
, ecEpochSize = epochSize
, ecMaxTxSize = maxTxSize
, ecRaiseExUnitsToMax = raiseUnitsToMax
}
plutipConfig = def {clusterWorkingDir = workingDir, extraConfig = extraConf}

putStrLn "Starting cluster..."
Expand Down Expand Up @@ -199,6 +207,23 @@ pInfoJson =
<> Options.value "local-cluster-info.json"
)

pTxSize :: Parser Natural
pTxSize =
Options.option
Options.auto
( Options.long "tx-size"
<> Options.short 't'
<> Options.metavar "MAX_TX_SIZE"
<> Options.value stdTxSize
)

pRaiseUnits :: Parser Bool
pRaiseUnits =
Options.switch
( Options.long "max-units"
<> Options.help "Whether to raise budget to max units"
)

pClusterConfig :: Parser ClusterConfig
pClusterConfig =
ClusterConfig
Expand All @@ -211,6 +236,8 @@ pClusterConfig =
<*> pSlotLen
<*> pEpochSize
<*> pInfoJson
<*> pTxSize
<*> pRaiseUnits

-- | Basic info about the cluster, to
-- be used by the command-line
Expand All @@ -224,5 +251,7 @@ data ClusterConfig = ClusterConfig
, slotLength :: NominalDiffTime
, epochSize :: EpochSize
, dumpInfo :: Maybe FilePath
, maxTxSize :: Natural
, raiseUnitsToMax :: Bool
}
deriving stock (Show, Eq)
3 changes: 2 additions & 1 deletion src/Plutip/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ module Plutip.Config (
ExtraConfig (..),
NominalDiffTime,
EpochSize (..),
stdTxSize,
) where

import Cardano.Ledger.Slot (EpochSize (EpochSize, unEpochSize))
import Data.Default (Default, def)
import Data.Time (NominalDiffTime)
import GHC.Generics (Generic)
import Plutip.Launch.Extra.Types (ExtraConfig (ExtraConfig, ecEpochSize, ecMaxTxSize, ecRaiseExUnitsToMax, ecSlotLength))
import Plutip.Launch.Extra.Types (ExtraConfig (ExtraConfig, ecEpochSize, ecMaxTxSize, ecRaiseExUnitsToMax, ecSlotLength), stdTxSize)

-- | Configuration for the cluster working directory
-- This determines where the node database, chain-index database,
Expand Down