Skip to content

gRPC: Add gRPC interface to cardano-node with tests in cardano-testnet#6273

Open
carbolymer wants to merge 7 commits intomasterfrom
mgalazyn/feature/add-grpc-interface
Open

gRPC: Add gRPC interface to cardano-node with tests in cardano-testnet#6273
carbolymer wants to merge 7 commits intomasterfrom
mgalazyn/feature/add-grpc-interface

Conversation

@carbolymer
Copy link
Contributor

@carbolymer carbolymer commented Jul 4, 2025

Description

This PR adds an experimental gRPC endpoint to cardano-node. The gRPC endpoint implements UTXORPC schema. For now the following methods are supported:

The gRPC endpoint is disabled by default, can be enabled by CLI flag or by configuration option.

Support for enabling gRPC endpoint is added into cardano-testnet.

Things necessary to do before the merge:

  • Release cardano-cli to remove SRP
  • Release cardano-rpc to remove SRP

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. These may include:
    • golden tests
    • property tests
    • roundtrip tests
    • integration tests
      See Runnings tests for more details
  • Any changes are noted in the CHANGELOG.md for affected package
  • The version bounds in .cabal files are updated
  • CI passes. See note on CI. The following CI checks are required:
    • Code is linted with hlint. See .github/workflows/check-hlint.yml to get the hlint version
    • Code is formatted with stylish-haskell. See .github/workflows/stylish-haskell.yml to get the stylish-haskell version
    • Code builds on Linux, MacOS and Windows for ghc-9.6 and ghc-9.12
  • Self-reviewed the diff

Note on CI

If your PR is from a fork, the necessary CI jobs won't trigger automatically for security reasons.
You will need to get someone with write privileges. Please contact IOG node developers to do this
for you.

@carbolymer carbolymer self-assigned this Jul 4, 2025
@carbolymer carbolymer changed the title cardano-rpc | Add gRPC interface to cardano-node, add tests to cardano-testnet cardano-rpc | Add gRPC interface to cardano-node with tests in cardano-testnet Jul 4, 2025
@carbolymer carbolymer force-pushed the mgalazyn/feature/add-grpc-interface branch 2 times, most recently from 864cf20 to 12bae80 Compare July 10, 2025 15:37
@carbolymer carbolymer force-pushed the mgalazyn/feature/add-grpc-interface branch from 0004d02 to 2c89086 Compare July 23, 2025 14:20
@carbolymer carbolymer force-pushed the mgalazyn/feature/add-grpc-interface branch 3 times, most recently from aaab28c to eab2ed1 Compare July 25, 2025 16:57
@palas palas force-pushed the mgalazyn/feature/add-grpc-interface branch 4 times, most recently from 4d19d4c to 98d8073 Compare August 3, 2025 20:00
@carbolymer carbolymer force-pushed the mgalazyn/feature/add-grpc-interface branch from 12d7ab5 to 73c37e6 Compare September 4, 2025 16:45
@carbolymer carbolymer force-pushed the mgalazyn/feature/add-grpc-interface branch from 8cbf3f2 to 0ec9ea7 Compare October 2, 2025 12:29
@carbolymer carbolymer changed the title cardano-rpc | Add gRPC interface to cardano-node with tests in cardano-testnet gRPC: Add gRPC interface to cardano-node with tests in cardano-testnet Nov 13, 2025
@carbolymer carbolymer force-pushed the mgalazyn/feature/add-grpc-interface branch 2 times, most recently from 7c29f29 to ebf5f8b Compare November 17, 2025 08:33
@carbolymer carbolymer force-pushed the mgalazyn/feature/add-grpc-interface branch 2 times, most recently from a8564a9 to 5d772e5 Compare November 28, 2025 20:50
@carbolymer carbolymer force-pushed the mgalazyn/feature/add-grpc-interface branch from 5d772e5 to 450a849 Compare January 7, 2026 18:51
@carbolymer carbolymer force-pushed the mgalazyn/feature/add-grpc-interface branch 7 times, most recently from 86ec635 to 9984a35 Compare February 24, 2026 17:13
@carbolymer carbolymer requested a review from Copilot February 24, 2026 17:13

This comment was marked as outdated.

