Skip to content

cardano-rpc: resolve genesis initial funds from sgExtraConfig - #1305

Open
carbolymer wants to merge 1 commit into
masterfrom
mgalazyn/fix/rpc-initial-funds-extraconfig
Open

cardano-rpc: resolve genesis initial funds from sgExtraConfig#1305
carbolymer wants to merge 1 commit into
masterfrom
mgalazyn/fix/rpc-initial-funds-extraconfig

Conversation

@carbolymer

Copy link
Copy Markdown
Contributor

Context

The UTxO RPC ReadGenesis response reported an empty initial_funds map for any network created with cardano-cli create-testnet-data.

create-testnet-data provisions wallets by writing their funded addresses into the Shelley genesis' sgExtraConfig.secInitialFunds, leaving the legacy sgInitialFunds field empty, but cardano-rpc's ReadGenesis handler read only sgInitialFunds.

This fixes it by resolving initial funds at GenesisBundle construction time using ledger's own resolveInjectionSource/foldInjectionData, via the SomeHasFS that ProtocolInfoArgsCardano already carries but was previously discarded. Both EmbeddedInjection and InjectionFromFile are handled, including hash verification for the latter.

As a consequence, mkNodeKernelAccess and readGenesisBundle are now monad-polymorphic under (MonadST m, MonadThrow m) rather than pinned to IO, unifying the ProtocolInfoArgs monad with the ambient one. This strengthens the exported signature, hence the breaking changelog kind alongside bugfix.

The bug was caught by the ReadGenesis integration test added in cardano-node PR #6655. A stacked cardano-node PR re-enabling the initialFunds assertion against this branch will follow once it can be pushed.

How to trust this PR

Consumed via a temporary source-repository-package stanza in cardano-node's cabal.project pointing at this branch's head commit, the stacked PR mentioned above will demonstrate the fix against the real integration test.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details - no cardano-api-level test is added; coverage is the ReadGenesis integration test in the stacked cardano-node PR
  • Self-reviewed the diff
  • Changelog fragment added in .changes/

@carbolymer
carbolymer requested a review from Jimbo4350 as a code owner August 20, 2026 13:42
Copilot AI lite review requested due to automatic review settings August 20, 2026 13:42
@carbolymer carbolymer self-assigned this Aug 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes cardano-rpc’s ReadGenesis behavior so initial_funds is correctly populated for networks produced by cardano-cli create-testnet-data, where funds are stored via sgExtraConfig.secInitialFunds rather than legacy sgInitialFunds. The change resolves initial funds during GenesisBundle construction using the ledger’s injection resolution APIs, and adjusts exported types accordingly.

Changes:

  • Resolve Shelley genesis initial funds from sgExtraConfig.secInitialFunds (including EmbeddedInjection and InjectionFromFile with hash verification) when constructing the GenesisBundle.
  • Make mkNodeKernelAccess / readGenesisBundle monad-polymorphic with (MonadST m, MonadThrow m) and unify the ProtocolInfoArgs monad with the ambient monad.
  • Update cardano-rpc library dependencies to include fs-api and io-classes.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
cardano-rpc/src/Cardano/Rpc/Server/NodeKernelAccess.hs Resolves Shelley initial funds via ledger injection resolution during genesis bundle construction; updates exported mkNodeKernelAccess signature accordingly.
cardano-rpc/cardano-rpc.cabal Adds fs-api and io-classes to support SomeHasFS usage and MonadST/MonadThrow constraints.
.changes/20260820_cardano_rpc_genesis_initial_funds_extraconfig.yml Adds a changelog fragment documenting the bugfix + breaking signature change.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +133 to +140
initialFundsSource <-
L.resolveInjectionSource
"initialFunds"
(L.sgExtraConfig genesis)
L.secInitialFunds
(L.sgInitialFunds genesis)
resolvedInitialFunds <-
Exts.fromList <$> L.foldInjectionData hasFS initialFundsSource (flip (:)) []
@@ -0,0 +1,10 @@
project: cardano-rpc

pr: 0
@carbolymer
carbolymer force-pushed the mgalazyn/fix/rpc-initial-funds-extraconfig branch from 444e652 to 518ecea Compare August 20, 2026 13:57
@carbolymer
carbolymer force-pushed the mgalazyn/fix/rpc-initial-funds-extraconfig branch from 8d2154b to c0d48b9 Compare August 20, 2026 14:27
@carbolymer
carbolymer force-pushed the mgalazyn/fix/rpc-initial-funds-extraconfig branch from c0d48b9 to 39619bb Compare August 20, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants