diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index b25be2c9..2dca08df 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: c92a3b5db78268e7f0db5f24c80ed6f49cf4b149 + ref: 8c50312e7b28b947901d4675e496ee7840a44ef4 path: cips - name: set env for reference CDDL run: | diff --git a/flake.lock b/flake.lock index 06ea2a99..437d116e 100644 --- a/flake.lock +++ b/flake.lock @@ -69,17 +69,17 @@ "cips": { "flake": false, "locked": { - "lastModified": 1776254122, - "narHash": "sha256-MmXsGDMGnZayYZEt40Y5a54Pis31plBQt2/hbdUTaos=", + "lastModified": 1777282412, + "narHash": "sha256-FY8CN+7njCclT+3eOEKq5iTKogoGKEmuXkZqmjO+0oM=", "owner": "tweag", "repo": "CIPs", - "rev": "c92a3b5db78268e7f0db5f24c80ed6f49cf4b149", + "rev": "8c50312e7b28b947901d4675e496ee7840a44ef4", "type": "github" }, "original": { "owner": "tweag", "repo": "CIPs", - "rev": "c92a3b5db78268e7f0db5f24c80ed6f49cf4b149", + "rev": "8c50312e7b28b947901d4675e496ee7840a44ef4", "type": "github" } }, diff --git a/flake.nix b/flake.nix index ab2381f8..8ee3988f 100644 --- a/flake.nix +++ b/flake.nix @@ -18,7 +18,7 @@ inputs.nixpkgs.follows = "nixpkgs"; }; inputs.cips = { - url = "github:tweag/CIPs?rev=c92a3b5db78268e7f0db5f24c80ed6f49cf4b149"; + url = "github:tweag/CIPs?rev=8c50312e7b28b947901d4675e496ee7840a44ef4"; 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 cec996b3..4f9d247e 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.EntitiesStakePools qualified as EntitiesStakePools import Cardano.SCLS.Namespace.GovCommittee qualified as GovCommittee import Cardano.SCLS.Namespace.GovConstitution qualified as GovConstitution import Cardano.SCLS.Namespace.GovPParams qualified as GovPParams @@ -56,6 +57,9 @@ instance KnownSpec "nonces/v0" where instance KnownSpec "entities/committee/v0" where namespaceSpec _ = mkDefinition EntitiesCommittee.record_entry +instance KnownSpec "entities/stake_pools/v0" where + namespaceSpec _ = mkDefinition EntitiesStakePools.record_entry + instance KnownSpec "gov/committee/v0" where namespaceSpec _ = mkDefinition GovCommittee.record_entry @@ -87,6 +91,7 @@ knownNamespaces = , mkNamespaceSymbol @"snapshots/go/v0" , mkNamespaceSymbol @"nonces/v0" , mkNamespaceSymbol @"entities/committee/v0" + , mkNamespaceSymbol @"entities/stake_pools/v0" , mkNamespaceSymbol @"gov/committee/v0" , mkNamespaceSymbol @"gov/constitution/v0" , mkNamespaceSymbol @"gov/pparams/v0" @@ -101,6 +106,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/stake_pools/v0" = 28 type instance Spec.NamespaceKeySize "gov/committee/v0" = 8 type instance Spec.NamespaceKeySize "gov/constitution/v0" = 8 type instance Spec.NamespaceKeySize "gov/pparams/v0" = 4 diff --git a/scls-cardano/cddl-src/Cardano/SCLS/Common.hs b/scls-cardano/cddl-src/Cardano/SCLS/Common.hs index 8af80cfd..fae352af 100644 --- a/scls-cardano/cddl-src/Cardano/SCLS/Common.hs +++ b/scls-cardano/cddl-src/Cardano/SCLS/Common.hs @@ -248,3 +248,27 @@ gov_action_id :: Rule gov_action_id = "gov_action_id" =:= arr ["transaction_id" ==> hash32, "gov_action_index" ==> VUInt `sized` (2 :: Word64)] + +staking_keyhash :: Rule +staking_keyhash = "staking_keyhash" =:= hash28 + +account_id :: Rule +account_id = "account_id" =:= credential + +relay :: Rule +relay = + "relay" + =:= arr + [ 0 + , a (port / VNil) + , a (ipv4 / VNil) + , a (ipv6 / VNil) + ] + / arr [1, a (port / VNil), a dns_name] + / arr [2, a dns_name] + +pool_metadata :: Rule +pool_metadata = + "pool_metadata" + =:= arr + [a url, a VBytes] diff --git a/scls-cardano/cddl-src/Cardano/SCLS/Namespace/EntitiesStakePools.hs b/scls-cardano/cddl-src/Cardano/SCLS/Namespace/EntitiesStakePools.hs new file mode 100644 index 00000000..33924dc6 --- /dev/null +++ b/scls-cardano/cddl-src/Cardano/SCLS/Namespace/EntitiesStakePools.hs @@ -0,0 +1,77 @@ +{-# 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.EntitiesStakePools 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: keyhash + | + | types: + | keyhash: + | seq: + | - id: keyhash_data + | size: 28 + | ``` + |] + $ "record_entry" =:= stake_pool + +stake_pool :: Rule +stake_pool = + "stake_pool" + =:= mp + [ "stake_pool_state" ==> stake_pool_state / VNil + , "retiring_epoch_no" ==> epoch_no / VNil + , "future_stake_pool_params" ==> stake_pool_params / VNil + ] + +stake_pool_state :: Rule +stake_pool_state = + "stake_pool_state" + =:= mp + [ "vrf" ==> vrf_keyhash + , "cost" ==> coin + , "margin" ==> unit_interval + , "owners" ==> set staking_keyhash + , "pledge" ==> coin + , "relays" ==> arr [0 <+ a relay] + , "deposit" ==> coin + , "metadata" ==> pool_metadata / VNil + , "account_id" ==> account_id + , "delegators" ==> set credential + ] + +stake_pool_params :: Rule +stake_pool_params = + "stake_pool_params" + =:= mp + [ "id" ==> pool_keyhash + , "vrf" ==> vrf_keyhash + , "cost" ==> coin + , "margin" ==> unit_interval + , "owners" ==> set staking_keyhash + , "pledge" ==> coin + , "relays" ==> arr [0 <+ a relay] + , "metadata" ==> pool_metadata / VNil + , "account_address" ==> address + ] diff --git a/scls-cardano/scls-cardano.cabal b/scls-cardano/scls-cardano.cabal index 74dd7613..fcb6bdaf 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.EntitiesStakePools Cardano.SCLS.Namespace.GovCommittee Cardano.SCLS.Namespace.GovConstitution Cardano.SCLS.Namespace.GovPParams diff --git a/scls-cardano/test/Reference.hs b/scls-cardano/test/Reference.hs index 65bcaed1..79f070d4 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/stake_pools/v0", "entities_stake_pools_v0.cddl") , ("gov/committee/v0", "gov_committee_v0.cddl") , ("gov/constitution/v0", "gov_constitution_v0.cddl") , ("gov/pparams/v0", "gov_pparams_v0.cddl") diff --git a/scls-cardano/testlib/Cardano/SCLS/Testlib.hs b/scls-cardano/testlib/Cardano/SCLS/Testlib.hs index d22ca020..6af173d5 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/stake_pools/v0" , ConstrNS "gov/committee/v0" , ConstrNS "gov/constitution/v0" , ConstrNS "gov/pparams/v0" @@ -70,6 +71,7 @@ testAllNS = describe "scls/conformance" $ do testNS @"snapshots/mark/v0" testNS @"snapshots/set/v0" testNS @"entities/committee/v0" + testNS @"entities/stake_pools/v0" testNS @"gov/committee/v0" testNS @"gov/constitution/v0" testNS @"gov/pparams/v0"