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

Dev --> main #12

Merged
merged 23 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
a995264
Override fetching ContractData for the main proxy
webthethird Jul 7, 2023
f09bdb7
Pylint
webthethird Jul 7, 2023
849b9b2
Black
webthethird Jul 7, 2023
c571f8f
In fork/hybrid mode, avoid fetching main proxy impl again
webthethird Jul 7, 2023
e4c74b5
Merge pull request #4 from crytic/dev-main-proxy
webthethird Jul 7, 2023
89c82fb
Update expected max solidity version
webthethird Jul 19, 2023
97f1726
Update starting block in `test_few_token_holders`
webthethird Jul 19, 2023
c06522c
Rename `-v/--version` to `-V/--solc-version`
webthethird Jul 19, 2023
a9351b2
Add a real `--version` option
webthethird Jul 19, 2023
f8f2711
Add a real `-v` shortcut for `--version`
webthethird Jul 19, 2023
69738e8
Update version flag in CI workflows
webthethird Jul 19, 2023
da106b5
Update version flag in README.md
webthethird Jul 19, 2023
ba6ad21
Update diffusc version to 0.1.1 in setup.py
webthethird Jul 19, 2023
53dec17
Merge pull request #9 from crytic/dev-update-pytests
webthethird Jul 19, 2023
ad1784a
Update solc version flag in e2e pytests
webthethird Jul 19, 2023
e194550
Install `types-setuptools` in mypy CI workflow
webthethird Jul 19, 2023
bad6ef0
Use `>=` instead of `^` in pragma statement
webthethird Jul 19, 2023
8a37a74
When using fork mode w/o a proxy, use suffix
webthethird Jul 19, 2023
36bc701
Update expected output
webthethird Jul 19, 2023
8178012
Merge pull request #10 from crytic/dev-fix-version-option
webthethird Jul 19, 2023
c8d8046
Merge remote-tracking branch 'origin/dev' into dev-fix-fork-mode-with…
webthethird Jul 19, 2023
3c2d155
Update expected output
webthethird Jul 20, 2023
66f0334
Merge pull request #11 from crytic/dev-fix-fork-mode-without-proxy
webthethird Jul 20, 2023
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
8 changes: 4 additions & 4 deletions .github/workflows/ci-fork-mode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ jobs:
matrix:
include:
- name: Safemoon
args: 0x0296201bfdfb410c29ef30bcae1b395537aeeb31 0xEb11a0a0beF1AC028B8C2d4CD64138DD5938cA7A -p 0x42981d0bfbAf196529376EE702F2a9Eb9092fcB5 -n bsc -v 0.8.11
args: 0x0296201bfdfb410c29ef30bcae1b395537aeeb31 0xEb11a0a0beF1AC028B8C2d4CD64138DD5938cA7A -p 0x42981d0bfbAf196529376EE702F2a9Eb9092fcB5 -n bsc -V 0.8.11
block: 26857408
rpckey: BSC_RPC_URL
apikey: BSC_API_KEY

# - name: Compound
# args: 0x75442Ac771a7243433e033F3F8EaB2631e22938f 0x374ABb8cE19A73f2c4EFAd642bda76c797f19233 -t 0x6C8c6b02E7b2BE14d4fA6022Dfd6d75921D90E4E,0xc00e94Cb662C3520282E6f5717214004A7f26888 -p 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B -u -v 0.8.10 -T --token-holder 0x309d413391e975B553B7B8D19bC11F8a6c2eB889
# args: 0x75442Ac771a7243433e033F3F8EaB2631e22938f 0x374ABb8cE19A73f2c4EFAd642bda76c797f19233 -t 0x6C8c6b02E7b2BE14d4fA6022Dfd6d75921D90E4E,0xc00e94Cb662C3520282E6f5717214004A7f26888 -p 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B -u -V 0.8.10 -T --token-holder 0x309d413391e975B553B7B8D19bC11F8a6c2eB889
# block: 13322797
# rpckey: ETHEREUM_RPC_URL
# apikey: ETHEREUM_API_KEY

