diff --git a/.github/workflows/haskell-ci.yml b/.github/workflows/haskell-ci.yml index 4052ac74..b25be2c9 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: 5a4f49835b01695583830e01e2dfd11e9e582efc + ref: c92a3b5db78268e7f0db5f24c80ed6f49cf4b149 path: cips - name: set env for reference CDDL run: | diff --git a/flake.lock b/flake.lock index bd5fde29..06ea2a99 100644 --- a/flake.lock +++ b/flake.lock @@ -69,17 +69,17 @@ "cips": { "flake": false, "locked": { - "lastModified": 1774517331, - "narHash": "sha256-Iu6jgcoa/WZcruKaym/3Y5/1awx53eKgvI0l6/+fMIQ=", + "lastModified": 1776254122, + "narHash": "sha256-MmXsGDMGnZayYZEt40Y5a54Pis31plBQt2/hbdUTaos=", "owner": "tweag", "repo": "CIPs", - "rev": "5a4f49835b01695583830e01e2dfd11e9e582efc", + "rev": "c92a3b5db78268e7f0db5f24c80ed6f49cf4b149", "type": "github" }, "original": { "owner": "tweag", "repo": "CIPs", - "rev": "5a4f49835b01695583830e01e2dfd11e9e582efc", + "rev": "c92a3b5db78268e7f0db5f24c80ed6f49cf4b149", "type": "github" } }, diff --git a/flake.nix b/flake.nix index 59874068..ab2381f8 100644 --- a/flake.nix +++ b/flake.nix @@ -18,7 +18,7 @@ inputs.nixpkgs.follows = "nixpkgs"; }; inputs.cips = { - url = "github:tweag/CIPs?rev=5a4f49835b01695583830e01e2dfd11e9e582efc"; + url = "github:tweag/CIPs?rev=c92a3b5db78268e7f0db5f24c80ed6f49cf4b149"; 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 d8ccbcc3..26348362 100644 --- a/scls-cardano/cddl-src/Cardano/SCLS/CDDL.hs +++ b/scls-cardano/cddl-src/Cardano/SCLS/CDDL.hs @@ -9,6 +9,7 @@ module Cardano.SCLS.CDDL ( ) where import Cardano.SCLS.Namespace.Blocks qualified as Blocks +import Cardano.SCLS.Namespace.EntitiesAccounts qualified as EntitiesAccounts import Cardano.SCLS.Namespace.EntitiesCommittee qualified as EntitiesCommittee import Cardano.SCLS.Namespace.GovCommittee qualified as GovCommittee import Cardano.SCLS.Namespace.GovConstitution qualified as GovConstitution @@ -52,6 +53,9 @@ instance KnownSpec "snapshots/go/v0" where instance KnownSpec "nonces/v0" where namespaceSpec _ = mkDefinition Nonces.record_entry +instance KnownSpec "entities/accounts/v0" where + namespaceSpec _ = mkDefinition EntitiesAccounts.record_entry + instance KnownSpec "entities/committee/v0" where namespaceSpec _ = mkDefinition EntitiesCommittee.record_entry @@ -82,6 +86,7 @@ knownNamespaces = , mkNamespaceSymbol @"snapshots/set/v0" , mkNamespaceSymbol @"snapshots/go/v0" , mkNamespaceSymbol @"nonces/v0" + , mkNamespaceSymbol @"entities/accounts/v0" , mkNamespaceSymbol @"entities/committee/v0" , mkNamespaceSymbol @"gov/committee/v0" , mkNamespaceSymbol @"gov/constitution/v0" @@ -95,6 +100,7 @@ type instance Spec.NamespaceKeySize "nonces/v0" = 1 -- Just zero type instance Spec.NamespaceKeySize "snapshots/mark/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/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/accounts/v0" = 29 -- 1 byte for tag, 28 bytes for hash type instance Spec.NamespaceKeySize "entities/committee/v0" = 8 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/EntitiesAccounts.hs b/scls-cardano/cddl-src/Cardano/SCLS/Namespace/EntitiesAccounts.hs new file mode 100644 index 00000000..866a950d --- /dev/null +++ b/scls-cardano/cddl-src/Cardano/SCLS/Namespace/EntitiesAccounts.hs @@ -0,0 +1,63 @@ +{-# 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.EntitiesAccounts 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" =:= account_state + +account_state :: Rule +account_state = + "account_state" + =:= mp + [ "balance" ==> coin + , "deposit" ==> coin + , "drep_delegation" ==> drep / VNil + , "stake_pool_delegation" ==> pool_keyhash / VNil + ] + +drep :: Rule +drep = + comment + [str| 0 - key hash + | 1 - script hash + | 2 - always abstain + | 3 - always no confidence + |] + $ "drep" + =:= arr [0, a keyhash28] + / arr [1, a script_hash] + / arr [2] + / arr [3] diff --git a/scls-cardano/scls-cardano.cabal b/scls-cardano/scls-cardano.cabal index a997368a..4e66e6d4 100644 --- a/scls-cardano/scls-cardano.cabal +++ b/scls-cardano/scls-cardano.cabal @@ -31,6 +31,7 @@ library other-modules: Cardano.SCLS.Common Cardano.SCLS.Namespace.Blocks + Cardano.SCLS.Namespace.EntitiesAccounts Cardano.SCLS.Namespace.EntitiesCommittee Cardano.SCLS.Namespace.GovCommittee Cardano.SCLS.Namespace.GovConstitution diff --git a/scls-cardano/test/Reference.hs b/scls-cardano/test/Reference.hs index 8822c48c..dd1b4d73 100644 --- a/scls-cardano/test/Reference.hs +++ b/scls-cardano/test/Reference.hs @@ -69,6 +69,7 @@ allReferenceCDDLs = , ("snapshots/set/v0", "snapshots_set_v0.cddl") , ("snapshots/go/v0", "snapshots_go_v0.cddl") , ("nonces/v0", "nonces_v0.cddl") + , ("entities/accounts/v0", "entities_accounts_v0.cddl") , ("entities/committee/v0", "entities_committee_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 42217e0a..401f856a 100644 --- a/scls-cardano/testlib/Cardano/SCLS/Testlib.hs +++ b/scls-cardano/testlib/Cardano/SCLS/Testlib.hs @@ -55,6 +55,7 @@ testAllNS :: , ConstrNS "snapshots/go/v0" , ConstrNS "snapshots/mark/v0" , ConstrNS "snapshots/set/v0" + , ConstrNS "entities/accounts/v0" , ConstrNS "entities/committee/v0" , ConstrNS "gov/committee/v0" , ConstrNS "gov/constitution/v0" @@ -68,6 +69,7 @@ testAllNS = describe "scls/conformance" $ do testNS @"snapshots/go/v0" testNS @"snapshots/mark/v0" testNS @"snapshots/set/v0" + testNS @"entities/accounts/v0" testNS @"entities/committee/v0" testNS @"gov/committee/v0" testNS @"gov/constitution/v0"