Skip to content

Commit

Permalink
Merge #2765
Browse files Browse the repository at this point in the history
2765: Fix weeder 2.x config and remove weeds r=rvl a=rvl

### Issue Number

This could fix #2695, I really hope it does.

### Overview

I was looking into #2695, running `weeder` locally to see what it could be doing.

But it turns out that Weeder has been doing nothing at all since upgrading `weeder` to 2.1.3, which happened when we upgraded to ghc-8.10.4.

It needed to have a ghc option added to generate `.hie` files, which I didn't set before. If Weeder can't find `.hie` files, it just reports zero weeds (ocharles/weeder#19).

So I have:
1. Fixed the Weeder config for Stack and Cabal.
2. Removed weeds which would have been introduced while weeder wasn't working.
3. Removed weeds found by Weeder 2.x, which were never found by Weeder 1.0.9.

### Comments

```
 49 files changed, 109 insertions(+), 1681 deletions(-)
```


Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
Co-authored-by: Jonathan Knowles <jonathan.knowles@iohk.io>
  • Loading branch information
3 people committed Jul 20, 2021
2 parents 66d0d8d + cb2c01d commit f366405
Show file tree
Hide file tree
Showing 49 changed files with 90 additions and 1,664 deletions.
42 changes: 0 additions & 42 deletions .weeder.yaml

This file was deleted.

6 changes: 4 additions & 2 deletions cabal-nix.project
Expand Up @@ -16,11 +16,11 @@
--
-- To build, start "nix-shell", then run Cabal inside:
-- nix-shell
-- cabal build --project-file=cabal-nix.project all
-- cabal --project-file=cabal-nix.project build all
--
-- To build with profiling enabled, use:
-- nix-shell --arg profiling true
-- cabal build --project-file=cabal-nix.project all --enable-profiling
-- cabal --project-file=cabal-nix.project build all --enable-profiling
--
--------------------------------------------------------------------------------

Expand All @@ -29,3 +29,5 @@ packages:

tests: True
benchmarks: True
package *
ghc-options: -fwrite-ide-info
9 changes: 9 additions & 0 deletions cabal.project
Expand Up @@ -175,30 +175,39 @@ test-show-details: direct

package cardano-wallet
tests: True
ghc-options: -fwrite-ide-info

package cardano-wallet-core
tests: True
ghc-options: -fwrite-ide-info

package cardano-wallet-cli
tests: True
ghc-options: -fwrite-ide-info

package cardano-wallet-launcher
tests: True
ghc-options: -fwrite-ide-info

package cardano-wallet-text-class
tests: True
ghc-options: -fwrite-ide-info

package cardano-numeric
tests: True
ghc-options: -fwrite-ide-info

package cardano-wallet-core-integration
tests: True
ghc-options: -fwrite-ide-info

package cardano-wallet-test-utils
tests: True
ghc-options: -fwrite-ide-info

package strict-non-empty-containers
tests: True
ghc-options: -fwrite-ide-info

-- Now disable all other tests with a global flag.
-- This is what they do in cardano-node/cabal.project.
Expand Down
26 changes: 0 additions & 26 deletions lib/cli/src/Cardano/CLI.hs
Expand Up @@ -36,7 +36,6 @@ module Cardano.CLI
, cmdWalletCreate
, cmdByronWalletCreate
, cmdTransaction
, cmdTransactionJormungandr
, cmdAddress
, cmdStakePool
, cmdNetwork
Expand All @@ -49,8 +48,6 @@ module Cardano.CLI
, databaseOption
, hostPreferenceOption
, listenOption
, nodePortOption
, nodePortMaybeOption
, shutdownHandlerFlag
, stateDirOption
, syncToleranceOption
Expand Down Expand Up @@ -744,14 +741,6 @@ cmdTransaction
-> Mod CommandFields (IO ())
cmdTransaction = cmdTransactionBase ShelleyFeatures

-- | cardano-wallet-jormungandr transaction
cmdTransactionJormungandr
:: ToJSON wallet
=> TransactionClient
-> WalletClient wallet
-> Mod CommandFields (IO ())
cmdTransactionJormungandr = cmdTransactionBase NoShelleyFeatures

cmdTransactionBase
:: ToJSON wallet
=> TransactionFeatures
Expand Down Expand Up @@ -1215,21 +1204,6 @@ randomPortOption = flag' False $ mempty
<> long "random-port"
<> help "serve wallet API on any available port (conflicts with --port)"

-- | [--node-port=INT], default: 8080
nodePortOption :: Parser (Port "Node")
nodePortOption = optionT $ optionNodePort <> value (Port 8080)

-- | [--node-port=INT], default: use any available port
nodePortMaybeOption :: Parser (Maybe (Port "Node"))
nodePortMaybeOption = optional $ optionT optionNodePort

optionNodePort :: Mod OptionFields (Port "Node")
optionNodePort = mempty
<> long "node-port"
<> metavar "INT"
<> help "port used for communicating with the target node."
<> showDefaultWith showT

-- | --payment=PAYMENT
paymentOption :: Parser Text
paymentOption = optionT $ mempty
Expand Down
3 changes: 0 additions & 3 deletions lib/core/cardano-wallet-core.cabal
Expand Up @@ -161,7 +161,6 @@ library
Cardano.Wallet.DB.Sqlite.Types
Cardano.Wallet.Logging
Cardano.Wallet.Network
Cardano.Wallet.Network.BlockHeaders
Cardano.Wallet.Network.Ports
Cardano.Wallet.Orphans
Cardano.Wallet.TokenMetadata
Expand Down Expand Up @@ -204,7 +203,6 @@ library
Cardano.Wallet.Version
Cardano.Wallet.Version.TH
Crypto.Hash.Utils
Data.Binary.Get.Safe
Data.Function.Utils
Data.Time.Text
Data.Time.Utils
Expand Down Expand Up @@ -357,7 +355,6 @@ test-suite unit
Cardano.Wallet.DB.Sqlite.TypesSpec
Cardano.Wallet.DB.StateMachine
Cardano.Wallet.DummyTarget.Primitive.Types
Cardano.Wallet.Network.BlockHeadersSpec
Cardano.Wallet.Network.PortsSpec
Cardano.Wallet.NetworkSpec
Cardano.Wallet.Primitive.AddressDerivation.ByronSpec
Expand Down
103 changes: 0 additions & 103 deletions lib/core/src/Cardano/Byron/Codec/Cbor.hs
Expand Up @@ -26,25 +26,17 @@ module Cardano.Byron.Codec.Cbor
, decodeAddressPayload
, decodeAllAttributes
, decodeDerivationPathAttr
, decodeSignedTx
, decodeTx
, decodeTxWitness
, decodeProtocolMagicAttr

-- * Encoding
, encodeAddress
, encodeAttributes
, encodeDerivationPathAttr
, encodeProtocolMagicAttr
, encodePublicKeyWitness
, encodeTx
, encodeSignedTx
, encodeTxWitness

-- * Helpers
, deserialiseCbor
, inspectNextToken
, decodeList
, decodeListIndef
, decodeNestedBytes
) where
Expand Down Expand Up @@ -79,12 +71,8 @@ import Data.Digest.CRC32
( crc32 )
import Data.Either.Extra
( eitherToMaybe )
import Data.List
( find )
import Data.Word
( Word8 )
import Debug.Trace
( traceShow )

import qualified Cardano.Wallet.Primitive.Types.TokenBundle as TokenBundle
import qualified Codec.CBOR.Decoding as CBOR
Expand Down Expand Up @@ -187,18 +175,6 @@ decodeAddressDerivationPath pwd = do
]
pure path

decodeProtocolMagicAttr
:: CBOR.Decoder s (Maybe ProtocolMagic)
decodeProtocolMagicAttr = do
_ <- CBOR.decodeListLenCanonicalOf 3
_ <- CBOR.decodeBytes
attrs <- decodeAllAttributes
case find ((== 2) . fst) attrs of
Nothing -> pure Nothing
Just (_, bytes) -> case deserialiseCbor decodeProtocolMagic bytes of
Nothing -> fail "unable to decode attribute into protocol magic"
Just pm -> pure (Just pm)

decodeEmptyAttributes :: CBOR.Decoder s ((), CBOR.Encoding)
decodeEmptyAttributes = do
_ <- CBOR.decodeMapLenCanonical -- Empty map of attributes
Expand Down Expand Up @@ -261,16 +237,6 @@ decodeDerivationPath = do
, show ixs
]

decodeProtocolMagic :: CBOR.Decoder s ProtocolMagic
decodeProtocolMagic = ProtocolMagic <$> CBOR.decodeInt32

decodeSignedTx :: CBOR.Decoder s (([TxIn], [TxOut]), [ByteString])
decodeSignedTx = do
_ <- CBOR.decodeListLenCanonicalOf 2
tx <- decodeTx
witnesses <- decodeList decodeTxWitness
return (tx, witnesses)

decodeTx :: CBOR.Decoder s ([TxIn], [TxOut])
decodeTx = do
_ <- CBOR.decodeListLenCanonicalOf 3
Expand Down Expand Up @@ -306,18 +272,6 @@ decodeTxOut = do
addr <- decodeAddress
TxOut addr . TokenBundle.fromCoin . Coin <$> CBOR.decodeWord64

decodeTxWitness :: CBOR.Decoder s ByteString
decodeTxWitness = do
_ <- CBOR.decodeListLenCanonicalOf 2
t <- CBOR.decodeWord8
_ <- CBOR.decodeTag
case t of
0 -> CBOR.decodeBytes
1 -> CBOR.decodeBytes
2 -> CBOR.decodeBytes
_ -> fail
$ "decodeTxWitness: unknown tx witness constructor: " <> show t

-- * Encoding

-- | Encode a public key to a corresponding Cardano Address. The encoding of the
Expand Down Expand Up @@ -411,12 +365,6 @@ encodeDerivationPath (Index acctIx) (Index addrIx) = mempty
<> CBOR.encodeWord32 addrIx
<> CBOR.encodeBreak

encodePublicKeyWitness :: XPub -> ByteString -> CBOR.Encoding
encodePublicKeyWitness xpub signatur = mempty
<> CBOR.encodeListLen 2
<> CBOR.encodeBytes (xpubToBytes xpub)
<> CBOR.encodeBytes signatur

encodeTx :: ([TxIn], [TxOut]) -> CBOR.Encoding
encodeTx (inps, outs) = mempty
<> CBOR.encodeListLen 3
Expand All @@ -428,29 +376,6 @@ encodeTx (inps, outs) = mempty
<> CBOR.encodeBreak
<> encodeTxAttributes

encodeSignedTx :: ([TxIn], [TxOut]) -> [ByteString] -> CBOR.Encoding
encodeSignedTx tx witnesses = mempty
<> CBOR.encodeListLen 2
<> encodeTx tx
<> CBOR.encodeListLen (fromIntegral $ length witnesses)
<> mconcat (map encodeTxWitness witnesses)

encodeTxWitness :: ByteString -> CBOR.Encoding
encodeTxWitness bytes = mempty
<> CBOR.encodeListLen 2
<> CBOR.encodeWord8 tag
<> CBOR.encodeTag 24
<> CBOR.encodeBytes bytes
where
-- NOTE
-- We only support 'PublicKey' witness types at the moment. However,
-- Byron nodes support more:
--
-- * 0 for Public Key
-- * 1 for Script
-- * 2 for Redeem
tag = 0

encodeTxAttributes :: CBOR.Encoding
encodeTxAttributes = mempty
<> CBOR.encodeMapLen 0
Expand Down Expand Up @@ -538,34 +463,6 @@ decryptDerivationPath (Passphrase passphrase) bytes = do
Helpers
-------------------------------------------------------------------------------}

-- | Inspect the next token that has to be decoded and print it to the console
-- as a trace. Useful for debugging Decoders.
-- Example:
--
-- @
-- myDecoder :: CBOR.Decoder s MyType
-- myDecoder = do
-- a <- CBOR.decodeWord64
-- inspectNextToken
-- [...]
-- @
inspectNextToken :: CBOR.Decoder s ()
inspectNextToken =
CBOR.peekTokenType >>= flip traceShow (return ())

-- | Decode an list of known length. Very similar to @decodeListIndef@.
--
-- @
-- myDecoder :: CBOR.Decoder s [MyType]
-- myDecoder = decodeList decodeOne
-- where
-- decodeOne :: CBOR.Decoder s MyType
-- @
decodeList :: forall s a . CBOR.Decoder s a -> CBOR.Decoder s [a]
decodeList decodeOne = do
l <- CBOR.decodeListLenCanonical
CBOR.decodeSequenceLenN (flip (:)) [] reverse l decodeOne

-- | Decode an arbitrary long list. CBOR introduce a "break" character to
-- mark the end of the list, so we simply decode each item until we encounter
-- a break character.
Expand Down
7 changes: 0 additions & 7 deletions lib/core/src/Cardano/DB/Sqlite.hs
Expand Up @@ -38,7 +38,6 @@ module Cardano.DB.Sqlite
, dbChunkedFor
, dbChunked'
, handleConstraint
, unsafeRunQuery

-- * Manual Migration
, ManualMigration (..)
Expand Down Expand Up @@ -149,12 +148,6 @@ newtype SqliteContext = SqliteContext

type ConnectionPool = Pool (SqlBackend, Sqlite.Connection)

-- | Run a raw query from the outside using an instantiate DB layer. This is
-- completely unsafe because it breaks the abstraction boundary and can have
-- disastrous results on the database consistency.
unsafeRunQuery :: SqliteContext -> SqlPersistT IO a -> IO a
unsafeRunQuery = runQuery

-- | Run an action, and convert any Sqlite constraints exception into the given
-- error result. No other exceptions are handled.
handleConstraint :: MonadUnliftIO m => e -> m a -> m (Either e a)
Expand Down

0 comments on commit f366405

Please sign in to comment.