@carbolymer carbolymer force-pushed the mgalazyn/feature/add-grpc-interface branch 4 times, most recently from 7b30930 to 8e67434 Compare February 26, 2026 14:55
@carbolymer carbolymer changed the title WIP: gRPC: Add gRPC interface to cardano-node with tests in cardano-testnet gRPC: Add gRPC interface to cardano-node with tests in cardano-testnet Mar 2, 2026
@carbolymer carbolymer force-pushed the mgalazyn/feature/add-grpc-interface branch 3 times, most recently from 2ea442d to 8f6a3b7 Compare March 9, 2026 16:26

This comment was marked as outdated.

This comment was marked as outdated.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 33 out of 34 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

cardano-node/src/Cardano/Node/Configuration/POM.hs:316

  • AdjustFilePaths for PartialNodeConfiguration only rewrites pncProtocolConfig and pncSocketConfig, but the new pncRpcConfig can also contain file paths (e.g. RpcSocketPath). This means relative RPC socket paths in configuration.yaml won’t be made relative to the config directory, unlike other path fields. Extend adjustFilePaths here to include pncRpcConfig (and any nested File fields via the new AdjustFilePaths instances).
instance AdjustFilePaths PartialNodeConfiguration where
  adjustFilePaths f x =
    x { pncProtocolConfig = adjustFilePaths f (pncProtocolConfig x)
      , pncSocketConfig   = adjustFilePaths f (pncSocketConfig x)
      }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +21 to +24
( Object
, Value (..)
, (.=)
)
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

This new module doesn’t follow the repository’s stylish-haskell formatting conventions (e.g. imports aren’t aligned/indented like other tracer modules). This is likely to fail the formatting CI check; please run stylish-haskell (or apply the repo formatter) on this file.

Suggested change
( Object
, Value (..)
, (.=)
)
( Object
, Value (..)
, (.=)
)

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +11
- name: Cardano gRPC Issues
url: https://github.com/IntersectMBO/cardano-api/issues
about: Report gRPC endpoint related issues here
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

The new “Cardano gRPC Issues” contact link points to the same URL as “Cardano API Issues” (cardano-api/issues). If gRPC issues should be tracked elsewhere (e.g. cardano-node or cardano-rpc), update the URL; otherwise this extra entry is redundant and may confuse reporters.

Suggested change
- name: Cardano gRPC Issues
url: https://github.com/IntersectMBO/cardano-api/issues
about: Report gRPC endpoint related issues here

Copilot uses AI. Check for mistakes.

- Added `--enable-grpc` flag to `cardano-testnet` to enable the gRPC interface (via `cardano-rpc`) when starting a testnet.
- Added `cardanoEnableRpc` field to `CardanoTestnetOptions` (default `False`).
- Added `nodeRpcSocketPath` helper to `Testnet.Types` for deriving the gRPC socket path from a node's socket path.
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

The PR changes the cardano-testnet CLI flag name from --nodeLoggingFormat to --node-logging-format (see updated golden help + parser), which is a user-facing breaking change. The changelog fragment currently doesn’t mention this rename; please add a bullet under “Added”/“Changed” documenting the flag rename (and any compatibility/aliasing, if supported).

Suggested change
- Added `nodeRpcSocketPath` helper to `Testnet.Types` for deriving the gRPC socket path from a node's socket path.
- Added `nodeRpcSocketPath` helper to `Testnet.Types` for deriving the gRPC socket path from a node's socket path.
- Renamed `cardano-testnet` CLI flag `--nodeLoggingFormat` to `--node-logging-format`.

Copilot uses AI. Check for mistakes.
Comment on lines +19 to +22
import qualified Cardano.Rpc.Proto.Api.UtxoRpc.Query as U5c hiding (cardano, items, tx)
import qualified Cardano.Rpc.Proto.Api.UtxoRpc.Query as UtxoRpc
import qualified Cardano.Rpc.Proto.Api.UtxoRpc.Submit as U5c
import qualified Cardano.Rpc.Proto.Api.UtxoRpc.Submit as UtxoRpc
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

U5c is used as the qualified alias for both ...UtxoRpc.Query and ...UtxoRpc.Submit, and the Query import also hides identifiers (cardano, items, tx) that are referenced later in the module (e.g. U5c.values . U5c.cardano, utxosResponse ^. U5c.items, U5c.tx). As written this won’t compile (hidden names out of scope / ambiguous qualified imports). Use distinct qualifiers (e.g. Query/Submit) or remove the incorrect hiding and consistently reference the intended module alias.

