Skip to content

Commit 6468c1c

Browse files
authored
[CBR-51] use stack lts-11.2 (input-output-hk#2735) (input-output-hk#2745)
* use stack lts-11.2 (input-output-hk#2735) * [CSL-2125] Bump nixpkgs and pkgs/generate.sh * use stack lts-11.2 * nixpkgs-src.json update this is probably wrong. What is the "unpacked" hash supposed to be? * update nixpkgs-src to 17.09 * remove purscript from the default shell * cardano-sl-util universum bound bumped * hide universum export in frontend deps gen * remove cabal-install from auxx and tools * bump log-warper revision (encoding fixes) * nixpkgs 18.03 * use fetchGit for nixpkgs, nixpkgs-unstable Probably not compatible with old nix versions. * Revert "use fetchGit for nixpkgs, nixpkgs-unstable" This reverts commit 07105a5. * use .hlint.yaml file (new HLint) * use custom stack2nix * bump stack2nix revision in default.nix * use custom servant-quickcheck Needs a function which is only in versions which depend upon base-compat 0.10.1 which induces dependency hell * default.nix uses ghc822 * do not use jemalloc for rocksdb This means cardano-sl-db will succesfully link! Hooray! gperftools will be used instead. * use jemalloc 510 with disabled tls flag * add git to system depends * use new stack2nix * move jemalloc into an overlay so release.nix doesnt overwrite it * make shellcheck test past * fix warnings after rebase * appveyor: try custom GHC build * temporarily disable Werror * shell.nix * kill dht-keygen * make wallet-new tests compile and pass * do not build cardano-post-mortem * fix missing extra-dep in stack.yaml * make crypto (tests) compile * pkgs/default.nix * Revert "temporarily disable Werror" This reverts commit c07c0bf. * pkgs/default.nix * fix name shadow * fix redundant constraint * fix cardano-sl cabal file * fix generator cabal file * generator redundant constraints * remove redundant import
1 parent caa0541 commit 6468c1c

File tree

212 files changed

+28141
-32711
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

212 files changed

+28141
-32711
lines changed

.hlint.yaml

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# HLint configuration file
2+
# https://github.com/ndmitchell/hlint
3+
##########################
4+
5+
# This file contains a template configuration file, which is typically
6+
# placed as .hlint.yaml in the root of your project
7+
8+
- arguments: [-XTypeApplications, --cpp-define=CONFIG=dev]
9+
10+
- ignore: {name: Redundant do}
11+
- ignore: {name: Redundant bracket}
12+
- ignore: {name: Redundant $}
13+
- ignore: {name: Redundant flip}
14+
- ignore: {name: Move brackets to avoid $}
15+
- ignore: {name: Eta reduce}
16+
- ignore: {name: Avoid lambda}
17+
- ignore: {name: Use camelCase}
18+
- ignore: {name: Use const}
19+
- ignore: {name: Use if}
20+
- ignore: {name: Use notElem}
21+
- ignore: {name: Use fromMaybe}
22+
- ignore: {name: Use maybe}
23+
- ignore: {name: Use fmap}
24+
- ignore: {name: Use foldl}
25+
- ignore: {name: 'Use :'}
26+
- ignore: {name: Use ++}
27+
- ignore: {name: Use ||}
28+
- ignore: {name: Use &&}
29+
- ignore: {name: 'Use ?~'}
30+
- ignore: {name: Use <$>}
31+
- ignore: {name: Use .}
32+
- ignore: {name: Use head}
33+
- ignore: {name: Use String}
34+
- ignore: {name: Use Foldable.forM_}
35+
- ignore: {name: Unused LANGUAGE pragma}
36+
- ignore: {name: Use newtype instead of data}
37+
# Rules not found in old HLint.hs file (prior to HLint 2.0)
38+
# Added when we made the change.
39+
- ignore: {name: Redundant lambda}
40+
- ignore: {name: Use section}
41+
42+
# Specify additional command line arguments
43+
#
44+
# - arguments: [--color, --cpp-simple, -XQuasiQuotes]
45+
46+
47+
# Control which extensions/flags/modules/functions can be used
48+
#
49+
# - extensions:
50+
# - default: false # all extension are banned by default
51+
# - name: [PatternGuards, ViewPatterns] # only these listed extensions can be used
52+
# - {name: CPP, within: CrossPlatform} # CPP can only be used in a given module
53+
#
54+
# - flags:
55+
# - {name: -w, within: []} # -w is allowed nowhere
56+
#
57+
# - modules:
58+
# - {name: [Data.Set, Data.HashSet], as: Set} # if you import Data.Set qualified, it must be as 'Set'
59+
# - {name: Control.Arrow, within: []} # Certain modules are banned entirely
60+
#
61+
# - functions:
62+
# - {name: unsafePerformIO, within: []} # unsafePerformIO can only appear in no modules
63+
64+
65+
# Add custom hints for this project
66+
#
67+
# Will suggest replacing "wibbleMany [myvar]" with "wibbleOne myvar"
68+
# - error: {lhs: "wibbleMany [x]", rhs: wibbleOne x}
69+
70+
71+
# Turn on hints that are off by default
72+
#
73+
# Ban "module X(module X) where", to require a real export list
74+
# - warn: {name: Use explicit module export list}
75+
#
76+
# Replace a $ b $ c with a . b $ c
77+
# - group: {name: dollar, enabled: true}
78+
#
79+
# Generalise map to fmap, ++ to <>
80+
# - group: {name: generalise, enabled: true}
81+
82+
83+
# Ignore some builtin hints
84+
# - ignore: {name: Use let}
85+
# - ignore: {name: Use const, within: SpecialModule} # Only within certain modules
86+
87+
88+
# Define some custom infix operators
89+
# - fixity: infixr 3 ~^#^~
90+
91+
92+
# To generate a suitable file for HLint do:
93+
# $ hlint --default > .hlint.yaml

HLint.hs

-516
This file was deleted.

appveyor.yml

+16-2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ before_test:
3535
.\cache-s3 --max-size=$env:CACHE_S3_MAX_SIZE --prefix=$env:APPVEYOR_PROJECT_NAME --git-branch=$env:APPVEYOR_REPO_BRANCH --suffix=windows -v info -c restore stack work --base-branch=develop
3636
}
3737
38+
# Get custom GHC
39+
- ps: >-
40+
mkdir C:\ghc
41+
42+
Invoke-WebRequest "https://s3.eu-central-1.amazonaws.com/ci-static/ghc-8.2.2-x86_64-unknown-mingw32.tar.xz" -OutFile "C:\ghc\ghc.tar.xz" -UserAgent "Curl"
43+
44+
7z x C:\ghc\ghc.tar.xz -oC:\ghc
45+
46+
7z x C:\ghc\ghc.tar -oC:\ghc
47+
48+
$env:PATH="$env:PATH;C:\ghc\ghc-8.2.2\bin"
49+
3850
# Install OpenSSL 1.0.2 (see https://github.com/appveyor/ci/issues/1665)
3951
- ps: (New-Object Net.WebClient).DownloadFile('https://slproweb.com/download/Win64OpenSSL-1_0_2o.exe', "$($env:USERPROFILE)\Win64OpenSSL.exe")
4052
- ps: cmd /c start /wait "$($env:USERPROFILE)\Win64OpenSSL.exe" /silent /verysilent /sp- /suppressmsgboxes /DIR=C:\OpenSSL-Win64-v102
@@ -62,10 +74,11 @@ before_test:
6274

6375
test_script:
6476
- cd "%WORK_DIR%"
65-
- stack exec -- ghc-pkg recache
66-
- stack --verbosity warn setup --no-reinstall > nul
77+
- stack exec --system-ghc -- ghc-pkg recache
78+
- stack --verbosity warn setup --system-ghc --no-reinstall > nul
6779
# Install happy separately: https://github.com/commercialhaskell/stack/issues/3151#issuecomment-310642487. Also install cpphs because it's a build-tool and Stack can't figure out by itself that it should be installed
6880
- scripts\ci\appveyor-retry call stack --verbosity warn install happy cpphs
81+
--system-ghc
6982
-j 2
7083
--no-terminal
7184
--local-bin-path %SYSTEMROOT%\system32
@@ -81,6 +94,7 @@ test_script:
8194
# Retry transient failures due to https://github.com/haskell/cabal/issues/4005
8295
# We intentionally don't build auxx here, because this build is for installer.
8396
- scripts\ci\appveyor-retry call stack --dump-logs install cardano-sl cardano-sl-tools cardano-sl-wallet cardano-sl-wallet-new
97+
--system-ghc
8498
-j 2
8599
--no-terminal
86100
--local-bin-path %WORK_DIR%

auxx/Main.hs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ module Main
33
) where
44

55
import Universum
6-
import Unsafe (unsafeFromJust)
76

87
import Control.Exception.Safe (handle)
8+
import Data.Maybe (fromMaybe)
99
import Formatting (sformat, shown, (%))
1010
import Mockable (Production (..), runProduction)
1111
import qualified Network.Transport.TCP as TCP (TCPAddr (..))
@@ -111,8 +111,8 @@ action opts@AuxxOptions {..} command = do
111111
{ acRealModeContext = realModeContext
112112
, acTempDbUsed = tempDbUsed }
113113
lift $ runReaderT auxxAction auxxContext
114-
115-
vssSK = unsafeFromJust $ npUserSecret nodeParams ^. usVss
114+
vssSK = fromMaybe (error "no user secret given")
115+
(npUserSecret nodeParams ^. usVss)
116116
sscParams = CLI.gtSscParams cArgs vssSK (npBehaviorConfig nodeParams)
117117

118118
bracketNodeResources nodeParams sscParams txpGlobalSettings initNodeDBs $ \nr -> Production $

auxx/cardano-sl-auxx.cabal

+2-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ library
126126

127127
executable cardano-auxx
128128
main-is: Main.hs
129-
build-depends: cardano-sl
129+
build-depends: base
130+
, cardano-sl
130131
, cardano-sl-auxx
131132
, cardano-sl-block
132133
, cardano-sl-core

