diff --git a/ChangeLog.md b/ChangeLog.md index fb07a7e8..73adc2d3 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,10 @@ # Revision history for cardano-byron-proxy +## 1.0.5 -- March 2020 + +* Update to latest version of cardano-ledger, ouroboros-network, + ouroboros-consensus and cardano-sl libs. + ## 1.0.4 -- February 2020 * Update to latest version of cardano-ledger, ouroboros-network, diff --git a/cabal.project b/cabal.project index 9e5b575f..4667ab7b 100644 --- a/cabal.project +++ b/cabal.project @@ -95,58 +95,93 @@ source-repository-package source-repository-package type: git location: https://github.com/input-output-hk/ouroboros-network - tag: 398004e1403367cc2a25c639eb6349d473e51b2d - --sha256: 1x940w0sma3mhl4hfd937sp25hdl3migkl8zsyl92p59468218i9 + tag: 85934cc7e19e4a94547c79073d28ca77bb29897f + --sha256: 1xgkdqi7cpmi0vq2lxq7d365yskp2v5rkh3g2m3ic3wplb00d7jd subdir: io-sim source-repository-package type: git location: https://github.com/input-output-hk/ouroboros-network - tag: 398004e1403367cc2a25c639eb6349d473e51b2d - --sha256: 1x940w0sma3mhl4hfd937sp25hdl3migkl8zsyl92p59468218i9 + tag: 85934cc7e19e4a94547c79073d28ca77bb29897f + --sha256: 1xgkdqi7cpmi0vq2lxq7d365yskp2v5rkh3g2m3ic3wplb00d7jd subdir: io-sim-classes source-repository-package type: git location: https://github.com/input-output-hk/ouroboros-network - tag: 398004e1403367cc2a25c639eb6349d473e51b2d - --sha256: 1x940w0sma3mhl4hfd937sp25hdl3migkl8zsyl92p59468218i9 + tag: 85934cc7e19e4a94547c79073d28ca77bb29897f + --sha256: 1xgkdqi7cpmi0vq2lxq7d365yskp2v5rkh3g2m3ic3wplb00d7jd subdir: ouroboros-consensus source-repository-package type: git location: https://github.com/input-output-hk/ouroboros-network - tag: 398004e1403367cc2a25c639eb6349d473e51b2d - --sha256: 1x940w0sma3mhl4hfd937sp25hdl3migkl8zsyl92p59468218i9 + tag: 85934cc7e19e4a94547c79073d28ca77bb29897f + --sha256: 1xgkdqi7cpmi0vq2lxq7d365yskp2v5rkh3g2m3ic3wplb00d7jd + subdir: ouroboros-consensus-byron + +source-repository-package + type: git + location: https://github.com/input-output-hk/ouroboros-network + tag: 85934cc7e19e4a94547c79073d28ca77bb29897f + --sha256: 1xgkdqi7cpmi0vq2lxq7d365yskp2v5rkh3g2m3ic3wplb00d7jd subdir: ouroboros-network source-repository-package type: git location: https://github.com/input-output-hk/ouroboros-network - tag: 398004e1403367cc2a25c639eb6349d473e51b2d - --sha256: 1x940w0sma3mhl4hfd937sp25hdl3migkl8zsyl92p59468218i9 + tag: 85934cc7e19e4a94547c79073d28ca77bb29897f + --sha256: 1xgkdqi7cpmi0vq2lxq7d365yskp2v5rkh3g2m3ic3wplb00d7jd + subdir: ouroboros-network-framework + +source-repository-package + type: git + location: https://github.com/input-output-hk/ouroboros-network + tag: 85934cc7e19e4a94547c79073d28ca77bb29897f + --sha256: 1xgkdqi7cpmi0vq2lxq7d365yskp2v5rkh3g2m3ic3wplb00d7jd subdir: ouroboros-network-testing source-repository-package type: git location: https://github.com/input-output-hk/ouroboros-network - tag: 398004e1403367cc2a25c639eb6349d473e51b2d - --sha256: 1x940w0sma3mhl4hfd937sp25hdl3migkl8zsyl92p59468218i9 + tag: 85934cc7e19e4a94547c79073d28ca77bb29897f + --sha256: 1xgkdqi7cpmi0vq2lxq7d365yskp2v5rkh3g2m3ic3wplb00d7jd subdir: network-mux source-repository-package type: git location: https://github.com/input-output-hk/ouroboros-network - tag: 398004e1403367cc2a25c639eb6349d473e51b2d - --sha256: 1x940w0sma3mhl4hfd937sp25hdl3migkl8zsyl92p59468218i9 + tag: 85934cc7e19e4a94547c79073d28ca77bb29897f + --sha256: 1xgkdqi7cpmi0vq2lxq7d365yskp2v5rkh3g2m3ic3wplb00d7jd subdir: typed-protocols source-repository-package type: git location: https://github.com/input-output-hk/ouroboros-network - tag: 398004e1403367cc2a25c639eb6349d473e51b2d - --sha256: 1x940w0sma3mhl4hfd937sp25hdl3migkl8zsyl92p59468218i9 - subdir: typed-protocols-cbor + tag: 85934cc7e19e4a94547c79073d28ca77bb29897f + --sha256: 1xgkdqi7cpmi0vq2lxq7d365yskp2v5rkh3g2m3ic3wplb00d7jd + subdir: typed-protocols-examples + +source-repository-package + type: git + location: https://github.com/input-output-hk/cardano-ledger-specs + tag: 2500720815d30a29c95d153b3d97b1e0307f6906 + --sha256: 1qb3a1wv65r73dkl07r48ni6j653b28fjfp1hdvr7049ibzfyb91 + subdir: byron/ledger/executable-spec + +source-repository-package + type: git + location: https://github.com/input-output-hk/cardano-ledger-specs + tag: 2500720815d30a29c95d153b3d97b1e0307f6906 + --sha256: 1qb3a1wv65r73dkl07r48ni6j653b28fjfp1hdvr7049ibzfyb91 + subdir: byron/chain/executable-spec + +source-repository-package + type: git + location: https://github.com/input-output-hk/cardano-ledger-specs + tag: f27e8b66a393f0b7da1893889dcea07da0fe4dec + --sha256: 1f1r1vidnlyka800jpm9z2myrggasqyzw0aw97q8vw81sh72l51s + subdir: byron/ledger/executable-spec -- -- from cardano-crypto-1.2.0.nix @@ -155,78 +190,78 @@ source-repository-package source-repository-package type: git location: https://github.com/input-output-hk/cardano-base - tag: eed4fc484366214831576eef0c7fe90d1d08c78b - --sha256: 0h9vbs2bsx6pvb300vl66znwpkqn169pmvsl4pv8mn0sz8iw4pk6 + tag: f869bee9b08ba1044b1476737c9d65083e1c6c7f + --sha256: 0df3bdf13cwx3hd8n4q53g9hybb0w8mh837y64ydd88xhdfaf6a3 subdir: binary source-repository-package type: git location: https://github.com/input-output-hk/cardano-base - tag: eed4fc484366214831576eef0c7fe90d1d08c78b - --sha256: 0h9vbs2bsx6pvb300vl66znwpkqn169pmvsl4pv8mn0sz8iw4pk6 + tag: f869bee9b08ba1044b1476737c9d65083e1c6c7f + --sha256: 0df3bdf13cwx3hd8n4q53g9hybb0w8mh837y64ydd88xhdfaf6a3 subdir: binary/test source-repository-package type: git location: https://github.com/input-output-hk/cardano-base - tag: eed4fc484366214831576eef0c7fe90d1d08c78b - --sha256: 0h9vbs2bsx6pvb300vl66znwpkqn169pmvsl4pv8mn0sz8iw4pk6 + tag: f869bee9b08ba1044b1476737c9d65083e1c6c7f + --sha256: 0df3bdf13cwx3hd8n4q53g9hybb0w8mh837y64ydd88xhdfaf6a3 subdir: cardano-crypto-class source-repository-package type: git location: https://github.com/input-output-hk/cardano-base - tag: eed4fc484366214831576eef0c7fe90d1d08c78b - --sha256: 0h9vbs2bsx6pvb300vl66znwpkqn169pmvsl4pv8mn0sz8iw4pk6 + tag: f869bee9b08ba1044b1476737c9d65083e1c6c7f + --sha256: 0df3bdf13cwx3hd8n4q53g9hybb0w8mh837y64ydd88xhdfaf6a3 subdir: slotting source-repository-package type: git location: https://github.com/input-output-hk/cardano-ledger - tag: c62e2eeba5756898cbf59732fccd6a83a4065c18 - --sha256: 04s2dp5dyikm2pxfphiyh429pckkg06dqx3sl4bbzvg6x5qfqvbn + tag: e2240ccda93e52835cd25b04e1963c8929bbfa64 + --sha256: 08c1dz9plnqb6i3ysnfbw6b6y2ij2f8crkij5aqrgsdjar51p91n subdir: cardano-ledger source-repository-package type: git location: https://github.com/input-output-hk/cardano-ledger - tag: c62e2eeba5756898cbf59732fccd6a83a4065c18 - --sha256: 04s2dp5dyikm2pxfphiyh429pckkg06dqx3sl4bbzvg6x5qfqvbn + tag: e2240ccda93e52835cd25b04e1963c8929bbfa64 + --sha256: 08c1dz9plnqb6i3ysnfbw6b6y2ij2f8crkij5aqrgsdjar51p91n subdir: crypto source-repository-package type: git location: https://github.com/input-output-hk/cardano-ledger - tag: c62e2eeba5756898cbf59732fccd6a83a4065c18 - --sha256: 04s2dp5dyikm2pxfphiyh429pckkg06dqx3sl4bbzvg6x5qfqvbn + tag: e2240ccda93e52835cd25b04e1963c8929bbfa64 + --sha256: 08c1dz9plnqb6i3ysnfbw6b6y2ij2f8crkij5aqrgsdjar51p91n subdir: cardano-ledger/test source-repository-package type: git location: https://github.com/input-output-hk/cardano-ledger - tag: c62e2eeba5756898cbf59732fccd6a83a4065c18 - --sha256: 04s2dp5dyikm2pxfphiyh429pckkg06dqx3sl4bbzvg6x5qfqvbn + tag: e2240ccda93e52835cd25b04e1963c8929bbfa64 + --sha256: 08c1dz9plnqb6i3ysnfbw6b6y2ij2f8crkij5aqrgsdjar51p91n subdir: crypto/test source-repository-package type: git location: https://github.com/input-output-hk/cardano-ledger-specs - tag: f27e8b66a393f0b7da1893889dcea07da0fe4dec - --sha256: 1f1r1vidnlyka800jpm9z2myrggasqyzw0aw97q8vw81sh72l51s + tag: afacc7969445e4db5427936489f5a49a8a3a8f99 + --sha256: 0j5c669x7lr5fi7s9lm4jrzhprq8vz8q5z0pb1mrbp5fv4ja352c subdir: byron/semantics/executable-spec source-repository-package type: git location: https://github.com/input-output-hk/cardano-ledger-specs - tag: f27e8b66a393f0b7da1893889dcea07da0fe4dec - --sha256: 1f1r1vidnlyka800jpm9z2myrggasqyzw0aw97q8vw81sh72l51s + tag: afacc7969445e4db5427936489f5a49a8a3a8f99 + --sha256: 0j5c669x7lr5fi7s9lm4jrzhprq8vz8q5z0pb1mrbp5fv4ja352c subdir: byron/ledger/executable-spec source-repository-package type: git location: https://github.com/input-output-hk/cardano-ledger-specs - tag: f27e8b66a393f0b7da1893889dcea07da0fe4dec - --sha256: 1f1r1vidnlyka800jpm9z2myrggasqyzw0aw97q8vw81sh72l51s + tag: afacc7969445e4db5427936489f5a49a8a3a8f99 + --sha256: 0j5c669x7lr5fi7s9lm4jrzhprq8vz8q5z0pb1mrbp5fv4ja352c subdir: byron/chain/executable-spec source-repository-package @@ -238,21 +273,22 @@ source-repository-package source-repository-package type: git location: https://github.com/input-output-hk/cardano-prelude - tag: 00487726c4bc21b4744e59d913334ebfeac7d68e - --sha256: 0v4fcq5kdd2r5dgwys8kv46ff33qp756n26ycxrca10wq14zkwm5 + tag: 3893f21db1665e7bab9e8c6504c547fc7c28f98c + --sha256: 09qqcjzmjsa3r7f1yiwk4bn8bpv7nvqf7hfyg784shasspwfq8n4 source-repository-package type: git location: https://github.com/input-output-hk/cardano-prelude - tag: 00487726c4bc21b4744e59d913334ebfeac7d68e - --sha256: 0v4fcq5kdd2r5dgwys8kv46ff33qp756n26ycxrca10wq14zkwm5 + tag: 3893f21db1665e7bab9e8c6504c547fc7c28f98c + --sha256: 09qqcjzmjsa3r7f1yiwk4bn8bpv7nvqf7hfyg784shasspwfq8n4 subdir: test + -- version number matching the one specified in the stack resolver file source-repository-package type: git - location: https://github.com/input-output-hk/cardano-crypto - tag: 4590efa638397e952a51a8994b5543e4ea3c1ecd - --sha256: 0hl2n3bba5v2j0lmxhs7hs01z3aznh2bwf9cb434icq2g0bl8ms3 + location: https://github.com/input-output-hk/cardano-crypto/ + tag: 2547ad1e80aeabca2899951601079408becbc92c + --sha256: 1p2kg2w02q5w1cvqzhfhqmxviy4xrzada3mmb096j2n6hfr20kri source-repository-package type: git diff --git a/cardano-byron-proxy.cabal b/cardano-byron-proxy.cabal index 89e05f1f..c92df845 100644 --- a/cardano-byron-proxy.cabal +++ b/cardano-byron-proxy.cabal @@ -1,5 +1,5 @@ name: cardano-byron-proxy -version: 1.0.4 +version: 1.0.5 synopsis: Cardano Byron network proxy for the old and new network protocols. -- description: homepage: https://github.com/input-output-hk/cardano-byron-proxy @@ -50,6 +50,7 @@ library memory, network-mux, ouroboros-consensus, + ouroboros-consensus-byron, ouroboros-network, resourcet, sqlite-simple, @@ -111,7 +112,9 @@ executable cardano-byron-proxy network-mux, optparse-applicative, ouroboros-consensus, + ouroboros-consensus-byron, ouroboros-network, + ouroboros-network-framework, random, reflection, resourcet, diff --git a/default.nix b/default.nix index 463dff51..04cd9480 100644 --- a/default.nix +++ b/default.nix @@ -51,7 +51,7 @@ let pkgconfig sqlite-interactive tmux - commonLib.cabalProjectRegenerate +# commonLib.cabalProjectRegenerate ]); # Prevents cabal from choosing alternate plans, so that diff --git a/src/exec/Byron.hs b/src/exec/Byron.hs index 01ce56a6..8f8fbc84 100644 --- a/src/exec/Byron.hs +++ b/src/exec/Byron.hs @@ -34,20 +34,22 @@ import qualified Pos.Chain.Block as CSL (Block, BlockHeader (..), GenesisBlock, MainBlockHeader, HeaderHash, headerHash) import qualified Pos.Infra.Diffusion.Types as CSL -import Ouroboros.Byron.Proxy.Block (ByronBlock, - coerceHashToLegacy, headerHash) -import Ouroboros.Byron.Proxy.Main +import Ouroboros.Consensus.Byron.Ledger.Block (ByronBlock) import Ouroboros.Consensus.Block (Header) -import Ouroboros.Consensus.Ledger.Byron (ByronHash(..), +import Ouroboros.Consensus.Byron.Ledger.Block (ByronHash(..), byronHeaderRaw, mkByronBlock) -import Ouroboros.Consensus.Ledger.Byron.Auxiliary as Cardano import Ouroboros.Consensus.Protocol.Abstract (SecurityParam (maxRollbacks)) import Ouroboros.Network.Block (ChainHash (..), Point, pointHash) import qualified Ouroboros.Network.AnchoredFragment as AF import qualified Ouroboros.Network.ChainFragment as CF -import Ouroboros.Storage.ChainDB.API (ChainDB) -import qualified Ouroboros.Storage.ChainDB.API as ChainDB +import Ouroboros.Consensus.Storage.ChainDB.API (ChainDB) +import qualified Ouroboros.Consensus.Storage.ChainDB.API as ChainDB +import Ouroboros.Byron.Proxy.Block (coerceHashToLegacy, headerHash) +import Ouroboros.Byron.Proxy.Main (ByronProxy, BestTip(..) + , bestTip + , downloadChain + , announceChain) -- | Download the best available chain from Byron peers and write to the -- database, over and over again. It will download the best chain from its -- Byron peers regardless of whether it has a better one in the database. @@ -73,7 +75,7 @@ download tracer genesisBlock epochSlots securityParam db bp = do Nothing -> do traceWith tracer "Seeding database with genesis" genesisBlock' :: ByronBlock <- recodeBlockOrFail epochSlots throwIO (Left genesisBlock) - ChainDB.addBlock db genesisBlock' + _ <- ChainDB.addBlock db genesisBlock' pure $ CSL.headerHash genesisBlock Just header -> pure $ coerceHashToLegacy (headerHash header) mainLoop gen tipHash @@ -171,7 +173,7 @@ download tracer genesisBlock epochSlots securityParam db bp = do commitBlock :: CSL.HeaderHash -> CSL.Block -> IO CSL.HeaderHash commitBlock _ blk = do blk' <- recodeBlockOrFail epochSlots throwIO blk - ChainDB.addBlock db blk' + _ <- ChainDB.addBlock db blk' pure $ CSL.headerHash blk -- Catch all sync exceptions from the downloadChain call that uses the @@ -219,6 +221,7 @@ recodeBlock epochSlots cslBlk = case Binary.decodeFullAnnotatedBytes "Block" dec -- stored... _unless_ in recovery mode! i.e. precisely when the new block is -- a continuation of the current chain. -- Do we wish to / need to stick to that style? + announce :: Maybe Cardano.HeaderHash -- ^ Of block most recently announced. -> ChainDB IO ByronBlock diff --git a/src/exec/DB.hs b/src/exec/DB.hs index bbaba28b..3b2048dd 100644 --- a/src/exec/DB.hs +++ b/src/exec/DB.hs @@ -17,19 +17,20 @@ import Ouroboros.Byron.Proxy.Block (ByronBlock) import qualified Ouroboros.Byron.Proxy.Index.ChainDB as Index (trackChainDB) import qualified Ouroboros.Byron.Proxy.Index.Sqlite as Sqlite import Ouroboros.Byron.Proxy.Index.Types (Index) -import Ouroboros.Consensus.Block (BlockProtocol, - GetHeader (Header)) +import Ouroboros.Consensus.Block (GetHeader (Header)) import Ouroboros.Consensus.BlockchainTime (BlockchainTime) -import Ouroboros.Consensus.Ledger.Byron.Config (pbftEpochSlots) import Ouroboros.Consensus.Ledger.Extended (ExtLedgerState) import Ouroboros.Consensus.Node (openChainDB) -import Ouroboros.Consensus.Protocol (NodeConfig) -import Ouroboros.Consensus.Protocol.ExtConfig (extNodeConfig) import Ouroboros.Consensus.Util.ResourceRegistry (ResourceRegistry) import qualified Ouroboros.Consensus.Util.ResourceRegistry as ResourceRegistry -import Ouroboros.Storage.ChainDB (ChainDB) -import qualified Ouroboros.Storage.ChainDB as ChainDB -import Ouroboros.Storage.ChainDB.Impl.Args (ChainDbArgs (..)) +import Ouroboros.Consensus.Storage.ChainDB.API (ChainDB) +import qualified Ouroboros.Consensus.Storage.ChainDB.API as ChainDB +import Ouroboros.Consensus.Storage.ChainDB.Impl.Args (ChainDbArgs (..)) +import Ouroboros.Consensus.Config (TopLevelConfig, configBlock) +import Ouroboros.Consensus.Byron.Ledger.Config (byronEpochSlots) +import Ouroboros.Consensus.Byron.Node () +import Ouroboros.Consensus.Storage.ChainDB.Impl.Types as ChainDB (TraceEvent) +import Ouroboros.Consensus.Storage.VolatileDB.Types (mkBlocksPerFile) data DBConfig = DBConfig { dbFilePath :: !FilePath @@ -41,6 +42,7 @@ data DBConfig = DBConfig -- | Set up and use a DB. -- -- The directory at `dbFilePath` will be created if it does not exist. + withDB :: forall t . DBConfig @@ -48,7 +50,7 @@ withDB -> Tracer IO Sqlite.TraceEvent -> ResourceRegistry IO -> BlockchainTime IO - -> NodeConfig (BlockProtocol ByronBlock) + -> TopLevelConfig ByronBlock -> ExtLedgerState ByronBlock -> (Index IO (Header ByronBlock) -> ChainDB IO ByronBlock -> IO t) -> IO t @@ -67,10 +69,10 @@ withDB dbOptions dbTracer indexTracer rr btime nodeConfig extLedgerState k = do where epochSlots :: Cardano.EpochSlots - epochSlots = pbftEpochSlots $ extNodeConfig nodeConfig + epochSlots = byronEpochSlots $ configBlock nodeConfig customiseArgs :: ChainDbArgs IO ByronBlock -> ChainDbArgs IO ByronBlock customiseArgs args = args - { cdbBlocksPerFile = 21600 -- ? + { cdbBlocksPerFile = mkBlocksPerFile 21600 -- ? , cdbGcDelay = secondsToDiffTime 20 } diff --git a/src/exec/Main.hs b/src/exec/Main.hs index 09ec4b1d..8d52ae2a 100644 --- a/src/exec/Main.hs +++ b/src/exec/Main.hs @@ -17,6 +17,7 @@ import Control.Monad.Trans.Except (runExceptT) import Control.Tracer (Tracer (..), contramap, nullTracer, traceWith) import Data.Functor.Contravariant (Op (..)) import Data.List (intercalate) +import Data.Proxy (Proxy(..)) import qualified Data.Reflection as Reflection (given) import Data.String (fromString) import Data.Text (Text) @@ -66,7 +67,6 @@ import qualified Pos.Util.Trace.Named as Trace (LogNamed (..), appendName, named import qualified Pos.Util.Trace import qualified Pos.Util.Wlog as Wlog -import Network.TypedProtocol.Driver.ByteLimit (DecoderFailureOrTooMuchInput (..)) import Network.Mux.Trace (MuxError (..), MuxErrorType (..)) import Ouroboros.Byron.Proxy.Block (ByronBlock) @@ -80,28 +80,31 @@ import Ouroboros.Consensus.BlockchainTime (SlotLength (..), focusSlotLengths, realBlockchainTime, singletonSlotLengths) -import Ouroboros.Consensus.Protocol.Abstract (SecurityParam (..), protocolSecurityParam) +import Ouroboros.Consensus.Config (configSecurityParam) +import Ouroboros.Consensus.Protocol.Abstract (SecurityParam (..)) import Ouroboros.Consensus.Mempool.API (Mempool) import Ouroboros.Consensus.Mempool.TxSeq (TicketNo) import Ouroboros.Consensus.Node (getMempool) import Ouroboros.Consensus.Node.ErrorPolicy (consensusErrorPolicy) -import Ouroboros.Consensus.Node.ProtocolInfo.Abstract (ProtocolInfo (..)) -import Ouroboros.Consensus.Node.ProtocolInfo.Byron (PBftSignatureThreshold (..), - protocolInfoByron) +import Ouroboros.Consensus.Node.ProtocolInfo (ProtocolInfo (..)) +import Ouroboros.Consensus.Node.Run () +import Ouroboros.Consensus.Byron.Node (PBftSignatureThreshold (..), protocolInfoByron) import Ouroboros.Network.NodeToNode import Ouroboros.Consensus.Util.ResourceRegistry (ResourceRegistry) import qualified Ouroboros.Consensus.Util.ResourceRegistry as ResourceRegistry (withRegistry) -import Ouroboros.Network.Block (BlockNo (..), Point (..)) +import Ouroboros.Network.Block (BlockNo (..)) import Ouroboros.Network.ErrorPolicy (WithAddr (..), ErrorPolicyTrace (..)) -import Ouroboros.Network.Point (WithOrigin (..)) import Ouroboros.Network.ErrorPolicy (SuspendDecision (..)) import Ouroboros.Network.BlockFetch.Client (BlockFetchProtocolFailure) import Ouroboros.Network.Protocol.Handshake.Type (HandshakeClientProtocolError) import qualified Ouroboros.Network.TxSubmission.Inbound as TxInbound import qualified Ouroboros.Network.TxSubmission.Outbound as TxOutbound import Ouroboros.Network.Server.ConnectionTable (ConnectionTable) -import Ouroboros.Storage.ChainDB.API (ChainDB) -import Ouroboros.Storage.ChainDB.Impl.Types (TraceEvent (..), TraceAddBlockEvent (..), TraceValidationEvent (..)) +import Ouroboros.Consensus.Storage.ChainDB.API (ChainDB) +import Ouroboros.Consensus.Storage.ChainDB.Impl.Types (TraceEvent (..), TraceAddBlockEvent (..), TraceValidationEvent (..)) + +import Ouroboros.Network.IOManager (AssociateWithIOCP, withIOManager) +import Ouroboros.Network.Snocket (socketSnocket) import qualified Byron import DB (DBConfig (..), withDB) @@ -319,48 +322,52 @@ cliParserInfo = Opt.info cliParser infoMod <> Opt.fullDesc runShelleyServer - :: Tracer IO (WithAddr Network.SockAddr ErrorPolicyTrace) + :: AssociateWithIOCP + -> Tracer IO (WithAddr Network.SockAddr ErrorPolicyTrace) -> Address -> ResourceRegistry IO -> ConnectionTable IO Network.SockAddr -> Shelley.ResponderVersions -> IO Void -runShelleyServer tracer addr _ _ rversions = do +runShelleyServer iocp tracer addr _ _ rversions = do addrInfo <- resolveAddress addr networkState <- newNetworkMutableState withServer + (socketSnocket iocp) NetworkServerTracers { nstMuxTracer = nullTracer, nstHandshakeTracer = nullTracer, nstErrorPolicyTracer = tracer } networkState - addrInfo + (Network.addrAddress addrInfo) rversions errorPolicy where -- TODO: We might need some additional proxy-specific policies - errorPolicy = networkErrorPolicy <> consensusErrorPolicy + errorPolicy :: ErrorPolicies + errorPolicy = networkErrorPolicy <> consensusErrorPolicy (Proxy :: Proxy ByronBlock) runShelleyClient - :: ( ) - => Tracer IO (WithAddr Network.SockAddr ErrorPolicyTrace) + :: AssociateWithIOCP + -> Tracer IO (WithAddr Network.SockAddr ErrorPolicyTrace) -> [Address] -> ResourceRegistry IO -> ConnectionTable IO Network.SockAddr -> Shelley.InitiatorVersions -> IO Void -runShelleyClient tracer producerAddrs _ _ iversions = do +runShelleyClient iocp tracer producerAddrs _ _ iversions = do -- Expect AddrInfo, convert to SockAddr, then pass to ipSubscriptionWorker sockAddrs <- mapM resolveAddress producerAddrs networkState <- newNetworkMutableState -- TODO: Ideally should share state with runShelleyServer ipSubscriptionWorker - NetworkIPSubscriptionTracers { - nistMuxTracer = nullTracer, - nistHandshakeTracer = nullTracer, - nistErrorPolicyTracer = tracer, - nistSubscriptionTracer = nullTracer + (socketSnocket iocp) + NetworkSubscriptionTracers { + nsMuxTracer = nullTracer, + nsHandshakeTracer = nullTracer, + nsErrorPolicyTracer = tracer, + nsSubscriptionTracer = nullTracer } networkState SubscriptionParams { @@ -378,11 +385,12 @@ runShelleyClient tracer producerAddrs _ _ iversions = do iversions where -- TODO: We might need some additional proxy-specific policies - errorPolicy = networkErrorPolicy <> consensusErrorPolicy + errorPolicy = networkErrorPolicy <> consensusErrorPolicy (Proxy :: Proxy ByronBlock) -- | Error policies for a trusted deployment (behind a firewall). -- -networkErrorPolicy :: ErrorPolicies Network.SockAddr a + +networkErrorPolicy :: ErrorPolicies networkErrorPolicy = ErrorPolicies { epAppErrorPolicies = [ -- Handshake client protocol error: we either did not recognise received @@ -394,9 +402,9 @@ networkErrorPolicy = ErrorPolicies { -- exception thrown by `runDecoderWithByteLimit`; we received to -- many bytes from the network. - , ErrorPolicy - $ \(_ :: DecoderFailureOrTooMuchInput DeserialiseFailure) - -> Just theyBuggy +-- , ErrorPolicy +-- $ \(_ :: DecoderFailureOrTooMuchInput DeserialiseFailure) +-- -> Just theyBuggy -- deserialisation failure; It means that the remote peer has -- a bug. @@ -416,9 +424,7 @@ networkErrorPolicy = ErrorPolicies { MuxUnknownMiniProtocol -> Just theyBuggy MuxDecodeError -> Just theyBuggy MuxIngressQueueOverRun -> Just theyBuggy - MuxControlProtocolError -> Just theyBuggy - MuxTooLargeMessage -> Just theyBuggy - + MuxInitiatorOnly -> Just theyBuggy -- in case of bearer closed / or IOException we do -- not suspend the peer, it can resume immediately MuxBearerClosed -> Nothing @@ -444,10 +450,7 @@ networkErrorPolicy = ErrorPolicies { -- If `connect` thrown an exception, try to re-connect to the peer after -- a short delay ErrorPolicy $ \(_ :: IOException) -> Just (SuspendConsumer shortDelay) - ], - - -- impossible happened, since none of the protocol terminates - epReturnCallback = \_ _ _ -> ourBug + ] } where misconfiguredPeer :: SuspendDecision DiffTime @@ -456,9 +459,6 @@ networkErrorPolicy = ErrorPolicies { theyBuggy :: SuspendDecision DiffTime theyBuggy = SuspendPeer shortDelay shortDelay - ourBug :: SuspendDecision DiffTime - ourBug = Throw - shortDelay :: DiffTime shortDelay = 10 -- seconds @@ -536,7 +536,7 @@ defineSeverity it = case it of ErrorPolicyAcceptException {} -> Monitoring.Error main :: IO () -main = do +main = withIOManager $ \iocp -> do bpo <- Opt.execParser cliParserInfo Logging.withLogging (bpoLoggerConfigPath bpo) "cardano_byron_proxy" $ \trace -> do -- We always need the cardano-sl configuration, even if we're not @@ -605,9 +605,7 @@ main = do let Tracer doConvertedTrace = Logging.convertTrace trace dbTracer :: Tracer IO (TraceEvent ByronBlock) dbTracer = Tracer $ \trEvent -> case trEvent of - TraceAddBlockEvent (AddedBlockToVolDB point (BlockNo blockno) _) -> case point of - Point Origin -> pure () - Point (At _) -> + TraceAddBlockEvent (AddedBlockToVolDB _point (BlockNo blockno) _) -> -- NB this is here because devops wanted an EKG metric on -- block count. FIXME should be done in a more sane way... let val = Monitoring.PureI (fromIntegral blockno) @@ -662,12 +660,14 @@ main = do let shelleyClientTracer = contramap (\it -> ("shelley.client", defineSeverity (wiaEvent it), fromString (show it))) (Logging.convertTrace' trace) shelleyServerTracer = contramap (\it -> ("shelley.server", defineSeverity (wiaEvent it), fromString (show it))) (Logging.convertTrace' trace) Shelley.withShelley rr cdb nodeConfig nodeState btime $ \kernel ctable iversions rversions -> do - let server = runShelleyServer shelleyServerTracer + let server = runShelleyServer iocp + shelleyServerTracer (soLocalAddress (bpoShelleyOptions bpo)) rr ctable rversions - client = runShelleyClient shelleyClientTracer + client = runShelleyClient iocp + shelleyClientTracer (soProducerAddresses (bpoShelleyOptions bpo)) rr ctable @@ -682,7 +682,7 @@ main = do (Reflection.given :: CSL.UpdateConfiguration) (Reflection.given :: CSL.NodeConfiguration) epochSlots - (protocolSecurityParam nodeConfig) + (configSecurityParam nodeConfig) idx cdb (getMempool kernel) diff --git a/src/exec/Shelley.hs b/src/exec/Shelley.hs index 5ffbefa5..0e98bdd0 100644 --- a/src/exec/Shelley.hs +++ b/src/exec/Shelley.hs @@ -16,61 +16,78 @@ import qualified Network.Socket as Socket import Cardano.Prelude (Proxy(..)) import Ouroboros.Byron.Proxy.Block (ByronBlock) -import Ouroboros.Consensus.Block (BlockProtocol) -import Ouroboros.Consensus.Protocol (NodeConfig, NodeState) import Ouroboros.Consensus.Util.ResourceRegistry (ResourceRegistry) -import Ouroboros.Storage.ChainDB.API (ChainDB) - +import Ouroboros.Consensus.Storage.ChainDB.API (ChainDB) +import Ouroboros.Consensus.Config (TopLevelConfig) import Ouroboros.Network.NodeToNode import Ouroboros.Network.Mux -import Ouroboros.Network.Protocol.ChainSync.PipelineDecision (pipelineDecisionLowHighMark) import Ouroboros.Network.Protocol.Handshake.Version import Ouroboros.Network.Server.ConnectionTable (ConnectionTable, newConnectionTable) import Ouroboros.Consensus.BlockchainTime (BlockchainTime) -import Ouroboros.Consensus.ChainSyncClient (ClockSkew (..)) +import Ouroboros.Consensus.MiniProtocol.ChainSync.Client (ClockSkew (..)) import Ouroboros.Consensus.Node +import Ouroboros.Consensus.Node.State (NodeState) import Ouroboros.Consensus.NodeKernel import Ouroboros.Consensus.Node.Tracers (nullTracers) -import Ouroboros.Consensus.Node.Run.Abstract (nodeBlockFetchSize, nodeBlockMatchesHeader) +import Ouroboros.Consensus.Node.Run (nodeBlockFetchSize, nodeBlockMatchesHeader) import Ouroboros.Consensus.NodeNetwork +import Ouroboros.Consensus.Byron.Node () -- Run instance +import Ouroboros.Consensus.Byron.Ledger.NetworkProtocolVersion + (ByronNetworkProtocolVersion(ByronNetworkProtocolVersion1)) -type InitiatorVersions = Versions NodeToNodeVersion DictVersion (OuroborosApplication 'InitiatorApp ConnectionId NodeToNodeProtocols IO Lazy.ByteString () Void) - -type ResponderVersions = Versions NodeToNodeVersion DictVersion (OuroborosApplication 'ResponderApp ConnectionId NodeToNodeProtocols IO Lazy.ByteString Void ()) +type InitiatorVersions = Versions + NodeToNodeVersion + DictVersion + (ConnectionId Socket.SockAddr + -> OuroborosApplication 'InitiatorApp Lazy.ByteString IO () Void) +type ResponderVersions = Versions + NodeToNodeVersion + DictVersion + (ConnectionId Socket.SockAddr + -> OuroborosApplication 'ResponderApp Lazy.ByteString IO Void ()) -- Must have `ByronGiven` because of the constraints on `nodeKernel` + withShelley :: ResourceRegistry IO -> ChainDB IO ByronBlock - -> NodeConfig (BlockProtocol ByronBlock) - -> NodeState (BlockProtocol ByronBlock) + -> TopLevelConfig ByronBlock + -> NodeState ByronBlock -> BlockchainTime IO - -> (NodeKernel IO ConnectionId ByronBlock -> ConnectionTable IO Socket.SockAddr -> InitiatorVersions -> ResponderVersions -> IO t) + -> (NodeKernel IO (ConnectionId Socket.SockAddr) ByronBlock + -> ConnectionTable IO Socket.SockAddr + -> InitiatorVersions + -> ResponderVersions -> IO t) -> IO t withShelley rr cdb conf state blockchainTime k = do ctable <- newConnectionTable let nodeParams = mkParams rr cdb conf state blockchainTime + miniconf = miniProtocolParameters nodeParams kernel <- initNodeKernel nodeParams let apps = consensusNetworkApps kernel nullProtocolTracers - (protocolCodecs conf) + (protocolCodecs conf ByronNetworkProtocolVersion1) (protocolHandlers nodeParams kernel) vs = versions conf apps - k kernel ctable (initiatorNetworkApplication <$> vs) (responderNetworkApplication <$> vs) + k kernel ctable + (initiatorNetworkApplication miniconf <$> vs) + (responderNetworkApplication miniconf <$> vs) versions - :: NodeConfig (BlockProtocol ByronBlock) -> NetworkApplication IO ConnectionId Lazy.ByteString Lazy.ByteString Lazy.ByteString Lazy.ByteString Lazy.ByteString Lazy.ByteString () - -> Versions NodeToNodeVersion DictVersion (NetworkApplication IO ConnectionId Lazy.ByteString Lazy.ByteString Lazy.ByteString Lazy.ByteString Lazy.ByteString Lazy.ByteString ()) + :: TopLevelConfig ByronBlock + -> r + -> Versions NodeToNodeVersion DictVersion r + versions conf = simpleSingletonVersions NodeToNodeV_1 (NodeToNodeVersionData (nodeNetworkMagic (Proxy @ByronBlock) conf)) (DictVersion nodeToNodeCodecCBORTerm) mkParams :: ResourceRegistry IO -> ChainDB IO ByronBlock - -> NodeConfig (BlockProtocol ByronBlock) - -> NodeState (BlockProtocol ByronBlock) + -> TopLevelConfig ByronBlock + -> NodeState ByronBlock -> BlockchainTime IO - -> NodeArgs IO ConnectionId ByronBlock + -> NodeArgs IO (ConnectionId Socket.SockAddr) ByronBlock mkParams rr cdb nconf nstate blockchainTime = NodeArgs { tracers = nullTracers , registry = rr @@ -85,8 +102,7 @@ mkParams rr cdb nconf nstate blockchainTime = NodeArgs , initChainDB = \_cfg _cdb -> return () , blockFetchSize = nodeBlockFetchSize , blockMatchesHeader = nodeBlockMatchesHeader - , maxUnackTxs = maxBound , maxBlockSize = MaxBlockBodySize maxBound - , chainSyncPipelining = pipelineDecisionLowHighMark 200 300 -- TODO: make configurable! , mempoolCap = NoMempoolCapacityBytesOverride + , miniProtocolParameters = defaultMiniProtocolParameters } diff --git a/src/lib/Ouroboros/Byron/Proxy/Block.hs b/src/lib/Ouroboros/Byron/Proxy/Block.hs index d1dd464e..629e7904 100644 --- a/src/lib/Ouroboros/Byron/Proxy/Block.hs +++ b/src/lib/Ouroboros/Byron/Proxy/Block.hs @@ -18,7 +18,6 @@ module Ouroboros.Byron.Proxy.Block , coerceHashFromLegacy , coerceHashToLegacy , headerHash - , isEBB ) where import qualified Codec.CBOR.Write as CBOR (toStrictByteString) @@ -31,9 +30,10 @@ import qualified Cardano.Chain.Block as Cardano import Cardano.Crypto.Hashing (AbstractHash (..)) import qualified Ouroboros.Consensus.Block as Consensus (GetHeader (..)) -import Ouroboros.Consensus.Ledger.Byron (ByronBlock (..), ByronHash (..), - encodeByronBlock, byronHeaderHash) -import Ouroboros.Storage.Common (EpochNo(..)) +import Ouroboros.Consensus.Byron.Ledger.Block (ByronBlock (..), ByronHash (..), + byronHeaderHash) +import Ouroboros.Consensus.Byron.Ledger.Serialisation (encodeByronBlock) +--import Ouroboros.Consensus.Storage.Common ( EpochNo(..) ) -- For type instance HeaderHash (Header blk) = HeaderHash blk -- Anyone who imports this module will almost certainly want that instance. @@ -57,14 +57,3 @@ coerceHashFromLegacy (Legacy.AbstractHash digest) = ByronHash $ AbstractHash dig -- | Same a `blockHash` but doesn't need `ByronGiven`. headerHash :: Consensus.Header ByronBlock -> Cardano.HeaderHash headerHash = unByronHash . byronHeaderHash - --- | Return @Just@ the epoch number if the block is an EBB, @Nothing@ for --- regular blocks -isEBB :: ByronBlock -> Maybe EpochNo -isEBB blk = case byronBlockRaw blk of - Cardano.ABOBBlock _ -> Nothing - Cardano.ABOBBoundary ebb -> Just - . EpochNo - . Cardano.boundaryEpoch - . Cardano.boundaryHeader - $ ebb diff --git a/src/lib/Ouroboros/Byron/Proxy/Genesis/Convert.hs b/src/lib/Ouroboros/Byron/Proxy/Genesis/Convert.hs index 9ccf45d6..2a5952a9 100644 --- a/src/lib/Ouroboros/Byron/Proxy/Genesis/Convert.hs +++ b/src/lib/Ouroboros/Byron/Proxy/Genesis/Convert.hs @@ -20,6 +20,7 @@ import Data.Time.Clock (NominalDiffTime, UTCTime) import Data.Time.Clock.POSIX (posixSecondsToUTCTime) import Data.Word (Word16) import Numeric.Natural (Natural) +import GHC.Real ((%)) import qualified Cardano.Binary as Binary import qualified Cardano.Chain.Common as Cardano @@ -103,9 +104,9 @@ convertGenesisInitializer :: CSL.GenesisInitializer -> Cardano.GenesisInitialize convertGenesisInitializer gi = Cardano.GenesisInitializer { Cardano.giTestBalance = convertTestnetBalanceOptions (CSL.giTestBalance gi) , Cardano.giFakeAvvmBalance = convertFakeAvvmOptions (CSL.giFakeAvvmBalance gi) - , Cardano.giAvvmBalanceFactor = convertCoinPortion (CSL.giAvvmBalanceFactor gi) + , Cardano.giAvvmBalanceFactor = toRational + (CSL.getCoinPortion (CSL.giAvvmBalanceFactor gi) % CSL.coinPortionDenominator) , Cardano.giUseHeavyDlg = CSL.giUseHeavyDlg gi - , Cardano.giSeed = CSL.giSeed gi } convertTestnetBalanceOptions :: CSL.TestnetBalanceOptions -> Cardano.TestnetBalanceOptions @@ -113,10 +114,7 @@ convertTestnetBalanceOptions tbo = Cardano.TestnetBalanceOptions { Cardano.tboPoors = CSL.tboPoors tbo , Cardano.tboRichmen = CSL.tboRichmen tbo , Cardano.tboTotalBalance = either (error . show) id (Cardano.mkLovelace (CSL.tboTotalBalance tbo)) - -- CSL uses a Double, presumably in [0,1] - -- Cardano uses a LovelacePortion, or Word64, the numerator over the - -- maximum lovelace value 1e15. - , Cardano.tboRichmenShare = either (error . show) id (Cardano.lovelacePortionFromDouble (CSL.tboRichmenShare tbo)) + , Cardano.tboRichmenShare = toRational $ CSL.tboRichmenShare tbo } convertFakeAvvmOptions :: CSL.FakeAvvmOptions -> Cardano.FakeAvvmOptions @@ -138,7 +136,8 @@ convertCoin :: CSL.Coin -> Cardano.Lovelace convertCoin = either (error . show) id . Cardano.mkLovelace . CSL.getCoin convertCoinPortion :: CSL.CoinPortion -> Cardano.LovelacePortion -convertCoinPortion = Cardano.LovelacePortion . CSL.getCoinPortion +convertCoinPortion x + = Cardano.rationalToLovelacePortion $ toRational (CSL.getCoinPortion x % CSL.coinPortionDenominator) -- Serokell.Data.Memory.Units.Byte -> Natural -- I don't want to import serokell-util so we leave it open for any Enum. diff --git a/src/lib/Ouroboros/Byron/Proxy/Index/ChainDB.hs b/src/lib/Ouroboros/Byron/Proxy/Index/ChainDB.hs index c1270203..64565bc6 100644 --- a/src/lib/Ouroboros/Byron/Proxy/Index/ChainDB.hs +++ b/src/lib/Ouroboros/Byron/Proxy/Index/ChainDB.hs @@ -13,8 +13,9 @@ import Ouroboros.Consensus.Block (GetHeader (Header)) import Ouroboros.Consensus.Util.ResourceRegistry (ResourceRegistry) import Ouroboros.Network.Block (ChainUpdate (..), Point (..)) import Ouroboros.Network.Point (WithOrigin (Origin)) -import Ouroboros.Storage.ChainDB.API (BlockComponent (..), ChainDB, Reader) -import qualified Ouroboros.Storage.ChainDB.API as ChainDB +import Ouroboros.Consensus.Storage.ChainDB.API (ChainDB, Reader) +import Ouroboros.Consensus.Storage.Common (BlockComponent (..)) +import qualified Ouroboros.Consensus.Storage.ChainDB.API as ChainDB -- | Reapaetedly take the reader instruction and update the index accordingly. trackReaderBlocking diff --git a/src/lib/Ouroboros/Byron/Proxy/Index/Sqlite.hs b/src/lib/Ouroboros/Byron/Proxy/Index/Sqlite.hs index 24165d6c..480d66f6 100644 --- a/src/lib/Ouroboros/Byron/Proxy/Index/Sqlite.hs +++ b/src/lib/Ouroboros/Byron/Proxy/Index/Sqlite.hs @@ -33,9 +33,8 @@ import Ouroboros.Network.Block (SlotNo (..)) import Ouroboros.Network.Point (WithOrigin (..), blockPointHash, blockPointSlot) import qualified Ouroboros.Network.Point as Point (Block (..)) -import Ouroboros.Consensus.Ledger.Byron (ByronHash(..), +import Ouroboros.Consensus.Byron.Ledger.Block (ByronHash(..), byronHeaderSlotNo, byronHeaderRaw) -import Ouroboros.Consensus.Ledger.Byron.Auxiliary as Cardano import Ouroboros.Byron.Proxy.Block (ByronBlock(..), Header, headerHash) diff --git a/src/lib/Ouroboros/Byron/Proxy/Main.hs b/src/lib/Ouroboros/Byron/Proxy/Main.hs index a5b5a2a8..0afdbd7a 100644 --- a/src/lib/Ouroboros/Byron/Proxy/Main.hs +++ b/src/lib/Ouroboros/Byron/Proxy/Main.hs @@ -6,6 +6,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE PatternSynonyms #-} {-# OPTIONS_GHC "-fwarn-incomplete-patterns" #-} @@ -125,9 +126,10 @@ import Ouroboros.Byron.Proxy.Index.Types (Index) import qualified Ouroboros.Byron.Proxy.Index.Types as Index import Ouroboros.Byron.Proxy.Genesis.Convert (convertEpochSlots) import Ouroboros.Consensus.Block (getHeader) -import Ouroboros.Consensus.Ledger.Byron (GenTx(ByronTx), - encodeByronBlock, +import Ouroboros.Consensus.Byron.Ledger.Mempool (GenTx(ByronTx), fromMempoolPayload) +import Ouroboros.Consensus.Byron.Ledger.Serialisation + (encodeByronBlock) import Ouroboros.Consensus.Mempool.API (GenTxId, Mempool) import qualified Ouroboros.Consensus.Mempool.API as Mempool @@ -136,13 +138,16 @@ import Ouroboros.Consensus.NodeKernel (getMempoolReader, getMempoolWriter) import Ouroboros.Consensus.Util.ResourceRegistry (ResourceRegistry) import qualified Ouroboros.Consensus.Util.ResourceRegistry as ResourceRegistry -import Ouroboros.Network.Block (ChainUpdate (..), - Point (..)) -import qualified Ouroboros.Network.Point as Point (block) +import Ouroboros.Network.Block (ChainUpdate (..)) import qualified Ouroboros.Network.TxSubmission.Inbound as Tx.In -import qualified Ouroboros.Network.TxSubmission.Outbound as Tx.Out -import Ouroboros.Storage.ChainDB.API (ChainDB) -import qualified Ouroboros.Storage.ChainDB.API as ChainDB +import Ouroboros.Network.TxSubmission.Mempool.Reader + ( TxSubmissionMempoolReader (..) + , MempoolSnapshot (..)) + +import Ouroboros.Consensus.Storage.ChainDB.API (ChainDB) +import qualified Ouroboros.Consensus.Storage.ChainDB.API as ChainDB +import Ouroboros.Consensus.Block.RealPoint (pattern RealPoint + ,realPointToPoint) -- | Configuration used to get a 'ByronProxy'. -- 'configFromGenesis' will make one from a genesis configuration. @@ -276,18 +281,18 @@ txKeyValFromMempool mempool txTicketMapVar = KeyVal ptag = Proxy keyFromValue :: TxMsgContents -> TxId keyFromValue = hash . taTx . getTxMsgContents - reader :: Tx.Out.TxSubmissionMempoolReader (GenTxId ByronBlock) (GenTx ByronBlock) TicketNo IO + reader :: TxSubmissionMempoolReader (GenTxId ByronBlock) (GenTx ByronBlock) TicketNo IO reader = getMempoolReader mempool writer :: Tx.In.TxSubmissionMempoolWriter (GenTxId ByronBlock) (GenTx ByronBlock) TicketNo IO writer = getMempoolWriter mempool lookupTx :: Tagged TxMsgContents TxId -> IO (Maybe TxMsgContents) lookupTx = \txId -> atomically $ do - snapshot <- Tx.Out.mempoolGetSnapshot reader + snapshot <- mempoolGetSnapshot reader ticketMap <- readTVar txTicketMapVar let outcome :: Maybe (Cardano.ATxAux ByteString) outcome = do ticketNo <- Map.lookup (untag txId) ticketMap - image <- Tx.Out.mempoolLookupTx snapshot ticketNo + image <- mempoolLookupTx snapshot ticketNo fmap snd (pickMoneyTransaction image) pure $ fmap toByronTxMsgContents outcome @@ -489,7 +494,7 @@ bbsStreamBlocks rr idx db _ hh f yieldFirst k = do -- Must include the block _at_ the start point, so we can't go straight -- to the reader API: advancing a reader to a given point means the -- block at the point will not come out of the reader. - let point = Point (Point.block slotNo (coerceHashFromLegacy hh)) + let point = (RealPoint slotNo (coerceHashFromLegacy hh)) mStartBlock <- ChainDB.getBlock db point case mStartBlock of Nothing -> k (pure ()) @@ -498,7 +503,7 @@ bbsStreamBlocks rr idx db _ hh f yieldFirst k = do -- reader will actually move forward to it. The only case in which it -- wouldn't is due to a fork, and legacy Byron API can't deal with that -- anyway... - _ <- ChainDB.readerForward rdr [point] + _ <- ChainDB.readerForward rdr [realPointToPoint point] -- ChainDB docs say we must expect this rollback mInstruction <- ChainDB.readerInstruction rdr case mInstruction of @@ -535,7 +540,7 @@ bbsGetSerializedBlock _ idx db hh = do Nothing -> pure Nothing Just slotNo -> (fmap . fmap) toSerializedBlock (ChainDB.getBlock db point) where - point = Point (Point.block slotNo (coerceHashFromLegacy hh)) + point = RealPoint slotNo (coerceHashFromLegacy hh) bbsGetBlockHeader :: EpochSlots @@ -559,7 +564,7 @@ bbsGetBlockHeader _ idx db onErr hh = do Left err -> onErr err Right legacyBlk -> pure $ Just $ Byron.Legacy.getBlockHeader legacyBlk where - point = Point (Point.block slotNo (coerceHashFromLegacy hh)) + point = RealPoint slotNo (coerceHashFromLegacy hh) -- TODO we're supposed to give 'Either GetHashesRangeError' but let's -- fill that in later at the use site. @@ -589,8 +594,8 @@ bbsGetHashesRange rr idx db onErr mLimit from to = do where streamFrom = ChainDB.StreamFromInclusive fromPoint streamTo = ChainDB.StreamToInclusive toPoint - fromPoint = Point (Point.block fromSlot (coerceHashFromLegacy from)) - toPoint = Point (Point.block toSlot (coerceHashFromLegacy to)) + fromPoint = RealPoint fromSlot (coerceHashFromLegacy from) + toPoint = RealPoint toSlot (coerceHashFromLegacy to) _ -> pure Nothing where