Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to GHC-9.4 resulting in lower compile-time memory usage #148

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 41 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ jobs:
SSH_KEY_FOR_NIXBUILD: ${{ secrets.SSH_KEY_FOR_NIXBUILD }}
steps:
- uses: actions/checkout@v3
- run: |
mkdir "$HOME/.ssh"
chmod 700 "$HOME/.ssh"
cat << EOF > "$HOME/.ssh/config"
Host *
ServerAliveInterval 300
basvandijk marked this conversation as resolved.
Show resolved Hide resolved
basvandijk marked this conversation as resolved.
Show resolved Hide resolved
ServerAliveCountMax 0
basvandijk marked this conversation as resolved.
Show resolved Hide resolved
EOF
chmod 600 "$HOME/.ssh/config"
- if: matrix.os == 'macos-latest'
uses: cachix/install-nix-action@v19
- if: matrix.os == 'ubuntu-latest'
Expand All @@ -28,29 +37,49 @@ jobs:
uses: nixbuild/nixbuild-action@v15
with:
nixbuild_ssh_key: ${{ secrets.SSH_KEY_FOR_NIXBUILD }}
- run: nix-env -iA nix-build-uncached -f nix/
- uses: cachix/cachix-action@v12
with:
name: ic-hs-test
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
# until https://github.com/cachix/cachix-action/issues/86 is fixed:
- run: cachix watch-store ic-hs-test &

# run a few targets explicitly, to get easier signal in the CI view
- run: nix-build-uncached -A universal-canister
- run: nix-build-uncached -A ic-hs
# Use Remote Store Builds.
# See: https://blog.nixbuild.net/posts/2022-03-16-lightning-fast-ci-with-nixbuild-net.html
- if: matrix.os == 'ubuntu-latest'
run: nix build -f default.nix --eval-store auto --store ssh-ng://eu.nixbuild.net --builders "" --max-jobs 2 --no-link universal-canister
- if: matrix.os == 'ubuntu-latest'
run: nix build -f default.nix --eval-store auto --store ssh-ng://eu.nixbuild.net --builders "" --max-jobs 2 --no-link ic-hs
- if: matrix.os == 'ubuntu-latest'
run: cp -r "$(nix-build -A ic-hs.doc)"/share/doc/*/html gh-page
- if: matrix.os == 'ubuntu-latest'
run: nix-build-uncached -A ic-hs-coverage
run: nix build -f default.nix --eval-store auto --store ssh-ng://eu.nixbuild.net --builders "" --max-jobs 2 --no-link ic-hs-coverage
- if: matrix.os == 'ubuntu-latest'
run: nix build -f default.nix --eval-store auto --store ssh-ng://eu.nixbuild.net --builders "" --max-jobs 2 --no-link coverage
- if: matrix.os == 'ubuntu-latest'
run: nix build -f default.nix --eval-store auto --store ssh-ng://eu.nixbuild.net --builders "" --max-jobs 2 --no-link check-generated
- if: matrix.os == 'ubuntu-latest'
run: nix build -f default.nix --eval-store auto --store ssh-ng://eu.nixbuild.net --builders "" --max-jobs 2 --no-link ic-ref-dist
- if: matrix.os == 'ubuntu-latest'
run: nix build -f default.nix --eval-store auto --store ssh-ng://eu.nixbuild.net --builders "" --max-jobs 2 --no-link ic-ref-test
- if: matrix.os == 'ubuntu-latest'
run: nix-build-uncached -A coverage
- run: nix-build-uncached -A check-generated
- run: nix-build-uncached -A ic-ref-dist
run: nix build -f default.nix --eval-store auto --store ssh-ng://eu.nixbuild.net --builders "" --max-jobs 2 --no-link ic-hs-shell
- if: matrix.os == 'ubuntu-latest'
run: nix-build-uncached -A ic-ref-test
- run: nix-build-uncached -A ic-hs-shell
- run: nix-build-uncached -A license-check
run: nix build -f default.nix --eval-store auto --store ssh-ng://eu.nixbuild.net --builders "" --max-jobs 2 --no-link license-check

- if: matrix.os == 'macos-latest'
run: nix-env -iA nix-build-uncached -f nix/
- if: matrix.os == 'macos-latest'
run: nix-build-uncached -A universal-canister
- if: matrix.os == 'macos-latest'
run: nix-build-uncached -A ic-hs
- if: matrix.os == 'macos-latest'
run: nix-build-uncached -A check-generated
- if: matrix.os == 'macos-latest'
run: nix-build-uncached -A ic-ref-dist
- if: matrix.os == 'macos-latest'
run: nix-build-uncached -A ic-hs-shell
- if: matrix.os == 'macos-latest'
run: nix-build-uncached -A license-check

release:
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
Expand Down
25 changes: 18 additions & 7 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,42 @@ let universal-canister = (naersk.buildPackage rec {
}); in

let haskellOverrides = self: super:
let generated = import nix/generated/all.nix self super; in
let generated = import nix/generated/all.nix self super;
inherit (nixpkgs.haskell.lib) doJailbreak;
in
generated //
{
wide-word = super.callHackage "wide-word" "0.1.5.0" {};
haskoin-core = nixpkgs.haskell.lib.dontCheck (nixpkgs.haskell.lib.markUnbroken super.haskoin-core);
microlens-platform = doJailbreak super.microlens-platform;
base16 = doJailbreak super.base16;
base32 = doJailbreak super.base32;
candid = doJailbreak generated.candid;
}; in

let haskellPackages = nixpkgs.haskellPackages.override {
let haskellPackages = nixpkgs.haskell.packages.ghc943.override {
overrides = haskellOverrides;
}; in

let staticHaskellPackages = nixpkgs.pkgsStatic.haskellPackages.override {
let staticHaskellPackages = nixpkgs.pkgsStatic.haskell.packages.ghc943.override {
overrides = haskellOverrides;
}; in

let
ic-hs = nixpkgs.haskell.lib.dontCheck (
haskellPackages.ic-hs.overrideAttrs (old: {
ic-hs =
let
ic-hs-pkg =
nixpkgs.haskell.lib.disableLibraryProfiling
(nixpkgs.haskell.lib.dontCheck haskellPackages.ic-hs);
in
ic-hs-pkg.overrideAttrs (old: {
installPhase = (old.installPhase or "") + ''
mkdir $out/test-data
cp ${universal-canister}/universal-canister.wasm $out/test-data
'';
# variant of justStaticExecutables that retains propagatedBuildInputs
postFixup = "rm -rf $out/lib $out/share/doc";
})
);
});

# Alias, to be replaced with a derivation that just copies bin/ic-ref
ic-ref = ic-hs;
Expand Down
4 changes: 2 additions & 2 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ let
});

all-cabal-hashes = self.fetchurl {
url = "https://github.com/commercialhaskell/all-cabal-hashes/archive/35f4996e28c5ba20a3a633346f21abe2072afeb6.tar.gz";
sha256 = "sha256-L/PmFUGlBOOd5rAx4NFxv+s2USI9q0YgOsfpdeRDyds=";
url = "https://github.com/commercialhaskell/all-cabal-hashes/archive/eddc2bddf45791cb743293d15ad8325fa0e050e4.tar.gz";
sha256 = "sha256-5+2pviyhfIeTr1yzbpG56dtP+BxMyEN/w3Tbwz9ePzw=";
};

# We override secp256k1 since the version in nixpkgs doesn't provide a
Expand Down
2 changes: 1 addition & 1 deletion nix/generated/candid.nix

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"homepage": null,
"owner": "nomeata",
"repo": "haskell-candid",
"rev": "87a4f01eb9cb93c827a0a7f5f29af0ee19135308",
"sha256": "0mcmj62x49k241k5rpc7j37yczjlcsgyssjwy1ncfs8ss0b8b03r",
"rev": "6d60e4464bd4a206d91a6cdade8810a37b09c6d0",
"sha256": "0m091vx76dmdwv0ad1y9n2chq28wd24521b8pq305jbqc78zr3rf",
"type": "tarball",
"url": "https://github.com/nomeata/haskell-candid/archive/87a4f01eb9cb93c827a0a7f5f29af0ee19135308.tar.gz",
"url": "https://github.com/nomeata/haskell-candid/archive/6d60e4464bd4a206d91a6cdade8810a37b09c6d0.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"http-client": {
Expand Down Expand Up @@ -64,10 +64,10 @@
"homepage": "https://github.com/dfinity-side-projects/winter",
"owner": "dfinity-side-projects",
"repo": "winter",
"rev": "530d5e395bb9919187d47d3966c4d526e668b62a",
"sha256": "1mnyhmkilald48p4gl29hq8qqs605nv5z97ps3vln1gn901s2f9c",
"rev": "cca827ab9299146c0b3b51920e5ad63c4c6014c3",
"sha256": "1cjwdqv4ar7d8pl9zj6rghj682yj54bwwi81d88fsblrbalmnhy1",
"type": "tarball",
"url": "https://github.com/dfinity-side-projects/winter/archive/530d5e395bb9919187d47d3966c4d526e668b62a.tar.gz",
"url": "https://github.com/dfinity-side-projects/winter/archive/cca827ab9299146c0b3b51920e5ad63c4c6014c3.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
2 changes: 1 addition & 1 deletion src/IC/Canister/Snapshot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ instance SnapshotAble ImpState where
Stable.imp (isStableMem rs) pmem
return rs
where
trapToFail (Trap err) = fail $ "replay failed: " ++ show err
trapToFail (Trap err) = error $ "replay failed: " ++ show err
trapToFail (Return x) = return x

deriving
Expand Down
3 changes: 2 additions & 1 deletion src/IC/Crypto/Ed25519.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module IC.Crypto.Ed25519
, verify
) where

import Data.Maybe (fromJust)
import qualified Data.ByteString.Lazy as BS
import qualified Crypto.Sign.Ed25519 as Ed25519

Expand All @@ -16,7 +17,7 @@ createKey seed | BS.length seed > 32 = error "Seed too long"
createKey seed = sk
where
seed' = seed <> BS.replicate (32 - BS.length seed) 0x00
Just (_, sk) = Ed25519.createKeypairFromSeed_ (BS.toStrict seed')
(_, sk) = fromJust $ Ed25519.createKeypairFromSeed_ (BS.toStrict seed')

toPublicKey :: SecretKey -> BS.ByteString
toPublicKey = BS.fromStrict . Ed25519.unPublicKey . Ed25519.toPublicKey
Expand Down
2 changes: 1 addition & 1 deletion src/IC/Purify.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeOperators #-}
module IC.Purify where

import Control.Monad.ST
Expand Down Expand Up @@ -58,4 +59,3 @@ instance Purify a (Replay a) where
return (replay', x)
where
replay' = Replay $ do x <- replay; void (act x); return x

5 changes: 3 additions & 2 deletions src/IC/Test/Agent.hs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ import qualified Text.Hex as H
import qualified Data.ByteString.Lazy as BS
import qualified Data.ByteString.Builder as BS
import qualified Data.HashMap.Lazy as HM
import Data.Maybe (fromJust)
import Network.HTTP.Client
import Network.HTTP.Client.TLS
import Network.HTTP.Types
Expand Down Expand Up @@ -883,5 +884,5 @@ toHash256 = Get.runGet Get.get

verifySignature :: Blob -> Blob -> Blob -> Bool
verifySignature msg sig key = Haskoin.verifyHashSig (toHash256 msg) s pk
where Just pk = Haskoin.importPubKey $ BS.toStrict key
Just s = Haskoin.decodeStrictSig $ BS.toStrict sig
where pk = fromJust $ Haskoin.importPubKey $ BS.toStrict key
s = fromJust $ Haskoin.decodeStrictSig $ BS.toStrict sig
6 changes: 4 additions & 2 deletions src/IC/Test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ import qualified IC.Test.Spec.TECDSA

icTests :: TestSubnetConfig -> TestSubnetConfig -> AgentConfig -> TestTree
icTests my_sub other_sub =
let (my_subnet_id_as_entity, my_type, _, ((ecid_as_word64, last_canister_id_as_word64):_)) = my_sub in
let (other_subnet_id_as_entity, _, _, ((other_ecid_as_word64, _):_)) = other_sub in
let (my_subnet_id_as_entity, my_type, _, my_ranges) = my_sub in
let (ecid_as_word64, last_canister_id_as_word64) = head my_ranges in
let (other_subnet_id_as_entity, _, _, other_ranges) = other_sub in
let (other_ecid_as_word64, _) = head other_ranges in
let my_subnet_id = rawEntityId my_subnet_id_as_entity in
let other_subnet_id = rawEntityId other_subnet_id_as_entity in
let my_is_root = isRootTestSubnet my_sub in
Expand Down
3 changes: 2 additions & 1 deletion src/IC/Test/Spec/HTTP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ check_http_body = aux . fromUtf8

canister_http_calls :: HasAgentConfig => TestSubnetConfig -> [TestTree]
canister_http_calls sub =
let (_, _, _, ((ecid_as_word64, _):_)) = sub in
let (_, _, _, ranges) = sub in
let (ecid_as_word64, _) = head ranges in
let ecid = rawEntityId $ wordToId ecid_as_word64 in
[
-- "Currently, the GET, HEAD, and POST methods are supported for HTTP requests."
Expand Down