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

Protocol parameter update with guard rail script #5834

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ packages:
trace-resources
trace-forward

program-options
ghc-options: -Werror
-- program-options
-- ghc-options: -Werror
Comment on lines +34 to +35
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
-- program-options
-- ghc-options: -Werror
program-options
ghc-options: -Werror


test-show-details: direct

Expand Down
11 changes: 7 additions & 4 deletions cardano-testnet/cardano-testnet.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ library
, cardano-ledger-conway
, cardano-ledger-core:{cardano-ledger-core, testlib}
, cardano-ledger-shelley
, cardano-node
, cardano-node
, cardano-ping ^>= 0.2.0.13
, contra-tracer
, containers
Expand Down Expand Up @@ -166,7 +166,7 @@ test-suite cardano-testnet-golden

ghc-options: -threaded -rtsopts "-with-rtsopts=-N -T"

build-tool-depends: cardano-node:cardano-node
build-tool-depends: cardano-node:cardano-node
, cardano-cli:cardano-cli
, cardano-submit-api:cardano-submit-api
, cardano-testnet:cardano-testnet
Expand Down Expand Up @@ -199,6 +199,7 @@ test-suite cardano-testnet-test
Cardano.Testnet.Test.Gov.GovActionTimeout
Cardano.Testnet.Test.Gov.TreasuryGrowth
Cardano.Testnet.Test.Gov.TreasuryWithdrawal
Cardano.Testnet.Test.Gov.UpdatePParam
Cardano.Testnet.Test.Misc
Cardano.Testnet.Test.Gov.DRepActivity
Cardano.Testnet.Test.Gov.PredefinedAbstainDRep
Expand All @@ -216,10 +217,12 @@ test-suite cardano-testnet-test
, cardano-api:{cardano-api, internal}
, cardano-cli
, cardano-crypto-class
, cardano-ledger-api
, cardano-ledger-core
, cardano-ledger-conway
, cardano-ledger-core
, cardano-ledger-shelley
, cardano-node
, cardano-node
, cardano-slotting
, cardano-strict-containers ^>= 0.1
, cardano-testnet
Expand All @@ -243,7 +246,7 @@ test-suite cardano-testnet-test

ghc-options: -threaded -rtsopts "-with-rtsopts=-N -T"

build-tool-depends: cardano-node:cardano-node
build-tool-depends: cardano-node:cardano-node
, cardano-cli:cardano-cli
, cardano-submit-api:cardano-submit-api
, cardano-testnet:cardano-testnet
133 changes: 115 additions & 18 deletions cardano-testnet/src/Testnet/Defaults.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
, defaultByronProtocolParamsJsonValue
, defaultYamlConfig
, defaultConwayGenesis
, defaultCommitteeHotAuthCertFp
, defaultCommitteeHotKeyPair
, defaultCommitteeHotVkeyFp
, defaultCommitteeHotSkeyFp
, defaultCommitteeKeyPair
, defaultCommitteeVkeyFp
, defaultCommitteeSkeyFp
Expand All @@ -26,6 +30,7 @@
, defaultSpoKeys
, defaultShelleyGenesis
, defaultGenesisFilepath
, defaultV3CostModel
, defaultYamlHardforkViaConfig
, defaultMainnetTopology
, plutusV3NonSpendingScript
Expand Down Expand Up @@ -60,6 +65,7 @@
import qualified Data.Aeson.Key as Key
import qualified Data.Aeson.KeyMap as KeyMapAeson
import qualified Data.Default.Class as DefaultClass
import qualified Data.Map.Strict as Map
import Data.Maybe
import Data.Proxy
import Data.Ratio
Expand All @@ -69,6 +75,7 @@
import Data.Time (UTCTime)
import Data.Typeable
import qualified Data.Vector as Vector
import GHC.Int
import GHC.Stack
import Lens.Micro
import Numeric.Natural
Expand Down Expand Up @@ -107,6 +114,76 @@
Nothing -> Left $ AlonzoGenErrTooMuchPrecision r
Just s -> return s

