-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add NTN CDDLs #1422
Changes from all commits
bb3c80c
d87a97e
5f6c76c
f588b29
bdeaba0
7e607f1
b93400c
0bba5c7
f9b52c0
35b793a
b688772
8401653
aa14ec0
ebfc6c2
9fa0532
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
source 'https://rubygems.org' | ||
gem 'cddlc' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
cddlc (0.4.2) | ||
neatjson (~> 0.10) | ||
treetop (~> 1) | ||
neatjson (0.10.5) | ||
polyglot (0.3.5) | ||
treetop (1.6.14) | ||
polyglot (~> 0.3) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
cddlc | ||
|
||
BUNDLED WITH | ||
2.6.2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
cddlc = { | ||
dependencies = [ | ||
"neatjson" | ||
"treetop" | ||
]; | ||
groups = [ "default" ]; | ||
platforms = [ ]; | ||
source = { | ||
remotes = [ "https://rubygems.org" ]; | ||
sha256 = "1s3fbgd5yqgji162zsmlwnva1v1r3zc1qiyv6im7karv5f08r8m3"; | ||
type = "gem"; | ||
}; | ||
version = "0.4.2"; | ||
}; | ||
neatjson = { | ||
groups = [ "default" ]; | ||
platforms = [ ]; | ||
source = { | ||
remotes = [ "https://rubygems.org" ]; | ||
sha256 = "0wm1lq8yl6rzysh3wg6fa55w5534k6ppiz0qb7jyvdy582mk5i0s"; | ||
type = "gem"; | ||
}; | ||
version = "0.10.5"; | ||
}; | ||
polyglot = { | ||
groups = [ "default" ]; | ||
platforms = [ ]; | ||
source = { | ||
remotes = [ "https://rubygems.org" ]; | ||
sha256 = "1bqnxwyip623d8pr29rg6m8r0hdg08fpr2yb74f46rn1wgsnxmjr"; | ||
type = "gem"; | ||
}; | ||
version = "0.3.5"; | ||
}; | ||
treetop = { | ||
dependencies = [ "polyglot" ]; | ||
groups = [ "default" ]; | ||
platforms = [ ]; | ||
source = { | ||
remotes = [ "https://rubygems.org" ]; | ||
sha256 = "1m5fqy7vq6y7bgxmw7jmk7y6pla83m16p7lb41lbqgg53j8x2cds"; | ||
type = "gem"; | ||
}; | ||
version = "1.6.14"; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ lib | ||
, bundlerApp | ||
, bundlerUpdateScript | ||
}: | ||
|
||
bundlerApp { | ||
pname = "cddlc"; | ||
|
||
gemdir = ./.; | ||
|
||
exes = [ "cddlc" ]; | ||
|
||
passthru.updateScript = bundlerUpdateScript "cddlc"; | ||
|
||
meta = { | ||
description = "CDDL conversion utilities"; | ||
homepage = "https://github.com/cabo/cddlc"; | ||
license = lib.licenses.mit; | ||
maintainers = with lib.maintainers; [ amesgen ]; | ||
platforms = lib.platforms.unix; | ||
mainProgram = "cddlc"; | ||
}; | ||
} |
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I don't think so. Eventually these files will go to the blueprint so there is no need there for a Haskell link.
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,23 @@ | ||
tx = | ||
base.ns7<byron.transaction, | ||
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 | ||
|
||
; See https://github.com/IntersectMBO/cardano-ledger/issues/5124 | ||
byron.transaction = [0, [byron.tx, [+ byron.twit]]] / [1, any] / [2, any] / [3, any] | ||
|
||
;# 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 |
Uh oh!
There was an error while loading. Please reload this page.