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

dapp: package local remappings #719

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
20 changes: 20 additions & 0 deletions src/dapp-tests/integration/tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,26 @@ dapp_testnet() {

dapp_testnet

# tests the behaviour of the package local dapp remappings
dapp_remappings() {
REV="fde82bd3319f7a1407a21553d120927d99a95f26"
TMPDIR=$(mktemp -d)
git clone https://github.com/dapphub/remappings-test "$TMPDIR"
(cd "$TMPDIR" && git checkout "$REV" && dapp update && dapp test)
}

dapp_remappings

# tests dapp remappings on a large legacy project with many transitive imports
dapp_remappings_compat() {
REV="bc6d7657f0f5190f65051543199e1b47bf29932b"
TMPDIR=$(mktemp -d)
git clone https://github.com/dapp-org/tinlake-tests "$TMPDIR"
(cd "$TMPDIR" && git checkout "$REV" && dapp update && dapp --use solc:0.7.6 build --allow-transitive-imports)
}

dapp_remappings_compat

test_hevm_symbolic() {
solc --bin-runtime -o . --overwrite factor.sol
# should find counterexample
Expand Down
4 changes: 2 additions & 2 deletions src/dapp-tests/shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ let
hypothesis
pytest
# other python packages you want
];
];
python-with-pkgs = python3.withPackages my-python-packages;
in

mkShell {
name = "dapp-tests";
buildInputs = [ killall cacert bashInteractive curl dapp gnumake hevm procps seth solc go-ethereum python-with-pkgs ];
buildInputs = [ killall cacert bashInteractive curl dapp git gnumake hevm procps seth solc go-ethereum python-with-pkgs ];
}
10 changes: 5 additions & 5 deletions src/dapp/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- `DAPP_TEST_DEPTH` env var to control `--depth`
- `--coverage` flag for `dapp test` to generate coverage via hevm
- `dapp debug` respects the `DAPP_LINK_TEST_LIBRARIES` environment variable.
- `dapp install` accepts URLs with git tags, branches or revs specified as `<url>@<tag>`

### Changed

- Dapp debug respects DAPP_LINK_TEST_LIBRARIES
- `dapp debug` respects the `DAPP_LINK_TEST_LIBRARIES` environment variable.

### Fixed

Expand All @@ -28,9 +27,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- `hevm` bumped to london hard fork.
- `dapp --use` now uses the solc binaries from https://binaries.soliditylang.org/ instead of the
versions built from source via nix
- `dapp remappings` now issues a warning instead of failing with a hard error in case of mistmatched
package versions in the dependency tree
versions built from source via nix
- `dapp remappings` now generates a unique set of remappings for each package in the dependency
tree that point into that pacakge's lib dir, allowing for multiple versions of the same package
to coexist in the dependency tree. More information in the [README](./README.md#package-structure-and-dependency-management).

## [0.33.0] - 2021-07-01

Expand Down
249 changes: 205 additions & 44 deletions src/dapp/README.md

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions src/dapp/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ lib, stdenv, fetchFromGitHub, makeWrapper, glibcLocales
, coreutils, git, gnused, gnumake, hevm, jshon, jq, nix
, nodejs, perl, python3, seth, shellcheck, solc, tre, dapptoolsSrc }:
, coreutils, findutils, ripgrep, git, gnused, gnumake, hevm
, jshon, jq, nix, nodejs, perl, python3, seth, shellcheck, solc
, tre, dapptoolsSrc }:

