Skip to content

feat(network): prep for van Rossem hard fork (NodeToClient v17–v23)#747

Merged
scarmuega merged 3 commits into
mainfrom
feat/van-rossem-network-prep
May 4, 2026
Merged

feat(network): prep for van Rossem hard fork (NodeToClient v17–v23)#747
scarmuega merged 3 commits into
mainfrom
feat/van-rossem-network-prep

Conversation

@scarmuega
Copy link
Copy Markdown
Member

@scarmuega scarmuega commented May 3, 2026

Summary

  • Catches the Node-to-Client handshake up to NodeToClientV_23 (the cardano-node 10.7.x line targeted for the van Rossem hard fork to protocol version 11).
  • Adds the new LocalStateQuery BlockQuery variants introduced between v17 and v23: GetPoolDistr2, GetStakeDistribution2, GetDRepsDelegations, and GetLedgerPeerSnapshot(kind) (with legacy single-element GetBigLedgerPeerSnapshot preserved and disambiguated by array length on decode).
  • Aligns ConwayLedgerFailure with the cardano-ledger 10.7 line: replaces the U8(u8) backward-compat placeholder at tag 8 with the real WithdrawalsMissingAccounts variant and adds IncompleteWithdrawals at tag 9. pallas-hardano Haskell-display formatter updated to match.

Van Rossem is intra-Conway, so this is a network-stack-only change. pallas-primitives and pallas-traverse need nothing — CostModels (Vec<i64> + extensible unknown) absorbs longer V1/V2/V3 cost vectors automatically, the Conway CDDL already accepts major_protocol_version = 11, and Plutus V4 is a Dijkstra-era concern, not van Rossem.

LedgerPeerSnapshot stays typed as AnyCbor, so the v22 SRV-record additions and the v23 snapshot CBOR encoding change pass through opaquely.

Wire shapes were derived from the upstream Haskell encoders (encodeShelleyQuery, ConwayLedgerPredFailure EncCBOR).

Test plan

  • cargo check --workspace clean
  • cargo test -p pallas-network --lib (240 passed)
  • cargo test -p pallas-hardano --lib (13 passed)
  • New test_post_v16_block_queries_roundtrip — encode/decode self-consistency for the four new BlockQuery variants
  • New test_post_v16_block_queries_wire_shape — asserts the exact CBOR envelope (e.g. [34, 0] = 82182200, [37] = 811825) against the upstream encodeShelleyQuery shape
  • Integration smoke against a live cardano-node 10.7.x preview/preprod node (out of scope for this PR; wire shapes derived from the upstream Haskell sources)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Support for blockchain protocol versions 17-23
    • New ledger peer snapshot query capabilities
    • Additional distribution query types
  • Bug Fixes

    • Enhanced withdrawal error reporting with specific failure types
  • Tests

    • Added codec validation tests for new query variants

Catches the Node-to-Client handshake up to NodeToClientV_23 (the cardano-node
10.7.x release line targeted for the van Rossem hard fork) and aligns the
LocalStateQuery and LocalTxSubmission codecs with the matching upstream
additions.

* handshake/n2c: add PROTOCOL_V17..V23 constants, extend v1_and_above and
  v10_and_above so newer cardano-node peers negotiate above V_16.
* localstate BlockQuery: add GetPoolDistr2 (v21), GetStakeDistribution2 (v21),
  GetDRepsDelegations (v23), and a new GetLedgerPeerSnapshot(kind) variant
  that encodes the v15+ two-element form of tag 34 (legacy
  GetBigLedgerPeerSnapshot is preserved for older peers and disambiguated by
  array length on decode). Replace the unreachable!() catch-all with a
  proper decode error.
* localtxsubmission ConwayLedgerFailure: replace the U8(u8) backward-compat
  placeholder at tag 8 with the real WithdrawalsMissingAccounts variant the
  ledger 10.7 line introduced, and add IncompleteWithdrawals at tag 9.
* pallas-hardano haskell_display: cover the two new ConwayLedgerFailure
  variants in the Haskell-style formatter.

LedgerPeerSnapshot stays typed as AnyCbor, so the v22 SRV-record additions
and v23 encoding change pass through opaquely. pallas-primitives and
pallas-traverse need no changes for this hard fork (intra-Conway, no new
transaction shape, no PlutusV4 — that lands in Dijkstra).

Wire shapes are derived from the upstream Haskell encoders
(encodeShelleyQuery, ConwayLedgerPredFailure EncCBOR). Roundtrip and
wire-shape unit tests assert codec self-consistency; byte-for-byte
agreement with a live 10.7 node should be confirmed at integration time.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 3, 2026

Warning

Rate limit exceeded

@scarmuega has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 29 minutes and 18 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c1107d6b-caf1-494f-9260-93e0b4265cea

📥 Commits

Reviewing files that changed from the base of the PR and between 27763e4 and 2f5cc60.

📒 Files selected for processing (4)
  • pallas-network/src/miniprotocols/localstate/queries_v16/codec.rs
  • pallas-network/src/miniprotocols/localstate/queries_v16/mod.rs
  • pallas-network/src/miniprotocols/localtxsubmission/protocol.rs
  • pallas-network2/src/protocol/handshake/n2c.rs
📝 Walkthrough

Walkthrough

The PR extends Cardano protocol support by adding withdrawal failure variants to ConwayLedgerFailure, introducing new ledger query types (GetLedgerPeerSnapshot, GetPoolDistr2, GetStakeDistribution2, GetDRepsDelegations), implementing their CBOR codec logic, and adding protocol version constants V17–V23 to the handshake version tables.

Changes

Withdrawal Variants & Display

Layer / File(s) Summary
Data Shape
pallas-network/src/miniprotocols/localtxsubmission/protocol.rs
ConwayLedgerFailure replaces the generic U8(u8) catch-all (tag 8) with two explicit withdrawal-related variants: WithdrawalsMissingAccounts (tag 8, containing missing account/coin map) and IncompleteWithdrawals (tag 9, containing account/coin pair map). Documentation updated to note tags 8–9 were added in cardano-ledger 10.7.
Display Formatting
pallas-hardano/src/display/haskell_display.rs
HaskellDisplay for ConwayLedgerFailure match arms updated to format the new WithdrawalsMissingAccounts and IncompleteWithdrawals variants using to_haskell_str_p(), with the old U8(v) arm removed.

Ledger Queries & Protocol Versions

Layer / File(s) Summary
Query Type Definitions
pallas-network/src/miniprotocols/localstate/queries_v16/mod.rs
BlockQuery enum gains four new variants: GetLedgerPeerSnapshot(LedgerPeerSnapshotKind), GetPoolDistr2(SMaybe<Pools>), GetStakeDistribution2, and GetDRepsDelegations(TaggedSet<DRep>). New LedgerPeerSnapshotKind enum introduced with All=0 and Big=1 discriminants.
CBOR Codec Implementation
pallas-network/src/miniprotocols/localstate/queries_v16/codec.rs
Encoding/decoding logic extended: tag 34 now encodes GetLedgerPeerSnapshot as a two-element array with discriminator; tags 36, 37, 39 added for new query variants. Decoding handles tag 34 as overloaded form (legacy single-element array maps to GetBigLedgerPeerSnapshot; two-element array with discriminator maps to GetLedgerPeerSnapshot). New roundtrip and wire-shape tests verify encode/decode correctness and exact CBOR byte outputs.
Protocol Version Support
pallas-network/src/miniprotocols/handshake/n2c.rs
Protocol version constants PROTOCOL_V17PROTOCOL_V23 added, with corresponding entries in VersionTable::v1_and_above and VersionTable::v10_and_above, each mapping to VersionData(network_magic, Some(false)).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

Poem