maxTxExUnits = Api.toAlonzoExUnits
$ Api.ExecutionUnits
{ Api.executionSteps = 100000000000
, Api.executionMemory = 1400000000
}
maxBlockExUnits = Api.toAlonzoExUnits
$ Api.ExecutionUnits
{ Api.executionSteps = 20000000000
, Api.executionMemory = 62000000
}
apiCostModels =
let pv1 = Api.AnyPlutusScriptVersion Api.PlutusScriptV1
pv2 = Api.AnyPlutusScriptVersion Api.PlutusScriptV2
pv3 = Api.AnyPlutusScriptVersion Api.PlutusScriptV3
in mconcat [ Map.singleton pv1 defaultV1CostModel
, Map.singleton pv2 defaultV2CostModel
, Map.singleton pv3 defaultV3CostModel
]
defaultV1CostModel = Api.CostModel
Copy link
Contributor

Choose a reason for hiding this comment

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

are those V1 and V2 values the same as in default genesis in cardano-api? Maybe it would be better to reference values from the default genesis there instead of redefining them here?

Same with V3 - maybe it would be better to just update single elements in the list instead?

[ 205665, 812, 1, 1, 1000, 571, 0, 1, 1000, 24177, 4, 1, 1000, 32, 117366, 102, 4
, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 100, 100
, 23000, 100, 19537, 32, 175354, 32, 46417, 4, 221973, 511, 0, 1, 89141, 32, 497525
, 14068, 4, 2, 196500, 453240, 220, 0, 1, 1, 1000, 28662, 4, 2, 245000, 216773, 62
, 1, 1060367, 12586, 1, 208512, 421, 1, 187000, 1000, 52998, 1, 80436, 32, 43249, 32
, 1000, 32, 80556, 1, 57667, 4, 1000, 10, 197145, 156, 1, 197145, 156, 1, 204924, 473
, 1, 208896, 511, 1, 52467, 32, 64832, 32, 65493, 32, 22558, 32, 16563, 32, 76511, 32
, 196500, 453240, 220, 0, 1, 1, 69522, 11687, 0, 1, 60091, 32, 196500, 453240, 220, 0
, 1, 1, 196500, 453240, 220, 0, 1, 1, 806990, 30482, 4, 1927926, 82523, 4, 265318, 0
, 4, 0, 85931, 32, 205665, 812, 1, 1, 41182, 32, 212342, 32, 31220, 32, 32696, 32, 43357
, 32, 32247, 32, 38314, 32, 57996947, 18975, 10
]
defaultV2CostModel = Api.CostModel
[ 205665, 812, 1, 1, 1000, 571, 0, 1, 1000, 24177, 4, 1, 1000, 32, 117366, 10475, 4
, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 100, 100
, 23000, 100, 19537, 32, 175354, 32, 46417, 4, 221973, 511, 0, 1, 89141, 32, 497525
, 14068, 4, 2, 196500, 453240, 220, 0, 1, 1, 1000, 28662, 4, 2, 245000, 216773, 62
, 1, 1060367, 12586, 1, 208512, 421, 1, 187000, 1000, 52998, 1, 80436, 32, 43249, 32
, 1000, 32, 80556, 1, 57667, 4, 1000, 10, 197145, 156, 1, 197145, 156, 1, 204924, 473
, 1, 208896, 511, 1, 52467, 32, 64832, 32, 65493, 32, 22558, 32, 16563, 32, 76511, 32
, 196500, 453240, 220, 0, 1, 1, 69522, 11687, 0, 1, 60091, 32, 196500, 453240, 220, 0
, 1, 1, 196500, 453240, 220, 0, 1, 1, 1159724, 392670, 0, 2, 806990, 30482, 4, 1927926
, 82523, 4, 265318, 0, 4, 0, 85931, 32, 205665, 812, 1, 1, 41182, 32, 212342, 32, 31220
, 32, 32696, 32, 43357, 32, 32247, 32, 38314, 32, 35892428, 10, 9462713, 1021, 10, 38887044
, 32947, 10
]


-- | Proposing script (protocol parameter update) fails to execute unless this is set to 0
cekStartupCost_exBudgetCPU :: Int64

Check warning on line 165 in cardano-testnet/src/Testnet/Defaults.hs

View workflow job for this annotation

GitHub Actions / build