auxx/src/Command/Tx.hs

+4-5
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ import Data.List ((!!))
2323
import qualified Data.List.NonEmpty as NE
2424
import qualified Data.Text as T
2525
import qualified Data.Text.IO as T
26-
import Data.Time.Units (toMicroseconds)
26+
import Data.Time.Units (Microsecond, toMicroseconds, fromMicroseconds)
2727
import Formatting (build, int, sformat, shown, stext, (%))
2828
import Mockable (Mockable, SharedAtomic, SharedAtomicT, concurrently, currentTime, delay,
2929
forConcurrently, modifySharedAtomic, newSharedAtomic)
30-
import Serokell.Util (ms, sec)
3130
import System.Environment (lookupEnv)
3231
import System.IO (BufferMode (LineBuffering), hClose, hSetBuffering)
3332
import System.Wlog (logError, logInfo)
@@ -98,7 +97,7 @@ sendToAllGenesis diffusion (SendToAllGenesisParams txsPerThread conc delay_ tpsS
9897
startAtTxt <- liftIO $ lookupEnv "AUXX_START_AT"
9998
let startAt = fromMaybe 0 . readMaybe . fromMaybe "" $ startAtTxt :: Int
10099
-- construct transaction output
101-
outAddr <- makePubKeyAddressAuxx (toPublic (fromMaybe (error "sendToAllGenesis: no keys") $ head keysToSend))
100+
outAddr <- makePubKeyAddressAuxx (toPublic (fromMaybe (error "sendToAllGenesis: no keys") $ (fmap fst . uncons) keysToSend))
102101
let txOut1 = TxOut {
103102
txOutAddress = outAddr,
104103
txOutValue = mkCoin 1
@@ -117,7 +116,7 @@ sendToAllGenesis diffusion (SendToAllGenesisParams txsPerThread conc delay_ tpsS
117116
-- every <slotDuration> seconds, write the number of sent transactions to a CSV file.
118117
let writeTPS :: m ()
119118
writeTPS = do
120-
delay (sec genesisSlotDuration)
119+
delay (fromMicroseconds . fromIntegral . (*) 1000000 $ genesisSlotDuration :: Microsecond)
121120
curTime <- show . toInteger . getTimestamp . Timestamp <$> currentTime
122121
finished <- modifySharedAtomic tpsMVar $ \(TxCount submitted sending) -> do
123122
-- CSV is formatted like this:
@@ -142,7 +141,7 @@ sendToAllGenesis diffusion (SendToAllGenesisParams txsPerThread conc delay_ tpsS
142141
logInfo $ if res
143142
then sformat ("Submitted transaction: "%txaF) tx
144143
else sformat ("Applied transaction "%txaF%", however no neighbour applied it") tx
145-
delay $ ms delay_
144+
delay $ (fromMicroseconds . fromIntegral . (*) 1000 $ delay_ :: Microsecond)
146145
logInfo "Continuing to send transactions."
147146
sendTxs (n - 1)
148147
Nothing -> do

auxx/src/Command/TyProjection.hs

+8-7
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ module Command.TyProjection
3131
import Universum
3232

3333
import Data.Scientific (Scientific, floatingOrInteger, toBoundedInteger, toRealFloat)
34-
import Data.Time.Units (TimeUnit, convertUnit)
34+
import Data.Time.Units (TimeUnit, Microsecond, convertUnit, fromMicroseconds)
3535
import Serokell.Data.Memory.Units (Byte, fromBytes)
36-
import Serokell.Util (sec)
3736

3837
import Pos.Core (AddrStakeDistribution (..), Address, BlockVersion, Coin,
3938
CoinPortion, EpochIndex, ScriptVersion, SoftwareVersion, StakeholderId,
@@ -93,8 +92,10 @@ tyByte = fromBytes <$> TyProjection "Byte" (sciToInteger <=< preview _ValueNumbe
9392
sciToInteger :: Scientific -> Maybe Integer
9493
sciToInteger = either (const Nothing) Just . floatingOrInteger @Double @Integer
9594

96-
tySecond :: TimeUnit a => TyProjection a
97-
tySecond = convertUnit . sec <$> TyProjection "Second" (toBoundedInteger <=< preview _ValueNumber)
95+
tySecond :: forall a . TimeUnit a => TyProjection a
96+
tySecond =
97+
convertUnit . (fromMicroseconds . fromIntegral . (*) 1000000 :: Int -> Microsecond) <$>
98+
TyProjection "Second" (toBoundedInteger <=< preview _ValueNumber)
9899

99100
tyScriptVersion :: TyProjection ScriptVersion
100101
tyScriptVersion = TyProjection "ScriptVersion" (toBoundedInteger <=< preview _ValueNumber)
@@ -149,10 +150,10 @@ tyProposeUpdateSystem :: TyProjection ProposeUpdateSystem
149150
tyProposeUpdateSystem = TyProjection "ProposeUpdateSystem" (preview _ValueProposeUpdateSystem)
150151

151152
tySystemTag :: TyProjection SystemTag
152-
tySystemTag = TyProjection "SystemTag" ((fmap . fmap) (SystemTag . fromString) (preview _ValueString))
153+
tySystemTag = TyProjection "SystemTag" ((fmap . fmap) (SystemTag) (preview _ValueString))
153154

154155
tyApplicationName :: TyProjection ApplicationName
155-
tyApplicationName = TyProjection "ApplicationName" ((fmap . fmap) (ApplicationName . fromString) (preview _ValueString))
156+
tyApplicationName = TyProjection "ApplicationName" ((fmap . fmap) (ApplicationName) (preview _ValueString))
156157

157-
tyString :: TyProjection String
158+
tyString :: TyProjection Text
158159
tyString = TyProjection "String" (preview _ValueString)

auxx/src/Lang/DisplayError.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ ppParseError (ParseError str (Report {..})) =
104104
<+> hcat (punctuate (text ", or ") $ map text expected)
105105
<$> renderLines
106106
where
107-
unconsumedDesc = maybe "end of input" show . head . fmap snd $ unconsumed
107+
unconsumedDesc = maybe "end of input" show . (fmap fst . uncons) . fmap snd $ unconsumed
108108
strLines = nonEmpty $ take spanLines . drop (spanLineStart - 1) $ lines str
109109
renderLines = case strLines of
110110
Nothing ->

auxx/src/Lang/Lexer.hs

+30-9
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ module Lang.Lexer
2424
, tokenize
2525
, tokenize'
2626
, detokenize
27+
, tokenRender
2728
) where
2829

29-
import Universum
30+
import Universum hiding (try)
3031

3132
import qualified Control.Applicative.Combinators.NonEmpty as NonEmpty
3233
import Control.Lens (makePrisms)
@@ -45,7 +46,7 @@ import Text.Megaparsec (Parsec, SourcePos (..), between, choice, eof,
4546
manyTill, notFollowedBy, parseMaybe, skipMany, takeP, takeWhile1P,
4647
try, unPos, (<?>))
4748
import Text.Megaparsec.Char (anyChar, char, satisfy, spaceChar, string)
48-
import Text.Megaparsec.Char.Lexer (charLiteral, decimal, scientific, signed)
49+
import Text.Megaparsec.Char.Lexer (decimal, scientific, signed)
4950

5051
import Lang.Name (Letter, Name (..), unsafeMkLetter)
5152
import Pos.Arbitrary.Core ()
@@ -98,7 +99,7 @@ isFilePathChar c = isAlphaNum c || c `elem` ['.', '/', '-', '_']
9899
data Token
99100
= TokenSquareBracket BracketSide
100101
| TokenParenthesis BracketSide
101-
| TokenString String
102+
| TokenString Text
102103
| TokenNumber Scientific
103104
| TokenAddress Address
104105
| TokenPublicKey PublicKey
@@ -124,7 +125,14 @@ tokenRender :: Token -> Text
124125
tokenRender = \case
125126
TokenSquareBracket bs -> withBracketSide "[" "]" bs
126127
TokenParenthesis bs -> withBracketSide "(" ")" bs
127-
TokenString s -> show s
128+
-- Double up every double quote, and surround the whole thing with double
129+
-- quotes.
130+
TokenString t -> quote (escapeQuotes t)
131+
where
132+
quote :: Text -> Text
133+
quote t' = Text.concat [Text.singleton '\"', t', Text.singleton '\"']
134+
escapeQuotes :: Text -> Text
135+
escapeQuotes = Text.intercalate "\"\"" . Text.splitOn "\""
128136
TokenNumber n -> show n
129137
TokenAddress a -> pretty a
130138
TokenPublicKey pk -> sformat fullPublicKeyF pk
@@ -186,7 +194,7 @@ pToken' = choice
186194
, string "~software~" *> (TokenSoftwareVersion <$> try pSoftwareVersion)
187195
, marking "filepath" $ TokenFilePath <$> pFilePath
188196
, marking "num" $ TokenNumber <$> pScientific
189-
, marking "str" $ TokenString <$> pString
197+
, marking "str" $ TokenString <$> pText
190198
, marking "ident" $ pIdent
191199
] <?> "token"
192200

@@ -200,10 +208,21 @@ pPunct = choice
200208
, char ';' $> TokenSemicolon
201209
] <?> "punct"
202210

203-
pString :: Lexer String
204-
pString =
205-
char '\"' *>
206-
manyTill (charLiteral <|> anyChar) (char '\"')
211+
pText :: Lexer Text
212+
pText = do
213+
_ <- char '\"'
214+
Text.pack <$> loop []
215+
where
216+
loop :: [Char] -> Lexer [Char]
217+
loop !acc = do
218+
next <- anyChar
219+
case next of
220+
-- Check for double double quotes. If it's a single double quote,
221+
-- it's the end of the string.
222+
'\"' -> try (doubleQuote acc) <|> pure (reverse acc)
223+
c -> loop (c : acc)
224+
doubleQuote :: [Char] -> Lexer [Char]
225+
doubleQuote !acc = char '\"' >> loop ('\"' : acc)
207226

208227
pSomeAlphaNum :: Lexer Text
209228
pSomeAlphaNum = takeWhile1P (Just "alphanumeric") isAlphaNum
@@ -281,3 +300,5 @@ pScientific = do
281300
n <- signed (return ()) scientific
282301
p <- isJust <$> optional (char '%')
283302
return $ if p then n / 100 else n
303+
304+
{-# ANN module ("HLint: ignore Use toText" :: Text) #-}

auxx/src/Lang/Name.hs

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import Data.Coerce (coerce)
1313
import qualified Data.List.NonEmpty as NonEmpty
1414
import Data.List.Split (splitWhen)
1515
import qualified Data.Text.Buildable as Buildable
16-
import Test.QuickCheck.Arbitrary.Generic (Arbitrary (..), genericArbitrary, genericShrink)
17-
import Test.QuickCheck.Gen (suchThat)
16+
import Test.QuickCheck.Arbitrary.Generic (Arbitrary (..))
17+
import Test.QuickCheck.Gen (Gen, suchThat, listOf)
1818

1919
-- | Invariant: @isAlpha . getLetter = const True@
2020
newtype Letter = Letter { getLetter :: Char }
@@ -33,8 +33,10 @@ unsafeMkName :: [String] -> Name
3333
unsafeMkName = coerce . fmap NonEmpty.fromList . NonEmpty.fromList
3434

3535
instance Arbitrary Name where
36-
arbitrary = genericArbitrary
37-
shrink = genericShrink
36+
arbitrary = Name <$> neList (neList arbitrary)
37+
where
38+
neList :: Gen a -> Gen (NonEmpty a)
39+
neList gen = (:|) <$> gen <*> listOf gen
3840

3941
instance Buildable Name where
4042
build

auxx/src/Lang/Syntax.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ deriving instance Show cmd => Show (Expr cmd)
2929

3030
data Lit
3131
= LitNumber Scientific
32-
| LitString String
32+
| LitString Text
3333
| LitAddress Address
3434
| LitPublicKey PublicKey
3535
| LitStakeholderId StakeholderId

auxx/src/Lang/Value.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ data AddKeyParams = AddKeyParams
8686
data Value
8787
= ValueUnit
8888
| ValueNumber Scientific
89-
| ValueString String
89+
| ValueString Text
9090
| ValueBool Bool
9191
| ValueList [Value]
9292
| ValueAddress Address

0 commit comments

Comments
 (0)