🐰 New protocols hop and bound,
With queries dancing all around,
Withdrawals tracked, no catch-all catch,
Each tag and byte a perfect match—
The Cardano trail grows ever bright! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately captures the main objective of the PR: preparing for the van Rossem hard fork by adding support for Node-to-Client protocol versions 17–23.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/van-rossem-network-prep

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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
Review rate limit: 0/1 reviews remaining, refill in 29 minutes and 18 seconds.

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pallas-network/src/miniprotocols/localstate/queries_v16/codec.rs`:
- Around line 903-965: Add explicit wire-shape assertions for the missing tags:
add a test in test_post_v16_block_queries_wire_shape that encodes
BlockQuery::GetPoolDistr2 and asserts the hex equals the exact CBOR bytes for
tag 36 (match the style used for 34/37, expected "811824"), and add another
assertion that encodes
BlockQuery::GetDRepsDelegations(TaggedSet::from(BTreeSet::new())) and compares
it to the exact expected hex for tag 39 with an empty TaggedSet payload (follow
the same pattern as the GetLedgerPeerSnapshot and GetStakeDistribution2
assertions to pin the discriminant). Ensure you reference
BlockQuery::GetPoolDistr2, BlockQuery::GetDRepsDelegations and TaggedSet when
adding these two assertions.

In `@pallas-network/src/miniprotocols/localstate/queries_v16/mod.rs`:
- Around line 77-90: The module still exposes legacy helper functions
(get_big_ledger_snapshot, get_pool_distr, get_stake_distribution) but the enum
now has new variants GetLedgerPeerSnapshot(LedgerPeerSnapshotKind),
GetPoolDistr2(SMaybe<Pools>), GetStakeDistribution2 and
GetDRepsDelegations(TaggedSet<DRep>) that callers need; update the public API in
queries_v16 to either (a) add new wrapper constructors named e.g.
get_ledger_peer_snapshot(kind: LedgerPeerSnapshotKind),
get_pool_distr_v2(payload: SMaybe<Pools>), get_stake_distribution_v2(),
get_dreps_delegations(set: TaggedSet<DRep>) that build
BlockQuery::GetLedgerPeerSnapshot / GetPoolDistr2 / GetStakeDistribution2 /
GetDRepsDelegations, or (b) rewire the existing helpers (get_big_ledger_snapshot
-> GetLedgerPeerSnapshot with LedgerPeerSnapshotKind::Big, get_pool_distr -> map
to GetPoolDistr2, get_stake_distribution -> GetStakeDistribution2) and mark old
names deprecated; implement one of these approaches so callers use the new
protocol variants and ensure the helper signatures use the correct payload types
(LedgerPeerSnapshotKind, SMaybe<Pools>, TaggedSet<DRep>).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 433e8944-2094-4bc4-b05d-f4b963da205f

📥 Commits

Reviewing files that changed from the base of the PR and between 0da71c2 and 27763e4.

📒 Files selected for processing (5)
  • pallas-hardano/src/display/haskell_display.rs
  • pallas-network/src/miniprotocols/handshake/n2c.rs
  • pallas-network/src/miniprotocols/localstate/queries_v16/codec.rs
  • pallas-network/src/miniprotocols/localstate/queries_v16/mod.rs
  • pallas-network/src/miniprotocols/localtxsubmission/protocol.rs

Comment thread pallas-network/src/miniprotocols/localstate/queries_v16/codec.rs
Comment thread pallas-network/src/miniprotocols/localstate/queries_v16/mod.rs
scarmuega and others added 2 commits May 3, 2026 18:16
* fmt: rewrap test imports / call chains to satisfy `cargo fmt --check`
  (CI Lints job was failing on the previously hand-formatted blocks).
* test: pin the wire shape of `GetPoolDistr2` (tag 36) and
  `GetDRepsDelegations` (tag 39) explicitly, so an off-by-one tag in
  encode/decode can no longer slip past the suite by virtue of using
  the same wrong constant on both sides.
* api: add the four post-V_16 query helpers that mirror the existing
  `block_query_*!` macro pattern: `get_ledger_peer_snapshot(kind)`,
  `get_pool_distr_v2(maybe_pools)`, `get_stake_distribution_v2()`, and
  `get_dreps_delegations(set)`. Without these wrappers callers hitting
  a v23 node still had to construct the new `BlockQuery` variants by
  hand. Legacy helpers (`get_big_ledger_snapshot`, `get_pool_distr`,
  `get_stake_distribution`) are kept untouched for back-compat with
  pre-v15/v21 peers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
pallas-network2 ships its own N2C handshake table (the crate is a
from-scratch P2P-focused rewrite, not a re-export of pallas-network),
and that table was byte-for-byte the same one pallas-network had
before this branch — capped at PROTOCOL_V16. Without the mirror, a
pallas-network2 client talking to a cardano-node 10.7.x peer would
negotiate down to v16 instead of v23.

Add PROTOCOL_V17..PROTOCOL_V23 (32785..32791) and extend
v1_and_above and v10_and_above to advertise them, matching the
pallas-network change in this PR.

The semantic-layer changes from this PR (new BlockQuery variants,
ConwayLedgerFailure tag-8/9 additions) do not apply here:
pallas-network2 has no LocalStateQuery and no LocalTxSubmission
modules — only the multiplexer/transport plus chainsync, blockfetch,
keepalive, peersharing, txsubmission (n2n flavor). The N2N table is
also stale (caps at v14 while upstream is at v16 with SRV / Peras
support) but that gap is from Plomin / Peras work, not van Rossem,
so it stays out of scope here.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@scarmuega scarmuega merged commit 3781f63 into main May 4, 2026
13 of 15 checks passed
@scarmuega scarmuega deleted the feat/van-rossem-network-prep branch May 4, 2026 10:31
scarmuega added a commit that referenced this pull request May 5, 2026
Backports the handshake half of #747 to the 0.18.x line so downstream
consumers can negotiate NodeToClient sessions with cardano-node 10.x
peers, including the 10.7.x release that targets the van Rossem hard
fork (protocol version 11).

The remaining changes from #747 (queries_v16 additions, the new
ConwayLedgerFailure tags, and the pallas-network2 / pallas-hardano
counterparts) depend on modules introduced after this branch diverged
and are intentionally out of scope.
scarmuega added a commit that referenced this pull request May 5, 2026
#758)

Mirrors the n2c handshake portion of #747 ("feat: prep for van Rossem
hard fork") so that NodeToClient sessions on the lts/v0 line can
negotiate protocol versions 17-23, including the v23 used by the
cardano-node 10.7.x release that targets the van Rossem hard fork.
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