Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

Commit 3004b4a

Browse files
committed
fix/disable builds for cwtools
1 parent be3982c commit 3004b4a

File tree

6 files changed

+44
-35
lines changed

6 files changed

+44
-35
lines changed

cwtools/cwtools.cabal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ executable compact
147147
executable db-checksum
148148
import: warning-flags, debugging-flags
149149
default-language: Haskell2010
150+
buildable: False
150151
ghc-options:
151152
-threaded
152153
-rtsopts
@@ -232,6 +233,7 @@ executable genconf
232233
executable header-dump
233234
import: warning-flags, debugging-flags
234235
default-language: Haskell2010
236+
buildable: False
235237
ghc-options:
236238
-threaded
237239
-rtsopts

cwtools/evm-genesis/Main.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ main = do
9696
queryNode :: Natural -> FilePath -> IO E.Header
9797
queryNode cid spec = withRethNode cid spec $ \uri -> do
9898
ctx <- mkRpcCtx uri
99-
hdr <- getBlockAtNumber ctx 0
100-
return hdr
99+
getBlockAtNumber ctx 0
101100

102101
-- | Run reth node with chain-spec file at default port 8545 and execute an
103102
-- action with the node URI.
@@ -107,7 +106,7 @@ withRethNode cid specfile act =
107106
withCreateProcess runProc $ \_stdin _stdout _stderr _ph -> do
108107
recoverAll policy $ \_ -> do
109108
hPutStrLn stderr $ "Waiting for reth node for chain " <> show cid <> " to start..."
110-
uri <- fromText (fromString ("http://localhost:" <> rethPort))
109+
uri <- fromTextM (fromString ("http://localhost:" <> rethPort))
111110
r <- act uri
112111
hFlush stdout
113112
return r

cwtools/header-dump/Main.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,9 @@ validateConfig o = do
246246
checkIfValidChain (_configChainId o)
247247
mapM_ (validateDirectory "database") (_configDatabasePath o)
248248
when (_configValidate o && isJust (_configChainId o))
249-
$ throwError $ "validation (--validate) can only be used if no particular chain is selected"
249+
$ throwError "validation (--validate) can only be used if no particular chain is selected"
250250
where
251-
chains = chainIds $ _configChainwebVersion o
251+
chains = withVersion (_configChainwebVersion o) chainIds
252252

253253
checkIfValidChain Nothing = return ()
254254
checkIfValidChain (Just cid) = unless (HS.member cid chains)

cwtools/known-graphs/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import System.Environment
2424
main :: IO ()
2525
main = do
2626
args <- getArgs
27-
graphs <- traverse (fromText . T.pack) args
27+
graphs <- traverse (fromTextM . T.pack) args
2828
BL8.putStrLn $ encode $ knownChainGraph <$> graphs
2929

3030
instance ToJSON KnownGraph where

cwtools/run-nodes/Main.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pNodes = option auto
4343
pVersion :: Parser ChainwebVersion
4444
pVersion = option (findKnownVersion =<< textReader)
4545
(long "chainweb-version" <> metavar "CHAINWEB_VERSION"
46-
<> value (fastForkingCpmTestVersion petersenChainGraph)
46+
<> value (barebonesTestVersion petersenChainGraph)
4747
<> help "Chainweb Version to run the Nodes with (default: timedCPM-petersen)")
4848

4949
pConfig :: Parser FilePath

cwtools/txstream/Main.hs

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
--
2727
module Main (main) where
2828

29+
import Chainweb.BlockHash
2930
import Chainweb.BlockHeader
3031
import Chainweb.BlockHeaderDB.RemoteDB
3132
import Chainweb.BlockHeight
@@ -85,7 +86,7 @@ defaultConfig = Config
8586
{ _configLogHandle = Y.StdOut
8687
, _configLogLevel = Y.Info
8788
, _configChainwebVersion = RecapDevelopment
88-
, _configChainId = someChainId RecapDevelopment
89+
, _configChainId = withVersion RecapDevelopment someChainId
8990
, _configNode = HostAddress (unsafeHostnameFromText "us1.tn1.chainweb.com") 443
9091
, _configPretty = True
9192
, _configOutputs = True
@@ -151,7 +152,6 @@ hostAddressBaseUrl h = BaseUrl
151152

152153
devNetDb :: Config -> Manager -> LogFunction -> IO RemoteDb
153154
devNetDb c mgr l = mkDb
154-
(_configChainwebVersion c)
155155
(_configChainId c)
156156
mgr
157157
l
@@ -160,25 +160,22 @@ devNetDb c mgr l = mkDb
160160
-- TreeDB
161161

162162
mkDb
163-
:: HasChainwebVersion v
164-
=> HasChainId cid
165-
=> v
166-
-> cid
163+
:: HasChainId cid
164+
=> cid
167165
-> Manager
168166
-> LogFunction
169167
-> HostAddress
170168
-> IO RemoteDb
171-
mkDb v c mgr logg h = do
169+
mkDb c mgr logg h = do
172170
return $ RemoteDb
173171
(env mgr h)
174172
(ALogFunction logg)
175-
(_chainwebVersion v)
176173
(_chainId c)
177174

178175
-- -------------------------------------------------------------------------- --
179176
-- Payload Data
180177

181-
run :: Config -> LogFunction -> IO ()
178+
run :: HasVersion => Config -> LogFunction -> IO ()
182179
run config logg = do
183180
mgr <- newTlsManager
184181
txStream config mgr logg
@@ -215,19 +212,20 @@ prettyCommand p (bh, c) = T.decodeUtf8
215212
, "payload" .= either
216213
(const $ String $ _cmdPayload c)
217214
(id @Value)
218-
(eitherDecodeStrict' $ T.encodeUtf8 $ _cmdPayload $ c)
215+
(eitherDecodeStrict' $ T.encodeUtf8 $ _cmdPayload c)
219216
]
220217

221218
txStream
222-
:: Config
219+
:: HasVersion
220+
=> Config
223221
-> Manager
224222
-> LogFunction
225223
-> S.Stream (Of (BlockHeight, Command T.Text)) IO ()
226224
txStream config mgr logg = do
227225
hdb <- liftIO $ devNetDb config mgr logg
228226

229227
c <- liftIO $ devNetCut config mgr
230-
let h = _bhwhHash $ _cutHashes c ^?! ix (_configChainId config)
228+
let h = _rankedBlockHashHash $ _cutHashes c ^?! ix (_configChainId config)
231229

232230
getBranch hdb mempty (HS.singleton (UpperBound h))
233231
& S.chain (logg @T.Text Debug . sshow)
@@ -243,7 +241,7 @@ txStream config mgr logg = do
243241
-- -------------------------------------------------------------------------- --
244242
-- PayloadWithOutputs
245243

246-
runOutputs :: Config -> LogFunction -> IO ()
244+
runOutputs :: HasVersion => Config -> LogFunction -> IO ()
247245
runOutputs config logg = do
248246
mgr <- newTlsManager
249247
txOutputsStream config mgr logg
@@ -269,20 +267,21 @@ prettyCommandWithOutputs p (bh, c, o) = T.decodeUtf8
269267
, "payload" .= either
270268
(const $ String $ _cmdPayload c)
271269
(id @Value)
272-
(eitherDecodeStrict' $ T.encodeUtf8 $ _cmdPayload $ c)
270+
(eitherDecodeStrict' $ T.encodeUtf8 $ _cmdPayload c)
273271
, "output" .= J.toJsonViaEncode o
274272
]
275273

276274
txOutputsStream
277-
:: Config
275+
:: HasVersion
276+
=> Config
278277
-> Manager
279278
-> LogFunction
280279
-> S.Stream (Of (BlockHeight, Command T.Text, CommandResult T.Text)) IO ()
281280
txOutputsStream config mgr logg = do
282281
hdb <- liftIO $ devNetDb config mgr logg
283282

284283
cut <- liftIO $ devNetCut config mgr
285-
let h = _bhwhHash $ _cutHashes cut ^?! ix (_configChainId config)
284+
let h = _rankedBlockHashHash $ _cutHashes cut ^?! ix (_configChainId config)
286285

287286
getBranch hdb mempty (HS.singleton (UpperBound h))
288287
& S.chain (logg @T.Text Debug . sshow)
@@ -303,55 +302,64 @@ txOutputsStream config mgr logg = do
303302
-- -------------------------------------------------------------------------- --
304303
-- Cut
305304

306-
devNetCut :: Config -> Manager -> IO CutHashes
307-
devNetCut config mgr = runClientM (cutGetClient ver) (env mgr node) >>= \case
305+
devNetCut :: HasVersion => Config -> Manager -> IO CutHashes
306+
devNetCut config mgr = runClientM cutGetClient (env mgr node) >>= \case
308307
Left e -> error (show e)
309308
Right x -> return x
310309
where
311-
ver = _configChainwebVersion config
312310
node = _configNode config
313311

314312
-- -------------------------------------------------------------------------- --
315313
-- Payloads
316314

317-
devNetPayload :: Config -> Manager -> BlockHeight -> BlockPayloadHash -> IO PayloadData
318-
devNetPayload config mgr h x = runClientM (payloadClient ver cid x (Just h)) (env mgr node) >>= \case
315+
devNetPayload
316+
:: HasVersion
317+
=> Config
318+
-> Manager
319+
-> BlockHeight
320+
-> BlockPayloadHash
321+
-> IO PayloadData
322+
devNetPayload config mgr h x = runClientM (payloadClient cid x (Just h)) (env mgr node) >>= \case
319323
Left e -> error (show e)
320324
Right a -> return a
321325
where
322326
cid = _configChainId config
323-
ver = _configChainwebVersion config
324327
node = _configNode config
325328

326-
devNetPayloadWithOutput :: Config -> Manager -> BlockHeight -> BlockPayloadHash -> IO PayloadWithOutputs
329+
devNetPayloadWithOutput
330+
:: HasVersion
331+
=> Config
332+
-> Manager
333+
-> BlockHeight
334+
-> BlockPayloadHash
335+
-> IO PayloadWithOutputs
327336
devNetPayloadWithOutput config mgr h x
328-
= runClientM (outputsClient ver cid x (Just h)) (env mgr node) >>= \case
337+
= runClientM (outputsClient cid x (Just h)) (env mgr node) >>= \case
329338
Left e -> error (show e)
330339
Right a -> return a
331340
where
332341
cid = _configChainId config
333-
ver = _configChainwebVersion config
334342
node = _configNode config
335343

336344
-- -------------------------------------------------------------------------- --
337345
-- Main
338346

339347
mainWithConfig :: Config -> IO ()
340-
mainWithConfig config = withLog $ \logger -> do
348+
mainWithConfig config = withLog $ \logger -> withVersion ver $ do
341349
let logg :: LogFunction
342350
logg = logFunction $ logger
343351
& addLabel ("host", toText $ _configNode config)
344352
& addLabel ("version", toText $ _versionName $ _configChainwebVersion config)
345353
& addLabel ("chain", toText $ _configChainId config)
346354
liftIO $ do
347-
registerVersion (_configChainwebVersion config)
348355
if _configOutputs config
349356
then runOutputs config logg
350357
else run config logg
351358

352359
where
360+
ver = _configChainwebVersion config
353361
logconfig = Y.defaultLogConfig
354-
& Y.logConfigLogger . Y.loggerConfigThreshold .~ (_configLogLevel config)
362+
& Y.logConfigLogger . Y.loggerConfigThreshold .~ _configLogLevel config
355363
& Y.logConfigBackend . Y.handleBackendConfigHandle .~ _configLogHandle config
356364
withLog inner = Y.withHandleBackend_ logText (logconfig ^. Y.logConfigBackend)
357365
$ \backend -> Y.withLogger (logconfig ^. Y.logConfigLogger) backend inner

0 commit comments

Comments
 (0)