Skip to content

Commit

Permalink
Merge pull request #12 from crytic/dev
Browse files Browse the repository at this point in the history
Dev --> main
  • Loading branch information
webthethird authored Jul 21, 2023
2 parents d383b04 + 66f0334 commit 40376a7
Show file tree
Hide file tree
Showing 24 changed files with 179 additions and 150 deletions.
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

0 comments on commit 40376a7

Please sign in to comment.