Skip to content

Add Dijkstra ledger era #1567

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

Merged
merged 17 commits into from
Jul 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-ledger
tag: b44ce911475794a15f908ad27a6f497d6a27e8ba
--sha256: sha256-MXaVKKH9siUsmOnJmYyL6if48dx11zugux7AWGPABfA=
tag: ca8d451bbce11dde3b68e99782c79f9b4c1dfca5
--sha256: sha256-YHIscWnp9GrFn0EYGM7xd8Ds8x0O00FWBAIZX22bWpA=
subdir:
eras/allegra/impl
eras/alonzo/impl
Expand All @@ -82,6 +82,7 @@ source-repository-package
eras/byron/ledger/impl
eras/conway/impl
eras/conway/test-suite
eras/dijkstra/
eras/mary/impl
eras/shelley/impl
eras/shelley-ma/test-suite
Expand Down
75 changes: 52 additions & 23 deletions docs/website/contents/for-developers/AddingAnEra.md
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for updating this!

Original file line number Diff line number Diff line change
Expand Up @@ -48,32 +48,20 @@ be adding is the Alonzo era, which comes after the Mary era.
the `cabal.project` file. You will have to add it to some other cabal files
too, let the compiler tell you which ones.

## `ouroboros-consensus-shelley`
## `ouroboros-consensus-cardano`

* Define `StandardAlonzo` in `Ouroboros.Consensus.Shelley.Eras` and add any
missing instances to that module, update the export list appropriately.

* In `Ouroboros.Consensus.Shelley.Node`, define `ProtocolParamsAlonzo` just like
the existing ones. In case the era in question needs extra parameters (e.g., a
new genesis config?), they can be added here.

## `ouroboros-consensus-shelley-test`

* In `Test.Consensus.Shelley.Examples`, define an `examplesAlonzo` similar to
how `examplesMary` is defined. If necessary, i.e., when new type families have
been created in the ledger (e.g., `TxOut`), the `examples` function might have
to take more arguments. This is where the golden test examples are defined,
but only the Shelley ones are tested as part of this test suite. The others
are only tested as part of the `ouroboros-consensus-cardano-test` test suite.

## `ouroboros-consensus-cardano`

* In `Ouroboros.Consensus.Cardano.Block`, include `AlonzoEra` in
`CardanoShelleyEras`. Update all the pattern synonyms in the module with the
new era. Don't forget to update the comments, the `COMPLETE` pragmas, and the
* In `Ouroboros.Consensus.Cardano.Block`, include `AlonzoEra` in `CardanoShelleyEras` and
`ShelleyBasedLedgerEras`. Update all the pattern synonyms in the module with the new era.
Don't forget to update the comments, the `COMPLETE` pragmas, and the
export lists. It's easy to forget a case and the compiler will likely not warn
you, you'll notice it when trying to use the pattern synonyms.

* In `Ouroboros.Consensus.Cardano.Ledger`, add new data constructors to `CardanoTxOut`.
Follow the pattern-matching failures to update the use sites.

* In `Ouroboros.Consensus.Cardano.CanHardFork`, update
`CardanoHardForkConstraints`, add additional translations to the `CanHardFork`
instance.
Expand All @@ -92,6 +80,39 @@ be adding is the Alonzo era, which comes after the Mary era.
add the extra arguments needed for `protocolInfoCardano` to the
`ProtocolCardano` constructor. Update `protocolInfo` accordingly.

* In `Cardano.Node.Types`, add a field for the new era into the `NodeHardForkProtocolConfiguration` record.

### CDDLs

The various entities, such as block headers, block bodies, transactions, etc. need to be serialised for on-disk storage and over-the-wire transmission. Adding an era changes the serialised representation, and thus the CDDL specs need to change as well.

* In `Test.Consensus.Cardano.GenCDDLs`, modify the `setupCDDLCEnv` function to bring the new era's CDDL in scope from Ledger. It could be the case that the new era is empty for now, and Ledger does not yet provide a CDDL. In this case, the new era's CDDL should be a copy of the previous era's one.
* In `Test.Consensus.Cardano.GenCDDLs`, possibly modify the `fixupBlockCDDL` function, adding a new `sed` replacement. These calls to `sed` are intended to be a temporary hack to fix-up the Ledger-provided CDDLs and will hopefully be removed soon.
* In `ouroboros-consensus-cardano/cddl/disk`, update the on-disk representation.
* In `ouroboros-consensus-cardano/cddl/node-to-node`, update the over-the-wire representation.

