gRPC: Add gRPC interface to cardano-node with tests in cardano-testnet#6273
gRPC: Add gRPC interface to cardano-node with tests in cardano-testnet#6273carbolymer wants to merge 7 commits intomasterfrom
Conversation
864cf20 to
12bae80
Compare
0004d02 to
2c89086
Compare
aaab28c to
eab2ed1
Compare
4d19d4c to
98d8073
Compare
12d7ab5 to
73c37e6
Compare
8cbf3f2 to
0ec9ea7
Compare
7c29f29 to
ebf5f8b
Compare
a8564a9 to
5d772e5
Compare
5d772e5 to
450a849
Compare
86ec635 to
9984a35
Compare
7b30930 to
8e67434
Compare
2ea442d to
8f6a3b7
Compare
There was a problem hiding this comment.
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
AdjustFilePathsforPartialNodeConfigurationonly rewritespncProtocolConfigandpncSocketConfig, but the newpncRpcConfigcan also contain file paths (e.g.RpcSocketPath). This means relative RPC socket paths inconfiguration.yamlwon’t be made relative to the config directory, unlike other path fields. ExtendadjustFilePathshere to includepncRpcConfig(and any nestedFilefields via the newAdjustFilePathsinstances).
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.
| ( Object | ||
| , Value (..) | ||
| , (.=) | ||
| ) |
There was a problem hiding this comment.
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.
| ( Object | |
| , Value (..) | |
| , (.=) | |
| ) | |
| ( Object | |
| , Value (..) | |
| , (.=) | |
| ) |
| - name: Cardano gRPC Issues | ||
| url: https://github.com/IntersectMBO/cardano-api/issues | ||
| about: Report gRPC endpoint related issues here |
There was a problem hiding this comment.
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.
| - name: Cardano gRPC Issues | |
| url: https://github.com/IntersectMBO/cardano-api/issues | |
| about: Report gRPC endpoint related issues here |
|
|
||
| - 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. |
There was a problem hiding this comment.
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).
| - 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`. |
| 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 |
There was a problem hiding this comment.
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.
| 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 |
| {- HLINT ignore "Functor law" -} | ||
|
|
There was a problem hiding this comment.
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).
| {- HLINT ignore "Functor law" -} |
Jimbo4350
left a comment
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Same here regarding the configuration being moved to consensus.
| , ncResponderCoreAffinityPolicy :: ResponderCoreAffinityPolicy | ||
|
|
||
| -- gRPC | ||
| , ncRpcConfig :: RpcConfig |
There was a problem hiding this comment.
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] |
| mconcat $ | ||
| ("reason" .= prettyShow tr) | ||
| : case tr of | ||
| TraceRpcFatalError _ -> ["kind" .= String "FatalError"] |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
I don't like this for boolean blindness reasons. Please define a sum type.
| --------------------------- | ||
| -- Test readParams response | ||
| --------------------------- | ||
| pparamsResponse ^. U5c.ledgerTip . U5c.slot === slot |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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] |
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:
cardano-clito remove SRPcardano-rpcto remove SRPChecklist
See Runnings tests for more details
CHANGELOG.mdfor affected package.cabalfiles are updatedhlint. See.github/workflows/check-hlint.ymlto get thehlintversionstylish-haskell. See.github/workflows/stylish-haskell.ymlto get thestylish-haskellversionghc-9.6andghc-9.12Note 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.