Skip to content

Commit 49da0f3

Browse files
tochicoolProofOfKeags
authored andcommitted
Update build
This commit updates the build to pass on the latest github runners. To this end we: * update the github workflows to use the latest versions of all actions * enable the schnorr signature and the recovery module in the installation of the `secp256k1` library on all platforms to resolve any issues with missing symbols * update the stackage resolver to version lts-22.6 - the macOS runner has issues building on GHC 9.0.X * did not upgrade but added lower bounds to the `secp256k1-haskell` dependency of `< 1` as presumably we plan to move to the new `libsecp256k1` library * small changes `Bitcoin.Transaction.Builder` and `Bitcoin.Util` to make the code compile with the latest version of `bytestring` and remove the reliance on a missing (likely orphan) instances of `Alternative` for `Either a`. Signed-off-by: Tochi Obudulu <[email protected]>
1 parent 8c6700d commit 49da0f3

File tree

10 files changed

+55
-38
lines changed

10 files changed

+55
-38
lines changed

.github/workflows/build.yaml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ jobs:
4646
name: Build
4747
runs-on: ${{ matrix.os }}
4848
steps:
49-
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
49+
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
5050
name: Checkout
5151

52-
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
52+
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
5353
name: Checkout bitcoin-core/secp256k1
5454
with:
5555
repository: bitcoin-core/secp256k1
56-
ref: 694ce8fb2d1fd8a3d641d7c33705691d41a2a860
56+
ref: 1ad5185cd42c0636104129fcc9f6a4bf9c67cc40
5757
path: lib/secp256k1
5858

59-
- uses: haskell/actions/setup@f7b0997283589ea5a6b4f2ade6a239d70a412877
59+
- uses: haskell-actions/setup@64aa5146ed5bd91f181552b8b5fbe50fbd2bd3fe
6060
name: Setup Haskell
6161
id: setup-haskell
6262
with:
@@ -65,7 +65,7 @@ jobs:
6565

6666
- name: Cache
6767
id: cache
68-
uses: actions/cache@56461b9eb0f8438fd15c7a9968e3c9ebb18ceff1
68+
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9
6969
with:
7070
path: |
7171
${{ steps.setup-haskell.outputs.stack-root }}
@@ -75,14 +75,15 @@ jobs:
7575
7676
- name: Install buildtools (MacOS)
7777
if: matrix.os == 'macOS-latest'
78-
run: brew install automake
78+
run: |
79+
brew install automake libtool
7980
8081
- name: Install libsecp256k1 (Unix)
8182
if: matrix.os != 'windows-latest'
8283
working-directory: ./lib/secp256k1
8384
run: |
8485
./autogen.sh
85-
./configure
86+
./configure --enable-module-schnorrsig --enable-module-recovery
8687
make
8788
make check
8889
sudo make install
@@ -95,11 +96,15 @@ jobs:
9596
pacman --noconfirm -Sy msys2-keyring
9697
pacman --noconfirm -S mingw-w64-x86_64-pkg-config
9798
pacman --noconfirm -S mingw-w64-x86_64-autotools
98-
./autogen.sh
99-
./configure --prefix=/mingw64
100-
make
101-
make check
102-
make install
99+
cmake -S . -B build -G "Unix Makefiles" \
100+
-DCMAKE_TOOLCHAIN_FILE=../cmake/x86_64-w64-mingw32.toolchain.cmake \
101+
-DCMAKE_BUILD_TYPE=Release \
102+
-DCMAKE_INSTALL_PREFIX=/mingw64 \
103+
-DENABLE_MODULE_SCHNORRSIG=ON \
104+
-DENABLE_MODULE_RECOVERY=ON
105+
cmake --build build --target all
106+
cmake --build build --target test
107+
cmake --build build --target install
103108
shell: stack exec -- bash {0}
104109

105110
- name: Install dependencies

.github/workflows/fourmolu.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ jobs:
3232
name: Format
3333
runs-on: ubuntu-latest
3434
steps:
35-
- uses: actions/checkout@8230315d06ad95c617244d2f265d237a1682d445
35+
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
3636
name: Checkout
37-
- uses: fourmolu/fourmolu-action@d88033a61a1d2f04072cabd6a0bd1308d92238e4
37+
- uses: haskell-actions/run-fourmolu@5a9f41fa092841e52e6c57dde5600e586fa766a4
3838
name: Run fourmolu
39+
with:
40+
version: "0.8.2.0"

