Skip to content
Draft
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 @@ -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
Expand Down Expand Up @@ -55,6 +56,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

Expand Down Expand Up @@ -83,6 +87,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"
Expand All @@ -96,6 +101,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
Expand Down
24 changes: 24 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,27 @@ protocol_version = "protocol_version" =:= arr [a major_protocol_version, a VUInt

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

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]
56 changes: 56 additions & 0 deletions scls-cardano/cddl-src/Cardano/SCLS/Namespace/EntitiesStakePools.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{-# 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: keyhash_stakepool
| doc: keyhash of the stake pool
| 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
]

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
]
1 change: 1 addition & 0 deletions scls-cardano/scls-cardano.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -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")
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 @@ -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"
Expand All @@ -69,6 +70,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"
Expand Down
Loading