Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed Mar 28, 2024
1 parent 8430590 commit 8e20c19
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 32 deletions.
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

test-show-details: direct

Expand Down
1 change: 1 addition & 0 deletions cardano-testnet/cardano-testnet.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ test-suite cardano-testnet-test
, cardano-api:{cardano-api, internal}
, cardano-cli
, cardano-crypto-class
, cardano-ledger-core
, cardano-ledger-conway
, cardano-ledger-core
, cardano-ledger-shelley
Expand Down
49 changes: 30 additions & 19 deletions cardano-testnet/src/Testnet/Defaults.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module Testnet.Defaults
, defaultConwayGenesis
, defaultShelleyGenesis
, defaultGenesisFilepath
, defaultV3CostModel
, defaultYamlHardforkViaConfig
, defaultMainnetTopology
, plutusV3NonSpendingScript
Expand Down Expand Up @@ -101,8 +102,8 @@ defaultAlonzoGenesis = do
}
where

priceExecStepsRat = promoteRatio $ 721 % (10000000 :: Word64)
priceMemStepsRat = promoteRatio $ 577 % (10000 :: Word64)
priceExecStepsRat = promoteRatio $ 721 % (100000000000 :: Word64)
priceMemStepsRat = promoteRatio $ 577 % (1000000000 :: Word64)

checkBoundedRational r =
case boundRational r of
Expand All @@ -111,8 +112,8 @@ defaultAlonzoGenesis = do

maxTxExUnits = Api.toAlonzoExUnits
$ Api.ExecutionUnits
{ Api.executionSteps = 10000000000
, Api.executionMemory = 140000000
{ Api.executionSteps = 100000000000
, Api.executionMemory = 1400000000
}
maxBlockExUnits = Api.toAlonzoExUnits
$ Api.ExecutionUnits
Expand All @@ -128,7 +129,7 @@ defaultAlonzoGenesis = do
, Map.singleton pv3 defaultV3CostModel
]
defaultV1CostModel = Api.CostModel
[ 205665, 812, 1, 1, 1000, 571, 0, 1, 1000, 24177, 4, 1, 1000, 32, 117366, 10475, 4
[ 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
Expand All @@ -154,20 +155,30 @@ defaultAlonzoGenesis = do
, 32, 32696, 32, 43357, 32, 32247, 32, 38314, 32, 35892428, 10, 9462713, 1021, 10, 38887044
, 32947, 10
]
defaultV3CostModel = Api.CostModel
[ 205665, 812, 1, 1, 1000, 571, 0, 1, 1000, 24177, 4, 1, 1000, 32, 117366, 10475, 4, 117366, 10475, 4, 832808, 18
, 3209094, 6, 331451, 1, 65990684, 23097, 18, 114242, 18, 94393407
, 87060, 18, 16420089, 18, 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
]


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

Check warning on line 161 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 :: Integer" ▫︎ Perhaps: "cekStartupCostExBudgetCPU :: Integer"
cekStartupCost_exBudgetCPU = 1

Check warning on line 162 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 :: Integer

Check warning on line 164 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 :: Integer" ▫︎ Perhaps: "cekLamCostExBudgetMemory :: Integer"
cekLamCost_exBudgetMemory = 1

Check warning on line 165 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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,22 +182,21 @@ hprop_ledger_events_propose_new_constitution = H.integrationWorkspace "propose-n
]

-- Create constitution proposal

