Skip to content

Add NTN CDDLs #1422

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: js/delete-deprecate-query
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Check CDDLs up-to-date with Blueprints
continue-on-error: true
run: |
./scripts/ci/diff-cddls.sh

- name: Install base libraries
uses: input-output-hk/actions/base@latest
with:
Expand Down Expand Up @@ -138,6 +143,13 @@ jobs:
- name: Build projects [build]
run: cabal build all -j

- name: Install cddl tools
run: |
export GEM_HOME="$HOME/.gem"
gem install cddlc
echo "PATH=$HOME/.gem/bin:$PATH" >> $GITHUB_ENV
cabal install cuddle-0.5.0.0

- name: Test
if: matrix.test-set == 'all'
run: cabal test all -j --test-show-details=streaming
Expand Down
8 changes: 4 additions & 4 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ repository cardano-haskell-packages
-- update either of these.
index-state:
-- Bump this if you need newer packages from Hackage
, hackage.haskell.org 2025-05-26T13:28:18Z
, hackage.haskell.org 2025-06-03T21:29:34Z
-- Bump this if you need newer packages from CHaP
, cardano-haskell-packages 2025-05-26T19:51:53Z
, cardano-haskell-packages 2025-06-03T13:42:38Z

packages:
ouroboros-consensus
Expand Down Expand Up @@ -68,8 +68,8 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-ledger
tag: acef8ca86b741455309753b1f02a5f339eb545b4
--sha256: sha256-Tahrli+IOzrC0JiXYPE/XXFCWToyBzbAlgDaxlaokGE=
tag: b44ce911475794a15f908ad27a6f497d6a27e8ba
--sha256: sha256-MXaVKKH9siUsmOnJmYyL6if48dx11zugux7AWGPABfA=
subdir:
eras/allegra/impl
eras/alonzo/impl
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

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

1 change: 1 addition & 0 deletions nix/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ hsPkgs.shellFor {
pkgs.ghcid
pkgs.xrefcheck
pkgs.fourmolu
pkgs.cuddle

# release management
(pkgs.scriv.overridePythonAttrs (_oldAttrs: {
Expand Down
9 changes: 9 additions & 0 deletions nix/tools.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ in

fourmolu = tool "fourmolu" "0.18.0.0" { };

cuddle = tool "cuddle" "git" {
src = final.fetchFromGitHub {
owner = "input-output-hk";
repo = "cuddle";
rev = "cuddle-0.5.0.0";
hash = "sha256-06a9N1IAh0kKW/xPu1qiLK22HpXyARnipA1YJxY4jOQ=";
};
};

haskellBuildUtils = prev.haskellBuildUtils.override {
inherit (final.hsPkgs.args) compiler-nix-name;
index-state = tool-index-state;
Expand Down
52 changes: 52 additions & 0 deletions ouroboros-consensus-cardano/cddl/base.cddl
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
telescope7<byron, shelley, allegra, mary, alonzo, babbage, conway>
= [pastEra, pastEra, pastEra, pastEra, pastEra, pastEra, currentEra<conway>] /
[pastEra, pastEra, pastEra, pastEra, pastEra, currentEra<babbage>] /
[pastEra, pastEra, pastEra, pastEra, currentEra<alonzo>] /
[pastEra, pastEra, pastEra, currentEra<mary>] /
[pastEra, pastEra, currentEra<allegra>] /
[pastEra, currentEra<shelley>] /
[currentEra<byron>]

ns7<byron, shelley, allegra, mary, alonzo, babbage, conway>
= [6, conway] /
[5, babbage] /
[4, alonzo] /
[3, mary] /
[2, allegra] /
[1, shelley] /
[0, byron]

;; Blockchain types
pastEra = [bound, bound]
currentEra<st> = [bound, st]
bound = [relativeTime, slotno, epochno]
eraIdx = word8
individualPoolStake = [stake, hash]
nonce = [0] / [1, hash]
point = [] / [ slotno, hash ]
poolDistr = map<keyhash, individualPoolStake>
slotno = word64
stake = rational

withOrigin<v> = [] / [v]

;; Collections
either<x, y> = [0, x] / [1, y]
map<x, y> = { * x => y }
maybe<x> = [] / [x]
seq<x> = [*23 x] / [24* x] ; encoded with indefinite-length encoding
set<x> = #6.258([* x])

;; Types from other packages
blockno = word64
epochno = word64
coin = word64
rational = [int, int]
keyhash = bstr .size 28
hash = bstr .size 32
relativeTime = int

;; Base word types
word8 = uint .size 1
word32 = uint .size 4
word64 = uint .size 8
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
serialisedCardanoBlock = #6.24(bytes .cbor cardanoBlock)

cardanoBlock = byron.block
/ [2, shelley.block]
/ [3, allegra.block]
/ [4, mary.block]
/ [5, alonzo.block]
/ [6, babbage.block]
/ [7, conway.block]

;# import byron as byron
;# import shelley as shelley
;# import allegra as allegra
;# import mary as mary
;# import alonzo as alonzo
;# import babbage as babbage
;# import conway as conway
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
header
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This a comment that applies to each file: do we want to state where the corresponding Haskell data definition lives? And conversely, when defining a CBOR instance, would it make sense to define where the CDDL a CBOR instance conforms to is located?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to state where the corresponding Haskell data definition lives?

I don't think so. Eventually these files will go to the blueprint so there is no need there for a Haskell link.

And conversely, when defining a CBOR instance, would it make sense to define where the CDDL a CBOR instance conforms to is located?

Perhaps?

= base.ns7<byronHeader,
serialisedShelleyHeader<shelley.header>,
serialisedShelleyHeader<allegra.header>,
serialisedShelleyHeader<mary.header>,
serialisedShelleyHeader<alonzo.header>,
serialisedShelleyHeader<babbage.header>,
serialisedShelleyHeader<conway.header>>

byronHeader = [byronRegularIdx, #6.24(bytes .cbor byron.blockhead)]
/ [byronBoundaryIdx, #6.24(bytes .cbor byron.ebbhead)]

byronBoundaryIdx = [0, base.word32]
byronRegularIdx = [1, base.word32]

serialisedShelleyHeader<era> = #6.24(bytes .cbor era)

;# include byron as byron
;# include shelley as shelley
;# include allegra as allegra
;# include mary as mary
;# include alonzo as alonzo
;# include babbage as babbage
;# include conway as conway
;# import base as base
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
tx =
base.ns7<byron.tx,
serialisedShelleyTx<shelley.transaction>,
serialisedShelleyTx<allegra.transaction>,
serialisedShelleyTx<mary.transaction>,
serialisedShelleyTx<alonzo.transaction>,
serialisedShelleyTx<babbage.transaction>,
serialisedShelleyTx<conway.transaction>>

serialisedShelleyTx<era> = #6.24(bytes .cbor era)

;# include byron as byron
;# include shelley as shelley
;# include allegra as allegra
;# include mary as mary
;# include alonzo as alonzo
;# include babbage as babbage
;# include conway as conway
;# import base as base
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
txId =
base.ns7<byronTxId,
shelley.transaction_id,
allegra.transaction_id,
mary.transaction_id,
alonzo.transaction_id,
conway.transaction_id,
babbage.transaction_id>

byronTxId = [0, byron.txid]
/ [1, byron.certificateid]
/ [2, byron.updid]
/ [3, byron.voteid]

;# include byron as byron
;# include shelley as shelley
;# include allegra as allegra
;# include mary as mary
;# include alonzo as alonzo
;# include babbage as babbage
;# include conway as conway
;# import base as base
15 changes: 14 additions & 1 deletion ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ extra-doc-files:
CHANGELOG.md
README.md

data-files:
cddl/**/*.cddl

source-repository head
type: git
location: https://github.com/IntersectMBO/ouroboros-consensus
Expand Down Expand Up @@ -435,6 +438,7 @@ test-suite cardano-test
main-is: Main.hs
other-modules:
Test.Consensus.Cardano.DiffusionPipelining
Test.Consensus.Cardano.GenCDDLs
Test.Consensus.Cardano.Golden
Test.Consensus.Cardano.MiniProtocol.LocalTxSubmission.ByteStringTxParser
Test.Consensus.Cardano.MiniProtocol.LocalTxSubmission.Server
Expand All @@ -448,27 +452,34 @@ test-suite cardano-test
Test.ThreadNet.MaryAlonzo
Test.ThreadNet.ShelleyAllegra

other-modules: Paths_ouroboros_consensus_cardano
build-depends:
QuickCheck,
base,
base16-bytestring,
bytestring,
cardano-ledger-allegra:testlib,
cardano-ledger-alonzo,
cardano-ledger-alonzo:testlib,
cardano-ledger-alonzo-test,
cardano-ledger-api,
cardano-ledger-babbage:testlib,
cardano-ledger-babbage-test,
cardano-ledger-binary:testlib,
cardano-ledger-byron,
cardano-ledger-byron:{cardano-ledger-byron, testlib},
cardano-ledger-conway:testlib,
cardano-ledger-core:{cardano-ledger-core, testlib},
cardano-ledger-mary:testlib,
cardano-ledger-shelley,
cardano-ledger-shelley:testlib,
cardano-ledger-shelley-test,
cardano-protocol-tpraos,
cardano-slotting,
cborg,
constraints,
containers,
contra-tracer,
directory,
filepath,
microlens,
ouroboros-consensus:{ouroboros-consensus, unstable-consensus-testlib, unstable-mempool-test-utils},
Expand All @@ -478,12 +489,14 @@ test-suite cardano-test
ouroboros-network-api,
ouroboros-network-protocols:{ouroboros-network-protocols, testlib},
pretty-simple,
process-extras,
sop-core,
sop-extras,
strict-sop-core,
tasty,
tasty-hunit,
tasty-quickcheck,
temporary,
typed-protocols ^>=0.3,
unstable-byron-testlib,
unstable-cardano-testlib,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ applyAlonzoBasedTx globals ledgerEnv mempoolState wti tx = do
pure (mempoolState', vtx)
where
intervenedTx = case wti of
DoNotIntervene -> tx{Alonzo.isValid = Alonzo.IsValid True}
DoNotIntervene -> tx{Alonzo.atIsValid = Alonzo.IsValid True}
Intervene -> tx

handler e = case (wti, e) of
Expand All @@ -289,7 +289,7 @@ applyAlonzoBasedTx globals ledgerEnv mempoolState wti tx = do
ledgerEnv
mempoolState
wti
tx{Alonzo.isValid = Alonzo.IsValid False}
tx{Alonzo.atIsValid = Alonzo.IsValid False}
_ -> throwError e

-- reject the transaction, protecting the local wallet
Expand Down
Loading
Loading