diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index 2dca08df..1b2e949c 100644 --- a/.github/workflows/haskell-ci.yml +++ b/.github/workflows/haskell-ci.yml @@ -165,7 +165,7 @@ jobs: uses: actions/checkout@v6 with: repository: tweag/CIPs - ref: 8c50312e7b28b947901d4675e496ee7840a44ef4 + ref: d92300f9cf14f94a2bfab334e55a76cdf451fe8b path: cips - name: set env for reference CDDL run: | diff --git a/flake.lock b/flake.lock index 04cc89de..d18ad869 100644 --- a/flake.lock +++ b/flake.lock @@ -69,17 +69,17 @@ "cips": { "flake": false, "locked": { - "lastModified": 1777282412, - "narHash": "sha256-FY8CN+7njCclT+3eOEKq5iTKogoGKEmuXkZqmjO+0oM=", + "lastModified": 1778152917, + "narHash": "sha256-DhrwT5qnmmZyHV+0QT4oAcgTw35SJZILrJ/2ViDxlvs=", "owner": "tweag", "repo": "CIPs", - "rev": "8c50312e7b28b947901d4675e496ee7840a44ef4", + "rev": "d92300f9cf14f94a2bfab334e55a76cdf451fe8b", "type": "github" }, "original": { "owner": "tweag", "repo": "CIPs", - "rev": "8c50312e7b28b947901d4675e496ee7840a44ef4", + "rev": "d92300f9cf14f94a2bfab334e55a76cdf451fe8b", "type": "github" } }, diff --git a/flake.nix b/flake.nix index 8ee3988f..cd70097d 100644 --- a/flake.nix +++ b/flake.nix @@ -18,7 +18,7 @@ inputs.nixpkgs.follows = "nixpkgs"; }; inputs.cips = { - url = "github:tweag/CIPs?rev=8c50312e7b28b947901d4675e496ee7840a44ef4"; + url = "github:tweag/CIPs?rev=d92300f9cf14f94a2bfab334e55a76cdf451fe8b"; flake = false; }; outputs = { self, nixpkgs, flake-utils, haskellNix, git-hooks, treefmt-nix diff --git a/scls-cardano/cddl-src/Cardano/SCLS/CDDL.hs b/scls-cardano/cddl-src/Cardano/SCLS/CDDL.hs index 4f9d247e..61b12f76 100644 --- a/scls-cardano/cddl-src/Cardano/SCLS/CDDL.hs +++ b/scls-cardano/cddl-src/Cardano/SCLS/CDDL.hs @@ -10,6 +10,7 @@ module Cardano.SCLS.CDDL ( import Cardano.SCLS.Namespace.Blocks qualified as Blocks import Cardano.SCLS.Namespace.EntitiesCommittee qualified as EntitiesCommittee +import Cardano.SCLS.Namespace.EntitiesDReps qualified as EntitiesDReps import Cardano.SCLS.Namespace.EntitiesStakePools qualified as EntitiesStakePools import Cardano.SCLS.Namespace.GovCommittee qualified as GovCommittee import Cardano.SCLS.Namespace.GovConstitution qualified as GovConstitution @@ -57,6 +58,9 @@ instance KnownSpec "nonces/v0" where instance KnownSpec "entities/committee/v0" where namespaceSpec _ = mkDefinition EntitiesCommittee.record_entry +instance KnownSpec "entities/dreps/v0" where + namespaceSpec _ = mkDefinition EntitiesDReps.record_entry + instance KnownSpec "entities/stake_pools/v0" where namespaceSpec _ = mkDefinition EntitiesStakePools.record_entry @@ -91,6 +95,7 @@ knownNamespaces = , mkNamespaceSymbol @"snapshots/go/v0" , mkNamespaceSymbol @"nonces/v0" , mkNamespaceSymbol @"entities/committee/v0" + , mkNamespaceSymbol @"entities/dreps/v0" , mkNamespaceSymbol @"entities/stake_pools/v0" , mkNamespaceSymbol @"gov/committee/v0" , mkNamespaceSymbol @"gov/constitution/v0" @@ -106,6 +111,7 @@ type instance Spec.NamespaceKeySize "snapshots/mark/v0" = 31 -- 1 byte for hash type instance Spec.NamespaceKeySize "snapshots/set/v0" = 31 -- 1 byte for hash type, 29 bytes for key hash (including 1-byte discriminator/padding; cred 29, key 28+1), 1 byte for value type type instance Spec.NamespaceKeySize "snapshots/go/v0" = 31 -- 1 byte for hash type, 29 bytes for key hash (including 1-byte discriminator/padding; cred 29, key 28+1), 1 byte for value type type instance Spec.NamespaceKeySize "entities/committee/v0" = 8 +type instance Spec.NamespaceKeySize "entities/dreps/v0" = 29 -- 1 byte for tag, 28 bytes for hash type instance Spec.NamespaceKeySize "entities/stake_pools/v0" = 28 type instance Spec.NamespaceKeySize "gov/committee/v0" = 8 type instance Spec.NamespaceKeySize "gov/constitution/v0" = 8 diff --git a/scls-cardano/cddl-src/Cardano/SCLS/Namespace/EntitiesDReps.hs b/scls-cardano/cddl-src/Cardano/SCLS/Namespace/EntitiesDReps.hs new file mode 100644 index 00000000..ae3349c5 --- /dev/null +++ b/scls-cardano/cddl-src/Cardano/SCLS/Namespace/EntitiesDReps.hs @@ -0,0 +1,49 @@ +{-# LANGUAGE ImportQualifiedPost #-} +{-# LANGUAGE OverloadedLists #-} +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE QuasiQuotes #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE NoImplicitPrelude #-} +{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} + +{-# HLINT ignore "Use camelCase" #-} +module Cardano.SCLS.Namespace.EntitiesDReps where + +import Cardano.SCLS.Common +import Codec.CBOR.Cuddle.Huddle +import Data.Function (($)) +import Text.Heredoc (str) + +record_entry :: Rule +record_entry = + comment + [str| The key for the namespace + | + | ``` + | meta: + | endian: be + | + | seq: + | - id: key + | type: credential + | + | types: + | credential: + | seq: + | - id: tag + | size: 1 + | - id: hash + | size: 28 + | ``` + |] + $ "record_entry" =:= drep_state + +drep_state :: Rule +drep_state = + "drep_state" + =:= mp + [ "expiry" ==> epoch_no + , "anchor" ==> anchor / VNil + , "deposit" ==> coin + , "delegations" ==> set credential + ] diff --git a/scls-cardano/scls-cardano.cabal b/scls-cardano/scls-cardano.cabal index 5bcbfa08..cb390b3d 100644 --- a/scls-cardano/scls-cardano.cabal +++ b/scls-cardano/scls-cardano.cabal @@ -32,6 +32,7 @@ library Cardano.SCLS.Common Cardano.SCLS.Namespace.Blocks Cardano.SCLS.Namespace.EntitiesCommittee + Cardano.SCLS.Namespace.EntitiesDReps Cardano.SCLS.Namespace.EntitiesStakePools Cardano.SCLS.Namespace.GovCommittee Cardano.SCLS.Namespace.GovConstitution diff --git a/scls-cardano/test/Reference.hs b/scls-cardano/test/Reference.hs index 79f070d4..d9f820f2 100644 --- a/scls-cardano/test/Reference.hs +++ b/scls-cardano/test/Reference.hs @@ -70,6 +70,7 @@ allReferenceCDDLs = , ("snapshots/go/v0", "snapshots_go_v0.cddl") , ("nonces/v0", "nonces_v0.cddl") , ("entities/committee/v0", "entities_committee_v0.cddl") + , ("entities/dreps/v0", "entities_dreps_v0.cddl") , ("entities/stake_pools/v0", "entities_stake_pools_v0.cddl") , ("gov/committee/v0", "gov_committee_v0.cddl") , ("gov/constitution/v0", "gov_constitution_v0.cddl") diff --git a/scls-cardano/testlib/Cardano/SCLS/Testlib.hs b/scls-cardano/testlib/Cardano/SCLS/Testlib.hs index 6af173d5..4c17b8ed 100644 --- a/scls-cardano/testlib/Cardano/SCLS/Testlib.hs +++ b/scls-cardano/testlib/Cardano/SCLS/Testlib.hs @@ -56,6 +56,7 @@ testAllNS :: , ConstrNS "snapshots/mark/v0" , ConstrNS "snapshots/set/v0" , ConstrNS "entities/committee/v0" + , ConstrNS "entities/dreps/v0" , ConstrNS "entities/stake_pools/v0" , ConstrNS "gov/committee/v0" , ConstrNS "gov/constitution/v0" @@ -71,6 +72,7 @@ testAllNS = describe "scls/conformance" $ do testNS @"snapshots/mark/v0" testNS @"snapshots/set/v0" testNS @"entities/committee/v0" + testNS @"entities/dreps/v0" testNS @"entities/stake_pools/v0" testNS @"gov/committee/v0" testNS @"gov/constitution/v0"