guardRailScriptFp <- H.note $ work </> "guard-rail-script.plutusV3"
H.writeFile guardRailScriptFp $ Text.unpack plutusV3NonSpendingScript
guardRailScript <- H.note $ work </> "guard-rail-script.plutusV3"
H.writeFile guardRailScript $ Text.unpack plutusV3NonSpendingScript
-- TODO: Update help text for policyid. The script hash is not
-- only useful for minting scripts
constitutionScriptHash <- filter (/= '\n') <$>
H.execCli' execConfig
[ anyEraToString cEra, "transaction"
, "policyid"
, "--script-file", guardRailScriptFp
, "--script-file", guardRailScript
]
void $ H.execCli' execConfig
[ "conway", "governance", "action", "create-constitution"
, "--testnet"
, "--governance-action-deposit", show @Int 1_000_000 -- TODO: Get this from the node
, "--deposit-return-stake-verification-key-file", stakeVkeyFp
, "--governance-action-deposit", show @Int 1_000_000 -- TODO: retrieve this from conway genesis.
, "--deposit-return-stake-script-file", guardRailScript
, "--anchor-url", "https://tinyurl.com/3wrwb2as"
, "--anchor-data-hash", proposalAnchorDataHash
, "--constitution-url", "https://tinyurl.com/2pahcy6z"
Expand Down Expand Up @@ -282,7 +281,7 @@ hprop_ledger_events_propose_new_constitution = H.integrationWorkspace "propose-n
[ "conway", "transaction", "build"
, "--change-address", Text.unpack $ paymentKeyInfoAddr $ wallets !! 0
, "--tx-in", Text.unpack $ renderTxIn txin3
, "--tx-out", Text.unpack (paymentKeyInfoAddr (wallets !! 1)) <> "+" <> show @Int 3_000_000
, "--tx-out", Text.unpack (paymentKeyInfoAddr (wallets !! 0)) <> "+" <> show @Int 3_000_000
, "--vote-file", voteFp 1
, "--vote-file", voteFp 2
, "--vote-file", voteFp 3
Expand All @@ -305,7 +304,7 @@ hprop_ledger_events_propose_new_constitution = H.integrationWorkspace "propose-n
[ "conway", "transaction", "submit"
, "--tx-file", voteTxFp
]

H.threadDelay 10_000_000
-- We check that constitution was succcessfully ratified

!eConstitutionAdopted
Expand All @@ -319,6 +318,56 @@ hprop_ledger_events_propose_new_constitution = H.integrationWorkspace "propose-n

void $ evalEither eConstitutionAdopted

-- TODO: Attempt a protocol parameters update (witnessed with guard rail script)
pparamsUpdateFp <- H.note $ work </> "protocol-parameters-upate.action"
void $ H.execCli' execConfig
[ convertToEraString cEra, "governance", "action", "create-protocol-parameters-update"
, "--testnet"
, "--governance-action-deposit", show @Int 1_000_000 -- TODO: retrieve this from conway genesis.
, "--deposit-return-stake-script-file", guardRailScript
, "--anchor-url", "https://tinyurl.com/3wrwb2as"
, "--anchor-data-hash", proposalAnchorDataHash
, "--constitution-script-hash", constitutionScriptHash
, "--committee-term-length", show @Int 1000
, "--out-file", pparamsUpdateFp
]
updateProposalTxBody <- H.note $ work </> "update-proposal.txbody"
txin4 <- findLargestUtxoForPaymentKey epochStateView sbe $ wallets !! 0
txin5 <- findLargestUtxoForPaymentKey epochStateView sbe $ wallets !! 1
txinColl <- findLargestUtxoForPaymentKey epochStateView sbe $ wallets !! 2

void $ H.execCli' execConfig
[ convertToEraString cEra, "transaction", "build"
, "--change-address", Text.unpack $ paymentKeyInfoAddr $ head wallets
, "--tx-in", Text.unpack $ renderTxIn txin4
, "--tx-in", Text.unpack $ renderTxIn txin5
, "--tx-in-collateral", Text.unpack $ renderTxIn txinColl
, "--tx-out", Text.unpack (paymentKeyInfoAddr (wallets !! 1)) <> "+" <> show @Int 5_000_000
, "--proposal-file", pparamsUpdateFp
, "--proposal-script-file", guardRailScript
, "--proposal-redeemer-value", "0"
, "--witness-override", show @Int 12
, "--out-file", updateProposalTxBody
]

updateProposalTx <- H.note $ work </> "update-proposal.tx"
void $ H.execCli' execConfig
[ "conway", "transaction", "sign"
, "--tx-body-file", updateProposalTxBody
, "--signing-key-file", paymentSKey $ paymentKeyInfoPair $ wallets !! 0
, "--signing-key-file", paymentSKey $ paymentKeyInfoPair $ wallets !! 1
, "--signing-key-file", paymentSKey $ paymentKeyInfoPair $ wallets !! 2
, "--signing-key-file", drepSKeyFp 1
, "--signing-key-file", drepSKeyFp 2
, "--signing-key-file", drepSKeyFp 3
, "--out-file", updateProposalTx
]

void $ H.execCli' execConfig
[ "conway", "transaction", "submit"
, "--tx-file", updateProposalTx
]

foldBlocksCheckProposalWasSubmitted
:: TxId -- TxId of submitted tx
-> Env
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ tests = do
pure $ testGroup "test/Spec.hs"
[ testGroup "Spec"
[ testGroup "Ledger Events"
[ H.ignoreOnWindows "Sanity Check" LedgerEvents.hprop_ledger_events_sanity_check
, H.ignoreOnWindows "Treasury Growth" LedgerEvents.prop_check_if_treasury_is_growing
[ --H.ignoreOnWindows "Sanity Check" LedgerEvents.hprop_ledger_events_sanity_check
-- , H.ignoreOnWindows "Treasury Growth" LedgerEvents.prop_check_if_treasury_is_growing
-- TODO: Replace foldBlocks with checkLedgerStateCondition
, testGroup "Governance"
testGroup "Governance"
[ H.ignoreOnMacAndWindows "ProposeAndRatifyNewConstitution" Cardano.Testnet.Test.LedgerEvents.Gov.ProposeNewConstitution.hprop_ledger_events_propose_new_constitution
-- FIXME Those tests are flaky
-- , H.ignoreOnWindows "InfoAction" LedgerEvents.hprop_ledger_events_info_action
Expand Down

0 comments on commit 8e20c19

Please sign in to comment.