Skip to content

Commit

Permalink
Merge pull request #4792 from IntersectMBO/aniketd/huddle-conway
Browse files Browse the repository at this point in the history
Refactor Conway CDDL to reuse Babbage CDDL
  • Loading branch information
aniketd authored Dec 12, 2024
2 parents b5571e4 + 803c906 commit b7fe1c3
Show file tree
Hide file tree
Showing 9 changed files with 565 additions and 498 deletions.
10 changes: 5 additions & 5 deletions eras/allegra/impl/cddl-files/allegra.cddl
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ multi_host_name = (2, dns_name)
;
operational_cert = ($kes_vkey, uint, uint, $signature)

; pool_keyhash: operator
; coin: pledge
; coin: cost
; unit_interval: margin
; set<addr_keyhash>: pool_owners
; pool_keyhash: operator
; coin: pledge
; coin: cost
; unit_interval: margin
; set<addr_keyhash>: pool_owners
;
pool_params = (pool_keyhash
, vrf_keyhash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ transaction_body =
]

-- TODO: Allow for adding to the comments of a Rule in order to not have to
-- redifine them in the subsequent eras.
-- redefine them in the subsequent eras.
script_data_hash :: Rule
script_data_hash =
comment
Expand Down
3 changes: 1 addition & 2 deletions eras/conway/impl/cardano-ledger-conway.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,11 @@ library testlib
cardano-ledger-shelley:{cardano-ledger-shelley, testlib},
cardano-strict-containers,
containers,
cuddle >=0.3.1.0,
cuddle >=0.3.2,
data-default,
deepseq,
generic-random,
here,
heredoc,
microlens,
microlens-mtl,
mtl,
Expand Down
300 changes: 182 additions & 118 deletions eras/conway/impl/cddl-files/conway.cddl

Large diffs are not rendered by default.

7 changes: 2 additions & 5 deletions eras/conway/impl/huddle-cddl/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ module Main where

import Paths_cardano_ledger_conway
import Test.Cardano.Ledger.Binary.Cuddle (writeSpec)
import qualified Test.Cardano.Ledger.Conway.CDDL as Conway
import Test.Cardano.Ledger.Conway.CDDL (conwayCDDL)

-- Generate cddl files for all relevant specifications
main :: IO ()
main = do
specFile <- getDataFileName "cddl-files/conway.cddl"
writeSpec Conway.conway specFile
main = writeSpec conwayCDDL =<< getDataFileName "cddl-files/conway.cddl"
52 changes: 24 additions & 28 deletions eras/conway/impl/test/Test/Cardano/Ledger/Conway/Binary/CddlSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ import Test.Cardano.Ledger.Binary.Cuddle (
)
import Test.Cardano.Ledger.Common
import Test.Cardano.Ledger.Conway.Binary.Cddl (readConwayCddlFiles)
import qualified Test.Cardano.Ledger.Conway.CDDL as ConwayCDDL
import Test.Cardano.Ledger.Conway.CDDL (conwayCDDL)

spec :: Spec
spec = do
newSpec
describe "CDDL" $
beforeAllCddlFile 3 readConwayCddlFiles $ do
let v = eraProtVerHigh @Conway
describe "CDDL" $ do
let v = eraProtVerHigh @Conway
describe "Ruby-based" $ beforeAllCddlFile 3 readConwayCddlFiles $ do
cddlRoundTripCborSpec @(Value Conway) v "positive_coin"
cddlRoundTripCborSpec @(Value Conway) v "value"
cddlRoundTripAnnCborSpec @(TxBody Conway) v "transaction_body"
Expand All @@ -41,32 +40,29 @@ spec = do
cddlRoundTripCborSpec @(Datum Conway) v "datum_option"
cddlRoundTripAnnCborSpec @(TxWits Conway) v "transaction_witness_set"
cddlRoundTripCborSpec @(PParamsUpdate Conway) v "protocol_param_update"
cddlRoundTripCborSpec @CostModels v "costmdls"
cddlRoundTripCborSpec @CostModels v "cost_models"
cddlRoundTripAnnCborSpec @(Redeemers Conway) v "redeemers"
cddlRoundTripAnnCborSpec @(Tx Conway) v "transaction"
cddlRoundTripCborSpec @(VotingProcedure Conway) v "voting_procedure"
cddlRoundTripCborSpec @(ProposalProcedure Conway) v "proposal_procedure"
cddlRoundTripCborSpec @(GovAction Conway) v "gov_action"
cddlRoundTripCborSpec @(TxCert Conway) v "certificate"

