Skip to content

Commit

Permalink
Fix #259: more elegant way to build (#264)
Browse files Browse the repository at this point in the history
* Fix #259: more elegant way to build

* Fix #259: more elegant way to build

* Fix #259: more elegant way to build
  • Loading branch information
jacob-chia authored Oct 23, 2023
1 parent e9421bb commit af591f6
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 51 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
# git clone https://github.com/Z3Prover/z3
# cd z3
# python scripts/mk_make.py --prefix=/usr/local
# cd build
# cd build
# make -j64
# sudo make install
Expand Down Expand Up @@ -153,12 +153,16 @@ jobs:
- name: Build binaries
env:
SVM_TARGET_PLATFORM: ${{ matrix.job.svm_target_platform }}
run: cargo build --release --bins --target ${{ matrix.job.target }}
run: |
cargo build --release --bins --target ${{ matrix.job.target }} \
--features "cmp dataflow evm print_txn_corpus full_trace" --no-default-features
- name: Build binaries with flashloan
env:
SVM_TARGET_PLATFORM: ${{ matrix.job.svm_target_platform }}
run: cargo build --release --bins --target ${{ matrix.job.target }} --target-dir "target_f" --features "default flashloan_v2 force_cache"
run: |
cargo build --release --bins --target ${{ matrix.job.target }} --target-dir "target_f" \
--features "cmp dataflow evm print_txn_corpus full_trace flashloan_v2 force_cache" --no-default-features
- name: Archive binaries
id: artifacts
Expand Down
16 changes: 7 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ COPY src ./src
COPY benches ./benches

# build offchain binary
RUN cargo build --release
RUN cargo build --release --features "cmp dataflow evm print_txn_corpus full_trace" --no-default-features
RUN cp target/release/ityfuzz /bins/cli_offchain

# build onchain binary
RUN sed -i -e 's/"cmp"/"cmp","flashloan_v2"/g' ./Cargo.toml
RUN cargo build --release
# RUN sed -i -e 's/"cmp"/"cmp","flashloan_v2"/g' ./Cargo.toml
RUN cargo build --release --features "cmp dataflow evm print_txn_corpus full_trace flashloan_v2" --no-default-features
RUN cp target/release/ityfuzz /bins/cli_onchain

RUN sed -i -e 's/"deployer_is_attacker"/"print_logs"/g' ./Cargo.toml
RUN sed -i -e 's/"print_txn_corpus",//g' ./Cargo.toml
RUN sed -i -e 's/"full_trace",//g' ./Cargo.toml
RUN cargo build --release
# RUN sed -i -e 's/"deployer_is_attacker"/"print_logs"/g' ./Cargo.toml
# RUN sed -i -e 's/"print_txn_corpus",//g' ./Cargo.toml
# RUN sed -i -e 's/"full_trace",//g' ./Cargo.toml
RUN cargo build --release --features "cmp dataflow evm flashloan_v2 print_logs" --no-default-features
RUN cp target/release/ityfuzz /bins/cli_print_logs

FROM run_environment
Expand All @@ -46,5 +46,3 @@ WORKDIR /bins
COPY tests /bins/tests

EXPOSE 8000


35 changes: 16 additions & 19 deletions integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,29 +184,26 @@ def test_onchain(test):

def build_fuzzer():
# build fuzzer
subprocess.run(["cargo", "build", "--release"])


def update_cargo_toml():
with open("Cargo.toml", "r") as file:
content = file.read()

if '"flashloan_v2"' in content:
return

if '"cmp"' in content:
content = content.replace('"cmp"', '"cmp","flashloan_v2","force_cache"')

with open("Cargo.toml", "w") as file:
file.write(content)

print("Cargo.toml has been updated!")
subprocess.run([
"cargo",
"build",
"--release",
"--features",
"cmp dataflow evm print_txn_corpus full_trace",
"--no-default-features"
])


def build_flash_loan_v2_fuzzer():
update_cargo_toml()
# build fuzzer
subprocess.run(["cargo", "build", "--release"])
subprocess.run([
"cargo",
"build",
"--release",
"--features",
"cmp dataflow evm print_txn_corpus full_trace flashloan_v2 force_cache",
"--no-default-features"
])


