-
Notifications
You must be signed in to change notification settings - Fork 171
Add PlutusV3 CostModel to UpgradeConwayPParams #4252
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| cabal-version: 3.0 | ||
| name: cardano-ledger-conway | ||
| version: 1.13.1.0 | ||
| version: 1.14.0.0 | ||
| license: Apache-2.0 | ||
| maintainer: [email protected] | ||
| author: IOHK | ||
|
|
@@ -90,7 +90,7 @@ library | |
| cardano-ledger-allegra ^>=1.4, | ||
| cardano-ledger-alonzo ^>=1.8, | ||
| cardano-ledger-babbage ^>=1.8, | ||
| cardano-ledger-core ^>=1.11, | ||
| cardano-ledger-core ^>=1.11.1, | ||
| cardano-ledger-mary ^>=1.5, | ||
| cardano-ledger-shelley ^>=1.10, | ||
| cardano-slotting, | ||
|
|
@@ -126,6 +126,7 @@ library testlib | |
| Test.Cardano.Ledger.Conway.Imp.RatifySpec | ||
| Test.Cardano.Ledger.Conway.Proposals | ||
| Test.Cardano.Ledger.Conway.TreeDiff | ||
| Test.Cardano.Ledger.Conway.Genesis | ||
|
|
||
| visibility: public | ||
| hs-source-dirs: testlib | ||
|
|
@@ -183,7 +184,6 @@ test-suite tests | |
| build-depends: | ||
| aeson, | ||
| base, | ||
| cardano-data, | ||
| cardano-ledger-core:testlib, | ||
| cardano-ledger-allegra, | ||
| cardano-ledger-alonzo:testlib, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151 changes: 33 additions & 118 deletions
151
eras/conway/impl/test/Test/Cardano/Ledger/Conway/GenesisSpec.hs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,141 +1,56 @@ | ||
| {-# LANGUAGE AllowAmbiguousTypes #-} | ||
| {-# LANGUAGE DataKinds #-} | ||
| {-# LANGUAGE FlexibleContexts #-} | ||
| {-# LANGUAGE FlexibleInstances #-} | ||
| {-# LANGUAGE OverloadedStrings #-} | ||
| {-# LANGUAGE ScopedTypeVariables #-} | ||
|
|
||
| module Test.Cardano.Ledger.Conway.GenesisSpec (spec) where | ||
| module Test.Cardano.Ledger.Conway.GenesisSpec (spec, expectedConwayGenesis) where | ||
|
|
||
| import Cardano.Ledger.BaseTypes (textToUrl) | ||
| import Cardano.Ledger.CertState (DRep (..), DRepState (..)) | ||
| import Cardano.Ledger.Coin (Coin (..)) | ||
| import Cardano.Ledger.Conway | ||
| import Cardano.Ledger.Conway.Genesis (ConwayGenesis (..)) | ||
| import Cardano.Ledger.Conway.Governance (Anchor (..), Committee (..)) | ||
| import Cardano.Ledger.Conway.TxCert (Delegatee (..)) | ||
| import Cardano.Ledger.Core | ||
| import Cardano.Ledger.Credential | ||
| import Cardano.Ledger.Crypto (StandardCrypto) | ||
| import Cardano.Ledger.Keys | ||
| import Cardano.Ledger.Slot (EpochNo (..)) | ||
| import Cardano.Ledger.Babbage (Babbage) | ||
| import Cardano.Ledger.Conway (Conway) | ||
| import Cardano.Ledger.Conway.Core | ||
| import Cardano.Ledger.Conway.PParams | ||
| import Cardano.Ledger.Plutus.CostModels (costModelsValid) | ||
| import Cardano.Ledger.Plutus.Language (Language (PlutusV3)) | ||
| import Data.Aeson hiding (Encoding) | ||
| import Data.Default.Class (Default (def)) | ||
| import qualified Data.ListMap as ListMap | ||
| import Data.Map as Map | ||
| import Data.Maybe (fromJust) | ||
| import Data.Maybe.Strict (StrictMaybe (..)) | ||
| import Data.Ratio ((%)) | ||
| import Data.Functor.Identity (Identity) | ||
| import qualified Data.Map.Strict as Map | ||
| import Lens.Micro | ||
| import Paths_cardano_ledger_conway (getDataFileName) | ||
| import Test.Cardano.Ledger.Common | ||
| import Test.Cardano.Ledger.Core.Utils (unsafeBoundRational) | ||
| import Test.Cardano.Ledger.Conway.Genesis (expectedConwayGenesis) | ||
| import Test.Cardano.Slotting.Numeric () | ||
|
|
||
| spec :: Spec | ||
| spec = do | ||
| describe "Genesis Golden Spec" $ do | ||
| goldenConwayGenesisJSON | ||
| describe "ConwayGenesis" $ do | ||
| describe "Golden Spec" goldenConwayGenesisJSON | ||
| prop "Upgrades" propConwayPParamsUpgrade | ||
|
|
||
| fileName :: String | ||
| fileName = "test/data/conway-genesis.json" | ||
|
|
||
| goldenConwayGenesisJSON :: Spec | ||
| goldenConwayGenesisJSON = | ||
| it "should deserialize to the default value" $ do | ||
| let fileName = "test/data/conway-genesis.json" | ||
| credMember = | ||
| KeyHashObj | ||
| (KeyHash "4e88cc2d27c364aaf90648a87dfb95f8ee103ba67fa1f12f5e86c42a") :: | ||
| Credential 'ColdCommitteeRole StandardCrypto | ||
| scriptMember = | ||
| ScriptHashObj | ||
| (ScriptHash "4e88cc2d27c364aaf90648a87dfb95f8ee103ba67fa1f12f5e86c42a") :: | ||
| Credential 'ColdCommitteeRole StandardCrypto | ||
| comm = | ||
| Committee | ||
| ( Map.fromList | ||
| [ | ||
| ( credMember | ||
| , EpochNo 1 | ||
| ) | ||
| , | ||
| ( scriptMember | ||
| , EpochNo 2 | ||
| ) | ||
| ] | ||
| ) | ||
| (unsafeBoundRational (1 % 2)) :: | ||
| Committee Conway | ||
| file <- getDataFileName fileName | ||
| dec <- eitherDecodeFileStrict' file | ||
| cg <- case dec of | ||
| Left err -> error ("Failed to deserialize JSON: " ++ err) | ||
| Right x -> pure x | ||
| let | ||
| expectedCg = | ||
| def | ||
| { cgCommittee = comm | ||
| , cgInitialDReps = | ||
| ListMap.fromList | ||
| [ | ||
| ( KeyHashObj | ||
| (KeyHash "78301005df84ba67fa1f12f95f8ee10335bc5e86c42afbc593ab4cdd") | ||
| , DRepState | ||
| { drepExpiry = 1000 | ||
| , drepAnchor = SNothing | ||
| , drepDeposit = Coin 5000 | ||
| } | ||
| ) | ||
| , | ||
| ( ScriptHashObj | ||
| (ScriptHash "01305df84b078ac5e86c42afbc593ab4cdd67fa1f12f95f8ee10335b") | ||
| , DRepState | ||
| { drepExpiry = 300 | ||
| , drepAnchor = | ||
| SJust $ | ||
| Anchor | ||
| { anchorUrl = fromJust $ textToUrl 99 "example.com" | ||
| , anchorDataHash = def | ||
| } | ||
| , drepDeposit = Coin 6000 | ||
| } | ||
| ) | ||
| ] | ||
| , cgDelegs = | ||
| ListMap.fromList | ||
| [ | ||
| ( KeyHashObj | ||
| (KeyHash "35bc5e86c42afbc593ab4cdd78301005df84ba67fa1f12f95f8ee103") | ||
| , DelegVote DRepAlwaysNoConfidence | ||
| ) | ||
| , | ||
| ( KeyHashObj | ||
| (KeyHash "4e88cc2d27c364aaf90648a87dfb95f8ee103ba67fa1f12f5e86c42a") | ||
| , DelegVote DRepAlwaysAbstain | ||
| ) | ||
| , | ||
| ( KeyHashObj | ||
| (KeyHash "5df84bcdd7a5f8ee93aafbc500b435bc5e83067fa1f12f9110386c42") | ||
| , DelegStake $ KeyHash "0335bc5e86c42afbc578301005df84ba67fa1f12f95f8ee193ab4cdd" | ||
| ) | ||
| , | ||
| ( KeyHashObj | ||
| (KeyHash "8ee93a5df84bc42cdd7a5fafbc500b435bc5e83067fa1f12f9110386") | ||
| , DelegStakeVote | ||
| (KeyHash "086c42afbc578301005df84ba67fa1f12f95f8ee193ab4cdd335bc5e") | ||
| DRepAlwaysAbstain | ||
| ) | ||
| , | ||
| ( KeyHashObj | ||
| (KeyHash "df93ab435bc5eafbc500583067fa1f12f9110386c42cdd784ba5f8ee") | ||
| , DelegVote $ | ||
| DRepCredential | ||
| (ScriptHashObj (ScriptHash "01305df84b078ac5e86c42afbc593ab4cdd67fa1f12f95f8ee10335b")) | ||
| ) | ||
| , | ||
| ( ScriptHashObj | ||
| (ScriptHash "afbc5005df84ba5f8ee93ab435bc5e83067fa1f12f9c42cdd7110386") | ||
| , DelegVote $ | ||
| DRepCredential | ||
| (KeyHashObj (KeyHash "78301005df84ba67fa1f12f95f8ee10335bc5e86c42afbc593ab4cdd")) | ||
| ) | ||
| ] | ||
| } | ||
| cg `shouldBe` expectedCg | ||
| cg `shouldBe` expectedConwayGenesis | ||
|
|
||
| propConwayPParamsUpgrade :: UpgradeConwayPParams Identity -> PParams Babbage -> Property | ||
| propConwayPParamsUpgrade ppu pp = property $ do | ||
| let pp' = upgradePParams ppu pp :: PParams Conway | ||
| pp' ^. ppPoolVotingThresholdsL `shouldBe` ucppPoolVotingThresholds ppu | ||
| pp' ^. ppDRepVotingThresholdsL `shouldBe` ucppDRepVotingThresholds ppu | ||
| pp' ^. ppCommitteeMinSizeL `shouldBe` ucppCommitteeMinSize ppu | ||
| pp' ^. ppCommitteeMaxTermLengthL `shouldBe` ucppCommitteeMaxTermLength ppu | ||
| pp' ^. ppGovActionLifetimeL `shouldBe` ucppGovActionLifetime ppu | ||
| pp' ^. ppGovActionDepositL `shouldBe` ucppGovActionDeposit ppu | ||
| pp' ^. ppDRepDepositL `shouldBe` ucppDRepDeposit ppu | ||
| pp' ^. ppDRepActivityL `shouldBe` ucppDRepActivity ppu | ||
| pp' ^. ppMinFeeRefScriptCostPerByteL `shouldBe` ucppMinFeeRefScriptCostPerByte ppu | ||
| Map.lookup PlutusV3 (costModelsValid (pp' ^. ppCostModelsL)) | ||
| `shouldBe` Just (ucppPlutusV3CostModel ppu) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.