diff --git a/.gitignore b/.gitignore index 5c88fe9214..6aa2a67b0a 100644 --- a/.gitignore +++ b/.gitignore @@ -100,3 +100,5 @@ cabal.project.local cabal.project.local~ .HTF/ .ghc.environment.* + +ouroboros-consensus-cardano/cddl/out/ \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..6bddba2884 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "cardano-blueprint"] + path = cardano-blueprint + url = git@github.com:cardano-scaling/cardano-blueprint.git diff --git a/cabal.project b/cabal.project index da2ec2c4e6..f6ad9bb9bf 100644 --- a/cabal.project +++ b/cabal.project @@ -57,3 +57,42 @@ if impl (ghc >= 9.12) -- https://github.com/kapralVV/Unique/issues/11 , Unique:hashable + +source-repository-package + type: git + location: https://github.com/IntersectMBO/cardano-ledger + tag: d48965e0dc1a324f432f1ee01bc0cf2d60a8a702 + --sha256: sha256-UFIQ1qinge1TMtqU2e0Nyjdpj42yj+lLKrpnXeqo1mI= + subdir: + eras/allegra/impl + eras/alonzo/impl + eras/alonzo/test-suite + eras/babbage/impl + eras/babbage/test-suite + eras/conway/impl + eras/conway/test-suite + eras/mary/impl + eras/shelley/impl + eras/shelley/test-suite + eras/shelley-ma/test-suite + libs/cardano-ledger-api + libs/cardano-ledger-core + libs/cardano-ledger-binary + libs/cardano-protocol-tpraos + libs/non-integral + libs/small-steps + libs/cardano-data + libs/set-algebra + libs/vector-map + eras/byron/chain/executable-spec + eras/byron/ledger/executable-spec + eras/byron/ledger/impl + eras/byron/crypto + +allow-newer: + ouroboros-consensus:cardano-ledger-core, + ouroboros-consensus-cardano:cardano-ledger-byron, + ouroboros-consensus-cardano:cardano-ledger-conway, + ouroboros-consensus-cardano:cardano-ledger-core, + ouroboros-consensus-cardano:cardano-ledger-shelley, + ouroboros-consensus-protocol:cardano-ledger-core, diff --git a/cardano-blueprint b/cardano-blueprint new file mode 160000 index 0000000000..9a60194619 --- /dev/null +++ b/cardano-blueprint @@ -0,0 +1 @@ +Subproject commit 9a601946194507de2876f4d7775f656ee7dd1543 diff --git a/nix/shell.nix b/nix/shell.nix index 01550952ff..09260a9eb3 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -17,6 +17,9 @@ hsPkgs.shellFor { pkgs.ghcid pkgs.xrefcheck + # testing cddls + pkgs.cddl + # release management pkgs.scriv (pkgs.python3.withPackages (p: [ p.beautifulsoup4 p.html5lib p.matplotlib p.pandas ])) diff --git a/ouroboros-consensus-cardano/cddl/base.cddl b/ouroboros-consensus-cardano/cddl/base.cddl new file mode 100644 index 0000000000..1b664542b3 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/base.cddl @@ -0,0 +1,53 @@ +telescope7 + = [pastEra, pastEra, pastEra, pastEra, pastEra, pastEra, currentEra] / + [pastEra, pastEra, pastEra, pastEra, pastEra, currentEra] / + [pastEra, pastEra, pastEra, pastEra, currentEra] / + [pastEra, pastEra, pastEra, currentEra] / + [pastEra, pastEra, currentEra] / + [pastEra, currentEra] / + [currentEra] + +ns7 + = [6, conway] / + [5, babbage] / + [4, alonzo] / + [3, mary] / + [2, allegra] / + [1, shelley] / + [0, byron] + +;; Blockchain types +pastEra = [bound, bound] +currentEra = [bound, st] +bound = [relativeTime, slotno, epochno] +eraIdx = word8 +individualPoolStake = [stake, hash] +nonce = [0] / [1, hash] +point = [] / [ slotno, hash ] +poolDistr = map +slotno = word64 +stake = rational + +withOrigin = [] / [v] +withOriginTH = [0] / [1, v] + +;; Collections +either = [0, x] / [1, y] +map = { * x => y } +maybe = [] / [x] +seq = [*23 x] / [24* x] ; encoded with indefinite-length encoding +set = #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 = unit .size 4 +word64 = unit .size 8 diff --git a/ouroboros-consensus-cardano/cddl/cddlc.sh b/ouroboros-consensus-cardano/cddl/cddlc.sh new file mode 100644 index 0000000000..8a881359b0 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/cddlc.sh @@ -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" diff --git a/ouroboros-consensus-cardano/cddl/disk/block.cddl b/ouroboros-consensus-cardano/cddl/disk/block.cddl new file mode 100644 index 0000000000..68a0f3ad46 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/disk/block.cddl @@ -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 diff --git a/ouroboros-consensus-cardano/cddl/disk/snapshot.cddl b/ouroboros-consensus-cardano/cddl/disk/snapshot.cddl new file mode 100644 index 0000000000..25c790d729 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/disk/snapshot.cddl @@ -0,0 +1,9 @@ +ledgerStateSnapshot = + [snapshotEncodingVersion1, extLedgerState] + +snapshotEncodingVersion1 = 1 + +extLedgerState = [ledgerState, headerState] + +;# import ledgerstate +;# import headerstate diff --git a/ouroboros-consensus-cardano/cddl/disk/snapshot/headerstate.cddl b/ouroboros-consensus-cardano/cddl/disk/snapshot/headerstate.cddl new file mode 100644 index 0000000000..0687f6a584 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/disk/snapshot/headerstate.cddl @@ -0,0 +1,23 @@ +headerState = + [withOrigin, headerStateChainDep] + +headerStateTip = + ns7 + +byronAnnTip = [slotno, hash, blockno, bool] +annTip = [slotno, hash, blockno] + +headerStateChainDep = + telescope7 + +versionedPbftState = [serializationFormat1, {* keyhash => [* slotno]}] + +;# import base +;# import praos +;# import tpraos diff --git a/ouroboros-consensus-cardano/cddl/disk/snapshot/ledgerstate.cddl b/ouroboros-consensus-cardano/cddl/disk/snapshot/ledgerstate.cddl new file mode 100644 index 0000000000..579a559dc1 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/disk/snapshot/ledgerstate.cddl @@ -0,0 +1,27 @@ +ledgerState = + telescope7, + versionedShelleyLedgerState, + versionedShelleyLedgerState, + versionedShelleyLedgerState, + versionedShelleyLedgerState, + versionedShelleyLedgerState> + +versionedShelleyLedgerState = [ shelleyVersion2, shelleyLedgerState ] + +shelleyVersion2 = 2 + +shelleyLedgerState = [ withOrigin, 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 diff --git a/ouroboros-consensus-cardano/cddl/disk/snapshot/praos.cddl b/ouroboros-consensus-cardano/cddl/disk/snapshot/praos.cddl new file mode 100644 index 0000000000..bddb7ad511 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/disk/snapshot/praos.cddl @@ -0,0 +1,13 @@ +versionedPraosState = [praosVersion, praosState] + +praosVersion = 0 + +praosState = [withOrigin, + {* keyhash => word64}, + nonce, + nonce, + nonce, + nonce, + nonce] + +;# import base diff --git a/ouroboros-consensus-cardano/cddl/disk/snapshot/tpraos.cddl b/ouroboros-consensus-cardano/cddl/disk/snapshot/tpraos.cddl new file mode 100644 index 0000000000..aa5cf974f9 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/disk/snapshot/tpraos.cddl @@ -0,0 +1,12 @@ +versionedTPraosState = + [serializationFormat1, [withOriginTH, tpraosState]] + +tpraosState = [prtclState, ticknState, nonce] + +prtclState = [{* keyhash => word64}, nonce, nonce] + +ticknState = [nonce, nonce] + +serializationFormat1 = 1 + +;# import base diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/byron/getUpdateInterfaceState.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/byron/getUpdateInterfaceState.cddl new file mode 100644 index 0000000000..ff28220a22 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/byron/getUpdateInterfaceState.cddl @@ -0,0 +1,4 @@ +query = 0 +result = byron.upistate + +;# import byron as byron diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getChainBlockNo.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getChainBlockNo.cddl new file mode 100644 index 0000000000..e0e6189b68 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getChainBlockNo.cddl @@ -0,0 +1,4 @@ +query = 2 +result = blockno + +;# import base diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getChainPoint.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getChainPoint.cddl new file mode 100644 index 0000000000..677ad90a2a --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getChainPoint.cddl @@ -0,0 +1,4 @@ +query = 3 +result = point + +;# import base diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getCurrentEra.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getCurrentEra.cddl new file mode 100644 index 0000000000..2527ad859a --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getCurrentEra.cddl @@ -0,0 +1,4 @@ +query = [1] +result = eraIdx + +;# import base diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getEraStart.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getEraStart.cddl new file mode 100644 index 0000000000..bb9a605d33 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getEraStart.cddl @@ -0,0 +1,4 @@ +query = [0] +result = maybe + +;# import base diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getInterpreter.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getInterpreter.cddl new file mode 100644 index 0000000000..1cb948d2a0 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getInterpreter.cddl @@ -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 diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getSystemStart.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getSystemStart.cddl new file mode 100644 index 0000000000..8b5b621d0b --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/consensus/getSystemStart.cddl @@ -0,0 +1,7 @@ +query = 1 +result = utctime + +utctime = [year, dayOfYear, timeOfDayPico] +year = bigint +dayOfYear = int +timeOfDayPico = bigint diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/query.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/query.cddl new file mode 100644 index 0000000000..691f1da79a --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/query.cddl @@ -0,0 +1,105 @@ +query = [0, blockQuery] + / [getSystemStart.query] + / [getChainBlockNo.query] + / [getChainPoint.query] + +blockQuery = queryIfCurrent + / queryAnyTime + / queryHardFork + +queryAnyTime = [1, getEraStart.query, eraIdx] + +queryHardFork = [2, getInterpreter.query / getCurrentEra.query] + +queryIfCurrent = + [0, ns7 + ] + +byronQuery = getUpdateInterfaceState.query + +shelleyQuery = getLedgerTip.query + / getEpochNo.query + / getNonMyopicMemberRewards.query + / getCurrentPParams.query + / getProposedPParamsUpdates.query + / getStakeDistribution.query + / getUTxOByAddress.query + / getUTxOWhole.query + / debugEpochState.query + / getCBOR.query + / getFilteredDelegationsAndRewardAccounts.query + / getGenesisConfig.query + / debugNewEpochState.query + / debugChainDepState.query + / getRewardProvenance.query + / getUTxOByTxIn.query + / getStakePools.query + / getStakePoolParams.query + / getRewardInfoPools.query + / getPoolState.query + / getStakeSnapshots.query + / getPoolDistr.query + / getStakeDelegDeposits.query + / getConstitution.query + / getGovState.query + / getDRepState.query + / getDRepStakeDistr.query + / getCommitteeMembersState.query + / getFilteredVoteDelegatees.query + / getAccountState.query + / getSPOStakeDistr.query + / getProposals.query + / getRatifyState.query + / getFuturePParams.query + / getBigLedgerPeersSnapshot.query + +getCBOR.query = [9, shelleyQuery] + +;# include getSystemStart as getSystemStart +;# include getChainBlockNo as getChainBlockNo +;# include getChainPoint as getChainPoint +;# include getEraStart as getEraStart +;# include getInterpreter as getInterpreter +;# include getCurrentEra as getCurrentEra +;# include getUpdateInterfaceState as getUpdateInterfaceState +;# include getLedgerTip as getLedgerTip +;# include getEpochNo as getEpochNo +;# include getNonMyopicMemberRewards as getNonMyopicMemberRewards +;# include getCurrentPParams as getCurrentPParams +;# include getProposedPParamsUpdates as getProposedPParamsUpdates +;# include getStakeDistribution as getStakeDistribution +;# include getUTxOByAddress as getUTxOByAddress +;# include getUTxOWhole as getUTxOWhole +;# include debugEpochState as debugEpochState +;# include getFilteredDelegationsAndRewardAccounts as getFilteredDelegationsAndRewardAccounts +;# include getGenesisConfig as getGenesisConfig +;# include debugNewEpochState as debugNewEpochState +;# include debugChainDepState as debugChainDepState +;# include getRewardProvenance as getRewardProvenance +;# include getUTxOByTxIn as getUTxOByTxIn +;# include getStakePools as getStakePools +;# include getStakePoolParams as getStakePoolParams +;# include getRewardInfoPools as getRewardInfoPools +;# include getPoolState as getPoolState +;# include getStakeSnapshots as getStakeSnapshots +;# include getPoolDistr as getPoolDistr +;# include getStakeDelegDeposits as getStakeDelegDeposits +;# include getConstitution as getConstitution +;# include getGovState as getGovState +;# include getDRepState as getDRepState +;# include getDRepStakeDistr as getDRepStakeDistr +;# include getCommitteeMembersState as getCommitteeMembersState +;# include getFilteredVoteDelegatees as getFilteredVoteDelegatees +;# include getAccountState as getAccountState +;# include getSPOStakeDistr as getSPOStakeDistr +;# include getProposals as getProposals +;# include getRatifyState as getRatifyState +;# include getFuturePParams as getFuturePParams +;# include getBigLedgerPeersSnapshot as getBigLedgerPeersSnapshot +;# import base diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/result.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/result.cddl new file mode 100644 index 0000000000..a09063be1a --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/result.cddl @@ -0,0 +1,98 @@ +result = blockQueryResult + / getSystemStart.result + / getChainBlockNo.result + / getChainPoint.result + +blockQueryResult = queryAnytimeResult + / queryHardForkResult + / queryIfCurrentResult + +queryAnytimeResult = getEraStart.result + +queryHardForkResult = getInterpreter.result / getCurrentEra.result + +queryIfCurrentResult = byronResult + / shelleyResult + +byronResult = getUpdateInterfaceState.result + +shelleyResult = getLedgerTip.result + / getEpochNo.result + / getNonMyopicMemberRewards.result + / getCurrentPParams.result + / getProposedPParamsUpdates.result + / getStakeDistribution.result + / getUTxOByAddress.result + / getUTxOWhole.result + / debugEpochState.result + / getCBOR.result + / getFilteredDelegationsAndRewardAccounts.result + / getGenesisConfig.result + / debugNewEpochState.result + / debugChainDepState.result + / getRewardProvenance.result + / getUTxOByTxIn.result + / getStakePools.result + / getStakePoolParams.result + / getRewardInfoPools.result + / getPoolState.result + / getStakeSnapshots.result + / getPoolDistr.result + / getStakeDelegDeposits.result + / getConstitution.result + / getGovState.result + / getDRepState.result + / getDRepStakeDistr.result + / getCommitteeMembersState.result + / getFilteredVoteDelegatees.result + / getAccountState.result + / getSPOStakeDistr.result + / getProposals.result + / getRatifyState.result + / getFuturePParams.result + / getBigLedgerPeersSnapshot.result + +getCBOR.result = #6.24(bstr .cbor shelleyResult) + +;# import getSystemStart as getSystemStart +;# import getChainBlockNo as getChainBlockNo +;# import getChainPoint as getChainPoint +;# import getEraStart as getEraStart +;# import getInterpreter as getInterpreter +;# import getCurrentEra as getCurrentEra +;# import getUpdateInterfaceState as getUpdateInterfaceState +;# import getLedgerTip as getLedgerTip +;# import getEpochNo as getEpochNo +;# import getNonMyopicMemberRewards as getNonMyopicMemberRewards +;# import getCurrentPParams as getCurrentPParams +;# import getProposedPParamsUpdates as getProposedPParamsUpdates +;# import getStakeDistribution as getStakeDistribution +;# import getUTxOByAddress as getUTxOByAddress +;# import getUTxOWhole as getUTxOWhole +;# import debugEpochState as debugEpochState +;# import getFilteredDelegationsAndRewardAccounts as getFilteredDelegationsAndRewardAccounts +;# import getGenesisConfig as getGenesisConfig +;# import debugNewEpochState as debugNewEpochState +;# import debugChainDepState as debugChainDepState +;# import getRewardProvenance as getRewardProvenance +;# import getUTxOByTxIn as getUTxOByTxIn +;# import getStakePools as getStakePools +;# import getStakePoolParams as getStakePoolParams +;# import getRewardInfoPools as getRewardInfoPools +;# import getPoolState as getPoolState +;# import getStakeSnapshots as getStakeSnapshots +;# import getPoolDistr as getPoolDistr +;# import getStakeDelegDeposits as getStakeDelegDeposits +;# import getConstitution as getConstitution +;# import getGovState as getGovState +;# import getDRepState as getDRepState +;# import getDRepStakeDistr as getDRepStakeDistr +;# import getCommitteeMembersState as getCommitteeMembersState +;# import getFilteredVoteDelegatees as getFilteredVoteDelegatees +;# import getAccountState as getAccountState +;# import getSPOStakeDistr as getSPOStakeDistr +;# import getProposals as getProposals +;# import getRatifyState as getRatifyState +;# import getFuturePParams as getFuturePParams +;# import getBigLedgerPeersSnapshot as getBigLedgerPeersSnapshot +;# import base diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/debugChainDepState.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/debugChainDepState.cddl new file mode 100644 index 0000000000..1126dbd1f9 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/debugChainDepState.cddl @@ -0,0 +1,5 @@ +query = [13] + +result = headerStateChainDep + +;# import headerstate diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/debugEpochState.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/debugEpochState.cddl new file mode 100644 index 0000000000..2f660f53e1 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/debugEpochState.cddl @@ -0,0 +1,5 @@ +query = [8] + +result = conway.epochState + +;# import conway as conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/debugNewEpochState.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/debugNewEpochState.cddl new file mode 100644 index 0000000000..f7b49c28e7 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/debugNewEpochState.cddl @@ -0,0 +1,5 @@ +query = [12] + +result = conway.newEpochState + +;# import conway as conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getAccountState.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getAccountState.cddl new file mode 100644 index 0000000000..2ca02093e8 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getAccountState.cddl @@ -0,0 +1,5 @@ +query = [29] + +result = conway.accountState + +;# import conway as conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getBigLedgerPeersSnapshot.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getBigLedgerPeersSnapshot.cddl new file mode 100644 index 0000000000..1531874579 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getBigLedgerPeersSnapshot.cddl @@ -0,0 +1,3 @@ +query = [34] + +result = network.ledgerPeerSnapshot diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getCBOR.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getCBOR.cddl new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getCommitteeMembersState.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getCommitteeMembersState.cddl new file mode 100644 index 0000000000..386783b020 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getCommitteeMembersState.cddl @@ -0,0 +1,6 @@ +query = [27, set, set, set] + +result = conway.committeeMembersState + +;# import base +;# import conway as conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getConstitution.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getConstitution.cddl new file mode 100644 index 0000000000..db458e6175 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getConstitution.cddl @@ -0,0 +1,5 @@ +query = [23] + +result = conway.constitution + +;# import conway as conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getCurrentPParams.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getCurrentPParams.cddl new file mode 100644 index 0000000000..357bfdcda3 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getCurrentPParams.cddl @@ -0,0 +1,5 @@ +query = [3] + +result = conway.pparams + +;# import conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getDRepStakeDistr.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getDRepStakeDistr.cddl new file mode 100644 index 0000000000..f4739c06bb --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getDRepStakeDistr.cddl @@ -0,0 +1,6 @@ +query = [26, set] + +result = map + +;# import base +;# import conway as conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getDRepState.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getDRepState.cddl new file mode 100644 index 0000000000..390547b24f --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getDRepState.cddl @@ -0,0 +1,6 @@ +query = [25, set] + +result = map + +;# import base +;# import conway as conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getEpochNo.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getEpochNo.cddl new file mode 100644 index 0000000000..25197ed410 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getEpochNo.cddl @@ -0,0 +1,5 @@ +query = [1] + +result = epochno + +;# import base diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getFilteredDelegationsAndRewardAccounts.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getFilteredDelegationsAndRewardAccounts.cddl new file mode 100644 index 0000000000..97382d42a7 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getFilteredDelegationsAndRewardAccounts.cddl @@ -0,0 +1,6 @@ +query = [10, set] + +result = [conway.delegations, conway.rewardAccounts] + +;# import base +;# import conway as conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getFilteredVoteDelegatees.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getFilteredVoteDelegatees.cddl new file mode 100644 index 0000000000..3675723e95 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getFilteredVoteDelegatees.cddl @@ -0,0 +1,6 @@ +query = [28, set] + +result = conway.voteDelegatees + +;# import base +;# import conway as conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getFuturePParams.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getFuturePParams.cddl new file mode 100644 index 0000000000..e4d3e75332 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getFuturePParams.cddl @@ -0,0 +1,6 @@ +query = [33] + +result = maybe + +;# import conway as conway +;# import base diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getGenesisConfig.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getGenesisConfig.cddl new file mode 100644 index 0000000000..76dd8faecf --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getGenesisConfig.cddl @@ -0,0 +1,5 @@ +query = [11] + +result = conway.compactGenesis + +;# import conway as conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getGovState.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getGovState.cddl new file mode 100644 index 0000000000..7766398646 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getGovState.cddl @@ -0,0 +1,5 @@ +query = [24] + +result = conway.govState + +;# import conway as conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getLedgerTip.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getLedgerTip.cddl new file mode 100644 index 0000000000..1f85a9bb8c --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getLedgerTip.cddl @@ -0,0 +1,4 @@ +query = [0] +result = point + +;# import base diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getNonMyopicMemberRewards.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getNonMyopicMemberRewards.cddl new file mode 100644 index 0000000000..894a44ab70 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getNonMyopicMemberRewards.cddl @@ -0,0 +1,6 @@ +query = [2, set>] + +result = conway.nonMyopicRewards + +;# import base +;# import conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getPoolDistr.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getPoolDistr.cddl new file mode 100644 index 0000000000..35a2d2b48e --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getPoolDistr.cddl @@ -0,0 +1,5 @@ +query = [21, maybe>] + +result = poolDistr + +;# import base diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getPoolState.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getPoolState.cddl new file mode 100644 index 0000000000..2947899d98 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getPoolState.cddl @@ -0,0 +1,6 @@ +query = [19, maybe>] + +result = conway.pstate + +;# import base +;# import conway as conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getProposals.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getProposals.cddl new file mode 100644 index 0000000000..449d0bc047 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getProposals.cddl @@ -0,0 +1,6 @@ +query = [31, set] + +result = seq + +;# import base +;# import conway as conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getProposedPParamsUpdates.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getProposedPParamsUpdates.cddl new file mode 100644 index 0000000000..7126e253ed --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getProposedPParamsUpdates.cddl @@ -0,0 +1,3 @@ +query = [4] + +result = {} \ No newline at end of file diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getRatifyState.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getRatifyState.cddl new file mode 100644 index 0000000000..3a84026806 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getRatifyState.cddl @@ -0,0 +1,5 @@ +query = [32] + +result = conway.ratifyState + +;# import conway as conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getRewardInfoPools.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getRewardInfoPools.cddl new file mode 100644 index 0000000000..fd58908a28 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getRewardInfoPools.cddl @@ -0,0 +1,6 @@ +query = [18] + +result = [conway.rewardParams, map] + +;# import conway as conway +;# import base diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getRewardProvenance.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getRewardProvenance.cddl new file mode 100644 index 0000000000..783272d765 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getRewardProvenance.cddl @@ -0,0 +1,5 @@ +query = [14] + +result = conway.rewardProvenance + +;# import conway as conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getSPOStakeDistr.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getSPOStakeDistr.cddl new file mode 100644 index 0000000000..96ccb5ffba --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getSPOStakeDistr.cddl @@ -0,0 +1,5 @@ +query = [30, set] + +result = map + +;# import base diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getStakeDelegDeposits.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getStakeDelegDeposits.cddl new file mode 100644 index 0000000000..42a832abbe --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getStakeDelegDeposits.cddl @@ -0,0 +1,6 @@ +query = [22, set] + +result = map + +;# import base +;# import conway as conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getStakeDistribution.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getStakeDistribution.cddl new file mode 100644 index 0000000000..7b83cb94ad --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getStakeDistribution.cddl @@ -0,0 +1,5 @@ +query = [5] + +result = poolDistr + +;# import base diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getStakePoolParams.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getStakePoolParams.cddl new file mode 100644 index 0000000000..b4254164b8 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getStakePoolParams.cddl @@ -0,0 +1,6 @@ +query = [17, set] + +result = map + +;# import base +;# import conway as conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getStakePools.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getStakePools.cddl new file mode 100644 index 0000000000..634be638fb --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getStakePools.cddl @@ -0,0 +1,5 @@ +query = [16] + +result = set + +;# import base diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getStakeSnapshots.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getStakeSnapshots.cddl new file mode 100644 index 0000000000..48fcd4e4c8 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getStakeSnapshots.cddl @@ -0,0 +1,6 @@ +query = [20, maybe>] + +result = conway.stakeSnapshots + +;# import base +;# import conway as conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getUTxOByAddress.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getUTxOByAddress.cddl new file mode 100644 index 0000000000..020bb283a8 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getUTxOByAddress.cddl @@ -0,0 +1,6 @@ +query = [6, set] + +result = conway.utxo + +;# import base +;# import conway as conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getUTxOByTxIn.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getUTxOByTxIn.cddl new file mode 100644 index 0000000000..7c4aa0a260 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getUTxOByTxIn.cddl @@ -0,0 +1,6 @@ +query = [15, set] + +result = conway.utxo + +;# import base +;# import conway as conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getUTxOWhole.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getUTxOWhole.cddl new file mode 100644 index 0000000000..166b9fd174 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/localstatequery/shelley/getUTxOWhole.cddl @@ -0,0 +1,5 @@ +query = [7] + +result = conway.utxo + +;# import conway as conway diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/txmonitor/slotno.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/txmonitor/slotno.cddl new file mode 100644 index 0000000000..9ae5243da2 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/txmonitor/slotno.cddl @@ -0,0 +1,3 @@ +slotno = base.slotno + +;# import base as base diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/txmonitor/tx.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/txmonitor/tx.cddl new file mode 120000 index 0000000000..0a8be97df8 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/txmonitor/tx.cddl @@ -0,0 +1 @@ +../../node-to-node/txsubmission2/tx.cddl \ No newline at end of file diff --git a/ouroboros-consensus-cardano/cddl/node-to-client/txmonitor/txid.cddl b/ouroboros-consensus-cardano/cddl/node-to-client/txmonitor/txid.cddl new file mode 120000 index 0000000000..1172366a4e --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-client/txmonitor/txid.cddl @@ -0,0 +1 @@ +../../node-to-node/txsubmission2/txid.cddl \ No newline at end of file diff --git a/ouroboros-consensus-cardano/cddl/node-to-node/blockfetch/block.cddl b/ouroboros-consensus-cardano/cddl/node-to-node/blockfetch/block.cddl new file mode 100644 index 0000000000..02a1c1b584 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-node/blockfetch/block.cddl @@ -0,0 +1,3 @@ +serialisedCardanoBlock = #6.24(bytes .cbor cardanoBlock) + +;# import cardanoBlock from block diff --git a/ouroboros-consensus-cardano/cddl/node-to-node/blockfetch/point.cddl b/ouroboros-consensus-cardano/cddl/node-to-node/blockfetch/point.cddl new file mode 100644 index 0000000000..f2dee00e56 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-node/blockfetch/point.cddl @@ -0,0 +1,3 @@ +point = base.point + +;# import base as base diff --git a/ouroboros-consensus-cardano/cddl/node-to-node/chainsync/header.cddl b/ouroboros-consensus-cardano/cddl/node-to-node/chainsync/header.cddl new file mode 100644 index 0000000000..fce611726a --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-node/chainsync/header.cddl @@ -0,0 +1,25 @@ +header + = ns7, + serialisedShelleyHeader, + serialisedShelleyHeader, + serialisedShelleyHeader, + serialisedShelleyHeader, + serialisedShelleyHeader> + +byronHeader = [byronRegularIdx, #6.24(bytes .cbor byron.blockhead)] + / [byronBoundaryIdx, #6.24(bytes .cbor byron.ebbhead)] + +byronBoundaryIdx = [0, word32] +byronRegularIdx = [1, word32] + +serialisedShelleyHeader = #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 diff --git a/ouroboros-consensus-cardano/cddl/node-to-node/chainsync/point.cddl b/ouroboros-consensus-cardano/cddl/node-to-node/chainsync/point.cddl new file mode 100644 index 0000000000..f2dee00e56 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-node/chainsync/point.cddl @@ -0,0 +1,3 @@ +point = base.point + +;# import base as base diff --git a/ouroboros-consensus-cardano/cddl/node-to-node/chainsync/tip.cddl b/ouroboros-consensus-cardano/cddl/node-to-node/chainsync/tip.cddl new file mode 100644 index 0000000000..3fc6aa495c --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-node/chainsync/tip.cddl @@ -0,0 +1,3 @@ +tip = [ point, blockno ] + +;# import base diff --git a/ouroboros-consensus-cardano/cddl/node-to-node/txsubmission2/ticketno.cddl b/ouroboros-consensus-cardano/cddl/node-to-node/txsubmission2/ticketno.cddl new file mode 100644 index 0000000000..914cfdf749 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-node/txsubmission2/ticketno.cddl @@ -0,0 +1,3 @@ +ticketNo = word64 + +;# import base diff --git a/ouroboros-consensus-cardano/cddl/node-to-node/txsubmission2/tx.cddl b/ouroboros-consensus-cardano/cddl/node-to-node/txsubmission2/tx.cddl new file mode 100644 index 0000000000..d5d176e125 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-node/txsubmission2/tx.cddl @@ -0,0 +1,19 @@ +tx = + ns7, + serialisedShelleyTx, + serialisedShelleyTx, + serialisedShelleyTx, + serialisedShelleyTx, + serialisedShelleyTx> + +serialisedShelleyTx = #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 diff --git a/ouroboros-consensus-cardano/cddl/node-to-node/txsubmission2/txid.cddl b/ouroboros-consensus-cardano/cddl/node-to-node/txsubmission2/txid.cddl new file mode 100644 index 0000000000..764ddf5974 --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/node-to-node/txsubmission2/txid.cddl @@ -0,0 +1,17 @@ +txId = + ns7 + +byronTxId = [0, byron.txid] + / [1, byron.certificateid] + / [2, byron.updid] + / [3, byron.voteid] + +;# include byron as byron +;# include shelley as shelley +;# import base diff --git a/ouroboros-consensus-cardano/cddl/pull-cddls.hs b/ouroboros-consensus-cardano/cddl/pull-cddls.hs new file mode 100644 index 0000000000..396ff20c6d --- /dev/null +++ b/ouroboros-consensus-cardano/cddl/pull-cddls.hs @@ -0,0 +1,201 @@ +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE CPP #-} +-- | + +module Main (main) where + +import qualified Control.Monad as Monad +import qualified Data.ByteString.Lazy as BL +import qualified Data.ByteString.Lazy.UTF8 as BL8 +import Data.Maybe (isNothing) +import qualified Data.List as L +import Paths_ouroboros_consensus_cardano +import qualified System.Directory as D +import qualified System.Environment as E +import System.Exit (exitFailure) +import qualified System.FilePath as F +import qualified System.Process.ByteString.Lazy as P +import qualified Test.Cardano.Chain.Binary.Cddl as Byron +import qualified Test.Cardano.Ledger.Allegra.Binary.Cddl as Allegra +import qualified Test.Cardano.Ledger.Alonzo.Binary.Cddl as Alonzo +import qualified Test.Cardano.Ledger.Babbage.Binary.Cddl as Babbage +import qualified Test.Cardano.Ledger.Conway.Binary.Cddl as Conway +import qualified Test.Cardano.Ledger.Mary.Binary.Cddl as Mary +import qualified Test.Cardano.Ledger.Shelley.Binary.Cddl as Shelley + +main :: IO () +main = do + probeTools + setupEnv + -- For now I just print this. + print =<< getCDDLs + +setupEnv :: IO () +setupEnv = do + byron <- map takePath <$> Byron.readByronCddlFileNames + shelley <- map takePath <$> Shelley.readShelleyCddlFileNames + allegra <- map takePath <$> Allegra.readAllegraCddlFileNames + mary <- map takePath <$> Mary.readMaryCddlFileNames + alonzo <- map takePath <$> Alonzo.readAlonzoCddlFileNames + babbage <- map takePath <$> Babbage.readBabbageCddlFileNames + conway <- map takePath <$> Conway.readConwayCddlFileNames + + localDataDir <- takePath <$> getDataDir + let local_paths = map (localDataDir F.) [ + "cddl" + , "cddl/disk" + , "cddl/disk/snapshot" + , "cddl/node-to-client/localstatequery/byron" + , "cddl/node-to-client/localstatequery/consensus" + , "cddl/node-to-client/localstatequery/shelley" + , "cddl/node-to-client/txmonitor" + ] + + include_path = + mconcat + $ L.intersperse ":" + $ map (mconcat . L.intersperse ":") [byron, shelley, allegra, mary, alonzo, babbage, conway] <> local_paths + + E.setEnv "CDDL_INCLUDE_PATH" (include_path <> ":") + +newtype CDDLSpec = CDDLSpec BL.ByteString deriving Show + +data CDDLs = CDDLs { + diskBlockCDDL :: CDDLSpec + , diskSnapshotCDDL :: CDDLSpec + + , ntnBlockFetchBlockCDDL :: CDDLSpec + , ntnBlockFetchPointCDDL :: CDDLSpec + + , ntnChainSyncHeaderCDDL :: CDDLSpec + , ntnChainSyncPointCDDL :: CDDLSpec + , ntnChainSyncTipCDDL :: CDDLSpec + + , ntnTxSubmissionTicketNoCDDL :: CDDLSpec + , ntnTxSubmissionTxCDDL :: CDDLSpec + , ntnTxSubmissionTxIdCDDL :: CDDLSpec + + , ntcLocalStateQueryQueryCDDL :: CDDLSpec + , ntcLocalStateQueryResultCDDL :: CDDLSpec + + , ntcTxMonitorTxCDDL :: CDDLSpec + , ntcTxMonitorTxIdCDDL :: CDDLSpec + , ntcTxMonitorSlotNoCDDL :: CDDLSpec + } deriving Show + +getCDDLs :: IO CDDLs +getCDDLs = CDDLs + -- Disk + <$> cddlc "cddl/disk/block.cddl" + <*> cddlc "cddl/disk/snapshot.cddl" + + -- Node to node + -- -- BlockFetch + <*> cddlc "cddl/node-to-node/blockfetch/block.cddl" + <*> cddlc "cddl/node-to-node/blockfetch/point.cddl" + + -- -- ChainSync + <*> cddlc "cddl/node-to-node/chainsync/header.cddl" + <*> cddlc "cddl/node-to-node/chainsync/point.cddl" + <*> cddlc "cddl/node-to-node/chainsync/tip.cddl" + + -- -- TxSubmission2 + <*> cddlc "cddl/node-to-node/txsubmission2/ticketno.cddl" + <*> cddlc "cddl/node-to-node/txsubmission2/tx.cddl" + <*> cddlc "cddl/node-to-node/txsubmission2/txid.cddl" + + -- Node to client + -- -- LocalStateQuery + <*> cddlc "cddl/node-to-client/localstatequery/query.cddl" + <*> cddlc "cddl/node-to-client/localstatequery/result.cddl" + + -- -- TxMonitor + <*> cddlc "cddl/node-to-client/txmonitor/tx.cddl" + <*> cddlc "cddl/node-to-client/txmonitor/txid.cddl" + <*> cddlc "cddl/node-to-client/txmonitor/slotno.cddl" + +cddlc :: FilePath -> IO CDDLSpec +cddlc dataFile = do + putStrLn $ "Generating: " <> dataFile + path <- getDataFileName dataFile + (_, cddl, err) <- +#ifdef POSIX + P.readProcessWithExitCode "cddlc" ["-u", "-2", "-t", "cddl", path] mempty +#else + -- we cannot call @cddlc@ directly because it is not an executable in + -- Haskell eyes, but we can call @ruby@ and pass the @cddlc@ script path as + -- an argument + do + prefix <- E.getEnv "MSYSTEM_PREFIX" + P.readProcessWithExitCode "ruby" [prefix F. "bin/cddlc", "-u", "-2", "-t", "cddl", path] mempty +#endif + Monad.unless (BL.null err) $ red $ BL8.toString err + return $ CDDLSpec cddl + where + red s = putStrLn $ "\ESC[31m" <> s <> "\ESC[0m" + +takePath :: FilePath -> FilePath +takePath x = +#ifdef POSIX + F.takeDirectory x +#else + -- @cddlc@ is not capable of using backlashes + -- + -- @cddlc@ mixes @C:@ with the separator in @CDDL_INCLUDE_PATH@, and it + -- doesn't understand @;@ as a separator. It works if we remove @C:@ and we + -- are running in the same drive as the cddl files. + let f = [ if c /= '\\' then c else '/' | c <- F.takeDirectory x ] + in if "C:" `L.isPrefixOf` f + then drop 2 f + else f +#endif + +probeTools :: IO () +probeTools = do + putStrLn "Probing tools:" +#ifdef POSIX + posixProbeTool "cddl" "install the `cddl` ruby gem" + posixProbeTool "cddlc" "install the `cddlc` ruby gem" + where + posixProbeTool :: String -> Sring -> IO () + posixProbeTool tool suggestion = do + putStr $ "- " <> tool <> " " + exe <- D.findExecutable tool + if isNothing exe + then do + putStrLn "not found!" + putStrLn $ "Please " <> suggestion + exitFailure + else + putStrLn "found" +#else + -- On Windows, the cddl and cddlc files are POSIX scripts and therefore not + -- recognized as executables by @findExecutable@, so we need to do some dirty + -- tricks here. We check that ruby executable exists and then that there are + -- cddl and cddlc files in the binary folder of the MSYS2 installation. + putStr "- ruby " + rubyExe <- D.findExecutable "ruby" + if (isNothing rubyExe) + then do + putStrLn "not found!\nPlease install ruby and the `cddl` and `cddlc` gems" + exitFailure + else + putStrLn "found" + + putStr "- cddl " + cddlExe <- D.doesFileExist . (F. "bin/cddlc") =<< E.getEnv "MSYSTEM_PREFIX" + if cddlExe + then putStrLn "found" + else do + putStrLn "not found!\nPlease install the `cddl` ruby gem" + exitFailure + + putStr "- cddlc " + cddlcExe <- D.doesFileExist . (F. "bin/cddlc") =<< E.getEnv "MSYSTEM_PREFIX" + if cddlcExe + then putStrLn "found" + else do + putStrLn "not found!\nPlease install the `cddlc` ruby gem" + exitFailure + pure () +#endif diff --git a/ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal b/ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal index 6bae94980a..88b4345af8 100644 --- a/ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal +++ b/ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal @@ -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 @@ -198,7 +201,7 @@ library unstable-byronspec byron-spec-ledger, cardano-binary, cardano-ledger-binary, - cardano-ledger-byron-test, + cardano-ledger-byron:testlib, cborg >=0.2.2 && <0.3, containers >=0.5 && <0.8, mtl, @@ -233,11 +236,9 @@ library unstable-byron-testlib cardano-binary, cardano-crypto, cardano-crypto-class, - cardano-crypto-test, - cardano-crypto-wrapper, + cardano-crypto-wrapper:{cardano-crypto-wrapper, testlib}, cardano-ledger-binary:{cardano-ledger-binary, testlib}, - cardano-ledger-byron, - cardano-ledger-byron-test, + cardano-ledger-byron:{cardano-ledger-byron, testlib}, cardano-ledger-core, containers, hedgehog-quickcheck, @@ -272,8 +273,7 @@ test-suite byron-test cardano-crypto-class, cardano-crypto-wrapper, cardano-ledger-binary, - cardano-ledger-byron, - cardano-ledger-byron-test, + cardano-ledger-byron:{cardano-ledger-byron, testlib}, cardano-ledger-core, cardano-slotting:testlib, cborg, @@ -446,6 +446,7 @@ test-suite cardano-test Test.Consensus.Cardano.SupportsSanityCheck Test.Consensus.Cardano.Translation Test.ThreadNet.AllegraMary + Test.Consensus.Ledger.Query Test.ThreadNet.Cardano Test.ThreadNet.MaryAlonzo Test.ThreadNet.ShelleyAllegra @@ -472,21 +473,27 @@ test-suite cardano-test containers, contra-tracer, filepath, + io-classes, microlens, - ouroboros-consensus:{ouroboros-consensus, unstable-consensus-testlib, unstable-mempool-test-utils}, ouroboros-consensus-cardano:{ouroboros-consensus-cardano, unstable-cardano-testlib}, + ouroboros-consensus-diffusion, ouroboros-consensus-diffusion:unstable-diffusion-testlib, ouroboros-consensus-protocol, + ouroboros-consensus:{ouroboros-consensus, unstable-consensus-testlib, unstable-mempool-test-utils}, + ouroboros-network, ouroboros-network-api, ouroboros-network-protocols:{ouroboros-network-protocols, testlib}, pretty-simple, + serialise, sop-core, sop-extras, strict-sop-core, tasty, tasty-hunit, tasty-quickcheck, + temporary, typed-protocols ^>=0.3, + typed-protocols-stateful, unstable-byron-testlib, unstable-cardano-testlib, unstable-shelley-testlib, @@ -745,3 +752,23 @@ executable gen-header autogen-modules: Paths_ouroboros_consensus_cardano + +executable pull-cddls + import: common-exe + hs-source-dirs: cddl + main-is: pull-cddls.hs + other-modules: Paths_ouroboros_consensus_cardano + build-depends: + base, + bytestring, + cardano-ledger-allegra:testlib, + cardano-ledger-alonzo:testlib, + cardano-ledger-babbage:testlib, + cardano-ledger-byron:testlib, + cardano-ledger-conway:testlib, + cardano-ledger-mary:testlib, + cardano-ledger-shelley:testlib, + directory, + filepath, + process-extras, + utf8-string, diff --git a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Eras.hs b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Eras.hs index 32a6ba6892..65d9fd471f 100644 --- a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Eras.hs +++ b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Eras.hs @@ -57,6 +57,7 @@ import qualified Cardano.Ledger.Conway.Governance as CG import qualified Cardano.Ledger.Conway.Rules as Conway import qualified Cardano.Ledger.Conway.Rules as SL (ConwayLedgerPredFailure (..)) +import Cardano.Ledger.Conway.State import qualified Cardano.Ledger.Conway.Translation as Conway import Cardano.Ledger.Core as Core import Cardano.Ledger.Mary (MaryEra) @@ -170,7 +171,7 @@ class ( Core.EraSegWits era getConwayEraGovDict :: proxy era -> Maybe (ConwayEraGovDict era) data ConwayEraGovDict era where - ConwayEraGovDict :: CG.ConwayEraGov era => ConwayEraGovDict era + ConwayEraGovDict :: (ConwayEraCertState era, CG.ConwayEraGov era) => ConwayEraGovDict era isBeforeConway :: forall era. L.Era era => Proxy era -> Bool isBeforeConway _ = diff --git a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Ledger.hs b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Ledger.hs index 31360ef9db..20cb4a5cad 100644 --- a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Ledger.hs +++ b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Ledger.hs @@ -586,7 +586,7 @@ applyHelper f cfg blk stBefore = do -- means the value must not be serialized. We're only passing it to -- 'STS.applyBlockOpts', which does not serialize it. So this is a -- safe use. - in SL.UnsafeUnserialisedBlock h' (SL.bbody b) + in SL.Block h' (SL.bbody b) ) let track :: diff --git a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query.hs b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query.hs index 760628a7e3..9374a81d81 100644 --- a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query.hs +++ b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query.hs @@ -47,12 +47,13 @@ import Cardano.Binary (FromCBOR (..), ToCBOR (..), encodeListLen, enforceSize) import Cardano.Ledger.Address import qualified Cardano.Ledger.Api.State.Query as SL -import Cardano.Ledger.CertState (lookupDepositDState) -import qualified Cardano.Ledger.CertState as SL +import Cardano.Ledger.State (lookupDepositDState) +import qualified Cardano.Ledger.State as SL import Cardano.Ledger.Coin (Coin) import Cardano.Ledger.Compactible (Compactible (fromCompact)) import qualified Cardano.Ledger.Conway.Governance as CG import qualified Cardano.Ledger.Core as SL +import Cardano.Ledger.Conway.State (ConwayEraCertState) import Cardano.Ledger.Credential (StakeCredential) import Cardano.Ledger.Keys (KeyHash, KeyRole (..)) import qualified Cardano.Ledger.Shelley.API as SL @@ -60,7 +61,6 @@ import qualified Cardano.Ledger.Shelley.Core as LC import Cardano.Ledger.Shelley.LedgerState (AccountState) import qualified Cardano.Ledger.Shelley.RewardProvenance as SL (RewardProvenance) -import qualified Cardano.Ledger.State as SL import Cardano.Ledger.UMap (UMap (..), rdReward, umElemDRep, umElemRDPair, umElemSPool) import Cardano.Protocol.Crypto (Crypto) @@ -266,7 +266,7 @@ data instance BlockQuery (ShelleyBlock proto era) fp result where -- -- Not supported in eras before Conway. GetDRepState - :: CG.ConwayEraGov era + :: (ConwayEraCertState era, CG.ConwayEraGov era) => Set (SL.Credential 'DRepRole) -> BlockQuery (ShelleyBlock proto era) QFNoTables @@ -292,7 +292,7 @@ data instance BlockQuery (ShelleyBlock proto era) fp result where -- -- Not supported in eras before Conway. GetCommitteeMembersState - :: CG.ConwayEraGov era + :: (ConwayEraCertState era, CG.ConwayEraGov era) => Set (SL.Credential 'ColdCommitteeRole) -> Set (SL.Credential 'HotCommitteeRole) -> Set SL.MemberStatus @@ -899,7 +899,7 @@ decodeShelleyQuery = do requireCG :: forall s ans. - (CG.ConwayEraGov era => Decoder s ans) + ((ConwayEraCertState era, CG.ConwayEraGov era) => Decoder s ans) -> Decoder s ans requireCG k = case SE.getConwayEraGovDict (Proxy @era) of Just SE.ConwayEraGovDict -> k diff --git a/ouroboros-consensus-cardano/test/cardano-test/Main.hs b/ouroboros-consensus-cardano/test/cardano-test/Main.hs index db1f720d7b..3855fe2d31 100644 --- a/ouroboros-consensus-cardano/test/cardano-test/Main.hs +++ b/ouroboros-consensus-cardano/test/cardano-test/Main.hs @@ -8,6 +8,7 @@ import qualified Test.Consensus.Cardano.Serialisation (tests) import qualified Test.Consensus.Cardano.SupportedNetworkProtocolVersion import qualified Test.Consensus.Cardano.SupportsSanityCheck import qualified Test.Consensus.Cardano.Translation (tests) +import qualified Test.Consensus.Ledger.Query (tests) import Test.Tasty import qualified Test.ThreadNet.AllegraMary import qualified Test.ThreadNet.Cardano @@ -35,4 +36,5 @@ tests = , Test.ThreadNet.ShelleyAllegra.tests , Test.Consensus.Cardano.MiniProtocol.LocalTxSubmission.Server.tests , Test.Consensus.Cardano.Translation.tests + , Test.Consensus.Ledger.Query.tests ] diff --git a/ouroboros-consensus-cardano/test/cardano-test/Test/Consensus/Ledger/Query.hs b/ouroboros-consensus-cardano/test/cardano-test/Test/Consensus/Ledger/Query.hs new file mode 100644 index 0000000000..70e33b79c6 --- /dev/null +++ b/ouroboros-consensus-cardano/test/cardano-test/Test/Consensus/Ledger/Query.hs @@ -0,0 +1,131 @@ +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE OverloadedStrings #-} + +-- | Serialization tests for local state queries and results. +module Test.Consensus.Ledger.Query (tests) where + +import Codec.CBOR.Read (DeserialiseFailure) +import Control.Monad.Class.MonadThrow (throwIO) +import qualified Data.ByteString as BS +import qualified Data.ByteString.Base16.Lazy as LBase16 +import qualified Data.ByteString.Lazy as LBS +import Network.TypedProtocol.Stateful.Codec (Codec (encode), SomeMessage (..), decode, runDecoder) +import qualified Network.TypedProtocol.Stateful.Codec as Stateful +import Ouroboros.Consensus.Block (Point) +import Ouroboros.Consensus.Cardano.Block (CardanoBlock, StandardCrypto) +import Ouroboros.Consensus.Cardano.Node () +import Ouroboros.Consensus.Ledger.Query (Query (GetSystemStart)) +import Ouroboros.Consensus.Network.NodeToClient (cStateQueryCodec, clientCodecs) +import Ouroboros.Consensus.Shelley.Ledger.SupportsProtocol () +import Ouroboros.Network.NodeToClient (NodeToClientVersion (NodeToClientV_20)) +import Ouroboros.Network.Protocol.LocalStateQuery.Type (LocalStateQuery, Message (MsgQuery, MsgResult), SingLocalStateQuery (SingAcquired, SingQuerying), State (StateAcquired, StateQuerying)) +import qualified Ouroboros.Network.Protocol.LocalStateQuery.Type as LocalStateQuery +import System.IO.Temp (withSystemTempDirectory) +import Test.Cardano.Ledger.Binary.Cddl (validateCddlConformance) +import Test.Tasty (TestTree, testGroup) +import Test.Tasty.HUnit (assertEqual, testCase) + +type Block = CardanoBlock StandardCrypto + +-- | We only test the latest query version and n2c protocol version against the API. +stateQueryCodec :: + Stateful.Codec + (LocalStateQuery Block (Point Block) (Query Block)) + DeserialiseFailure + LocalStateQuery.State + IO + LBS.ByteString +stateQueryCodec = + cStateQueryCodec $ + clientCodecs mockCodecConfig mockBlockNodeToClientVersion latestN2CVersion + where + latestN2CVersion = NodeToClientV_20 + + -- NOTE: Not used for non-block queries + mockCodecConfig = error "CodecConfig used unexpectedly" + + -- NOTE: Not used for non-block queries + mockBlockNodeToClientVersion = error "BlockNodeToClientVersion used unexpectedly" + +tests :: TestTree +tests = + testGroup + "LocalStateQuery" + [ -- TODO: do this for all queries + -- TODO: reuse cddlRoundTripExpectation from cardano-ledger-binary? + testGroup + "getSystemStart" + [ testCase "Query example" $ do + -- Decode blueprint example query + exampleHex <- LBS.readFile "../cardano-blueprint/src/api/examples/getSystemStart/query.cbor" + decoder <- decode stateQueryCodec SingAcquired StateAcquired + runDecoder [LBase16.decodeLenient exampleHex] decoder >>= \case + Left err -> throwIO err + -- XXX: can't bind monadically into test case? + Right (SomeMessage (MsgQuery query)) -> do + -- Re-encode query + let encoded = encode stateQueryCodec StateAcquired (MsgQuery query) + -- Check whether re-encoded cbor is equal + -- NOTE: Using hex-encoded bytes for better debugging + assertEqual "re-encoded query" exampleHex (LBase16.encode encoded) + -- Validate against composed cddl + -- REVIEW: Do we want to use $sockets or the ;# include module extension? + protocolCddlBytes <- BS.readFile "../cardano-blueprint/src/api/cddl/local-state-query.cddl" + queryCddlBytes <- BS.readFile "../cardano-blueprint/src/api/cddl/getSystemStart.cddl" + withSystemTempDirectory "ouroboros-consensus-cardano-test" $ \dir -> do + let cddlFile = dir <> "/composed.cddl" + BS.writeFile cddlFile (protocolCddlBytes <> queryCddlBytes) + validateCddlConformance cddlFile encoded >>= either fail (const $ pure ()) + Right (SomeMessage _) -> fail "Decoded unexpected message" + , testCase "Query roundtrip" $ do + -- TODO: generate arbitrary query terms given cddl + -- TODO: decode with queryDecodeNodeToClient + -- TODO: encode query with queryEncodeNodeToClient + -- TODO: check whether cbor is equal + -- TODO: validate cbor against cddl + fail "TODO" + , testCase "Query conformance" $ do + -- TODO: generate arbitrary 'GetSystemStart :: Query Block SystemStart' values + -- TODO: encode with queryEncodeNodeToClient + -- TODO: validate cbor against cddl + fail "TODO" + , testCase "Result example" $ do + -- Decode blueprint example query + exampleHex <- LBS.readFile "../cardano-blueprint/src/api/examples/getSystemStart/result.cbor" + decoder <- decode stateQueryCodec SingQuerying (StateQuerying GetSystemStart) + result <- + runDecoder [LBase16.decodeLenient exampleHex] decoder >>= \case + Left err -> throwIO err + Right (SomeMessage (MsgResult result)) -> pure result + + -- Re-encode result + let encoded = encode stateQueryCodec (StateQuerying GetSystemStart) (MsgResult result) + -- Check whether re-encoded cbor is equal + -- NOTE: Using hex-encoded bytes for better debugging + -- FIXME: this fails because 'fromOrdinalDate' is used in 'FromCBOR UTCTime' + assertEqual "re-encoded result" exampleHex (LBase16.encode encoded) + + -- Validate against composed cddl + -- REVIEW: Do we want to use $sockets or the ;# include module extension? + protocolCddlBytes <- BS.readFile "../cardano-blueprint/src/api/cddl/local-state-query.cddl" + queryCddlBytes <- BS.readFile "../cardano-blueprint/src/api/cddl/getSystemStart.cddl" + withSystemTempDirectory "ouroboros-consensus-cardano-test" $ \dir -> do + let cddlFile = dir <> "/composed.cddl" + BS.writeFile cddlFile (protocolCddlBytes <> queryCddlBytes) + validateCddlConformance cddlFile encoded >>= either fail (const $ pure ()) + , testCase "Query roundtrip" $ do + -- TODO: generate arbitrary result terms given cddl + -- TODO: decode result with decodeResult + -- TODO: encode result with encodeResult + -- TODO: check whether cbor is equal + -- TODO: validate cbor against cddl + fail "TODO" + , testCase "Result conformance" $ do + -- TODO: generate arbitrary 'SystemStart' values + -- TODO: encode result with encodeResult + -- TODO: validate cbor against cddl + fail "TODO" + ] + ] diff --git a/ouroboros-consensus/ouroboros-consensus.cabal b/ouroboros-consensus/ouroboros-consensus.cabal index af9a1c338b..baa7f38a00 100644 --- a/ouroboros-consensus/ouroboros-consensus.cabal +++ b/ouroboros-consensus/ouroboros-consensus.cabal @@ -600,6 +600,8 @@ test-suite consensus-test async, base, base-deriving-via, + bytestring, + base16-bytestring, cardano-binary, cardano-crypto-class ^>=2.2, cardano-crypto-tests ^>=2.2, diff --git a/ouroboros-consensus/src/unstable-mock-block/Ouroboros/Consensus/Mock/Node/Serialisation.hs b/ouroboros-consensus/src/unstable-mock-block/Ouroboros/Consensus/Mock/Node/Serialisation.hs index 8748f20059..bd6a7a1063 100644 --- a/ouroboros-consensus/src/unstable-mock-block/Ouroboros/Consensus/Mock/Node/Serialisation.hs +++ b/ouroboros-consensus/src/unstable-mock-block/Ouroboros/Consensus/Mock/Node/Serialisation.hs @@ -33,6 +33,9 @@ import Ouroboros.Network.Block (Serialised) -- | Local shorthand to make the instances more readable type MockBlock ext = SimpleBlock SimpleMockCrypto ext +instance MockProtocolSpecific SimpleMockCrypto () where + type MockLedgerConfig SimpleMockCrypto () = () + {------------------------------------------------------------------------------- Disk