For feedback, run the CDDL tests:

```sh
cabal test cardano-test --test-options '-p "CDDL"'
```

These test serialise blocks, headers, transactions and transactions IDs into CDOR, and then validate the resulting binary blobs against the CDDL specs.

Failing golden tests will produce several files in the `ouroboros-consensus-cardano/failing_cddl_tests` directory, for example:

| Filename | Description |
|:----------------------------------------------|:------------------------------------------------------------------|
| serialisedCardanoBlock_failing.cbor | The binary CBOR term that failed the test |
| serialisedCardanoBlock_failing.cddl | The complete CDDL spec that was used to validate the above term |
| call_cuddle_serialisedCardanoBlock_failing.sh | The call to the `cuddle` tool to reproduce the validation failure |

Assuming the `cuddle` and `pretty-simple` executable are available, the `cuddle` failure could be pretty-printed as follows:

```sh
bash ouroboros-consensus-cardano/failing_cddl_tests/call_cuddle_serialisedCardanoBlock_failing.sh 2>&1 | pretty-simple
```

### `test`

* In `Test.Consensus.Cardano.Serialisation`, update `testCodecCfg` and
Expand All @@ -107,15 +128,23 @@ be adding is the Alonzo era, which comes after the Mary era.

* Run the golden tests
(`cabal run ouroboros-consensus-cardano:cardano-test -- -p /Golden/`).
Golden test results should have been created for the new Cardano versions.
Golden test results should have been created for the new Cardano versions.
Don't forget to commit those files, otherwise they will be recreated on each
run in CI and not compared against the previous results, rendering them
useless.
run in CI and not compared against the previous results, rendering them
useless.

* Extend `Test.ThreadNet.Cardano` with the new era.

#### `unstable-shelley-testlib`

* In `Test.Consensus.Shelley.Examples`, define an `examplesAlonzo` similar to
how `examplesMary` is defined. If necessary, i.e., when new type families have
been created in the ledger (e.g., `TxOut`), the `examples` function might have
to take more arguments. This is where the golden test examples are defined,
but only the Shelley ones are tested as part of this test suite. The others
are only tested as part of the `ouroboros-consensus-cardano-test` test suite.

### `unstable-cardano-testlib`
#### `unstable-cardano-testlib`

* In `Test.Consensus.Cardano.Generators`, update `arbitraryNodeToNode`,
`arbitraryNodeToClient`. Try to understand the logic of these two, you will
Expand Down
1 change: 1 addition & 0 deletions nix/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ hsPkgs.shellFor {
pkgs.fourmolu
pkgs.cuddle
pkgs.cddlc
pkgs.pretty-simple

# release management
pkgs.scriv
Expand Down
10 changes: 6 additions & 4 deletions ouroboros-consensus-cardano/cddl/base.cddl
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
telescope7<byron, shelley, allegra, mary, alonzo, babbage, conway>
= [pastEra, pastEra, pastEra, pastEra, pastEra, pastEra, currentEra<conway>] /
telescope8<byron, shelley, allegra, mary, alonzo, babbage, conway, dijkstra>
= [pastEra, pastEra, pastEra, pastEra, pastEra, pastEra, pastEra, currentEra<dijkstra>] /
[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] /
ns8<byron, shelley, allegra, mary, alonzo, babbage, conway, dijkstra>
= [7, dijkstra] /
[6, conway] /
[5, babbage] /
[4, alonzo] /
[3, mary] /
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ headerState =
[withOrigin<headerStateTip>, headerStateChainDep]

headerStateTip =
ns7<byronAnnTip, annTip, annTip, annTip, annTip, annTip, annTip>
ns8<byronAnnTip, annTip, annTip, annTip, annTip, annTip, annTip, annTip>

byronAnnTip = [slotno,
hash,
Expand All @@ -14,15 +14,16 @@ annTip = [slotno,
blockno]

headerStateChainDep =
telescope7<versionedPbftState,
telescope8<versionedPbftState,
versionedTPraosState,
versionedTPraosState,
versionedTPraosState,
versionedTPraosState,
versionedPraosState,
versionedPraosState,
versionedPraosState>

;# import withOrigin, ns7, telescope7, slotno, hash, blockno from base
;# import withOrigin, ns8, telescope8, slotno, hash, blockno from base
;# import versionedPbftState from pbft
;# import versionedPraosState from praos
;# import versionedTPraosState from tpraos
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
ledgerState =
telescope7<byron.ledgerstate,
telescope8<byron.ledgerstate,
versionedShelleyLedgerState<shelley.ledgerstate>,
versionedShelleyLedgerState<allegra.ledgerstate>,
versionedShelleyLedgerState<mary.ledgerstate>,
versionedShelleyLedgerState<alonzo.ledgerstate>,
versionedShelleyLedgerState<babbage.ledgerstate>,
versionedShelleyLedgerState<conway.ledgerstate>>
versionedShelleyLedgerState<conway.ledgerstate>,
versionedShelleyLedgerState<dijkstra.ledgerstate>>

versionedShelleyLedgerState<eraSt1> = [ shelleyVersion2, shelleyLedgerState<eraSt1> ]

Expand All @@ -26,5 +27,6 @@ mary.ledgerstate = any
alonzo.ledgerstate = any
babbage.ledgerstate = any
conway.ledgerstate = any
dijkstra.ledgerstate = any

;# import telescope7, withOrigin, slotno, blockno, hash, word32 from base
;# import telescope8, withOrigin, slotno, blockno, hash, word32 from base
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ cardanoBlock = byron.block
/ [5, alonzo.block]
/ [6, babbage.block]
/ [7, conway.block]
/ [8, dijkstra.block]

;# import byron as byron
;# import shelley as shelley
Expand All @@ -15,3 +16,4 @@ cardanoBlock = byron.block
;# import alonzo as alonzo
;# import babbage as babbage
;# import conway as conway
;# import dijkstra as dijkstra
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
header
= base.ns7<byronHeader,
= base.ns8<byronHeader,
serialisedShelleyHeader<shelley.header>,
serialisedShelleyHeader<allegra.header>,
serialisedShelleyHeader<mary.header>,
serialisedShelleyHeader<alonzo.header>,
serialisedShelleyHeader<babbage.header>,
serialisedShelleyHeader<conway.header>>
serialisedShelleyHeader<conway.header>,
serialisedShelleyHeader<dijkstra.header>>

byronHeader = [byronRegularIdx, #6.24(bytes .cbor byron.blockhead)]
/ [byronBoundaryIdx, #6.24(bytes .cbor byron.ebbhead)]
Expand All @@ -22,4 +23,5 @@ serialisedShelleyHeader<era> = #6.24(bytes .cbor era)
;# include alonzo as alonzo
;# include babbage as babbage
;# include conway as conway
;# include dijkstra as dijkstra
;# import base as base
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
tx =
base.ns7<byron.transaction,
base.ns8<byron.transaction,
serialisedShelleyTx<shelley.transaction>,
serialisedShelleyTx<allegra.transaction>,
serialisedShelleyTx<mary.transaction>,
serialisedShelleyTx<alonzo.transaction>,
serialisedShelleyTx<babbage.transaction>,
serialisedShelleyTx<conway.transaction>>
serialisedShelleyTx<conway.transaction>,
serialisedShelleyTx<dijkstra.transaction>>

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

Expand All @@ -20,4 +21,5 @@ byron.transaction = [0, [byron.tx, [+ byron.twit]]] / [1, any] / [2, any] / [3,
;# include alonzo as alonzo
;# include babbage as babbage
;# include conway as conway
;# include dijkstra as dijkstra
;# import base as base
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
; TODO(geo2a): why are this order? Why babbage is last?
txId =
base.ns7<byronTxId,
base.ns8<byronTxId,
shelley.transaction_id,
allegra.transaction_id,
mary.transaction_id,
alonzo.transaction_id,
conway.transaction_id,
dijkstra.transaction_id,
babbage.transaction_id>

byronTxId = [0, byron.txid]
Expand All @@ -19,4 +21,5 @@ byronTxId = [0, byron.txid]
;# include alonzo as alonzo
;# include babbage as babbage
;# include conway as conway
;# include dijkstra as dijkstra
;# import base as base
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!--
### Patch

- A bullet item for the Patch category.

-->
<!--
### Non-Breaking

- A bullet item for the Non-Breaking category.

-->

### Breaking

- Add Dijkstra era
- Add dependency on the new Dijkstra Ledger package:
- `cardano-ledger-dijkstra`: `^>=0.1`
Binary file not shown.

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

Binary file not shown.
Binary file not shown.

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

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

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

Binary file not shown.

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

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

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

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

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

Binary file not shown.

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

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

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

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

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

Binary file not shown.

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

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

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

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

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

Binary file not shown.

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

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

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

Binary file not shown.

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

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

Binary file not shown.

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

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

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

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

Binary file not shown.
Loading
Loading