- name: AnkrRewardEarningBNB
args: 0xE380B02b16e050c2801CcA83461916FEca652ecF 0x952398318838b4915ee5E800622a9613887759f5 -p 0xfe39985D7eFF914c50A06bA0cFfcCA8361e00C0e -t 0x52F24a5e03aee338Da5fd9Df68D2b6FAe1178827:0x2c00CE1a935FF8c9e78580533e2E17c36281c26E -T -n bsc -v 0.8.16
args: 0xE380B02b16e050c2801CcA83461916FEca652ecF 0x952398318838b4915ee5E800622a9613887759f5 -p 0xfe39985D7eFF914c50A06bA0cFfcCA8361e00C0e -t 0x52F24a5e03aee338Da5fd9Df68D2b6FAe1178827:0x2c00CE1a935FF8c9e78580533e2E17c36281c26E -T -n bsc -V 0.8.16
block: 28261629
rpckey: BSC_RPC_URL
apikey: BSC_API_KEY

- name: DeusFinanceDEI
args: 0x1472b3081d81b792e697aea90accbbc4adc5baf9 0xbc1b62db243b51dabcd9540473324f36e094ec55 -p 0xde1e704dae0b4051e80dabb26ab6ad6c12262da0 -n arbi -v 0.8.4
args: 0x1472b3081d81b792e697aea90accbbc4adc5baf9 0xbc1b62db243b51dabcd9540473324f36e094ec55 -p 0xde1e704dae0b4051e80dabb26ab6ad6c12262da0 -n arbi -V 0.8.4
block: 87626025
rpckey: ARBITRUM_RPC_URL
apikey: ARBITRUM_API_KEY
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-path-mode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
include:
- name: Safemoon
out: ./contracts/test/safemoon/
args: ./diffusc/tests/test_data/safemoon/SafemoonV2.sol ./diffusc/tests/test_data/safemoon/SafemoonV3.sol -p ./diffusc/tests/test_data/safemoon/TransparentProxyTestHarness.sol -v 0.8.11 --run-custom ./contracts/test/safemoon/DiffFuzzCustomInit.sol DiffFuzzInit
args: ./diffusc/tests/test_data/safemoon/SafemoonV2.sol ./diffusc/tests/test_data/safemoon/SafemoonV3.sol -p ./diffusc/tests/test_data/safemoon/TransparentProxyTestHarness.sol -V 0.8.11 --run-custom ./contracts/test/safemoon/DiffFuzzCustomInit.sol DiffFuzzInit

- name: Compound
out: ./contracts/test/compound
args: ./contracts/implementation/compound/compound-0.8.10/ComptrollerHarnessV1.sol ./contracts/implementation/compound/compound-0.8.10/ComptrollerHarnessV2.sol -t ./contracts/implementation/compound/compound-0.8.10/CErc20.sol,./contracts/implementation/compound/compound-0.8.10/CompHarness.sol -p ./contracts/implementation/compound/compound-0.8.10/Unitroller.sol -u -v 0.8.10 --run-custom ./contracts/test/compound/DiffFuzzCustomInit.sol DiffFuzzCustomInit
args: ./contracts/implementation/compound/compound-0.8.10/ComptrollerHarnessV1.sol ./contracts/implementation/compound/compound-0.8.10/ComptrollerHarnessV2.sol -t ./contracts/implementation/compound/compound-0.8.10/CErc20.sol,./contracts/implementation/compound/compound-0.8.10/CompHarness.sol -p ./contracts/implementation/compound/compound-0.8.10/Unitroller.sol -u -V 0.8.10 --run-custom ./contracts/test/compound/DiffFuzzCustomInit.sol DiffFuzzCustomInit

steps:
- name: Checkout repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
python-version: '3.10'

- name: Install mypy
run: python3 -m pip install mypy==1.2.0 types-requests
run: python3 -m pip install mypy==1.2.0 types-requests types-setuptools

