packages feed

haskoin-node 2.5.1 → 2.6.0

raw patch · 11 files changed

+95/−54 lines, 11 filesdep +temporarydep −unliftiodep ~asyncdep ~haskoin-coredep ~nqePVP ok

version bump matches the API change (PVP)

Dependencies added: temporary

Dependencies removed: unliftio

Dependency ranges changed: async, haskoin-core, nqe, rocksdb-haskell-jprupp, rocksdb-query, stm

API changes (from Hackage documentation)

Files

CHANGELOG.md view
@@ -6,6 +6,31 @@  ## [Unreleased] +## [2.6.0] - 2026-11-15++### Changed+- **Builds against haskoin-core 2.0.0**, which keeps the context of+  libsecp256k1 to itself: nothing takes a `Ctx` any more. This package+  never took one, and its own API is the same. A program that uses both+  packages must move to haskoin-core 2.0.0 with it.+- **Builds against nqe 0.7.0**, which runs in plain `IO` and no longer uses+  unliftio. This package already ran in `IO`, and its own API is the same. A+  program that uses both packages must move to nqe 0.7.0 with it, and has to+  lift the calls to NQE that it makes from another monad, as in+  `liftIO (receive events)`.+- **Peers can be stopped wherever they are.** A supervisor of nqe before+  0.7.0 started its children with asynchronous exceptions masked, so a peer+  could be cancelled, or timed out, only where it blocked. With nqe 0.7.0+  each peer is an ordinary thread.+- **Builds against rocksdb-haskell-jprupp 2.8** as well as 2.6 and 2.7, and+  against rocksdb-query 0.7 as well as 0.6. With 0.7 a list read from the+  database takes one foreign call for a few hundred entries where it took+  one for each, and a stack that does not grow with the list.+- The tests no longer use unliftio. They take threads, STM, exceptions and+  timeouts from base, async and stm, and temporary directories from+  temporary. With that the unliftio package is gone from everything this+  package builds with. Only unliftio-core remains, which conduit needs.+ ## [2.5.1] - 2026-11-11  ### Changed
README.md view
@@ -169,13 +169,13 @@  ```yaml extra-deps:-  - haskoin-node-2.5.1-  - haskoin-core-1.6.1-  - secp256k1-haskell-2.0.1+  - haskoin-node-2.6.0+  - haskoin-core-2.0.0+  - secp256k1-haskell-3.0.0   - base16-2.0-  - rocksdb-haskell-jprupp-2.7.1-  - rocksdb-query-0.6.1-  - nqe-0.6.9+  - rocksdb-haskell-jprupp-2.8.0+  - rocksdb-query-0.7.0+  - nqe-0.7.0 ```  ### Step by step with Stack
haskoin-node.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           haskoin-node-version:        2.5.1+version:        2.6.0 synopsis:       P2P library for Bitcoin and Bitcoin Cash description:    Connect to Bitcoin (BTC) and Bitcoin Cash (BCH) peers, keep them healthy, and                 sync block headers into a RocksDB database. Blocks and transactions can be@@ -68,12 +68,12 @@     , conduit-extra ==1.3.*     , containers >=0.6 && <0.8     , fast-logger ==3.2.*-    , haskoin-core >=1.6.1 && <1.7+    , haskoin-core >=2.0.0 && <2.1     , network >=3.1 && <3.3-    , nqe >=0.6.9 && <0.7+    , nqe >=0.7.0 && <0.8     , random >=1.2 && <1.4-    , rocksdb-haskell-jprupp >=2.6.1 && <2.8-    , rocksdb-query >=0.6.1 && <0.7+    , rocksdb-haskell-jprupp >=2.6.1 && <2.9+    , rocksdb-query >=0.6.1 && <0.8     , stm ==2.5.*     , streaming-commons ==0.2.*     , string-conversions ==0.4.*@@ -101,6 +101,7 @@   ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wpartial-fields -Wredundant-constraints -Wunused-packages -threaded -rtsopts -with-rtsopts=-N   build-depends:       HUnit+    , async     , base >=4.20 && <5     , bytestring     , cereal@@ -115,9 +116,10 @@     , process     , random     , rocksdb-haskell-jprupp+    , stm+    , temporary     , text     , time-    , unliftio   default-language: GHC2024  test-suite spec@@ -165,9 +167,10 @@     , nqe     , random     , rocksdb-haskell-jprupp+    , stm+    , temporary     , text     , time-    , unliftio   default-language: GHC2024   build-tool-depends:       hspec-discover:hspec-discover
src/Haskoin/Node/Address.hs view
@@ -24,20 +24,19 @@   ) where +import Conduit (liftIO, yield) import Control.Applicative ((<|>)) import Control.Arrow (second)-import Control.Exception (IOException, catch)-import Data.Bits (complement, shiftR, (.&.), (.|.))-import Conduit (liftIO, yield)-import Control.Exception (finally)+import Control.Exception (IOException, catch, finally) import Control.Monad (unless)+import Data.Bits (complement, shiftR, (.&.), (.|.)) import Data.ByteString (ByteString) import Data.ByteString qualified as B import Data.Conduit.Network (sinkSocket)-import Data.Streaming.Network (clientSettingsTCP, getReadBufferSize, getSocketFamilyTCP)-import Data.Time.Clock (NominalDiffTime) import Data.List (elemIndex)+import Data.Streaming.Network (clientSettingsTCP, getReadBufferSize, getSocketFamilyTCP) import Data.String.Conversions (cs)+import Data.Time.Clock (NominalDiffTime) import Data.Word (Word16, Word8) import Haskoin (Network (..)) import Haskoin.Node.Peer (Conduits (..), WithConnection)
test/common/Haskoin/Node/Test.hs view
@@ -51,12 +51,17 @@   ) where -import Conduit (awaitForever, yield)+import Conduit (awaitForever, liftIO, yield)+import Control.Concurrent (threadDelay)+import Control.Concurrent.Async (withAsync)+import Control.Concurrent.STM (TVar, atomically, newTVarIO, readTVarIO, writeTVar)+import Control.Exception (finally) import Control.Monad (forM_, unless) import Data.Bits ((.|.)) import Data.ByteString (ByteString) import Data.ByteString qualified as B import Data.Default (def)+import Data.IORef (IORef, newIORef, readIORef, writeIORef) import Data.List (elemIndex) import Data.Maybe (fromMaybe, listToMaybe, mapMaybe) import Data.Serialize (decode, encode, runGet, runPut)@@ -72,10 +77,10 @@ import NQE import Network.Socket (SockAddr (..)) import System.Environment (lookupEnv)+import System.IO.Temp (withSystemTempDirectory) import System.Random (randomIO)+import System.Timeout (timeout) import Test.HUnit (assertFailure)-import UnliftIO-import UnliftIO.Concurrent (threadDelay)  -- | Run with logging to stderr if HASKOIN_TEST_LOG is set, silently otherwise. withTestLogger :: (Logger -> IO a) -> IO a@@ -272,10 +277,10 @@             closed = closed           }       src =-        receive to_local_in >>= \case+        liftIO (receive to_local_in) >>= \case           Nothing -> return ()           Just b -> yield b >> src-      snk = awaitForever $ \b -> Just b `send` from_local+      snk = awaitForever $ \b -> liftIO (Just b `send` from_local)       close_local = do         atomically (writeTVar closed True)         Nothing `send` from_local
test/regtest/Regtest/Podman.hs view
@@ -19,6 +19,7 @@   ) where +import Control.Concurrent (threadDelay) import Control.Exception (bracket) import Control.Monad (unless, void) import Data.Char (isHexDigit, isSpace)@@ -28,8 +29,7 @@ import System.Exit (ExitCode (..)) import System.Process (readProcessWithExitCode) import System.Random (randomRIO)-import UnliftIO (timeout)-import UnliftIO.Concurrent (threadDelay)+import System.Timeout (timeout)  data Impl = BitcoinCore | BitcoinCashNode   deriving stock (Eq, Show)
test/unit/Haskoin/Node/AddressSpec.hs view
@@ -33,8 +33,8 @@ spec :: Spec spec = do   describe "routable addresses" $ do-    it "refuses the reserved IPv4 ranges" $-      forM_+    it "refuses the reserved IPv4 ranges"+      $ forM_         [ (198, 18, 0, 1), -- benchmarking, 198.18.0.0/15           (198, 19, 255, 1),           (192, 0, 2, 1), -- documentation@@ -43,19 +43,19 @@           (0, 1, 2, 3), -- this network           (192, 0, 0, 1) -- protocol assignments         ]-        $ \a -> isRoutable (v4 a) `shouldBe` False+      $ \a -> isRoutable (v4 a) `shouldBe` False      it "accepts the addresses just outside the benchmarking range" $ do       isRoutable (v4 (198, 17, 255, 1)) `shouldBe` True       isRoutable (v4 (198, 20, 0, 1)) `shouldBe` True -    it "refuses the reserved IPv6 ranges" $-      forM_+    it "refuses the reserved IPv6 ranges"+      $ forM_         [ (0xff02, 0, 0, 0, 0, 0, 0, 1), -- multicast           (0xfec0, 0, 0, 0, 0, 0, 0, 1), -- site-local           (0x2001, 0x0db8, 0, 0, 0, 0, 0, 1) -- documentation         ]-        $ \a -> isRoutable (v6 a) `shouldBe` False+      $ \a -> isRoutable (v6 a) `shouldBe` False      it "refuses the ORCHID ranges, as Bitcoin Core does" $       -- RFC 4843: 2001:10::/28; RFC 7343: 2001:20::/28
test/unit/Haskoin/Node/ChainSpec.hs view
@@ -3,6 +3,8 @@ -- | Header chain process driven by fake peers. module Haskoin.Node.ChainSpec (spec) where +import Control.Concurrent.Async (link, withAsync)+import Control.Concurrent.STM import Control.Monad (forM_, forever, void) import Data.Text (Text) import Data.Time.Clock (NominalDiffTime)@@ -14,7 +16,6 @@ import NQE import Test.HUnit (assertFailure) import Test.Hspec hiding (pending)-import UnliftIO  data ChainTest = ChainTest   { chain :: !Chain,
test/unit/Haskoin/Node/PeerMgrSpec.hs view
@@ -1,6 +1,9 @@ -- | Full node connected to scripted remote peers over in-memory connections. module Haskoin.Node.PeerMgrSpec (spec) where +import Control.Concurrent (threadDelay)+import Control.Concurrent.MVar+import Control.Concurrent.STM import Control.Monad (forever, void, when) import Data.Time.Clock (diffUTCTime, getCurrentTime) import Haskoin@@ -9,8 +12,6 @@ import Network.Socket (SockAddr (..)) import System.Random (randomIO) import Test.Hspec-import UnliftIO-import UnliftIO.Concurrent (threadDelay)  -- | Node connected to a single remote running the given script. Each -- connection attempt runs the script again with the attempt number.
test/unit/Haskoin/Node/PeerSpec.hs view
@@ -1,25 +1,28 @@ -- | Peer process talking to a scripted remote over an in-memory connection. module Haskoin.Node.PeerSpec (spec) where -import Control.Concurrent.Async (ExceptionInLinkedThread (..)) import Conduit (sinkNull, yieldMany)+import Control.Concurrent (threadDelay)+import Control.Concurrent.Async+import Control.Concurrent.MVar+import Control.Concurrent.STM+import Control.Exception (evaluate, fromException) import Control.Monad (forM_, forever)+import Control.Monad.IO.Class (liftIO) import Data.ByteString qualified as B-import Data.Serialize (putWord32le, runPut) import Data.Int (Int64)+import Data.Serialize (putWord32le, runPut) import Data.Word (Word32) import Haskoin import Haskoin.Node import Haskoin.Node.Peer.Lock (Lock (..)) import Haskoin.Node.Test import NQE+import System.Mem (getAllocationCounter) import Test.HUnit (assertFailure) import Test.Hspec hiding (pending) import Test.Hspec.QuickCheck (prop) import Test.QuickCheck (Positive (..), ioProperty)-import UnliftIO-import UnliftIO.Concurrent (threadDelay)-import System.Mem (getAllocationCounter)  data PeerTest = PeerTest   { peer :: !Peer,
test/unit/Haskoin/NodeSpec.hs view
@@ -12,6 +12,9 @@ module Haskoin.NodeSpec (spec) where  import Conduit+import Control.Concurrent (threadDelay)+import Control.Concurrent.Async+import Control.Concurrent.STM import Control.Monad (forM_, forever, replicateM) import Data.ByteString (ByteString) import Data.ByteString qualified as B@@ -23,17 +26,17 @@ import Data.Serialize (decode, get, put, runGet, runPut) import Data.Time.Clock (NominalDiffTime) import Data.Time.Clock.POSIX (getPOSIXTime)+import Data.Word (Word32, Word8) import Database.RocksDB qualified as R import Haskoin import Haskoin.Node-import NQE-import Data.Word (Word32, Word8) import Haskoin.Node.Test (eventually)+import NQE import Network.Socket (PortNumber, SockAddr (..), tupleToHostAddress, tupleToHostAddress6)+import System.IO.Temp (withSystemTempDirectory) import System.Random (randomIO)+import System.Timeout (timeout) import Test.Hspec-import UnliftIO-import UnliftIO.Concurrent (threadDelay)  data TestNode = TestNode   { testMgr :: PeerMgr,@@ -86,8 +89,8 @@   s <- newInbox   let s' = inboxToMailbox s   withAsync (go r s') $ \_ -> do-    let o = awaitForever (`send` r)-        i = forever (receive s >>= yield)+    let o = awaitForever (liftIO . (`send` r))+        i = forever (liftIO (receive s) >>= yield)     f (Conduits i o) :: IO ()   where     go :: Inbox ByteString -> Mailbox ByteString -> IO ()@@ -98,12 +101,12 @@           ver = buildVersion net nonce 0 ad rmt now       runPut (putMessage net (MVersion ver)) `send` s       runConduit $-        forever (receive r >>= yield)+        forever (liftIO (receive r) >>= yield)           .| inc           .| iterMC count_getheaders           .| concatMapC react           .| outc-          .| awaitForever (`send` s)+          .| awaitForever (liftIO . (`send` s))     outc = mapMC $ return . either id (runPut . putMessage net)     count_getheaders = \case       MGetHeaders _ -> atomically (modifyTVar' count (+ 1))@@ -326,17 +329,18 @@           threadDelay (6 * 1000 * 1000)           tried <- readTVarIO attempts           length (filter (`elem` sameGroup) tried) `shouldBe` 1-    it "does not connect to a DNS seed result that is not routable" $+    it "does not connect to a DNS seed result that is not routable"+      $       -- The seed of regtest is localhost, which resolves to loopback       -- addresses. With no static peers, nothing else could be tried.       withTestNodeOpts         (defOpts allBlocks) {discover = True, staticPeers = []}         net         "seed-loopback"-        $ \TestNode {..} -> do-          -- the node tries a new address every 0.1 to 5 seconds-          threadDelay (6 * 1000 * 1000)-          readTVarIO attempts `shouldReturn` []+      $ \TestNode {..} -> do+        -- the node tries a new address every 0.1 to 5 seconds+        threadDelay (6 * 1000 * 1000)+        readTVarIO attempts `shouldReturn` []     it "does not connect to private addresses that peers relay" $ do       let v4 a b c d p = SockAddrInet p (tupleToHostAddress (a, b, c, d))           v6 t p = SockAddrInet6 p 0 (tupleToHostAddress6 t) 0@@ -376,7 +380,7 @@       -- take that as the end of the sync instead of asking again.       withTestNodeBlocks [] net "no-headers" $ \TestNode {..} -> do         _ <- waitForPeer nodeEvents-        atomically $ readTVar getHeadersCount >>= checkSTM . (>= 1)+        atomically $ readTVar getHeadersCount >>= check . (>= 1)         threadDelay (1000 * 1000)         readTVarIO getHeadersCount `shouldReturn` 1     it "reports the headers as synced when the best header has the minimum chain work" $ do