Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
8 changes: 4 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions scls-cardano/cddl-src/Cardano/SCLS/CDDL.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Cardano.SCLS.Namespace.GovCommittee qualified as GovCommittee
import Cardano.SCLS.Namespace.GovConstitution qualified as GovConstitution
import Cardano.SCLS.Namespace.GovPParams qualified as GovPParams
import Cardano.SCLS.Namespace.GovProposals qualified as GovProposals
import Cardano.SCLS.Namespace.GovProposalsRoots qualified as GovProposalsRoots
import Cardano.SCLS.Namespace.Nonces qualified as Nonces
import Cardano.SCLS.Namespace.Snapshots qualified as Snapshots
import Cardano.SCLS.Namespace.UTxO qualified as UTxO
Expand Down Expand Up @@ -67,6 +68,9 @@ instance KnownSpec "gov/pparams/v0" where
instance KnownSpec "gov/proposals/v0" where
namespaceSpec _ = mkDefinition GovProposals.record_entry

instance KnownSpec "gov/proposals/roots/v0" where
namespaceSpec _ = mkDefinition GovProposalsRoots.record_entry

mkDefinition :: Rule -> Huddle
mkDefinition r = collectFromInit [HIRule r]

Expand All @@ -87,6 +91,7 @@ knownNamespaces =
, mkNamespaceSymbol @"gov/constitution/v0"
, mkNamespaceSymbol @"gov/pparams/v0"
, mkNamespaceSymbol @"gov/proposals/v0"
, mkNamespaceSymbol @"gov/proposals/roots/v0"
]

type instance Spec.NamespaceKeySize "utxo/v0" = 34
Expand All @@ -100,3 +105,4 @@ type instance Spec.NamespaceKeySize "gov/committee/v0" = 8
type instance Spec.NamespaceKeySize "gov/constitution/v0" = 8
type instance Spec.NamespaceKeySize "gov/pparams/v0" = 4
type instance Spec.NamespaceKeySize "gov/proposals/v0" = 34 -- 32 bytes txid+tx index + 2 bytes for proposal index
Comment thread
joaosreis marked this conversation as resolved.
type instance Spec.NamespaceKeySize "gov/proposals/roots/v0" = 1 -- 1 byte for proposal purpose
5 changes: 5 additions & 0 deletions scls-cardano/cddl-src/Cardano/SCLS/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,8 @@ protocol_version = "protocol_version" =:= arr [a major_protocol_version, a VUInt

major_protocol_version :: Rule
major_protocol_version = "major_protocol_version" =:= VUInt

gov_action_id :: Rule
gov_action_id =
"gov_action_id"
=:= arr ["transaction_id" ==> hash32, "gov_action_index" ==> VUInt `sized` (2 :: Word64)]
5 changes: 0 additions & 5 deletions scls-cardano/cddl-src/Cardano/SCLS/Namespace/GovProposals.hs
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,6 @@ gov_action =
/ (arr [5, "purpose" ==> (gov_action_id / VNil), "constitution" ==> constitution] //- "New constitution")
/ (arr [6] //- "Info action")

gov_action_id :: Rule
gov_action_id =
"gov_action_id"
=:= arr ["transaction_id" ==> hash32, "gov_action_index" ==> VUInt `sized` (2 :: Word64)]

gov_params_update :: Rule
gov_params_update =
comment
Expand Down
40 changes: 40 additions & 0 deletions scls-cardano/cddl-src/Cardano/SCLS/Namespace/GovProposalsRoots.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{-# 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.GovProposalsRoots where

import Cardano.SCLS.Common
import Codec.CBOR.Cuddle.Huddle
import Data.Function (($))
import Text.Heredoc (str)

record_entry :: Rule
record_entry =
comment
[str| Size of the key
|
| ```
| meta:
| endian: be
|
| seq:
| - id: key
| type: u1
| enum: gov_proposals_purpose
|
| enums:
| gov_proposals_purpose:
| 0: pparams_update
Comment thread
joaosreis marked this conversation as resolved.
| 1: hard_fork
| 2: committee
| 3: constitution
| ```
|
|]
$ "record_entry" =:= gov_action_id
1 change: 1 addition & 0 deletions scls-cardano/scls-cardano.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ library
Cardano.SCLS.Namespace.GovConstitution
Cardano.SCLS.Namespace.GovPParams
Cardano.SCLS.Namespace.GovProposals
Cardano.SCLS.Namespace.GovProposalsRoots
Cardano.SCLS.Namespace.Nonces
Cardano.SCLS.Namespace.Snapshots
Cardano.SCLS.Namespace.UTxO
Expand Down
1 change: 1 addition & 0 deletions scls-cardano/test/Reference.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ allReferenceCDDLs =
, ("gov/constitution/v0", "gov_constitution_v0.cddl")
, ("gov/pparams/v0", "gov_pparams_v0.cddl")
, ("gov/proposals/v0", "gov_proposals_v0.cddl")
, ("gov/proposals/roots/v0", "gov_proposals_roots_v0.cddl")
]

loadAllReferenceCDDLs :: IO (Maybe ([(Text, Either LoadError (CTreeRoot MonoReferenced))]))
Expand Down
2 changes: 2 additions & 0 deletions scls-cardano/testlib/Cardano/SCLS/Testlib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ testAllNS ::
, ConstrNS "gov/constitution/v0"
, ConstrNS "gov/pparams/v0"
, ConstrNS "gov/proposals/v0"
, ConstrNS "gov/proposals/roots/v0"
) =>
Spec
testAllNS = describe "scls/conformance" $ do
Expand All @@ -73,6 +74,7 @@ testAllNS = describe "scls/conformance" $ do
testNS @"gov/constitution/v0"
testNS @"gov/pparams/v0"
testNS @"gov/proposals/v0"
testNS @"gov/proposals/roots/v0"

-- | Validate concrete type against its definition in CDDL
validateType :: forall ns a. (KnownSymbol ns, ToCanonicalCBOR ns a, Arbitrary a, Show a, Typeable a) => T.Text -> Spec
Expand Down
Loading