Suggestion in cekStartupCost_exBudgetCPU in module Testnet.Defaults: Use camelCase ▫︎ Found: "cekStartupCost_exBudgetCPU :: Int64" ▫︎ Perhaps: "cekStartupCostExBudgetCPU :: Int64"
cekStartupCost_exBudgetCPU = 1

Check warning on line 166 in cardano-testnet/src/Testnet/Defaults.hs

View workflow job for this annotation

GitHub Actions / build

Suggestion in cekStartupCost_exBudgetCPU in module Testnet.Defaults: Use camelCase ▫︎ Found: "cekStartupCost_exBudgetCPU = ..." ▫︎ Perhaps: "cekStartupCostExBudgetCPU = ..."

cekLamCost_exBudgetMemory :: Int64

Check warning on line 168 in cardano-testnet/src/Testnet/Defaults.hs

View workflow job for this annotation

GitHub Actions / build

Suggestion in cekLamCost_exBudgetMemory in module Testnet.Defaults: Use camelCase ▫︎ Found: "cekLamCost_exBudgetMemory :: Int64" ▫︎ Perhaps: "cekLamCostExBudgetMemory :: Int64"
cekLamCost_exBudgetMemory = 1

Check warning on line 169 in cardano-testnet/src/Testnet/Defaults.hs

View workflow job for this annotation

GitHub Actions / build

Suggestion in cekLamCost_exBudgetMemory in module Testnet.Defaults: Use camelCase ▫︎ Found: "cekLamCost_exBudgetMemory = ..." ▫︎ Perhaps: "cekLamCostExBudgetMemory = ..."

defaultV3CostModel :: Api.CostModel
defaultV3CostModel = Api.CostModel
[ 205665, 812, 1, 1, 1000, 571, 0, 1, 1000, 24177, 4, 1, 1000, 32, 100, 10475, 4, 117366, 10475, 4, 103, 18
, 3209094, 6, 331451, 1, 65990684, 23097, 19, cekStartupCost_exBudgetCPU, cekLamCost_exBudgetMemory, 107
, 87060, 21, 16420089, 22, 2145798, 36, 3795345, 12, 889023, 1, 204237282, 23271, 36, 129165, 36, 189977790
, 85902, 36, 33012864, 36, 388443360, 1, 401885761, 72, 2331379, 72, 23000, 100, 23000, 100, 23000, 100, 23000, 100, 23000
, 100, 23000, 100, 23000, 100, 23000, 100, 100, 100, 23000, 100
, 19537, 32, 175354, 32, 46417, 4, 221973, 511, 0, 1, 89141, 32, 497525, 14068, 4, 2, 196500, 453240, 220, 0, 1, 1, 1000, 28662
, 4, 2, 245000, 216773, 62, 1, 1060367, 12586, 1, 208512, 421, 1, 187000, 1000, 52998, 1, 80436, 32
, 43249, 1000, 32, 32, 80556, 1, 57667, 4, 1927926, 82523, 4, 1000, 10, 197145, 156, 1, 197145, 156, 1, 204924, 473, 1, 208896
, 511, 1, 52467, 32, 64832, 32, 65493, 32, 22558, 32, 16563, 32, 76511, 32, 196500, 453240, 220, 0
, 1, 1, 69522, 11687, 0, 1, 60091, 32, 196500, 453240, 220, 0, 1, 1, 196500, 453240, 220, 0, 1, 1, 1159724, 392670, 0, 2, 806990
, 30482, 4, 1927926, 82523, 4, 265318, 0, 4, 0, 85931, 32, 205665, 812, 1, 1, 41182
, 32, 212342, 32, 31220, 32, 32696, 32, 43357, 32, 32247, 32, 38314, 32, 35190005, 10, 57996947, 18975, 10, 39121781, 32260, 10
]