Suggested change
import qualified Cardano.Rpc.Proto.Api.UtxoRpc.Query as U5c hiding (cardano, items, tx)
import qualified Cardano.Rpc.Proto.Api.UtxoRpc.Query as UtxoRpc
import qualified Cardano.Rpc.Proto.Api.UtxoRpc.Submit as U5c
import qualified Cardano.Rpc.Proto.Api.UtxoRpc.Submit as UtxoRpc
import qualified Cardano.Rpc.Proto.Api.UtxoRpc.Query as U5c
import qualified Cardano.Rpc.Proto.Api.UtxoRpc.Query as UtxoRpcQuery
import qualified Cardano.Rpc.Proto.Api.UtxoRpc.Submit as U5cSubmit
import qualified Cardano.Rpc.Proto.Api.UtxoRpc.Submit as UtxoRpcSubmit

Copilot uses AI. Check for mistakes.
Comment on lines +13 to +14
{- HLINT ignore "Functor law" -}

Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

This file adds a top-level {- HLINT ignore "Functor law" -} directive, but there are no Functor instances in this module. This suppression is likely stale/unnecessary and makes it easier to miss real Functor-law violations introduced later. Consider removing it, or scoping the suppression to the specific declaration/expression that triggers hlint (if any).

Suggested change
{- HLINT ignore "Functor law" -}

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

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

Minor comments but I would solicit feedback from @jasagredo regarding the configuration change. Will approve after that is discussed.

, pncResponderCoreAffinityPolicy :: !(Last ResponderCoreAffinityPolicy)

-- gRPC
, pncRpcConfig :: !PartialRpcConfig
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here regarding the configuration being moved to consensus.

, ncResponderCoreAffinityPolicy :: ResponderCoreAffinityPolicy

-- gRPC
, ncRpcConfig :: RpcConfig
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. @jasagredo is working on moving the cardano node configuration machinery to ouroboros-consensus. To prevent future pain I would run this change by him.

Usage: cardano-testnet cardano [--num-pool-nodes COUNT]
[--max-lovelace-supply WORD64]
[--nodeLoggingFormat LOGGING_FORMAT]
[--node-logging-format LOGGING_FORMAT]
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

mconcat $
("reason" .= prettyShow tr)
: case tr of
TraceRpcFatalError _ -> ["kind" .= String "FatalError"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Where can one see the reason for the fatal error?

, cardanoEnableNewEpochStateLogging :: Bool -- ^ if epoch state logging is enabled
, cardanoEnableTxGenerator :: TxGeneratorSupport -- ^ Options regarding support for the tx-generator on the testnet (config generation, execution, etc.)
, cardanoOutputDir :: UserProvidedEnv -- ^ The output directory where to store files, sockets, and so on. If unset, a temporary directory is used.
, cardanoEnableRpc :: Bool
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like this for boolean blindness reasons. Please define a sum type.

---------------------------
-- Test readParams response
---------------------------
pparamsResponse ^. U5c.ledgerTip . U5c.slot === slot
Copy link
Contributor

@Jimbo4350 Jimbo4350 Mar 12, 2026

Choose a reason for hiding this comment

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

How flaky is this test?

import qualified Hedgehog.Extras.Test.Base as H
import qualified Hedgehog.Extras.Test.TestWatchdog as H

hprop_rpc_query_pparams :: Property
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment describing what this property is testing and a command we can use to run only this property.


import RIO (ByteString, threadDelay)

hprop_rpc_transaction :: Property
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, a comment describing what this tests along with a command to run just this property.


txBody <- H.leftFail $ createTransactionBody sbe content

let signedTx = signShelleyTransaction sbe txBody [wit0]
Copy link
Contributor

Choose a reason for hiding this comment

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

I see we are using the "old" api. Fine for this PR but I'd like you to migrate to the new api if possible in a follow up PR.

loop

utxos <-
Rpc.nonStreaming conn (Rpc.rpc @(Rpc.Protobuf UtxoRpc.QueryService "readUtxos")) def -- & # U5c.keys .~ [T.encodeUtf8 addrTxt1]
Copy link
Contributor

Choose a reason for hiding this comment

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

Left over comment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants