Skip to content

Commit

Permalink
Merge branch 'master' into polina/paramtests
Browse files Browse the repository at this point in the history
  • Loading branch information
polinavino committed Oct 20, 2020
2 parents fad5cfe + 1606adc commit 303f20f
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 60 deletions.
112 changes: 112 additions & 0 deletions .github/workflows/haskell.yml
@@ -0,0 +1,112 @@
name: Haskell CI

on: [push]

jobs:
build:
runs-on: ${{ matrix.os }}

defaults:
run:
shell: bash

strategy:
fail-fast: false
matrix:
ghc: ["8.6.5", "8.10.2"]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v1

- name: Select build directory
run: echo "CABAL_BUILDDIR=dist" >> $GITHUB_ENV

- name: Install pkgconfiglite (Windows)
if: matrix.os == 'windows-latest'
run: choco install -y pkgconfiglite

- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6

- name: Install cbor-diag and cddl
run: gem install cbor-diag cddl

- name: Install libsodium (MacOS)
if: matrix.os == 'macos-latest'
run: brew install libsodium

- name: Install libsodium (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get -y install libsodium23 libsodium-dev
sudo apt-get -y remove --purge software-properties-common
sudo apt-get -y autoremove
- name: Install libsodium (Windows)
if: matrix.os == 'windows-latest'
run: |
curl -Ls https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-mingw.tar.gz -o libsodium-1.0.18-mingw.tar.gz
tar zxvf libsodium-1.0.18-mingw.tar.gz
sed -i "s|/d/a/1/s/|D:/a/cardano-node/cardano-node/|g" libsodium-win64/lib/pkgconfig/libsodium.pc
export PKG_CONFIG_PATH="$(readlink -f libsodium-win64/lib/pkgconfig)"
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" >> $GITHUB_ENV
export LIBSODIUM_PATH="$(readlink -f libsodium-win64/bin | sed 's|^/d|D:|g' | tr / '\\')"
echo "LIBSODIUM_PATH=$LIBSODIUM_PATH"
echo "$LIBSODIUM_PATH" >> $GITHUB_PATH
- uses: actions/setup-haskell@v1
id: setup-haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: '3.2.0.0'

- name: Patch GHC 8.10.2 linker
if: matrix.os == 'windows-latest'
run: |
sed -i \
's|C:/GitLabRunner/builds/2WeHDSFP/0/ghc/ghc/inplace/mingw/bin/ld.exe|C:/ProgramData/chocolatey/lib/ghc.8.10.2/tools/ghc-8.10.2/mingw/bin/ld.exe|g' \
C:/ProgramData/chocolatey/lib/ghc.8.10.2/tools/ghc-8.10.2/lib/settings
- name: Configure to use libsodium
run: |
cat >> cabal.project <<EOF
package cardano-crypto-praos
flags: -external-libsodium-vrf
EOF
- name: Cabal update
run: cabal update

- name: Cabal Configure
run: cabal configure --builddir="$CABAL_BUILDDIR" --enable-tests --enable-benchmarks --write-ghc-environment-files=always

- uses: actions/cache@v2
if: matrix.os != 'macos-latest'
name: Cache cabal store
with:
path: |
${{ steps.setup-haskell.outputs.cabal-store }}
dist
key: cache-${{ runner.os }}-${{ matrix.ghc }}-v1-${{ hashFiles('cabal-cache.cabal') }}-${{ github.sha }}
restore-keys: cache-${{ runner.os }}-${{ matrix.ghc }}-v1-${{ hashFiles('cabal-cache.cabal') }}-

- name: Install dependencies
run: cabal build all --builddir="$CABAL_BUILDDIR" --only-dependencies

- name: Build
run: cabal build all -v3 --builddir="$CABAL_BUILDDIR"

- name: Git clone
run: git clone https://github.com/input-output-hk/cardano-mainnet-mirror

- name: Run tests
run: |
export CARDANO_MAINNET_MIRROR="$(pwd)/cardano-mainnet-mirror/epochs"
cabal test all --builddir="$CABAL_BUILDDIR"
36 changes: 0 additions & 36 deletions nix/haskell-extra.nix

This file was deleted.

Expand Up @@ -511,7 +511,7 @@ straverse_ f = foldr c (pure ())
-- | 'sfor_' is 'straverse_' with its arguments flipped. For a version
-- that doesn't ignore the results see 'Data.Traversable.for'.
--
-- >>> sfor_ [1..4] print
-- >>> sfor_ ([1..4] :: [Int]) print
-- 1
-- 2
-- 3
Expand Down
19 changes: 1 addition & 18 deletions shell.nix
Expand Up @@ -10,23 +10,6 @@ with pkgs;
let
ormolu = import pkgs.commonLib.sources.ormolu {};

haskell-extra =
# The Hackage index-state from cabal.project
let checkMaterialization = false;
index-state =
let
# Borrowed from haskell.nix
parseIndexState = rawCabalProject:
let
indexState = pkgs.lib.lists.concatLists (
pkgs.lib.lists.filter (l: l != null)
(builtins.map (l: builtins.match "^index-state: *(.*)" l)
(pkgs.lib.splitString "\n" rawCabalProject)));
in pkgs.lib.lists.head (indexState ++ [ null ]);
in parseIndexState (builtins.readFile ./cabal.project);
# Extra Haskell packages which we use but aren't part of the main project definition.
in pkgs.callPackage ./nix/haskell-extra.nix { inherit index-state checkMaterialization; };

# This provides a development environment that can be used with nix-shell or
# lorri. See https://input-output-hk.github.io/haskell.nix/user-guide/development/
shell = cardanoLedgerSpecsHaskellPackages.shellFor {
Expand All @@ -38,7 +21,6 @@ let

# These programs will be available inside the nix-shell.
buildInputs = with haskellPackages; [
haskell-extra.haskell-language-server.components.exes.haskell-language-server
niv
pkg-config
hlint
Expand All @@ -47,6 +29,7 @@ let

tools = {
cabal = "3.2.0.0";
haskell-language-server="0.5.1";
};

# Prevents cabal from choosing alternate plans, so that
Expand Down
Expand Up @@ -226,7 +226,8 @@ potsSumIncreaseWdrlsPerTx SourceSignalTarget {source = chainSt, signal = block}
signal = tx,
target = (UTxOState {_utxo = u', _deposited = d', _fees = f'}, _)
} =
(balance u' <+> (Val.inject $ d' <+> f')) <-> (balance u <+> (Val.inject $ d <+> f)) === (Val.inject $ fold (unWdrl . _wdrls $ _body tx))
(balance u' <+> (Val.inject $ d' <+> f')) <-> (balance u <+> (Val.inject $ d <+> f))
=== (Val.inject $ fold (unWdrl . _wdrls $ _body tx))

-- | (Utxo + Deposits + Fees) increases by the reward delta
potsSumIncreaseByRewardsPerTx :: SourceSignalTarget (CHAIN C) -> Property
Expand All @@ -247,7 +248,8 @@ potsSumIncreaseByRewardsPerTx SourceSignalTarget {source = chainSt, signal = blo
DPState {_dstate = DState {_rewards = rewards'}}
)
} =
(balance u' <+> (Val.inject $ d' <+> f')) <-> (balance u <+> (Val.inject $ d <+> f)) === (Val.inject $ fold rewards <-> fold rewards')
(balance u' <+> (Val.inject $ d' <+> f')) <-> (balance u <+> (Val.inject $ d <+> f))
=== (Val.inject $ fold rewards <-> fold rewards')

-- | The Rewards pot decreases by the sum of withdrawals in a transaction
potsRewardsDecreaseByWdrlsPerTx :: SourceSignalTarget (CHAIN C) -> Property
Expand All @@ -266,7 +268,7 @@ potsRewardsDecreaseByWdrlsPerTx SourceSignalTarget {source = chainSt, signal = b
} =
let totalRewards = rewardsSum dpstate
totalRewards' = rewardsSum dpstate'
txWithdrawals = fold (unWdrl . _wdrls $ _body tx)
txWithdrawals = fold (unWdrl . _wdrls $ _body @C tx)
in conjoin
[ counterexample
"A transaction should not increase the Rewards pot"
Expand Down Expand Up @@ -561,7 +563,7 @@ poolTraceFromBlock chainSt block =
)
where
(tickedChainSt, ledgerEnv, ledgerSt0, txs) = ledgerTraceBase chainSt block
certs = concatMap (toList . _certs . _body)
certs = concatMap (toList . _certs . _body @C)
poolCerts = filter poolCert (certs txs)
poolEnv =
let (LedgerEnv s _ pp _) = ledgerEnv
Expand All @@ -581,7 +583,7 @@ delegTraceFromBlock chainSt block =
)
where
(tickedChainSt, ledgerEnv, ledgerSt0, txs) = ledgerTraceBase chainSt block
certs = concatMap (reverse . toList . _certs . _body)
certs = concatMap (reverse . toList . _certs . _body @C)
blockCerts = filter delegCert (certs txs)
delegEnv =
let (LedgerEnv s txIx _ reserves) = ledgerEnv
Expand Down

0 comments on commit 303f20f

Please sign in to comment.