import multiprocessing
Expand Down
40 changes: 20 additions & 20 deletions ityfuzzup/ityfuzzup
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ main() {
# Enter local repo and build
say "installing from $ITYFUZZ_LOCAL_REPO"
cd "$ITYFUZZ_LOCAL_REPO"
ensure cargo build --bins --release # need 4 speed
ensure cargo build --bins --release --features "cmp dataflow evm print_txn_corpus full_trace" --no-default-features # need 4 speed

for bin in "${BINS[@]}"; do
# Remove prior installations if they exist
Expand Down Expand Up @@ -192,7 +192,7 @@ EOF
fi

# Build the repo and install the binaries locally to the .ityfuzz bin directory.
ensure cargo build --bins --release
ensure cargo build --bins --release --features "cmp dataflow evm print_txn_corpus full_trace" --no-default-features
for bin in "${BINS[@]}"; do
for try_path in target/release/$bin target/release/$bin.exe; do
if [ -f "$try_path" ]; then
Expand Down Expand Up @@ -275,32 +275,32 @@ download() {
fi
}

# Banner Function for ITYFUZZ
# Banner Function for ITYFUZZ
banner() {
printf '
IIIIIIIIII tttt FFFFFFFFFFFFFFFFFFFFFF
I::::::::I ttt:::t F::::::::::::::::::::F
I::::::::I t:::::t F::::::::::::::::::::F
II::::::II t:::::t FF::::::FFFFFFFFF::::F
printf '
IIIIIIIIII tttt FFFFFFFFFFFFFFFFFFFFFF
I::::::::I ttt:::t F::::::::::::::::::::F
I::::::::I t:::::t F::::::::::::::::::::F
II::::::II t:::::t FF::::::FFFFFFFFF::::F
I::::I ttttttt:::::ttttttt yyyyyyy yyyyyyy F:::::F FFFFFFuuuuuu uuuuuu zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
I::::I t:::::::::::::::::t y:::::y y:::::y F:::::F u::::u u::::u z:::::::::::::::zz:::::::::::::::z
I::::I t:::::::::::::::::t y:::::y y:::::y F::::::FFFFFFFFFF u::::u u::::u z::::::::::::::z z::::::::::::::z
I::::I tttttt:::::::tttttt y:::::y y:::::y F:::::::::::::::F u::::u u::::u zzzzzzzz::::::z zzzzzzzz::::::z
I::::I t:::::t y:::::y y:::::y F:::::::::::::::F u::::u u::::u z::::::z z::::::z
I::::I t:::::t y:::::y y:::::y F::::::FFFFFFFFFF u::::u u::::u z::::::z z::::::z
I::::I t:::::t y:::::y:::::y F:::::F u::::u u::::u z::::::z z::::::z
I::::I t:::::t tttttt y:::::::::y F:::::F u:::::uuuu:::::u z::::::z z::::::z
I::::I t:::::::::::::::::t y:::::y y:::::y F::::::FFFFFFFFFF u::::u u::::u z::::::::::::::z z::::::::::::::z
I::::I tttttt:::::::tttttt y:::::y y:::::y F:::::::::::::::F u::::u u::::u zzzzzzzz::::::z zzzzzzzz::::::z
I::::I t:::::t y:::::y y:::::y F:::::::::::::::F u::::u u::::u z::::::z z::::::z
I::::I t:::::t y:::::y y:::::y F::::::FFFFFFFFFF u::::u u::::u z::::::z z::::::z
I::::I t:::::t y:::::y:::::y F:::::F u::::u u::::u z::::::z z::::::z
I::::I t:::::t tttttt y:::::::::y F:::::F u:::::uuuu:::::u z::::::z z::::::z
II::::::II t::::::tttt:::::t y:::::::y FF:::::::FF u:::::::::::::::uu z::::::zzzzzzzz z::::::zzzzzzzz
I::::::::I tt::::::::::::::t y:::::y F::::::::FF u:::::::::::::::u z::::::::::::::z z::::::::::::::z
I::::::::I tt:::::::::::tt y:::::y F::::::::FF uu::::::::uu:::uz:::::::::::::::zz:::::::::::::::z
IIIIIIIIII ttttttttttt y:::::y FFFFFFFFFFF uuuuuuuu uuuuzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
y:::::y
y:::::y
y:::::y
y:::::y
yyyyyyy
y:::::y
y:::::y
y:::::y
y:::::y
yyyyyyy
'
}


main "$@" || exit 1
main "$@" || exit 1

0 comments on commit af591f6

Please sign in to comment.