newSpec :: Spec
newSpec = describe "Huddle" $ specWithHuddle ConwayCDDL.conway 100 $ do
let v = eraProtVerHigh @Conway
huddleRoundTripCborSpec @(Value Conway) v "positive_coin"
huddleRoundTripCborSpec @(Value Conway) v "value"
huddleRoundTripCborSpec @(Datum Conway) v "datum_option"
huddleRoundTripCborSpec @CostModels v "costmdls"
huddleRoundTripCborSpec @(VotingProcedure Conway) v "voting_procedure"
huddleRoundTripCborSpec @(PParamsUpdate Conway) v "protocol_param_update"
huddleRoundTripCborSpec @(ProposalProcedure Conway) v "proposal_procedure"
huddleRoundTripCborSpec @(GovAction Conway) v "gov_action"
huddleRoundTripCborSpec @(TxCert Conway) v "certificate"
huddleRoundTripCborSpec @(TxOut Conway) v "transaction_output"
huddleRoundTripAnnCborSpec @(TxBody Conway) v "transaction_body"
huddleRoundTripAnnCborSpec @(TxAuxData Conway) v "auxiliary_data"
huddleRoundTripAnnCborSpec @(Timelock Conway) v "native_script"
huddleRoundTripAnnCborSpec @(Data Conway) v "plutus_data"
huddleRoundTripAnnCborSpec @(Script Conway) v "script"
huddleRoundTripAnnCborSpec @(TxWits Conway) v "transaction_witness_set"
huddleRoundTripAnnCborSpec @(Redeemers Conway) v "redeemers"
huddleRoundTripAnnCborSpec @(Tx Conway) v "transaction"
describe "Huddle" $ specWithHuddle conwayCDDL 100 $ do
huddleRoundTripCborSpec @(Value Conway) v "positive_coin"
huddleRoundTripCborSpec @(Value Conway) v "value"
huddleRoundTripAnnCborSpec @(TxBody Conway) v "transaction_body"
huddleRoundTripAnnCborSpec @(TxAuxData Conway) v "auxiliary_data"
huddleRoundTripAnnCborSpec @(Timelock Conway) v "native_script"
huddleRoundTripAnnCborSpec @(Data Conway) v "plutus_data"
huddleRoundTripCborSpec @(TxOut Conway) v "transaction_output"
huddleRoundTripAnnCborSpec @(Script Conway) v "script"
huddleRoundTripCborSpec @(Datum Conway) v "datum_option"
huddleRoundTripAnnCborSpec @(TxWits Conway) v "transaction_witness_set"
huddleRoundTripCborSpec @(PParamsUpdate Conway) v "protocol_param_update"
huddleRoundTripCborSpec @CostModels v "cost_models"
huddleRoundTripAnnCborSpec @(Redeemers Conway) v "redeemers"
huddleRoundTripAnnCborSpec @(Tx Conway) v "transaction"
huddleRoundTripCborSpec @(VotingProcedure Conway) v "voting_procedure"
huddleRoundTripCborSpec @(ProposalProcedure Conway) v "proposal_procedure"
huddleRoundTripCborSpec @(GovAction Conway) v "gov_action"
huddleRoundTripCborSpec @(TxCert Conway) v "certificate"
Loading

0 comments on commit b7fe1c3

Please sign in to comment.