Skip to content

Drastically reduce the cardano-api vendored modules in preparation for dependency inversion - #2082

Closed
jasagredo wants to merge 2 commits into
f-f/prepare-11.1from
js/port-cardano-api
Closed

Drastically reduce the cardano-api vendored modules in preparation for dependency inversion#2082
jasagredo wants to merge 2 commits into
f-f/prepare-11.1from
js/port-cardano-api

Conversation

@jasagredo

Copy link
Copy Markdown
Contributor

Subtle errors are lurking in these functions. This is preparatory work for cardano-api to get these definitions from Consensus instead of Consensus vendoring modules that get out of data.

Based on #2043

@jasagredo jasagredo self-assigned this Jun 18, 2026
@jasagredo jasagredo moved this to 🏗 In progress in Consensus Team Backlog Jun 18, 2026
@f-f
f-f force-pushed the f-f/prepare-11.1 branch from 0411b4d to e6fad06 Compare June 18, 2026 14:32
Add a minimal, Consensus-native implementation of the cardano-api and
cardano-node functionality that the db-tools need (reading genesis files,
loading forging credentials, assembling a Cardano protocol), so that the
unstable-cardano-tools sublib no longer has to vendor copies of those
modules.

This lives in a small namespace in the cardano sublib:

  * Ouroboros.Consensus.Cardano.Api.Serialise -- HasTypeProxy/AsType, raw
    bytes and CBOR (de)serialisation, Error/FileError, the TextEnvelope
    file reader and the deriving-via helpers.
  * Ouroboros.Consensus.Cardano.Api.Keys -- the Key interface and the four
    key roles actually used (StakePoolKey, VrfKey, UnsoundPureKesKey,
    ByronKey), plus OperationalCertificate.
  * Ouroboros.Consensus.Cardano.Api.Genesis -- GenesisFile/GenesisHash,
    ProtocolFilepaths, the polymorphic genesis reader shared by the
    Shelley-based eras, the Byron genesis reader, the Byron and Praos
    leader-credential loaders and genesisHashToPraosNonce.

Only the surface transitively reachable from what the tools call is kept:
bech32, the unused key roles, key generation, cast-role classes, the
operational-certificate issue counter and the dead genesis validation are
all omitted.
…red copies

Point the db-tools at the new Ouroboros.Consensus.Cardano.Api.* modules and
remove the vendored cardano-api/cardano-node copies:

  * mkConsensusProtocolCardano now imports the genesis readers, credential
    loaders, genesisHashToPraosNonce and error types from
    Ouroboros.Consensus.Cardano.Api.Genesis, and Error/displayError from
    Ouroboros.Consensus.Cardano.Api.Serialise.
  * Cardano.Node.Types keeps only the per-era protocol configuration
    records (the inputs to mkConsensusProtocolCardano) and re-exports
    GenesisFile/GenesisHash/ProtocolFilepaths from the sublib.
  * DBSynthesizer.Run gets displayError from the sublib.

Delete the now-unused vendored Cardano.Api.* and
Cardano.Node.Protocol.{Byron,Shelley,Alonzo,Conway} modules, and drop the
build-depends (base16-bytestring, cardano-crypto) that only they used.
@jasagredo
jasagredo force-pushed the js/port-cardano-api branch from e36095c to f07e465 Compare June 18, 2026 17:18
@jasagredo

Copy link
Copy Markdown
Contributor Author

Superseded by #2087

@jasagredo jasagredo closed this Jun 19, 2026
@github-project-automation github-project-automation Bot moved this from 🏗 In progress to ✅ Done in Consensus Team Backlog Jun 19, 2026
@jasagredo
jasagredo deleted the js/port-cardano-api branch June 19, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

1 participant