.github/workflows/hlint.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ jobs:
3838
if: github.event.pull_request.draft == false
3939
runs-on: ubuntu-latest
4040
steps:
41-
- uses: actions/checkout@v3
41+
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
4242

4343
- name: "Set up HLint"
44-
uses: haskell/actions/hlint-setup@v2
44+
uses: haskell-actions/hlint-setup@0b0024319753ba0c8b2fa21b7018ed252aed8181
4545
with:
4646
version: "3.5"
4747

4848
- name: "Run HLint"
49-
uses: haskell/actions/hlint-run@v2
49+
uses: haskell-actions/hlint-run@96199a3357287063c67606b26d533f1acb4b6c4e
5050
with:
5151
# For some reason this has to be a string containing JSON rather than a YAML sequence
5252
path: '[ "bitcoin/", "bitcoin-test/", "bitcoin-bench/" ]'

bitcoin-test/bitcoin-test.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 1.12
22

3-
-- This file has been generated from package.yaml by hpack version 0.35.0.
3+
-- This file has been generated from package.yaml by hpack version 0.36.0.
44
--
55
-- see: https://github.com/sol/hpack
66

bitcoin/bitcoin.cabal

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 1.12
22

3-
-- This file has been generated from package.yaml by hpack version 0.35.0.
3+
-- This file has been generated from package.yaml by hpack version 0.36.0.
44
--
55
-- see: https://github.com/sol/hpack
66

@@ -66,7 +66,7 @@ library
6666
build-depends:
6767
array >=0.5.4.0
6868
, base >=4.9 && <5
69-
, base16 >=0.3.0.1
69+
, base16 >=1
7070
, binary >=0.8.8
7171
, bytestring >=0.10.10.0
7272
, containers >=0.6.2.1
@@ -76,7 +76,7 @@ library
7676
, memory >=0.15.0
7777
, murmur3 >=1.0.3
7878
, network >=3.1.1.1
79-
, secp256k1-haskell >=0.4.0
79+
, secp256k1-haskell >=0.4.0 && <1
8080
, split >=0.2.3.3
8181
, string-conversions >=0.4.0.1
8282
, text >=1.2.3.0

bitcoin/package.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ bug-reports: http://github.com/haskell-bitcoin/bitcoin/issues
1717
dependencies:
1818
- array >= 0.5.4.0
1919
- base >=4.9 && <5
20-
- base16 >= 0.3.0.1
20+
- base16 >= 1
2121
- binary >= 0.8.8
2222
- bytestring >= 0.10.10.0
2323
- containers >= 0.6.2.1
@@ -28,7 +28,7 @@ dependencies:
2828
- murmur3 >= 1.0.3
2929
- network >= 3.1.1.1
3030
- split >= 0.2.3.3
31-
- secp256k1-haskell >= 0.4.0
31+
- secp256k1-haskell >= 0.4.0 && < 1
3232
- string-conversions >= 0.4.0.1
3333
- text >= 1.2.3.0
3434
- transformers >= 0.5.6.2

bitcoin/src/Bitcoin/Transaction/Builder.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,9 +273,10 @@ verifyStdInput net tx i so0 val
273273
| isSegwit so0 =
274274
fromRight False $ (inp == mempty &&) . verifySegwitInput so0 <$> wp so0
275275
| otherwise =
276-
fromRight False $
277-
(verifyLegacyInput so0 <$> decodeInputBS net inp)
278-
<|> (nestedScriptOutput >>= \so -> verifyNestedInput so0 so <$> wp so)
276+
either
277+
(const (fromRight False (nestedScriptOutput >>= \so -> verifyNestedInput so0 so <$> wp so)))
278+
(verifyLegacyInput so0)
279+
(decodeInputBS net inp)
279280
where
280281
inp = scriptInput $ txIn tx !! i
281282
theTxSigHash so = S.makeSigHash net tx i so val

