Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/scripts/install-libsecp256k1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -eux -o pipefail

## The following script builds and installs libsecp256k1 to ~/.local/lib

INSTALL_VERSION=0.3.2
INSTALL_VERSION=0.4.1

if [[ "$(uname -s)" =~ ^MSYS_NT.* ]]; then
echo "This script is only meant to run on Windows under MSYS2"
Expand Down
51 changes: 17 additions & 34 deletions flake.lock

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

51 changes: 11 additions & 40 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
foundry.url = "github:shazow/foundry.nix/monthly";
bitwuzla-pkgs.url = "github:d-xo/nixpkgs/94e802bce3a1bc05b3acfc5e876de15fd2ecb564";
foundry.url = "github:shazow/foundry.nix/6089aad0ef615ac8c7b0c948d6052fa848c99523";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
Expand All @@ -28,11 +27,10 @@
};
};

outputs = { self, nixpkgs, flake-utils, solidity, forge-std, ethereum-tests, foundry, cabal-head, bitwuzla-pkgs, ... }:
outputs = { self, nixpkgs, flake-utils, solidity, forge-std, ethereum-tests, foundry, cabal-head, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = (import nixpkgs { inherit system; config = { allowBroken = true; }; });
bitwuzla = (import bitwuzla-pkgs { inherit system; }).bitwuzla;
testDeps = with pkgs; [
go-ethereum
solc
Expand All @@ -46,47 +44,24 @@

# custom package set capable of building latest (unreleased) `cabal-install`.
# This gives us support for multiple home units in cabal repl
cabal-multi-pkgs = pkgs.haskell.packages.ghc94.override {
cabal-multi-pkgs = pkgs.haskellPackages.override {
overrides = with pkgs.haskell.lib; self: super: rec {
cabal-install = dontCheck (self.callCabal2nix "cabal-install" "${cabal-head}/cabal-install" {});
cabal-install-solver = dontCheck (self.callCabal2nix "cabal-install-solver" "${cabal-head}/cabal-install-solver" {});
Cabal-described = dontCheck (self.callCabal2nix "Cabal-described" "${cabal-head}/Cabal-described" {});
Cabal-QuickCheck = dontCheck (self.callCabal2nix "Cabal-QuickCheck" "${cabal-head}/Cabal-QuickCheck" {});
Cabal-tree-diff = dontCheck (self.callCabal2nix "Cabal-tree-diff" "${cabal-head}/Cabal-tree-diff" {});
Cabal-syntax = dontCheck (self.callCabal2nix "Cabal-syntax" "${cabal-head}/Cabal-syntax" {});
Cabal-tests = dontCheck (self.callCabal2nix "Cabal-tests" "${cabal-head}/Cabal-tests" {});
Cabal = dontCheck (self.callCabal2nix "Cabal" "${cabal-head}/Cabal" {});
unix = dontCheck (doJailbreak super.unix_2_8_1_1);
filepath = dontCheck (doJailbreak super.filepath_1_4_100_4);
process = dontCheck (doJailbreak super.process_1_6_17_0);
directory = dontCheck (doJailbreak (super.directory_1_3_7_1));
tasty = dontCheck (doJailbreak super.tasty);
QuickCheck = dontCheck (doJailbreak super.QuickCheck);
hashable = dontCheck (doJailbreak super.hashable);
async = dontCheck (doJailbreak super.async);
hspec-meta = dontCheck (doJailbreak super.hspec-meta);
hpc = dontCheck (doJailbreak super.hpc);
ghci = dontCheck (doJailbreak super.ghci);
ghc-boot = dontCheck (doJailbreak super.ghc-boot);
setenv = dontCheck (doJailbreak super.setenv);
vector = dontCheck (doJailbreak super.vector);
network-uri = dontCheck (doJailbreak super.network-uri);
aeson = dontCheck (doJailbreak super.aeson);
th-compat = dontCheck (doJailbreak super.th-compat);
safe-exceptions = dontCheck (doJailbreak super.safe-exceptions);
bifunctors = dontCheck (doJailbreak super.bifunctors);
base-compat-batteries = dontCheck (doJailbreak super.base-compat-batteries);
distributative = dontCheck (doJailbreak super.distributative);
semialign = dontCheck (doJailbreak super.semialign);
semigroupoids = dontCheck (doJailbreak super.semigroupoids);
hackage-security = dontCheck (doJailbreak super.hackage-security);
};
};

secp256k1-static = stripDylib (pkgs.secp256k1.overrideAttrs (attrs: {
configureFlags = attrs.configureFlags ++ [ "--enable-static" ];
}));

hevmUnwrapped = (with pkgs; lib.pipe (
hevmUnwrapped = (with (if pkgs.stdenv.isDarwin then pkgs else pkgs.pkgsStatic); lib.pipe (
haskellPackages.callCabal2nix "hevm" ./. {
# Haskell libs with the same names as C libs...
# Depend on the C libs, not the Haskell libs.
Expand All @@ -98,20 +73,16 @@
(haskell.lib.compose.addTestToolDepends testDeps)
(haskell.lib.compose.appendBuildFlags ["-v3"])
(haskell.lib.compose.appendConfigureFlags (
[ "-fci"
[ # "-fci"
"-O2"
"--extra-lib-dirs=${stripDylib (pkgs.gmp.override { withStatic = true; })}/lib"
]
++ lib.optionals stdenv.isDarwin
[ "--extra-lib-dirs=${stripDylib (pkgs.gmp.override { withStatic = true; })}/lib"
"--extra-lib-dirs=${stripDylib secp256k1-static}/lib"
"--extra-lib-dirs=${stripDylib (libff.override { enableStatic = true; })}/lib"
"--extra-lib-dirs=${zlib.static}/lib"
"--extra-lib-dirs=${stripDylib (libffi.overrideAttrs (_: { dontDisableStatic = true; }))}/lib"
"--extra-lib-dirs=${stripDylib (ncurses.override { enableStatic = true; })}/lib"
]
++ lib.optionals stdenv.isLinux [
"--enable-executable-static"
# TODO: replace this with musl: https://stackoverflow.com/a/57478728
"--extra-lib-dirs=${glibc}/lib"
"--extra-lib-dirs=${glibc.static}/lib"
]))
haskell.lib.dontHaddock
]).overrideAttrs(final: prev: {
Expand Down Expand Up @@ -199,8 +170,8 @@
packages = _: [ hevmUnwrapped ];
buildInputs = [
# cabal from nixpkgs
# haskellPackages.cabal-install
cabal-multi-pkgs.cabal-install
haskellPackages.cabal-install
# cabal-multi-pkgs.cabal-install
mdbook
yarn
haskellPackages.eventlog2html
Expand Down
37 changes: 9 additions & 28 deletions hevm.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,11 @@ library
Paths_hevm
autogen-modules:
Paths_hevm
if impl(ghc >= 9.4) && !os(darwin)
-- darwin is skipped because it produces this error when building
-- > ghc: loadArchive: Neither an archive, nor a fat archive: `/nix/store/l3lkdfm7sg1wwc850451cikqds766h15-clang-wrapper-11.1.0/bin/clang++'
if os(linux)
build-depends: system-cxx-std-lib
elif !os(darwin)
extra-libraries: stdc++
else
-- extra-libraries: c++
if os(darwin)
extra-libraries: c++
-- https://gitlab.haskell.org/ghc/ghc/-/issues/11829
ld-options: -Wl,-keep_dwarf_unwind
ghc-options: -fcompact-unwind
Expand All @@ -131,53 +128,44 @@ library
ethjet/tinykeccak.h, ethjet/ethjet.h, ethjet/ethjet-ff.h, ethjet/blake2.h
build-depends:
QuickCheck >= 2.13.2 && < 2.15,
quickcheck-text >= 0.1.2 && < 0.2,
Decimal >= 0.5.1 && < 0.6,
containers >= 0.6.0 && < 0.7,
deepseq >= 1.4.4 && < 1.5,
time >= 1.11 && < 1.14,
transformers >= 0.5.6 && < 0.6,
transformers >= 0.5 && < 0.7,
tree-view >= 0.5 && < 0.6,
abstract-par >= 0.3.3 && < 0.4,
aeson >= 2.0.0 && < 2.2,
bytestring >= 0.11.3.1 && < 0.12,
scientific >= 0.3.6 && < 0.4,
binary >= 0.8.6 && < 0.9,
text >= 1.2.3 && < 2.1,
unordered-containers >= 0.2.10 && < 0.3,
vector >= 0.12.1 && < 0.14,
base16 >= 0.3.2.0 && < 0.3.3.0,
base16 >= 1.0 && < 1.1,
megaparsec >= 9.0.0 && < 10.0,
mtl >= 2.2.2 && < 2.3,
mtl >= 2.2 && < 2.4,
directory >= 1.3.3 && < 1.4,
filepath >= 1.4.2 && < 1.5,
cereal >= 0.5.8 && < 0.6,
cryptonite >= 0.30 && < 0.31,
memory >= 0.16.0 && < 0.20,
data-dword >= 0.3.1 && < 0.4,
free >= 5.1.3 && < 5.2,
haskeline >= 0.8.0 && < 0.9,
process >= 1.6.5 && < 1.7,
optics-core >= 0.4.1 && < 0.5,
optics-extra >= 0.4.2.1 && < 0.5,
optics-th >= 0.4.1 && < 0.5,
aeson-optics >= 1.2.0.1 && < 1.3,
monad-par >= 0.3.5 && < 0.4,
async >= 2.2.4 && < 2.3,
multiset >= 0.3.4 && < 0.4,
operational >= 0.2.3 && < 0.3,
optparse-generic >= 1.3.1 && < 1.5,
optparse-generic >= 1.3.1 && < 1.6,
pretty-hex >= 1.1 && < 1.2,
quickcheck-text >= 0.1.2 && < 0.2,
restless-git >= 0.7 && < 0.8,
rosezipper >= 0.2 && < 0.3,
temporary >= 1.3 && < 1.4,
witherable >= 0.3.5 && < 0.5,
wreq >= 0.5.3 && < 0.6,
regex-tdfa >= 1.2.3 && < 1.4,
base >= 4.9 && < 5,
here >= 1.2.13 && < 1.3,
smt2-parser >= 0.1.0.1,
word-wrap >= 0.5 && < 0.6,
spool >= 0.1 && < 0.2,
stm >= 2.5.0 && < 2.6.0,
spawn >= 0.3 && < 0.4,
Expand All @@ -196,8 +184,6 @@ executable hevm
ghc-options: -threaded -with-rtsopts=-N
other-modules:
Paths_hevm
if os(darwin)
extra-libraries: c++
build-depends:
QuickCheck,
aeson,
Expand All @@ -209,12 +195,9 @@ executable hevm
containers,
cryptonite,
data-dword,
deepseq,
directory,
filepath,
free,
hevm,
memory,
mtl,
optparse-generic,
operational,
Expand All @@ -223,7 +206,6 @@ executable hevm
regex-tdfa,
temporary,
text,
unordered-containers,
vector,
stm,
spawn,
Expand Down Expand Up @@ -284,8 +266,7 @@ common test-base
optics-extra,
witch,
unliftio-core,
exceptions,
MissingH
exceptions

library test-utils
import:
Expand Down
3 changes: 2 additions & 1 deletion src/EVM.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ import EVM.Types qualified as Expr (Expr(Gas))
import EVM.Sign qualified
import EVM.Concrete qualified as Concrete

import Control.Monad (unless, when)
import Control.Monad.ST (ST)
import Control.Monad.State.Strict hiding (state)
import Control.Monad.State.Strict (MonadState, State, get, gets, lift, modify', put)
import Data.Bits (FiniteBits, countLeadingZeros, finiteBitSize)
import Data.ByteArray qualified as BA
import Data.ByteString (ByteString)
Expand Down
2 changes: 1 addition & 1 deletion src/EVM/ABI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ bytesP :: ReadP ByteStringS
bytesP = do
_ <- string "0x"
hex <- munch isHexDigit
case BS16.decodeBase16 (encodeUtf8 (Text.pack hex)) of
case BS16.decodeBase16Untyped (encodeUtf8 (Text.pack hex)) of
Right d -> pure $ ByteStringS d
Left _ -> pfail

Expand Down
Loading