stdenv.mkDerivation rec {
name = "dapp-${version}";
Expand All @@ -16,7 +17,7 @@ stdenv.mkDerivation rec {
postInstall =
let
path = lib.makeBinPath [
coreutils git gnused gnumake hevm jshon jq nix nodejs perl seth solc tre python3
coreutils findutils git gnused gnumake hevm jshon jq nix nodejs perl seth solc tre python3 ripgrep
];
in
''
Expand Down
202 changes: 102 additions & 100 deletions src/dapp/libexec/dapp/dapp
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,26 @@
### dapp <command> --help
### --
### Compilation options:
### optimize activate solidity optimizer
### legacy compile using the '--combined-json' format
### extract after building, write the .abi, .bin and .bin-runtime. Implies '--legacy'
### optimize activate solidity optimizer
### legacy compile using the '--combined-json' format
### extract after building, write the .abi, .bin and .bin-runtime. Implies '--legacy'
### allow-transitive-imports allow imports with the short syntax from transitive dependencies
###
### Testing options:
### verbosity=<number> verbosity of 'dapp test' output (0-3)
### v,verbose sets verbosity to 1
### fuzz-runs=<number> number of times to run fuzzing tests
### depth=<number> number of transactions to sequence per invariant cycle
### replay=<string> rerun a particular test case
### m,match=<string> only run test methods matching regex
### cache=<string> use the cache at directory
### ffi allow the use of the ffi cheatcode (WARNING: allows test authors to execute arbitrary code on your machine)
### coverage print coverage data

### verbosity=<number> verbosity of 'dapp test' output (0-3)
### v,verbose sets verbosity to 1
### fuzz-runs=<number> number of times to run fuzzing tests
### depth=<number> number of transactions to sequence per invariant cycle
### replay=<string> rerun a particular test case
### m,match=<string> only run test methods matching regex
### cache=<string> use the cache at directory
### ffi allow the use of the ffi cheatcode (WARNING: allows test authors to execute arbitrary code on your machine)
### coverage print coverage data
###
### RPC options:
### rpc fetch remote state via ETH_RPC_URL
### rpc-url=<string> fetch remote state via <url>
### rpc-block=<number> block number (latest if not specified)
### rpc fetch remote state via ETH_RPC_URL
### rpc-url=<string> fetch remote state via <url>
### rpc-block=<number> block number (latest if not specified)
###
### SMT options:
### smttimeout=<number> timeout passed to the smt solver in ms (default 60000)
Expand All @@ -41,62 +42,63 @@
### async don't wait for confirmation

### Dapp testnet options:
### rpc-port=port change RPC port (default: 8545)
### rpc-addr=address change RPC address (default: 127.0.0.1)
### chain-id=number change chain ID (default: 99)
### period=seconds use a block time instead of instamine
### accounts=number create multiple accounts (default: 1)
### save=name after finishing, save snapshot
### load=name start from a previously saved snapshot
### dir=directory testnet directory
### rpc-port=port change RPC port (default: 8545)
### rpc-addr=address change RPC address (default: 127.0.0.1)
### chain-id=number change chain ID (default: 99)
### period=seconds use a block time instead of instamine
### accounts=number create multiple accounts (default: 1)
### save=name after finishing, save snapshot
### load=name start from a previously saved snapshot
### dir=directory testnet directory


OPTS="dapp [<options>] <command> [<args>]
dapp <command> --help
--
Compilation options:
optimize activate solidity optimizer
legacy compile using the '--combined-json' format
extract after building, write the .abi, .bin and .bin-runtime. Implies '--legacy'
optimize activate solidity optimizer
legacy compile using the '--combined-json' format
extract after building, write the .abi, .bin and .bin-runtime. Implies '--legacy'
allow-transitive-imports allow imports with the short syntax from transitive dependencies

Testing options:
verbosity=<number> verbosity of 'dapp test' output (0-3)
v,verbose sets verbosity to 1
fuzz-runs=<number> number of times to run fuzzing tests
depth=<number> number of transactions to sequence per invariant cycle
replay=<string> rerun a particular test case
m,match=<string> only run test methods matching regex
cov-match=<string> only print coverage for files matching regex
cache=<string> use the cache at directory
ffi allow the use of the ffi cheatcode (WARNING: allows test authors to execute arbitrary code on your machine)
coverage print coverage data
verbosity=<number> verbosity of 'dapp test' output (0-3)
v,verbose sets verbosity to 1
fuzz-runs=<number> number of times to run fuzzing tests
depth=<number> number of transactions to sequence per invariant cycle
replay=<string> rerun a particular test case
m,match=<string> only run test methods matching regex
cov-match=<string> only print coverage for files matching regex
cache=<string> use the cache at directory
ffi allow the use of the ffi cheatcode (WARNING: allows test authors to execute arbitrary code on your machine)
coverage print coverage data

RPC options:
rpc fetch remote state via ETH_RPC_URL
rpc-url=<string> fetch remote state via <url>
rpc-block=<number> block number (latest if not specified)
rpc fetch remote state via ETH_RPC_URL
rpc-url=<string> fetch remote state via <url>
rpc-block=<number> block number (latest if not specified)

SMT options:
smttimeout=<number> timeout passed to the smt solver in ms (default 60000)
solver=<string> name of the smt solver to use (either 'z3' or 'cvc4')
max-iterations=<number> number of times we may revisit a particular branching point
smtdebug print the SMT queries produced by hevm
smttimeout=<number> timeout passed to the smt solver in ms (default 60000)
solver=<string> name of the smt solver to use (either 'z3' or 'cvc4')
max-iterations=<number> number of times we may revisit a particular branching point
smtdebug print the SMT queries produced by hevm

Deployment options:
verify verify contract on etherscan
verify verify contract on etherscan

Contract verifying options:
async don't wait for confirmation
async don't wait for confirmation

Dapp testnet options:
rpc-port=port change RPC port (default: 8545)
rpc-addr=address change RPC address (default: 127.0.0.1)
chain-id=number change chain ID (default: 99)
period=seconds use a block time instead of instamine
accounts=number create multiple accounts (default: 1)
save=name after finishing, save snapshot
load=name start from a previously saved snapshot
dir=directory testnet directory
rpc-port=port change RPC port (default: 8545)
rpc-addr=address change RPC address (default: 127.0.0.1)
chain-id=number change chain ID (default: 99)
period=seconds use a block time instead of instamine
accounts=number create multiple accounts (default: 1)
save=name after finishing, save snapshot
load=name start from a previously saved snapshot
dir=directory testnet directory
"

set -e
Expand All @@ -109,13 +111,6 @@ if ! [[ $DAPP_INIT ]]; then
[[ $(pwd) != ~ && -e .dapprc ]] && . .dapprc
fi

export DAPP_SRC=${DAPP_SRC-src}
export DAPP_LIB=${DAPP_LIB-lib}
export DAPP_OUT=${DAPP_OUT-out}
export DAPP_JSON=${DAPP_JSON-${DAPP_OUT}/dapp.sol.json}
export DAPP_ROOT=${DAPP_ROOT-.}
export DAPP_REMAPPINGS=${DAPP_REMAPPINGS-"$(dapp-remappings)"}

if [[ $2 = --help ]]; then
exec "${0##*/}" help -- "$1"
elif [[ $DAPP_SOLC_VERSION ]]; then
Expand All @@ -138,50 +133,57 @@ shopt -s extglob

while [[ $1 ]]; do
case $1 in
--) shift; break;;
--extract) export DAPP_BUILD_EXTRACT=1;;
--optimize) export DAPP_BUILD_OPTIMIZE=1;;
--legacy) export DAPP_BUILD_LEGACY=1;;

-m|--match) shift; export DAPP_TEST_MATCH=$1;;
-v|--verbose) export DAPP_TEST_VERBOSITY=1;;
--cov-match) shift; export DAPP_TEST_COV_MATCH=$1;;
--verbosity) shift; export DAPP_TEST_VERBOSITY=$1;;
--fuzz-runs) shift; export DAPP_TEST_FUZZ_RUNS=$1;;
--depth) shift; export DAPP_TEST_DEPTH=$1;;

--smttimeout) shift; export DAPP_TEST_SMTTIMEOUT=$1;;
--solver) shift; export DAPP_TEST_SOLVER=$1;;
--max-iterations) shift; export DAPP_TEST_MAX_ITERATIONS=$1;;
--smtdebug) export DAPP_TEST_SMTDEBUG=1;;
--coverage) export DAPP_TEST_COVERAGE=1;;

--replay) shift; export DAPP_TEST_REPLAY=$1;;
--cache) shift; export DAPP_TEST_CACHE=$1;;
--ffi) export DAPP_TEST_FFI=1;;
--rpc-url) shift; export HEVM_RPC=yes; export ETH_RPC_URL=$1;;
--rpc-block) shift; export HEVM_RPC=yes; export DAPP_TEST_NUMBER=$1;;
--rpc) [ -n "$ETH_RPC_URL" ] || fail "ETH_RPC_URL not set.";
export HEVM_RPC=yes;;

--verify) export DAPP_VERIFY_CONTRACT=yes;;

--async) export DAPP_ASYNC=yes;;

--rpc-port) shift; export DAPP_TESTNET_RPC_PORT=$1;;
--rpc-addr) shift; export DAPP_TESTNET_RPC_ADDRESS=$1;;
--chain-id) shift; export DAPP_TESTNET_CHAINID=$1;;
--period) shift; export DAPP_TESTNET_PERIOD=$1;;
--accounts) shift; export DAPP_TESTNET_ACCOUNTS=$(($1 - 1));;
--save) shift; export DAPP_TESTNET_SAVE=$1;;
--load) shift; export DAPP_TESTNET_LOAD=$1;;
--dir) shift; export DAPP_TESTNET_gethdir=$1;;

--) shift; break;;
--extract) export DAPP_BUILD_EXTRACT=1;;
--optimize) export DAPP_BUILD_OPTIMIZE=1;;
--legacy) export DAPP_BUILD_LEGACY=1;;
--allow-transitive-imports) export DAPP_ALLOW_TRANSITIVE_IMPORTS=1;;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a shorter alias? --trans?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a shorter alias? --trans?

ayy my own flag

xD


-m|--match) shift; export DAPP_TEST_MATCH=$1;;
-v|--verbose) export DAPP_TEST_VERBOSITY=1;;
--cov-match) shift; export DAPP_TEST_COV_MATCH=$1;;
--verbosity) shift; export DAPP_TEST_VERBOSITY=$1;;
--fuzz-runs) shift; export DAPP_TEST_FUZZ_RUNS=$1;;
--depth) shift; export DAPP_TEST_DEPTH=$1;;

--smttimeout) shift; export DAPP_TEST_SMTTIMEOUT=$1;;
--solver) shift; export DAPP_TEST_SOLVER=$1;;
--max-iterations) shift; export DAPP_TEST_MAX_ITERATIONS=$1;;
--smtdebug) export DAPP_TEST_SMTDEBUG=1;;
--coverage) export DAPP_TEST_COVERAGE=1;;

--replay) shift; export DAPP_TEST_REPLAY=$1;;
--cache) shift; export DAPP_TEST_CACHE=$1;;
--ffi) export DAPP_TEST_FFI=1;;
--rpc-url) shift; export HEVM_RPC=yes; export ETH_RPC_URL=$1;;
--rpc-block) shift; export HEVM_RPC=yes; export DAPP_TEST_NUMBER=$1;;
--rpc) [ -n "$ETH_RPC_URL" ] || fail "ETH_RPC_URL not set.";
export HEVM_RPC=yes;;

--verify) export DAPP_VERIFY_CONTRACT=yes;;

--async) export DAPP_ASYNC=yes;;

--rpc-port) shift; export DAPP_TESTNET_RPC_PORT=$1;;
--rpc-addr) shift; export DAPP_TESTNET_RPC_ADDRESS=$1;;
--chain-id) shift; export DAPP_TESTNET_CHAINID=$1;;
--period) shift; export DAPP_TESTNET_PERIOD=$1;;
--accounts) shift; export DAPP_TESTNET_ACCOUNTS=$(($1 - 1));;
--save) shift; export DAPP_TESTNET_SAVE=$1;;
--load) shift; export DAPP_TESTNET_LOAD=$1;;
--dir) shift; export DAPP_TESTNET_gethdir=$1;;

*) printf "${0##*/}: internal error: %q\\n" "$1"; exit 1
esac; shift
done

export DAPP_SRC=${DAPP_SRC-src}
export DAPP_LIB=${DAPP_LIB-lib}
export DAPP_OUT=${DAPP_OUT-out}
export DAPP_JSON=${DAPP_JSON-${DAPP_OUT}/dapp.sol.json}
export DAPP_ROOT=${DAPP_ROOT-.}
export DAPP_REMAPPINGS=${DAPP_REMAPPINGS-"$(dapp-remappings)"}

if ! [ -x "$(command -v "${0##*/}-${1-help}")" ]; then
# look for approximate matches
echo >&2 "'$1' is not a dapp command. See 'dapp help'."
Expand Down
Loading