Skip to content

fix(configs): read the extraConfig block of a shelley genesis - #797

Open
geofflittle wants to merge 1 commit into
txpipe:mainfrom
geofflittle:fix/genesis-extra-config
Open

fix(configs): read the extraConfig block of a shelley genesis#797
geofflittle wants to merge 1 commit into
txpipe:mainfrom
geofflittle:fix/genesis-extra-config

Conversation

@geofflittle

@geofflittle geofflittle commented Sep 9, 2026

Copy link
Copy Markdown

What?

This PR adds an injection module that reads the extraConfig block of a shelley genesis file. For each field in the file, it picks between the new injected value and the old top level value. It uses whichever holds entries (injected or top level) and refuses if both do. The shelley parser uses it for the three fields that can appear in extraConfig: initial funds, stake pools, and stake credentials.

The PR also has Pool entries now parse under the poolId and accountAddress names, which are the ledger's current names for those fields (as well as still parsing the old publicKey and rewardAccount).

Why?

cardano-cli 11.2.0.0 changed the format of the generated genesis file. It now has initial funds, pools, credentials, delegations, and initial DReps under extraConfig in the shelley and conway files and leaves the old top level fields empty (changelog at the tag, marked breaking). pallas-configs reads only the top level and not the changed injected fields, so pallas parses a genesis written by current tooling without error, reads it as empty, and so yields a chain that has no funds and no pools.

The published Musashi shelley genesis is a file generated by the new tool (pinned copy, blake2b-256 735d3f9f1f79066ead4ef7df4ac7e6ed25e8d78b7b9c7e5ec5ee1b88476e1c3f, which is the ShelleyGenesisHash its config.json declares). All 30000000900000000 lovelace of its supply is under extraConfig, its byron genesis has no funds at all and pallas main parses it to yield zero utxos.

Testing done

Added tests. One loads that Musashi genesis, asserts its top level initialFunds is empty, and asserts the utxos computed from it add up to the full 30000000900000000 lovelace. The rest use a fixture generated by cardano-cli 11.2.2.0 genesis create-testnet-data and committed exactly as the tool wrote it. The injection-vs-top-level resolve rule is tested case by case, each of the three shelley fields is tested end to end including its refusal, and the four existing fixtures still parse to what they did before.

$ cargo test -p pallas-configs
running 43 tests
test result: ok. 43 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.05s

Notes

Three places this change deliberately differs from how the ledger resolves the same fields:

  • A file injection, one that names a separate file and its hash instead of holding the data inline, is refused rather than read. This would've caused a larger change that would require the parser to need to know about the path to the file that seemed unnecessary to add to this PR.
  • A pool entry that carries both the old and the new name for a field is accepted, preferring the new one, which is what the ledger does. A serde alias would have rejected it as a duplicate field.

Summary by CodeRabbit

  • New Features
    • Added support for Shelley genesis data supplied through extraConfig, including initial funds, stake pools, and stake credentials.
    • Added compatibility for legacy and current stake pool field names.
    • Added validation for conflicting, incomplete, or unsupported injected configuration sources.
  • Documentation
    • Documented the new configuration injection support.
  • Tests
    • Added comprehensive coverage for injection handling, validation, pool field compatibility, and representative Shelley genesis configurations.

- injection.rs: the arms, and one populated source or a refusal
- shelley.rs: fold the three fields, prefer the current pool names
- refuse an extraConfig key or an injection key nothing reads
@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 3aa7f608-be93-4d1d-978f-37208a85c1d3

📥 Commits

Reviewing files that changed from the base of the PR and between 6537096 and 215bd9b.

📒 Files selected for processing (6)
  • pallas-configs/README.md
  • pallas-configs/src/injection.rs
  • pallas-configs/src/lib.rs
  • pallas-configs/src/shelley.rs
  • test_data/generated-shelley-genesis.json
  • test_data/musashi-shelley-genesis.json

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

Adds shared extraConfig injection handling for Shelley genesis data. The parser now folds embedded values into top-level fields, supports current and legacy pool keys, rejects conflicting or file-based injections, and adds fixtures and tests.

Changes

Shelley genesis injection

Layer / File(s) Summary
Injection contract and public module
pallas-configs/src/injection.rs, pallas-configs/src/lib.rs, pallas-configs/README.md
Adds Injection<T>, resolve, deserialization validation, public module exposure, documentation, and unit tests.
Shelley parsing and value folding
pallas-configs/src/shelley.rs
Adds ExtraConfig, folds injected funds, pools, and credentials into GenesisFile, reconstructs staking data, and reconciles current and legacy pool field names.
Fixture coverage and integration validation
pallas-configs/src/shelley.rs, test_data/*.json
Adds generated and Musashi fixtures plus tests for injection folding, fallback behavior, conflicts, file injections, pool parsing, and staking state.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to 215bd

The Shelley genesis compatibility update is covered across new and existing fixture shapes, with no actionable merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 73.91% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 46 functions across 3 files. (3 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding support for reading the Shelley genesis extraConfig block.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 73.91% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 46 functions across 3 files. (3 skipped: 3 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant