Skip to content

Commit 073b75f

Browse files
committed
cardano-testnet | Add gRPC evalTx test
1 parent 8217ef5 commit 073b75f

6 files changed

Lines changed: 441 additions & 3 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,5 @@ cardano-tracer/cardano-tracer-test
7777
.idea/
7878

7979
.codex
80+
81+
.serena/

cardano-node/src/Cardano/Node/Run.hs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import Cardano.Node.Protocol.Types
5757
import Cardano.Node.Queries
5858
import Cardano.Rpc.Server
5959
import Cardano.Rpc.Server.Config
60+
import Data.IORef
6061
import Cardano.Node.Startup
6162
import Cardano.Node.TraceConstraints (TraceConstraints)
6263
import Cardano.Node.Tracing.API
@@ -541,6 +542,7 @@ handleSimpleNode blockType runP tracers nc networkMagic onKernel = do
541542
#endif
542543
nForkPolicy <- getForkPolicy $ ncResponderCoreAffinityPolicy nc
543544
cForkPolicy <- getForkPolicy $ ncResponderCoreAffinityPolicy nc
545+
nodeAccessRef <- newIORef Nothing
544546
void $
545547
let diffusionNodeArguments :: Cardano.Diffusion.CardanoNodeArguments IO
546548
diffusionNodeArguments = Cardano.Diffusion.CardanoNodeArguments {
@@ -573,7 +575,7 @@ handleSimpleNode blockType runP tracers nc networkMagic onKernel = do
573575
(readTVar ledgerPeerSnapshotVar)
574576
nc
575577
in
576-
withAsync (rpcServerLoop (startupTracer tracers) (rpcTracer tracers) rpcConfigVar networkMagic) $ \_ ->
578+
withAsync (rpcServerLoop (startupTracer tracers) (rpcTracer tracers) rpcConfigVar networkMagic nodeAccessRef) $ \_ ->
577579
Node.run
578580
nodeArgs {
579581
rnNodeKernelHook = \registry nodeKernel -> do
@@ -858,16 +860,17 @@ rpcServerLoop :: Tracer IO (StartupTrace blk)
858860
-> Tracer IO TraceRpc
859861
-> StrictTVar IO RpcConfig
860862
-> NetworkMagic
863+
-> IORef (Maybe (NodeAccess IO))
861864
-> IO ()
862-
rpcServerLoop startupTracer rpcTracer rpcConfigVar networkMagic = go
865+
rpcServerLoop startupTracer rpcTracer rpcConfigVar networkMagic nodeAccessRef = go
863866
where
864867
go = do
865868
config@RpcConfig{isEnabled = Identity enabled} <- readTVarIO rpcConfigVar
866869
if enabled
867870
then
868871
race_
869872
(do
870-
runRpcServer rpcTracer (config, networkMagic)
873+
runRpcServer rpcTracer config networkMagic nodeAccessRef
871874
traceWith startupTracer RpcForceDisabled
872875
disableRpcServer)
873876
(waitForRpcConfigChange config)

cardano-node/src/Cardano/Node/Tracing/Tracers/Rpc.hs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ instance LogFormatting TraceRpc where
4646
TraceRpcSubmitTxDecodingError _ -> []
4747
TraceRpcSubmitTxValidationError _ -> []
4848
TraceRpcSubmitSpan s -> [spanToObject s]
49+
TraceRpcEvalTxDecodingError _ -> []
50+
TraceRpcEvalTxSpan s -> [spanToObject s]
4951

5052
forHuman = docToText . pretty
5153

@@ -56,6 +58,7 @@ instance LogFormatting TraceRpc where
5658
TraceRpcQuery (TraceRpcQueryReadUtxosSpan (SpanBegin _)) -> [CounterM "rpc.request.QueryService.ReadUtxos" Nothing]
5759
TraceRpcQuery (TraceRpcQuerySearchUtxosSpan (SpanBegin _)) -> [CounterM "rpc.request.QueryService.SearchUtxos" Nothing]
5860
TraceRpcSubmit (TraceRpcSubmitSpan (SpanBegin _)) -> [CounterM "rpc.request.SubmitService.SubmitTx" Nothing]
61+
TraceRpcSubmit (TraceRpcEvalTxSpan (SpanBegin _)) -> [CounterM "rpc.request.SubmitService.EvalTx" Nothing]
5962
_ -> []
6063

6164
instance MetaTrace TraceRpc where
@@ -76,6 +79,8 @@ instance MetaTrace TraceRpc where
7679
TraceRpcSubmitTxDecodingError _ -> ["TxDecodingError"]
7780
TraceRpcSubmitTxValidationError _ -> ["TxValidationError"]
7881
TraceRpcSubmitSpan _ -> ["SubmitTx", "Span"]
82+
TraceRpcEvalTxDecodingError _ -> ["EvalTxDecodingError"]
83+
TraceRpcEvalTxSpan _ -> ["EvalTx", "Span"]
7984

8085
severityFor (Namespace _ nsInner) _ = case nsInner of
8186
["FatalError"] -> Just Error -- RPC server startup errors
@@ -84,9 +89,11 @@ instance MetaTrace TraceRpc where
8489
["QueryService", "ReadUtxos", "Span"] -> Just Debug
8590
["QueryService", "SearchUtxos", "Span"] -> Just Debug
8691
["SubmitService", "SubmitTx", "Span"] -> Just Debug
92+
["SubmitService", "EvalTx", "Span"] -> Just Debug
8793
["SubmitService", "N2cConnectionError"] -> Just Warning -- this is a more serious error, this shouldn't happen
8894
["SubmitService", "TxDecodingError"] -> Just Debug -- request error
8995
["SubmitService", "TxValidationError"] -> Just Debug -- request error
96+
["SubmitService", "EvalTxDecodingError"] -> Just Debug -- request error
9097
_ -> Nothing
9198

9299
documentFor (Namespace _ nsInner) = case nsInner of
@@ -96,11 +103,13 @@ instance MetaTrace TraceRpc where
96103
["QueryService", "ReadUtxos", "Span"] -> Just "Span for the ReadUtxos UTXORPC method."
97104
["QueryService", "SearchUtxos", "Span"] -> Just "Span for the SearchUtxos UTXORPC method."
98105
["SubmitService", "SubmitTx", "Span"] -> Just "Span for the SubmitTx UTXORPC method."
106+
["SubmitService", "EvalTx", "Span"] -> Just "Span for the EvalTx UTXORPC method."
99107
["SubmitService", "N2cConnectionError"] ->
100108
Just
101109
"Node connection error. This should not happen, as this means that there is an issue in cardano-rpc configuration."
102110
["SubmitService", "TxDecodingError"] -> Just "A regular request error, when submitted transaction decoding fails."
103111
["SubmitService", "TxValidationError"] -> Just "A regular request error, when submitted transaction is invalid."
112+
["SubmitService", "EvalTxDecodingError"] -> Just "A regular request error, when evalTx transaction decoding fails."
104113
_ -> Nothing
105114

106115
metricsDocFor (Namespace _ nsInner) = case nsInner of
@@ -112,6 +121,8 @@ instance MetaTrace TraceRpc where
112121
[("rpc.request.QueryService.SearchUtxos", "Span for the SearchUtxos UTXORPC method.")]
113122
["SubmitService", "SubmitTx", "Span"] ->
114123
[("rpc.request.SubmitService.SubmitTx", "Span for the SubmitTx UTXORPC method.")]
124+
["SubmitService", "EvalTx", "Span"] ->
125+
[("rpc.request.SubmitService.EvalTx", "Span for the EvalTx UTXORPC method.")]
115126
_ -> []
116127

117128
allNamespaces =
@@ -122,9 +133,11 @@ instance MetaTrace TraceRpc where
122133
, ["QueryService", "ReadUtxos", "Span"]
123134
, ["QueryService", "SearchUtxos", "Span"]
124135
, ["SubmitService", "SubmitTx", "Span"]
136+
, ["SubmitService", "EvalTx", "Span"]
125137
, ["SubmitService", "N2cConnectionError"]
126138
, ["SubmitService", "TxDecodingError"]
127139
, ["SubmitService", "TxValidationError"]
140+
, ["SubmitService", "EvalTxDecodingError"]
128141
]
129142

130143
-- helper functions

cardano-testnet/cardano-testnet.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ test-suite cardano-testnet-test
238238
Cardano.Testnet.Test.Gov.TreasuryDonation
239239
Cardano.Testnet.Test.Gov.TreasuryGrowth
240240
Cardano.Testnet.Test.Gov.TreasuryWithdrawal
241+
Cardano.Testnet.Test.Rpc.Eval
241242
Cardano.Testnet.Test.Rpc.Query
242243
Cardano.Testnet.Test.Rpc.SearchUtxos
243244
Cardano.Testnet.Test.Rpc.Transaction

0 commit comments

Comments
 (0)