cardano-rpc: Add ReadGenesis method - #1277
Open
carbolymer wants to merge 5 commits into
Open
Conversation
carbolymer
marked this pull request as ready for review
August 4, 2026 14:22
carbolymer
requested review from
CarlosLopezDeLara,
Jimbo4350,
disassembler,
erikd and
palas
as code owners
August 4, 2026 14:22
carbolymer
force-pushed
the
mgalazyn/feature/rpc-add-readgenesis-method
branch
from
August 4, 2026 14:25
34a5576 to
6588f07
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Implements the UTxO RPC QueryService.ReadGenesis endpoint in cardano-rpc, sourcing per-era genesis configuration from in-process node kernel access (boot-time parsed configs) and exposing it over gRPC along with a Shelley genesis hash and CAIP-2 chain identifier.
Changes:
- Add
ReadGenesisto the QueryService proto and generated bindings, wire it into the server, and implementreadGenesisMethod. - Introduce a
GenesisBundlein node-kernel access and a newUtxoRpc.Type.Genesismapper to populate the full per-eracardano.Genesismessage (Byron/Shelley/Alonzo/Conway). - Add fixture-based and property-based tests plus genesis JSON fixtures to validate mapping/encoding.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Query.hs | Implements readGenesisMethod, CAIP-2 derivation, and returns genesis hash + mapped config. |
| cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type/Genesis.hs | New conversion module mapping per-era ledger genesis/params into the U5c.Genesis proto. |
| cardano-rpc/src/Cardano/Rpc/Server/NodeKernelAccess/Type.hs | Adds GenesisBundle and stores genesis config in NodeKernelAccess. |
| cardano-rpc/src/Cardano/Rpc/Server/NodeKernelAccess.hs | Changes mkNodeKernelAccess to accept boot-time inputs and builds GenesisBundle. |
| cardano-rpc/src/Cardano/Rpc/Server/Internal/Tracing.hs | Adds new trace constructors for ReadGenesis and node-kernel-access events. |
| cardano-rpc/src/Cardano/Rpc/Server.hs | Registers ReadGenesis handler and wraps it in a tracing span. |
| cardano-rpc/proto/utxorpc/v1beta/query/query.proto | Adds rpc ReadGenesis(...) to QueryService. |
| cardano-rpc/gen/Proto/Utxorpc/V1beta/Query/Query.hs | Regenerated service bindings to include ReadGenesis. |
| cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type/Certificate.hs | Factors constitution conversion into a shared helper (reused by genesis mapping). |
| cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type/Governance.hs | Uses the new constitution helper. |
| cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Type.hs | Re-exports genesisBundleToProto. |
| cardano-rpc/cardano-rpc.cabal | Adds new module and dependencies; extends test-suite deps and modules. |
| cardano-rpc/test/cardano-rpc-test/Test/Cardano/Rpc/Genesis/Fixture.hs | Differential tests against real (trimmed) mainnet genesis JSON fixtures. |
| cardano-rpc/test/cardano-rpc-test/Test/Cardano/Rpc/Genesis/Property.hs | Structural property tests for all era mappers with bounded generators/clipping. |
| cardano-rpc/test/cardano-rpc-test/files/genesis/byron-genesis.json | Byron genesis fixture. |
| cardano-rpc/test/cardano-rpc-test/files/genesis/shelley-genesis.json | Shelley genesis fixture. |
| cardano-rpc/test/cardano-rpc-test/files/genesis/alonzo-genesis.json | Alonzo genesis fixture. |
| cardano-rpc/test/cardano-rpc-test/files/genesis/conway-genesis.json | Conway genesis fixture. |
| cardano-rpc/test/cardano-rpc-test/cardano-rpc-test.hs | Adjusts tasty-discover options. |
| cardano-api/src/Cardano/Api/LedgerState.hs | Exports readShelleyGenesis + error types for downstream use. |
| cardano-api/src/Cardano/Api/Consensus.hs | Re-exports additional consensus helpers needed for node-kernel threading. |
| cardano-api/src/Cardano/Api/Consensus/Internal/Protocol.hs | Exposes helpers to extract transition config / Byron params from protocol args. |
| cardano-api/src/Cardano/Api/Consensus/Internal/Reexport.hs | Re-exports shelleyLedgerGenesis. |
| .changes/20260804_cardano_rpc_readgenesis.yml | Changelog fragment for cardano-rpc ReadGenesis work. |
| .changes/20260804_cardano_api_readgenesis_reexports.yml | Changelog fragment for cardano-api export/re-export additions. |
Comment on lines
+169
to
+173
| -- | Handle the @ReadGenesis@ RPC method. | ||
| -- Returns the chain's identity - the Shelley genesis hash and the CAIP-2 chain | ||
| -- identifier - together with the @cardano@ config, the Byron, Shelley, Alonzo | ||
| -- and Conway genesis parameters mapped by 'genesisBundleToProto'. | ||
| readGenesisMethod |
Comment on lines
+3
to
+6
| kind: | ||
| - feature | ||
| description: | | ||
| Add the `QueryService.ReadGenesis` UTxO RPC method, returning the full per-era genesis configuration. |
Jimbo4350
approved these changes
Aug 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Implements the UTxO RPC
QueryService.ReadGenesismethod in cardano-rpc.Fixes #1217.
The response carries:
genesis- the Blake2b-256 hash of the raw Shelley genesis file bytes, matching what Dolos returns and what cardano-node itself computes at startup.caip2- a chain identifier keyed on the Shelley network magic:cardano:mainnet,cardano:preprod,cardano:preview, orcardano:<magic>for other networks (matches Dolos, since the spec leaves the format open).cardano- the full per-era genesis configuration: Byron (proto fields 1-9), Shelley (10-23, includinginitial_funds), Alonzo (24-31) and Conway (32-42), withcost_modelscomposed from Alonzo's PlutusV1 and Conway's PlutusV3 models.The handler performs no disk reads: all genesis data comes from values cardano-node already parsed at boot, threaded into
mkNodeKernelAccessviaProtocolInfoArgs(whoseTransitionConfigretains the full, uncompactedShelleyGenesis- consensus's own copy erasessgInitialFunds/sgStaking) and a Shelley genesis hash returned alongsideSomeConsensusProtocol. The cardano-node side of that threading is a separate cardano-node PR.How to trust this PR
Regenerate proto codecommit can be skipped when reviewing.Test.Cardano.Rpc.Genesis.Fixtureproves the wire encodings byte-for-byte against trimmed mainnet genesis JSON parsed with the ledger's own readers (AVVM base64 keys, base58 Byron addresses, hex hashes,LovelacePortionnumerators, the seconds-to-millisecondsslotLengthconversion).Test.Cardano.Rpc.Genesis.Propertychecks structural correspondence of all four era mappers on arbitrary ledger-generated genesis values (map sizes, key sets, exact rational numerators/denominators).TASTY_PATTERN='/RPC ReadGenesis/' cabal test cardano-testnet-test, in the cardano-node PR) starts a testnet with RPC enabled and assertsinitial_fundsis non-empty - which only holds if the uncompacted boot-time genesis reaches the wire.TASTY_PATTERN='genesis' cabal test cardano-rpc-test.Checklist
.changes/