Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
project: cardano-api
pr: 1268
kind:
- compatible
description: |
Re-export the ChainDB follower API from Cardano.Api.Consensus: newFollower, Follower, ChainType, ChainUpdate, withRegistry, ResourceRegistry, configSecurityParam and SecurityParam.
6 changes: 6 additions & 0 deletions .changes/20260722_cardano_rpc_follow_tip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
project: cardano-rpc
pr: 1268
kind:
- feature
description: |
Implement the FollowTip SyncService method: streams fully parsed blocks as the chain advances, starting from the first intersection point found on the chain (an empty-hash block ref denotes origin). An empty intersect list follows from the current tip; an unmatched intersect list fails with NOT_FOUND. Rollbacks are delivered as undo actions carrying the rolled-back blocks where they can be reconstructed from ChainDB, falling back to reset otherwise.
Comment thread
carbolymer marked this conversation as resolved.
1 change: 1 addition & 0 deletions cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ library
prettyprinter-ansi-terminal,
prettyprinter-configurable ^>=1.36,
random,
resource-registry ^>=0.2,
safe-exceptions,
scientific,
serialise,
Expand Down
9 changes: 9 additions & 0 deletions cardano-api/src/Cardano/Api/Consensus.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,29 @@ module Cardano.Api.Consensus
, ByronBlock
, CardanoBlock
, ChainDB.ChainDB
, ChainDB.ChainType (..)
, ChainDB.Follower (..)
, ChainDB.getBlockComponent
, ChainDB.getCurrentLedger
, ChainDB.getTipHeader
, ChainDB.newFollower
, ChainUpdate (..)
, ConfigSupportsNode
, ChainDepState
, GenTx (..)
, EraMismatch (..)
, HasHardForkHistory (..)
, HasHeader
, Header
, HeaderHash
, NodeKernel (..)
, OneEraHash (..)
, PastHorizonException
, PraosProtocolSupportsNode
, PraosProtocolSupportsNodeCrypto
, RealPoint (..)
, ResourceRegistry
, SecurityParam (..)
, ShelleyGenesisStaking (..)
, StandardCrypto
, TopLevelConfig
Expand All @@ -79,12 +86,14 @@ module Cardano.Api.Consensus
, byronIdTx
, configBlock
, configLedger
, configSecurityParam
, condense
, getOpCertCounters
, interpreterToEpochInfo
, mkInterpreter
, unsafeExtendSafeZone
, txId
, withRegistry
)
where

Expand Down
18 changes: 17 additions & 1 deletion cardano-api/src/Cardano/Api/Consensus/Internal/Reexport.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ module Cardano.Api.Consensus.Internal.Reexport
( BlockComponent (..)
, ByronBlock
, CardanoBlock
, ChainUpdate (..)
, ConfigSupportsNode
, ChainDepState
, GenTx (..)
, HasHeader
, Header
, HeaderHash
, EraMismatch (..)
, NodeKernel (..)
Expand All @@ -15,6 +17,8 @@ module Cardano.Api.Consensus.Internal.Reexport
, PraosProtocolSupportsNode
, PraosProtocolSupportsNodeCrypto
, RealPoint (..)
, ResourceRegistry
, SecurityParam (..)
, ShelleyGenesisStaking (..)
, StandardCrypto
, TopLevelConfig
Expand All @@ -26,18 +30,21 @@ module Cardano.Api.Consensus.Internal.Reexport
, byronIdTx
, configBlock
, configLedger
, configSecurityParam
, condense
, getOpCertCounters
, interpreterToEpochInfo
, mkInterpreter
, unsafeExtendSafeZone
, txId
, withRegistry
)
where

import Cardano.Protocol.Crypto (StandardCrypto)
import Ouroboros.Consensus.Block
( HasHeader
, Header
, HeaderHash
, RealPoint (..)
, blockHash
Expand All @@ -46,7 +53,13 @@ import Ouroboros.Consensus.Block
)
import Ouroboros.Consensus.Byron.Ledger (ByronBlock (byronBlockRaw), GenTx (..), byronIdTx)
import Ouroboros.Consensus.Cardano.Block (CardanoBlock, EraMismatch (..))
import Ouroboros.Consensus.Config (TopLevelConfig, configBlock, configLedger)
import Ouroboros.Consensus.Config
( TopLevelConfig
, configBlock
, configLedger
, configSecurityParam
)
import Ouroboros.Consensus.Config.SecurityParam (SecurityParam (..))
import Ouroboros.Consensus.Config.SupportsNode (ConfigSupportsNode)
import Ouroboros.Consensus.HardFork.Abstract (HasHardForkHistory (..))
import Ouroboros.Consensus.HardFork.Combinator.AcrossEras (OneEraHash (..))
Expand All @@ -68,3 +81,6 @@ import Ouroboros.Consensus.Protocol.Praos.Common
import Ouroboros.Consensus.Shelley.Node (ShelleyGenesisStaking (..))
import Ouroboros.Consensus.Storage.Common (BlockComponent (..))
import Ouroboros.Consensus.Util.Condense (condense)
import Ouroboros.Network.Block (ChainUpdate (..))

