-
Notifications
You must be signed in to change notification settings - Fork 174
Support standart canonical state instances #5486
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
Draft
qnikst
wants to merge
37
commits into
IntersectMBO:master
Choose a base branch
from
tweag:scls-canonical-2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4,198
−4
Draft
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
929c550
Implement standart canonical state instances
qnikst ae17f46
Introduce an example utility to read scls file
qnikst 705602f
Remove OVERLAPPING pragma as we do not need them anymore
qnikst f1ca45d
Parethises hunt
qnikst 61fa238
Put scls package source-repository-package repository in a single entry
qnikst ee0a666
Update the path to cls repository
qnikst ea03b5c
carnano-ledger-conway fix typo in tests
qnikst 1bc03ed
Remove ImportQualifiedPost
qnikst c71bf0a
Use explicit import
qnikst 7aa9529
Support Nonce namespace
qnikst 82219d9
Merge branch 'master' into scls-canonical-2
qnikst e5d2cc3
Update usage to support changes in cardano-ledger
qnikst 4dd40d8
SCLS: update canonical gov/constitution with proxy types
qnikst 22862dc
Scls gov/committee/v0 use proxy types for instances
qnikst f0a1750
Update style in Nonce namespace
qnikst d05eed3
Support proxe data types in PParams
qnikst b3c522e
Do not use CoinPerByte in proxy types for the PParams
qnikst 5bf0cfa
Introduce CanonicalExUnits proxy type
qnikst 5258282
Introduce CanonicalPurposeId proxy type
qnikst b07eb5f
Introduce CanonicalRewardAccount
qnikst d807767
Add CanonicalWithOrigin proxy type
qnikst 5eba199
Implement CanonicalNonce type
qnikst 9d04e42
Introduce canonical types for the PoolStake
qnikst 2ae0d57
Add more canonical wrappers
qnikst 08558df
WIP
qnikst 72bd5c4
Add test-suite
qnikst 5328f14
Introduce a hierarchy for namespaces
qnikst fded10f
Introduce testlib and updates
qnikst 8ce326e
Update hierarchy
qnikst bc93ce8
Port era-dependent scls code a-top of the canonical-ledger library
qnikst fb21740
Restructure SCLS libraries
qnikst 5b871a1
Merge remote-tracking branch 'origin/master' into scls-canonical-2
qnikst 5240e65
Merge remote-tracking branch 'origin/master' into scls-canonical-2
qnikst 0cc8548
Update cardano-canonical to support new Metadata representation
qnikst 19ed0f9
Update scls code to the lastest changes in the library
qnikst dcf7d53
Merge remote-tracking branch 'origin/master' into scls-canonical-2
qnikst 283dfe2
Update scls to support RewardAccount renaming
qnikst 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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -246,6 +246,76 @@ library testlib | |||||
| time, | ||||||
| tree-diff, | ||||||
|
|
||||||
| library scls | ||||||
| exposed-modules: | ||||||
| Cardano.Ledger.Conway.SCLS | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this will be a better prefix. Again abbreviations are not really saving time.
Suggested change
|
||||||
| Cardano.Ledger.Conway.SCLS.Namespace.GovCommittee | ||||||
| Cardano.Ledger.Conway.SCLS.Namespace.GovConstitution | ||||||
| Cardano.Ledger.Conway.SCLS.Namespace.GovPParams | ||||||
| Cardano.Ledger.Conway.SCLS.Namespace.GovProposals | ||||||
| Cardano.Ledger.Conway.SCLS.Namespace.UTxO | ||||||
|
|
||||||
| visibility: public | ||||||
| hs-source-dirs: scls/src | ||||||
| default-language: Haskell2010 | ||||||
| ghc-options: | ||||||
| -Wall | ||||||
| -Wcompat | ||||||
| -Wincomplete-record-updates | ||||||
| -Wincomplete-uni-patterns | ||||||
| -Wpartial-fields | ||||||
| -Wredundant-constraints | ||||||
| -Wunused-packages | ||||||
| -Werror | ||||||
|
|
||||||
| build-depends: | ||||||
| base, | ||||||
| -- bytestring, | ||||||
| cardano-canonical, | ||||||
| cardano-ledger-allegra, | ||||||
| cardano-ledger-alonzo, | ||||||
| cardano-ledger-babbage, | ||||||
| cardano-ledger-binary, | ||||||
| cardano-ledger-conway, | ||||||
| cardano-ledger-core, | ||||||
| cardano-ledger-mary, | ||||||
| cardano-ledger-shelley, | ||||||
| -- cardano-slotting, | ||||||
| -- cardano-strict-containers, | ||||||
| bytestring, | ||||||
| cborg, | ||||||
| containers, | ||||||
| -- mempack, | ||||||
| -- scls-cbor, | ||||||
| -- scls-core, | ||||||
|
|
||||||
| library scls-testlib | ||||||
| exposed-modules: | ||||||
| Cardano.Ledger.Conway.SCLS.Arbitrary | ||||||
|
|
||||||
| visibility: public | ||||||
| hs-source-dirs: scls/testlib | ||||||
| default-language: Haskell2010 | ||||||
| ghc-options: | ||||||
| -Wall | ||||||
| -Wcompat | ||||||
| -Wincomplete-record-updates | ||||||
| -Wincomplete-uni-patterns | ||||||
| -Wpartial-fields | ||||||
| -Wredundant-constraints | ||||||
| -Wunused-packages | ||||||
| -Werror | ||||||
|
|
||||||
| build-depends: | ||||||
| QuickCheck, | ||||||
| base, | ||||||
| cardano-ledger-core, | ||||||
| cardano-ledger-conway:{cardano-ledger-conway, testlib, scls}, | ||||||
| cardano-ledger-babbage:{cardano-ledger-babbage, testlib}, | ||||||
| cardano-ledger-shelley:{cardano-ledger-shelley, testlib}, | ||||||
| cardano-canonical:{cardano-canonical, testlib}, | ||||||
| generic-random, | ||||||
|
|
||||||
| executable gen-golden | ||||||
| main-is: GenerateGoldenFileMain.hs | ||||||
| hs-source-dirs: test | ||||||
|
|
@@ -275,6 +345,7 @@ test-suite tests | |||||
| Test.Cardano.Ledger.Conway.Binary.CddlSpec | ||||||
| Test.Cardano.Ledger.Conway.GoldenSpec | ||||||
| Test.Cardano.Ledger.Conway.GoldenTranslation | ||||||
| Test.Cardano.Ledger.Conway.Scls | ||||||
|
|
||||||
| default-language: Haskell2010 | ||||||
| ghc-options: | ||||||
|
|
@@ -284,7 +355,7 @@ test-suite tests | |||||
| -Wincomplete-uni-patterns | ||||||
| -Wredundant-constraints | ||||||
| -Wpartial-fields | ||||||
| -Wunused-packages | ||||||
| -- -Wunused-packages | ||||||
| -threaded | ||||||
| -rtsopts | ||||||
| -with-rtsopts=-N | ||||||
|
|
@@ -295,8 +366,17 @@ test-suite tests | |||||
| cardano-ledger-allegra, | ||||||
| cardano-ledger-alonzo:{cardano-ledger-alonzo, testlib}, | ||||||
| cardano-ledger-binary:testlib, | ||||||
| cardano-ledger-conway, | ||||||
| cardano-ledger-conway:cddl, | ||||||
| cardano-ledger-conway:{cardano-ledger-conway, cddl, scls, scls-testlib}, | ||||||
| cardano-ledger-core:{cardano-ledger-core, testlib}, | ||||||
| cardano-ledger-shelley:testlib, | ||||||
| cardano-ledger-shelley:{testlib}, | ||||||
| scls-cardano:testlib, | ||||||
| testlib, | ||||||
|
|
||||||
| -- | ||||||
| containers, | ||||||
| bytestring, | ||||||
| cardano-ledger-byron, | ||||||
| cardano-strict-containers, | ||||||
| cardano-canonical, | ||||||
| cardano-ledger-byron, | ||||||
| -- cardano-ledger-test, | ||||||
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 |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| module Cardano.Ledger.Conway.SCLS ( | ||
| module Cardano.Ledger.SCLS.Common, | ||
| module Cardano.Ledger.SCLS.Namespace.Blocks.V0, | ||
| module Cardano.Ledger.Conway.SCLS.Namespace.GovCommittee, | ||
| module Cardano.Ledger.Conway.SCLS.Namespace.GovConstitution, | ||
| module Cardano.Ledger.Conway.SCLS.Namespace.GovPParams, | ||
| module Cardano.Ledger.Conway.SCLS.Namespace.GovProposals, | ||
| module Cardano.Ledger.SCLS.Namespace.Nonces.V0, | ||
| module Cardano.Ledger.SCLS.Namespace.PoolStake.V0, | ||
| module Cardano.Ledger.SCLS.Namespace.Pots.V0, | ||
| module Cardano.Ledger.SCLS.Namespace.Snapshots.V0, | ||
| module Cardano.Ledger.Conway.SCLS.Namespace.UTxO, | ||
| ) where | ||
|
|
||
| import Cardano.Ledger.Conway.SCLS.Namespace.GovCommittee | ||
| import Cardano.Ledger.Conway.SCLS.Namespace.GovConstitution | ||
| import Cardano.Ledger.Conway.SCLS.Namespace.GovPParams | ||
| import Cardano.Ledger.Conway.SCLS.Namespace.GovProposals | ||
| import Cardano.Ledger.Conway.SCLS.Namespace.UTxO | ||
| import Cardano.Ledger.SCLS.Common | ||
| import Cardano.Ledger.SCLS.Namespace.Blocks.V0 | ||
| import Cardano.Ledger.SCLS.Namespace.Nonces.V0 | ||
| import Cardano.Ledger.SCLS.Namespace.PoolStake.V0 | ||
| import Cardano.Ledger.SCLS.Namespace.Pots.V0 | ||
| import Cardano.Ledger.SCLS.Namespace.Snapshots.V0 |
34 changes: 34 additions & 0 deletions
34
eras/conway/impl/scls/src/Cardano/Ledger/Conway/SCLS/Namespace/GovCommittee.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 |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| {-# LANGUAGE RecordWildCards #-} | ||
|
|
||
| module Cardano.Ledger.Conway.SCLS.Namespace.GovCommittee ( | ||
| module Cardano.Ledger.SCLS.Namespace.GovCommittee.V0, | ||
| mkCanonicalCommitteeState, | ||
| fromCanonicalCommitteeState, | ||
| ) where | ||
|
|
||
| import Cardano.Ledger.Conway (ConwayEra) | ||
| import Cardano.Ledger.SCLS.Common ( | ||
| fromCanonicalCredential, | ||
| mkCanonicalCredential, | ||
| ) | ||
| import Cardano.Ledger.SCLS.Namespace.GovCommittee.V0 | ||
| import Cardano.Ledger.State (CommitteeState (..)) | ||
| import qualified Data.Map.Strict as Map | ||
|
|
||
| mkCanonicalCommitteeState :: CommitteeState ConwayEra -> CanonicalCommitteeState | ||
| mkCanonicalCommitteeState CommitteeState {..} = | ||
| CanonicalCommitteeState | ||
| ( Map.fromList | ||
| [ (mkCanonicalCredential k, mkCanonicalCommitteeAuthorization v) | ||
| | (k, v) <- Map.toList csCommitteeCreds | ||
| ] | ||
| ) | ||
|
|
||
| fromCanonicalCommitteeState :: CanonicalCommitteeState -> CommitteeState ConwayEra | ||
| fromCanonicalCommitteeState CanonicalCommitteeState {..} = | ||
| CommitteeState | ||
| ( Map.fromList | ||
| [ (fromCanonicalCredential k, fromCanonicalCommitteeAuthorization v) | ||
| | (k, v) <- Map.toList csCommitteeCreds | ||
| ] | ||
| ) |
15 changes: 15 additions & 0 deletions
15
eras/conway/impl/scls/src/Cardano/Ledger/Conway/SCLS/Namespace/GovConstitution.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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| {-# LANGUAGE FlexibleInstances #-} | ||
| {-# LANGUAGE RecordWildCards #-} | ||
| {-# OPTIONS_GHC -Wno-orphans #-} | ||
|
|
||
| module Cardano.Ledger.Conway.SCLS.Namespace.GovConstitution ( | ||
| module Cardano.Ledger.SCLS.Namespace.GovConstitution.V0, | ||
| ) where | ||
|
|
||
| import Cardano.Ledger.Conway (ConwayEra) | ||
| import Cardano.Ledger.Conway.Governance (Constitution (..)) | ||
| import Cardano.Ledger.SCLS.Namespace.GovConstitution.V0 | ||
|
|
||
| instance IsCanonicalConstitution (Constitution ConwayEra) where | ||
| mkCanonicalConstitution Constitution {..} = CanonicalConstitution {..} | ||
| fromCanonicalConstitution CanonicalConstitution {..} = Constitution {..} |
104 changes: 104 additions & 0 deletions
104
eras/conway/impl/scls/src/Cardano/Ledger/Conway/SCLS/Namespace/GovPParams.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 |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| {-# LANGUAGE FlexibleInstances #-} | ||
| {-# LANGUAGE RecordWildCards #-} | ||
| {-# OPTIONS_GHC -Wno-orphans #-} | ||
|
|
||
| module Cardano.Ledger.Conway.SCLS.Namespace.GovPParams ( | ||
| module Cardano.Ledger.SCLS.Namespace.GovPParams.V0, | ||
| ) where | ||
|
|
||
| import Cardano.Ledger.Alonzo.PParams (OrdExUnits (..)) | ||
| import Cardano.Ledger.Conway (ConwayEra) | ||
| import Cardano.Ledger.Conway.PParams ( | ||
| ConwayPParams (..), | ||
| DRepVotingThresholds (..), | ||
| PoolVotingThresholds (..), | ||
| THKD (..), | ||
| ) | ||
| import Cardano.Ledger.Core (PParams (..)) | ||
| import Cardano.Ledger.SCLS.Common ( | ||
| CoinPerByte (..), | ||
| fromCanonicalCoin, | ||
| mkCanonicalCoin, | ||
| ) | ||
| import Cardano.Ledger.SCLS.Namespace.GovPParams.V0 | ||
| import Data.Function ((&)) | ||
|
|
||
| instance IsCanonicalPParams (PParams ConwayEra) where | ||
| mkCanonicalPParams (PParams ConwayPParams {..}) = | ||
| CanonicalPParams | ||
| { ccppA0 = unTHKD cppA0 | ||
| , ccppTxFeePerByte = mkCanonicalCoin $ unCoinPerByte $ unTHKD cppTxFeePerByte | ||
| , ccppTxFeeFixed = mkCanonicalCoin $ unTHKD cppTxFeeFixed | ||
| , ccppMaxBBSize = unTHKD cppMaxBBSize | ||
| , ccppMaxTxSize = unTHKD cppMaxTxSize | ||
| , ccppMaxBHSize = unTHKD cppMaxBHSize | ||
| , ccppKeyDeposit = mkCanonicalCoin $ unTHKD cppKeyDeposit | ||
| , ccppPoolDeposit = mkCanonicalCoin $ unTHKD cppPoolDeposit | ||
| , ccppEMax = unTHKD cppEMax | ||
| , ccppNOpt = unTHKD cppNOpt | ||
| , ccppRho = unTHKD cppRho | ||
| , ccppTau = unTHKD cppTau | ||
| , ccppProtocolVersion = cppProtocolVersion | ||
| , ccppMinPoolCost = mkCanonicalCoin $ unTHKD cppMinPoolCost | ||
| , ccppCoinsPerUTxOByte = mkCanonicalCoin $ unCoinPerByte $ unTHKD cppCoinsPerUTxOByte | ||
| , ccppCostModels = mkCanonicalCostModels $ unTHKD cppCostModels | ||
| , ccppPrices = mkCanonicalPrices $ unTHKD cppPrices | ||
| , ccppMaxTxExUnits = unTHKD cppMaxTxExUnits & unOrdExUnits & mkCanonicalExUnits | ||
| , ccppMaxBlockExUnits = unTHKD cppMaxBlockExUnits & unOrdExUnits & mkCanonicalExUnits | ||
| , ccppMaxValSize = unTHKD cppMaxValSize | ||
| , ccppCollateralPercentage = unTHKD cppCollateralPercentage | ||
| , ccppMaxCollateralInputs = unTHKD cppMaxCollateralInputs | ||
| , ccppPoolVotingThresholds = mkCanonicalPoolVotingThresholds $ unTHKD cppPoolVotingThresholds | ||
| , ccppDRepVotingThresholds = mkCanonicalDRepVotingThresholds $ unTHKD cppDRepVotingThresholds | ||
| , ccppCommitteeMinSize = unTHKD cppCommitteeMinSize | ||
| , ccppCommitteeMaxTermLength = unTHKD cppCommitteeMaxTermLength | ||
| , ccppGovActionLifetime = unTHKD cppGovActionLifetime | ||
| , ccppGovActionDeposit = mkCanonicalCoin $ unTHKD cppGovActionDeposit | ||
| , ccppDRepDeposit = mkCanonicalCoin $ unTHKD cppDRepDeposit | ||
| , ccppDRepActivity = unTHKD cppDRepActivity | ||
| , ccppMinFeeRefScriptCostPerByte = unTHKD cppMinFeeRefScriptCostPerByte | ||
| } | ||
|
|
||
| fromCanonicalPParams CanonicalPParams {..} = | ||
| PParams | ||
| ConwayPParams | ||
| { cppA0 = THKD ccppA0 | ||
| , cppTxFeePerByte = THKD (CoinPerByte $ fromCanonicalCoin ccppTxFeePerByte) | ||
| , cppTxFeeFixed = THKD (fromCanonicalCoin ccppTxFeeFixed) | ||
| , cppMaxBBSize = THKD ccppMaxBBSize | ||
| , cppMaxTxSize = THKD ccppMaxTxSize | ||
| , cppMaxBHSize = THKD ccppMaxBHSize | ||
| , cppKeyDeposit = THKD (fromCanonicalCoin ccppKeyDeposit) | ||
| , cppPoolDeposit = THKD (fromCanonicalCoin ccppPoolDeposit) | ||
| , cppEMax = THKD ccppEMax | ||
| , cppNOpt = THKD ccppNOpt | ||
| , cppRho = THKD ccppRho | ||
| , cppTau = THKD ccppTau | ||
| , cppProtocolVersion = ccppProtocolVersion | ||
| , cppMinPoolCost = THKD (fromCanonicalCoin ccppMinPoolCost) | ||
| , cppCoinsPerUTxOByte = THKD (CoinPerByte $ fromCanonicalCoin ccppCoinsPerUTxOByte) | ||
| , cppCostModels = THKD (fromCanonicalCostModels ccppCostModels) | ||
| , cppPrices = THKD (fromCanonicalPrices ccppPrices) | ||
| , cppMaxTxExUnits = THKD (ccppMaxTxExUnits & fromCanonicalExUnits & OrdExUnits) | ||
| , cppMaxBlockExUnits = THKD (ccppMaxBlockExUnits & fromCanonicalExUnits & OrdExUnits) | ||
| , cppMaxValSize = THKD ccppMaxValSize | ||
| , cppCollateralPercentage = THKD ccppCollateralPercentage | ||
| , cppMaxCollateralInputs = THKD ccppMaxCollateralInputs | ||
| , cppPoolVotingThresholds = THKD (fromCanonicalPoolVotingThresholds ccppPoolVotingThresholds) | ||
| , cppDRepVotingThresholds = THKD (fromCanonicalDRepVotingThresholds ccppDRepVotingThresholds) | ||
| , cppCommitteeMinSize = THKD ccppCommitteeMinSize | ||
| , cppCommitteeMaxTermLength = THKD ccppCommitteeMaxTermLength | ||
| , cppGovActionLifetime = THKD ccppGovActionLifetime | ||
| , cppGovActionDeposit = THKD (fromCanonicalCoin ccppGovActionDeposit) | ||
| , cppDRepDeposit = THKD (fromCanonicalCoin ccppDRepDeposit) | ||
| , cppDRepActivity = THKD ccppDRepActivity | ||
| , cppMinFeeRefScriptCostPerByte = THKD ccppMinFeeRefScriptCostPerByte | ||
| } | ||
|
|
||
| instance IsCanonicalDRepVotingThresholds DRepVotingThresholds where | ||
| mkCanonicalDRepVotingThresholds DRepVotingThresholds {..} = CanonicalDRepVotingThresholds {..} | ||
| fromCanonicalDRepVotingThresholds CanonicalDRepVotingThresholds {..} = DRepVotingThresholds {..} | ||
|
|
||
| instance IsCanonicalPoolVotingThresholds PoolVotingThresholds where | ||
| fromCanonicalPoolVotingThresholds CanonicalPoolVotingThresholds {..} = PoolVotingThresholds {..} | ||
| mkCanonicalPoolVotingThresholds PoolVotingThresholds {..} = CanonicalPoolVotingThresholds {..} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We try to avoid abbreviations as much as possible