- name: Install dependencies
run: pip3 install -r requirements.txt
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ Additional options unlock greater functionality:
* `--senders`: Explicitly specify a list of sender addresses to use (in fork mode). Echidna defaults to `0x1000`, `0x2000` and `0x3000`.
* `--min-token-balance`: The minimum token balance required when searching for holders (default 10000).
* `--max-token-holders`: The maximum number of holders to find per token (default 5).
* `-v, --version`: The solc compiler version to use (default 0.8.0).
* `-V, --solc-version`: The solc compiler version to use (default 0.8.0).
* `-v, --version`: The current version of Diffusc.
* `-u, --fuzz-upgrade`: Flag to include an upgrade function in test contract, to upgrade to V2 mid-transaction sequence (default false).
* `-P, --protected`: Flag to include test wrappers for protected functions, i.e., with modifier like `onlyOwner` (default false).
* `-x, --external-taint`: Flag to analyze external calls to find tainted external contracts (default false).
Expand Down
4 changes: 2 additions & 2 deletions diffusc/core/code_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ def wrap_low_level_call(
target = camel_case(c_data["name"])
else:
target = camel_case(proxy["name"])
if not self._fork:
if not self._fork or proxy is None:
target += c_data["suffix"]
_, call_args, _, _ = self.get_args_and_returns_for_wrapping(func)
wrapped = ""
Expand Down Expand Up @@ -936,7 +936,7 @@ def generate_test_contract(self, diff: Diff, output_dir: str = "./") -> str:

CryticPrint.print_information("\n* Generating exploit contract...")
# Add solidity pragma and SPDX to avoid warnings
final_contract += f"// SPDX-License-Identifier: AGPLv3\npragma solidity ^{version};\n\n"
final_contract += f"// SPDX-License-Identifier: AGPLv3\npragma solidity >={version};\n\n"
try:
# Check the major version number, and include abi encoder if below 0.8.0
major_version = int(self._version.split(".")[1])
Expand Down
7 changes: 6 additions & 1 deletion diffusc/core/fork_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,12 @@ def analyze_contracts(self) -> None:
)
if is_address(self._proxy_address):
self._proxy = get_contract_data_from_address(
self._proxy_address, "", self._provider, self.net_info
self._proxy_address,
"",
self._provider,
self.net_info,
is_main_proxy=True,
main_proxy_impl=self._v2,
)
if not self._proxy["valid_data"]:
CryticPrint.print_error(
Expand Down
7 changes: 6 additions & 1 deletion diffusc/core/hybrid_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,12 @@ def analyze_contracts(self) -> None:
)
if is_address(self._proxy_address):
self._proxy = get_contract_data_from_address(
self._proxy_address, "", self._network_provider, self.net_info
self._proxy_address,
"",
self._network_provider,
self.net_info,
is_main_proxy=True,
main_proxy_impl=self._v2,
)
if not self._proxy["valid_data"]:
CryticPrint.print_error(
Expand Down
12 changes: 10 additions & 2 deletions diffusc/diffusc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import os
import sys
from typing import Sequence, Optional
from pkg_resources import require

from solc_select.solc_select import switch_global_version
from eth_utils import is_address
Expand Down Expand Up @@ -54,11 +55,18 @@ def main(_args: Optional[Sequence[str]] = None) -> int:
help="Specifies the address to which to deploy the test contract.",
)
parser.add_argument(
"-v",
"--version",
"-V",
"--solc-version",
dest="version",
help="Specifies the solc version to use in the test contract (default is 0.8.0).",
)
parser.add_argument(
"-v",
"--version",
help="Displays the current version of diffusc",
version=require("diffusc")[0].version,
action="version",
)
parser.add_argument(
"-u",
"--fuzz-upgrade",
Expand Down
2 changes: 1 addition & 1 deletion diffusc/tests/e2e/test_fork_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_diffusc_fork_mode() -> None:
"bsc",
"-b",
"26857408",
"-v",
"-V",
"0.8.11",
"-d",
output_dir,
Expand Down
4 changes: 2 additions & 2 deletions diffusc/tests/e2e/test_path_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_diffusc_path_mode() -> None:
os.path.join(TEST_DATA_DIR, "ContractV2.sol"),
"-d",
output_dir,
"-v",
"-V",
"0.8.2",
]
assert main(args) == 0
Expand Down Expand Up @@ -122,7 +122,7 @@ def test_diffusc_path_run_mode() -> None:
os.path.join(safemoon_dir, "SafemoonV3.sol"),
"-p",
os.path.join(safemoon_dir, "TransparentProxyTestHarness.sol"),
"-v",
"-V",
"0.8.11",
"-d",
output_dir,
Expand Down
Loading