defaultConwayGenesis :: ConwayGenesis StandardCrypto
defaultConwayGenesis =
let upPParams :: UpgradeConwayPParams Identity
Expand All @@ -115,31 +192,31 @@
, ucppDRepVotingThresholds = drepVotingThresholds
, ucppCommitteeMinSize = 0
, ucppCommitteeMaxTermLength = EpochInterval 200
, ucppGovActionLifetime = EpochInterval 1 -- One Epoch
, ucppGovActionDeposit = Coin 1_000_000
, ucppGovActionLifetime = EpochInterval 2 -- One Epoch
, ucppGovActionDeposit = Coin 2_000_000
, ucppDRepDeposit = Coin 1_000_000
, ucppDRepActivity = EpochInterval 100
, ucppMinFeeRefScriptCostPerByte = 0 %! 1 -- FIXME GARBAGE VALUE
, ucppPlutusV3CostModel = testingCostModelV3
}
drepVotingThresholds = DRepVotingThresholds
{ dvtMotionNoConfidence = 0 %! 1
, dvtCommitteeNormal = 1 %! 2
, dvtCommitteeNormal = 0 %! 2
, dvtCommitteeNoConfidence = 0 %! 1
, dvtUpdateToConstitution = 0 %! 2 -- TODO: Requires a constitutional committee when non-zero
, dvtHardForkInitiation = 1 %! 2
, dvtPPNetworkGroup = 1 %! 2
, dvtPPEconomicGroup = 1 %! 2
, dvtPPTechnicalGroup = 1 %! 2
, dvtPPGovGroup = 1 %! 2
, dvtTreasuryWithdrawal = 1 %! 2
, dvtHardForkInitiation = 0 %! 2
, dvtPPNetworkGroup = 0 %! 2
, dvtPPEconomicGroup = 0 %! 2
, dvtPPTechnicalGroup = 0 %! 2
, dvtPPGovGroup = 0 %! 3
, dvtTreasuryWithdrawal = 0 %! 2
}
poolVotingThresholds = PoolVotingThresholds
{ pvtMotionNoConfidence = 1 %! 2
, pvtCommitteeNormal = 1 %! 2
, pvtCommitteeNoConfidence = 1 %! 2
, pvtHardForkInitiation = 1 %! 2
, pvtPPSecurityGroup = 1 %! 2
{ pvtMotionNoConfidence = 0 %! 2
, pvtCommitteeNormal = 0 %! 2
, pvtCommitteeNoConfidence = 0 %! 2
, pvtHardForkInitiation = 0 %! 2
, pvtPPSecurityGroup = 0 %! 2
}
in ConwayGenesis
{ cgUpgradePParams = upPParams
Expand Down Expand Up @@ -523,13 +600,33 @@
-> FilePath
defaultDRepSkeyFp n = "drep-keys" </> ("drep" <> show n) </> "drep.skey"

defaultCommitteeKeyPair :: Int -> KeyPair PaymentKey
defaultCommitteeKeyPair n =
defaultCommitteeKeyPair :: FilePath -> Int -> KeyPair CCColdKey
defaultCommitteeKeyPair work n =
KeyPair
{ verificationKey = File $ work </> defaultCommitteeVkeyFp n
, signingKey = File $ work </> defaultCommitteeSkeyFp n
}

defaultCommitteeHotKeyPair :: FilePath -> Int -> KeyPair CCHotKey
defaultCommitteeHotKeyPair work n =
KeyPair
{ verificationKey = File $ defaultCommitteeVkeyFp n
, signingKey = File $ defaultCommitteeSkeyFp n
{ verificationKey = File $ work </> defaultCommitteeHotVkeyFp n
, signingKey = File $ work </> defaultCommitteeHotSkeyFp n
}

defaultCommitteeHotAuthCertFp :: Int -> FilePath
defaultCommitteeHotAuthCertFp n = "committee-keys" </> "committee" <> show n <>"hot.auth"

defaultCommitteeHotVkeyFp
:: Int -- ^ The Committee's index (starts at 1)
-> FilePath
defaultCommitteeHotVkeyFp n = "committee-keys" </> "committee" <> show n <> "hot.vkey"

defaultCommitteeHotSkeyFp
:: Int -- ^ The Committee's index (starts at 1)
-> FilePath
defaultCommitteeHotSkeyFp n = "committee-keys" </> "committee" <> show n <> "hot.skey"

-- | The relative path to SPO cold verification key in directories created by cardano-testnet
defaultSPOColdVKeyFp :: Int -> FilePath
defaultSPOColdVKeyFp n = "pools-keys" </> "pool" <> show n </> "cold.vkey"
Expand Down
31 changes: 31 additions & 0 deletions cardano-testnet/src/Testnet/Process/Cli/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module Testnet.Process.Cli.DRep
, generateRegistrationCertificate
, createCertificatePublicationTxBody
, generateVoteFiles
, generateVoteFilesCC
, createVotingTxBody
, registerDRep
, delegateToDRep
Expand Down Expand Up @@ -171,6 +172,36 @@ generateVoteFiles execConfig work prefix governanceActionTxId governanceActionIn
]
return path

generateVoteFilesCC
:: MonadTest m
=> MonadIO m
=> MonadCatch m
=> H.ExecConfig -- ^ Specifies the CLI execution configuration.
-> FilePath -- ^ Base directory path where the voting files and directories will be
-- stored.
-> String -- ^ Name for the subfolder that will be created under 'work' to store
-- the output voting files.
-> String -- ^ Transaction ID string of the governance action.
-> Word32 -- ^ Index of the governance action.
-> [(KeyPair CCHotKey, [Char])] -- ^ List of tuples where each tuple contains a 'PaymentKeyPair'
-- representing the DRep key pair and a 'String' representing the
-- vote type (i.e: "yes", "no", or "abstain").
-> m [File VoteFile In]
generateVoteFilesCC execConfig work prefix governanceActionTxId governanceActionIndex allVotes = do
baseDir <- H.createDirectoryIfMissing $ work </> prefix
forM (zip [(1 :: Integer)..] allVotes) $ \(idx, (ccKeyPair, vote)) -> do
let path = File (baseDir </> "vote-hot-committee-" <> show idx)
void $ execCli' execConfig
[ "conway", "governance", "vote", "create"
, "--" ++ vote
, "--governance-action-tx-id", governanceActionTxId
, "--governance-action-index", show @Word32 governanceActionIndex
, "--cc-hot-verification-key-file", verificationKeyFp ccKeyPair
, "--out-file", unFile path
]
return path


-- | Composes a voting transaction body file using @cardano-cli@.
-- For the transaction to be valid it needs witnesses corresponding
-- to the spent UTxOs and votes issued (typically these witnesses are
Expand Down
7 changes: 7 additions & 0 deletions cardano-testnet/src/Testnet/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
, VKey
, SKey
, ColdPoolKey
, CCColdKey
, CCHotKey
, VrfKey
, StakingKey
, PaymentKey
Expand Down Expand Up @@ -130,6 +132,8 @@
data ColdPoolKey
data StakingKey
data SpoColdKey
data CCColdKey
data CCHotKey

data PoolNodeKeys = PoolNodeKeys
{ poolNodeKeysCold :: KeyPair SpoColdKey
Expand All @@ -142,6 +146,9 @@
, paymentKeyInfoAddr :: Text
} deriving (Eq, Show)

data CommitteeMember = CommitteeMember

Check warning on line 149 in cardano-testnet/src/Testnet/Types.hs

View workflow job for this annotation

GitHub Actions / build

Suggestion in CommitteeMember in module Testnet.Types: Use newtype instead of data ▫︎ Found: "data CommitteeMember\n = CommitteeMember {ccPaymentKeyPair :: KeyPair CCColdKey}" ▫︎ Perhaps: "newtype CommitteeMember\n = CommitteeMember {ccPaymentKeyPair :: KeyPair CCColdKey}" ▫︎ Note: decreases laziness
{ ccPaymentKeyPair :: KeyPair CCColdKey }

data Delegator = Delegator
{ paymentKeyPair :: KeyPair PaymentKey
, stakingKeyPair :: KeyPair StakingKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ hprop_gov_no_confidence = integrationWorkspace "no-confidence" $ \tempAbsBasePat

-- Step 4. We confirm the no confidence motion has been ratified by checking
-- for an empty constitutional committee.
H.nothingFailM $ watchEpochStateUpdate epochStateView (EpochInterval 10) (return . committeeIsPresent False)
H.nothingFailM $ watchEpochStateUpdate epochStateView (EpochInterval 15) (return . committeeIsPresent False)

-- | Checks if the committee is empty or not.
committeeIsPresent :: Bool -> (AnyNewEpochState, SlotNo, BlockNo) -> Maybe ()
Expand Down
Loading
Loading