bitcoin/src/Bitcoin/Util.hs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ module Bitcoin.Util (
5757

5858
import Control.Monad (replicateM)
5959
import Control.Monad.Trans.Except (ExceptT (..), except)
60+
import qualified Data.Base16.Types as B16
6061
import Data.Bifunctor (bimap)
6162
import Data.Binary (Binary, Get, Put)
6263
import qualified Data.Binary as Bin
@@ -106,21 +107,21 @@ hexBuilder = lazyByteStringHex
106107

107108

108109
encodeHex :: ByteString -> Text
109-
encodeHex = B16.encodeBase16
110+
encodeHex = B16.extractBase16 . B16.encodeBase16
110111

111112

112113
-- | Encode as string of human-readable hex characters.
113114
encodeHexLazy :: BSL.ByteString -> TL.Text
114-
encodeHexLazy = BL16.encodeBase16
115+
encodeHexLazy = B16.extractBase16 . BL16.encodeBase16
115116

116117

117118
decodeHex :: Text -> Maybe ByteString
118-
decodeHex = eitherToMaybe . B16.decodeBase16 . E.encodeUtf8
119+
decodeHex = eitherToMaybe . B16.decodeBase16Untyped . E.encodeUtf8
119120

120121

121122
-- | Decode string of human-readable hex characters.
122123
decodeHexLazy :: TL.Text -> Maybe BSL.ByteString
123-
decodeHexLazy = eitherToMaybe . BL16.decodeBase16 . EL.encodeUtf8
124+
decodeHexLazy = eitherToMaybe . BL16.decodeBase16Untyped . EL.encodeUtf8
124125

125126

126127
-- | Obtain 'Int' bits from beginning of 'ByteString'. Resulting 'ByteString'
@@ -153,7 +154,7 @@ maybeToEither err = maybe (Left err) Right
153154

154155

155156
-- | Lift a 'Maybe' computation into the 'ExceptT' monad.
156-
liftMaybe :: Monad m => b -> Maybe a -> ExceptT b m a
157+
liftMaybe :: (Monad m) => b -> Maybe a -> ExceptT b m a
157158
liftMaybe err = except . maybeToEither err
158159

159160

@@ -243,11 +244,11 @@ convertBits pad frombits tobits i = (reverse yout, rem')
243244
-- Serialization helpers
244245
--
245246

246-
encodeS :: Binary a => a -> ByteString
247+
encodeS :: (Binary a) => a -> ByteString
247248
encodeS = BSL.toStrict . Bin.encode
248249

249250

250-
decode :: Binary a => BSL.ByteString -> Either String a
251+
decode :: (Binary a) => BSL.ByteString -> Either String a
251252
decode = bimap lst3 lst3 . Get.decodeOrFail
252253

253254

stack.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
resolver: lts-19.27
1+
resolver: lts-22.6
22
system-ghc: true
33
nix:
44
packages:
@@ -7,6 +7,7 @@ nix:
77
extra-deps:
88
- fourmolu-0.8.2.0
99
- cryptonite-0.30
10+
- secp256k1-haskell-0.7.0
1011
packages:
1112
- ./bitcoin
1213
- ./bitcoin-test

stack.yaml.lock

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,16 @@ packages:
1818
size: 23323
1919
original:
2020
hackage: cryptonite-0.30
21+
- completed:
22+
hackage: secp256k1-haskell-0.7.0@sha256:1585601c67d7c62c698402ffe8462de216a499608521a8136d0aa15f0a03a23f,2140
23+
pantry-tree:
24+
sha256: a7726275193ac4ef14c9d97378222d3ca494524c48354edf69214513def7d48d
25+
size: 599
26+
original:
27+
hackage: secp256k1-haskell-0.7.0
2128
snapshots:
2229
- completed:
23-
sha256: 1ecad1f0bd2c27de88dbff6572446cfdf647c615d58a7e2e2085c6b7dfc04176
24-
size: 619403
25-
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/27.yaml
26-
original: lts-19.27
30+
sha256: 1b4c2669e26fa828451830ed4725e4d406acc25a1fa24fcc039465dd13d7a575
31+
size: 714100
32+
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/6.yaml
33+
original: lts-22.6

0 commit comments

Comments
 (0)