import Control.ResourceRegistry (ResourceRegistry, withRegistry)
2 changes: 1 addition & 1 deletion cardano-rpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ It implements [UTxO RPC](https://utxorpc.org/introduction) protobuf communicatio
|--------|--------|
| [FetchBlock](https://utxorpc.org/sync/spec/#fetchblockrequest) | ✅ Supported |
| [DumpHistory](https://utxorpc.org/sync/spec/#dumphistoryrequest) | ⬜ Not supported |
| [FollowTip](https://utxorpc.org/sync/spec/#followtiprequest) | ⬜ Not supported |
| [FollowTip](https://utxorpc.org/sync/spec/#followtiprequest) | ✅ Supported |
| [ReadTip](https://utxorpc.org/sync/spec/#readtiprequest) | ✅ Supported |

### [WatchService](https://utxorpc.org/watch/spec/)
Expand Down
3 changes: 3 additions & 0 deletions cardano-rpc/cardano-rpc.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ library
Cardano.Rpc.Server.Internal.UtxoRpc.Sync
Cardano.Rpc.Server.Internal.UtxoRpc.Type
Cardano.Rpc.Server.Internal.UtxoRpc.Type.BigInt
Cardano.Rpc.Server.Internal.UtxoRpc.Type.Block
Cardano.Rpc.Server.Internal.UtxoRpc.Type.Byron
Cardano.Rpc.Server.Internal.UtxoRpc.Type.Certificate
Cardano.Rpc.Server.Internal.UtxoRpc.Type.ChainPoint
Expand Down Expand Up @@ -173,6 +174,7 @@ test-suite cardano-rpc-test
hedgehog,
hedgehog-extras,
memory,
ouroboros-consensus:cardano,
proto-lens,
rio,
tasty,
Expand All @@ -191,6 +193,7 @@ test-suite cardano-rpc-test
Test.Cardano.Rpc.ByronTx
Test.Cardano.Rpc.Eval
Test.Cardano.Rpc.FetchBlockTx
Test.Cardano.Rpc.FollowTipStream
Test.Cardano.Rpc.Pagination
Test.Cardano.Rpc.Predicate
Test.Cardano.Rpc.ProtocolParameters
Expand Down
2 changes: 1 addition & 1 deletion cardano-rpc/src/Cardano/Rpc/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ methodsSyncRpc
methodsSyncRpc =
Method (mkNonStreaming $ const unimplemented) -- dumpHistory
. Method (mkNonStreaming $ wrapInSpan TraceRpcFetchBlockSpan . fetchBlockMethod)
. Method (mkServerStreaming $ \_ _ -> unimplemented) -- followTip
. Method (mkServerStreaming $ \req -> wrapInSpan TraceRpcFollowTipSpan . followTipMethod req)
. Method (mkNonStreaming $ wrapInSpan TraceRpcReadTipSpan . readTipMethod)
$ NoMoreMethods
where
Expand Down
7 changes: 4 additions & 3 deletions cardano-rpc/src/Cardano/Rpc/Server/Internal/Tracing.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ data TraceRpcSync
TraceRpcFetchBlockSpan TraceSpanEvent
| -- | ReadTip span
TraceRpcReadTipSpan TraceSpanEvent
| -- | FollowTip span
TraceRpcFollowTipSpan TraceSpanEvent
| -- | Requested block was not found
TraceRpcFetchBlockNotFound SlotNo
| -- | Node kernel access is not yet available
TraceRpcNodeKernelAccessUnavailable
| -- | Ledger forker error
TraceRpcForkerError String
deriving Show

instance Pretty TraceRpcSync where
Expand All @@ -115,9 +115,10 @@ instance Pretty TraceRpcSync where
TraceRpcFetchBlockSpan (SpanEnd _) -> "Finished FetchBlock method"
TraceRpcReadTipSpan (SpanBegin _) -> "Started ReadTip method"
TraceRpcReadTipSpan (SpanEnd _) -> "Finished ReadTip method"
TraceRpcFollowTipSpan (SpanBegin _) -> "Started FollowTip method"
TraceRpcFollowTipSpan (SpanEnd _) -> "Finished FollowTip method"
TraceRpcFetchBlockNotFound slot -> "Block not found at slot " <> pshow slot
TraceRpcNodeKernelAccessUnavailable -> "Node kernel access not yet initialised"
TraceRpcForkerError e -> "Ledger forker error: " <> pretty e

instance Error TraceRpcSync where
prettyError = pretty
Expand Down
Loading
Loading