-
Notifications
You must be signed in to change notification settings - Fork 26
Add 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
Draft
jasagredo
wants to merge
8
commits into
main
Choose a base branch
from
js/cddls
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add CDDLs #1422
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
472ba7a
Add CDDLs
jasagredo b266eb8
Add pull-cddls
jasagredo 958e447
Improve pull-cddls
jasagredo 2b61ab9
Integrate latest ledger
jasagredo 30f9ec0
Remove git submodule
jasagredo 8fe0c61
Make use of cuddle for validation
jasagredo 470d841
Validate also NTN blocks and headers
jasagredo e480dcb
Small tweaks
jasagredo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,3 +100,5 @@ cabal.project.local | |
cabal.project.local~ | ||
.HTF/ | ||
.ghc.environment.* | ||
|
||
ouroboros-consensus-cardano/cddl/out/ |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
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] | ||
withOriginTH<v> = [0] / [1, 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
mkdir -p out | ||
|
||
gen () { | ||
echo -n -e "\t- $1" | ||
mkdir -p out/$(echo $1 | rev | cut -d'/' -f2- | rev) | ||
cddlc -u2tcddl $1.cddl > "out/$1.compiled.cddl" | ||
echo " ok" | ||
} | ||
|
||
CDDL_INCLUDE_PATH="" | ||
for f in $(fd -t d); do | ||
CDDL_INCLUDE_PATH+="$f:" | ||
done | ||
|
||
export CDDL_INCLUDE_PATH=$CDDL_INCLUDE_PATH.: | ||
|
||
IN=$(fd -e cddl \ | ||
-E ledger-cddls \ | ||
-E out \ | ||
-E base.cddl \ | ||
-E node-to-client/localstatequery/shelley \ | ||
-E node-to-client/localstatequery/byron \ | ||
-E node-to-client/localstatequery/consensus \ | ||
-E disk/snapshot | ||
) | ||
|
||
echo "Generating complete CDDLs:" | ||
for f in $IN; do | ||
gen $(echo $f | cut -d'.' -f1) | ||
done | ||
|
||
UNDEFINEDS=$(grep -R undefined out) | ||
|
||
if [ ! -z "$UNDEFINEDS" ]; then | ||
echo -e "\033[0;31mThere were undefined references!\n$UNDEFINEDS\033[0m" | ||
|
||
while IFS= read -r line || [[ -n $line ]]; do | ||
fileName=$(echo $line | cut -d':' -f1) | ||
ref=$(echo $line | cut -d':' -f3 | tr -d ' ') | ||
echo "$ref = any" >> $fileName | ||
done < <(printf '%s' "$UNDEFINEDS") | ||
fi | ||
|
||
echo "Done" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
ledgerStateSnapshot = | ||
[snapshotEncodingVersion1, extLedgerState] | ||
|
||
snapshotEncodingVersion1 = 1 | ||
|
||
extLedgerState = [ledgerState, headerState] | ||
|
||
;# import ledgerstate | ||
;# import headerstate |
23 changes: 23 additions & 0 deletions
23
ouroboros-consensus-cardano/cddl/disk/snapshot/headerstate.cddl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
headerState = | ||
[withOrigin<headerStateTip>, headerStateChainDep] | ||
|
||
headerStateTip = | ||
ns7<byronAnnTip, annTip, annTip, annTip, annTip, annTip, annTip> | ||
|
||
byronAnnTip = [slotno, hash, blockno, bool] | ||
annTip = [slotno, hash, blockno] | ||
|
||
headerStateChainDep = | ||
telescope7<versionedPbftState, | ||
versionedTPraosState, | ||
versionedTPraosState, | ||
versionedTPraosState, | ||
versionedTPraosState, | ||
versionedPraosState, | ||
versionedPraosState> | ||
|
||
versionedPbftState = [serializationFormat1, {* keyhash => [* slotno]}] | ||
|
||
;# import base | ||
;# import praos | ||
;# import tpraos |
27 changes: 27 additions & 0 deletions
27
ouroboros-consensus-cardano/cddl/disk/snapshot/ledgerstate.cddl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
ledgerState = | ||
telescope7<byron.ledgerstate, | ||
versionedShelleyLedgerState<shelley.ledgerstate>, | ||
versionedShelleyLedgerState<allegra.ledgerstate>, | ||
versionedShelleyLedgerState<mary.ledgerstate>, | ||
versionedShelleyLedgerState<alonzo.ledgerstate>, | ||
versionedShelleyLedgerState<babbage.ledgerstate>, | ||
versionedShelleyLedgerState<conway.ledgerstate>> | ||
|
||
versionedShelleyLedgerState<era> = [ shelleyVersion2, shelleyLedgerState<era> ] | ||
|
||
shelleyVersion2 = 2 | ||
|
||
shelleyLedgerState<era> = [ withOrigin<shelleyTip>, era, shelleyTransition ] | ||
|
||
shelleyTip = [slotno, blockno, hash] | ||
|
||
shelleyTransition = word32 | ||
|
||
;# import base | ||
;# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
versionedPraosState = [praosVersion, praosState] | ||
|
||
praosVersion = 0 | ||
|
||
praosState = [withOrigin<slotno>, | ||
{* keyhash => word64}, | ||
nonce, | ||
nonce, | ||
nonce, | ||
nonce, | ||
nonce] | ||
|
||
;# import base |
12 changes: 12 additions & 0 deletions
12
ouroboros-consensus-cardano/cddl/disk/snapshot/tpraos.cddl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
versionedTPraosState = | ||
[serializationFormat1, [withOriginTH<slotno>, tpraosState]] | ||
|
||
tpraosState = [prtclState, ticknState, nonce] | ||
|
||
prtclState = [{* keyhash => word64}, nonce, nonce] | ||
|
||
ticknState = [nonce, nonce] | ||
|
||
serializationFormat1 = 1 | ||
|
||
;# import base |
4 changes: 4 additions & 0 deletions
4
...-consensus-cardano/cddl/node-to-client/localstatequery/byron/getUpdateInterfaceState.cddl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
query = 0 | ||
result = byron.upistate | ||
|
||
;# import byron as byron |
4 changes: 4 additions & 0 deletions
4
...oros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getChainBlockNo.cddl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
query = 2 | ||
result = blockno | ||
|
||
;# import base |
4 changes: 4 additions & 0 deletions
4
ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getChainPoint.cddl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
query = 3 | ||
result = point | ||
|
||
;# import base |
4 changes: 4 additions & 0 deletions
4
ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getCurrentEra.cddl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
query = [1] | ||
result = eraIdx | ||
|
||
;# import base |
4 changes: 4 additions & 0 deletions
4
ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getEraStart.cddl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
query = [0] | ||
result = maybe<bound> | ||
|
||
;# import base |
18 changes: 18 additions & 0 deletions
18
...boros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getInterpreter.cddl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
query = [0] | ||
result = interpreter | ||
|
||
interpreter = [* eraSummary] | ||
eraSummary = [eraStart, eraEnd, eraParams] | ||
eraStart = bound | ||
eraEnd = null / bound | ||
eraParams = [epochSize, slotLength, safeZone, genesisWindow] | ||
epochSize = word64 | ||
slotLength = int ; millisec | ||
safeZone = standardSafeZone / unsafeIndefiniteSafeZone | ||
standardSafeZone = [0, safeFromTip, safeBeforeEpoch] | ||
safeFromTip = word64 | ||
safeBeforeEpoch = [0] | ||
unsafeIndefiniteSafeZone = [1] | ||
genesisWindow = word64 | ||
|
||
;# import base | ||
7 changes: 7 additions & 0 deletions
7
...boros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getSystemStart.cddl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
query = 1 | ||
result = utctime | ||
|
||
utctime = [year, dayOfYear, timeOfDayPico] | ||
year = bigint | ||
dayOfYear = int | ||
timeOfDayPico = bigint |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use qualified or explicit imports? Then it would be more clear which rules come from this library. For example we could have
eraStart = base.bound