Skip to content

Commit

Permalink
bump gigahorse version, update setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ruaronicola committed Aug 8, 2023
1 parent c0c74d3 commit 5ca5c3f
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 78 deletions.
6 changes: 3 additions & 3 deletions resources/analyze_hex.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ GIGAHORSE_DIR=$GREED_DIR/gigahorse-toolchain
if [ ! -f $GIGAHORSE_DIR/clients/main.dl_compiled ]; then
echo "Can't find main.dl_compiled (something went wrong in setup.sh)"
exit 1
elif [ ! -f $GIGAHORSE_DIR/clients/guards.dl_compiled ]; then
echo "Can't find guards.dl_compiled (something went wrong in setup.sh)"
elif [ ! -f $GIGAHORSE_DIR/clients/greed_client.dl_compiled ]; then
echo "Can't find greed_client.dl_compiled (something went wrong in setup.sh)"
exit 1
fi

echo "Running gigahorse.py"
/usr/bin/time -v $GIGAHORSE_DIR/gigahorse.py -q QUIET -T $TIMEOUT --reuse_datalog_bin --disable_inline -C $GIGAHORSE_DIR/clients/guards.dl_compiled,$GIGAHORSE_DIR/clients/visualizeout.py $HEX_FILE &> exec_info &&
/usr/bin/time -v $GIGAHORSE_DIR/gigahorse.py -q QUIET -T $TIMEOUT --reuse_datalog_bin --disable_inline -C $GIGAHORSE_DIR/clients/greed_client.dl_compiled,$GIGAHORSE_DIR/clients/visualizeout.py $HEX_FILE &> exec_info &&
curr_dir=$(pwd) && cd $GIGAHORSE_DIR && gigahorse_version=$(git rev-parse HEAD) && cd $curr_dir && printf "\tGigahorse version: $gigahorse_version\n" >> exec_info &&
curr_dir=$(pwd) && cd $GREED_DIR && greed_version=$(git rev-parse HEAD) && cd $curr_dir && printf "\tgreed version: $greed_version\n" >> exec_info
cp .temp/contract/out/* .
Expand Down
4 changes: 2 additions & 2 deletions resources/download_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

# connect to web3
w3 = Web3(Web3.HTTPProvider(args.w3))
assert w3.isConnected()
assert w3.is_connected()

code = w3.eth.getCode(args.address).hex()[2:]
code = w3.eth.get_code(args.address).hex()[2:]

if args.peek:
print(code, end='')
Expand Down
12 changes: 0 additions & 12 deletions resources/patches/gigahorse_data_structures.patch

This file was deleted.

37 changes: 37 additions & 0 deletions resources/patches/gigahorse_greed_client.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
diff --git a/clientlib/greed_client.dl b/clientlib/greed_client.dl
new file mode 100644
index 0000000..d88493b
--- /dev/null
+++ b/clientlib/greed_client.dl
@@ -0,0 +1,30 @@
+#include "decompiler_imports.dl"
+#include "guards.dl"
+#include "loops_semantics.dl"
+
+// storage layout output
+.output StorageVariableType
+
+// guards analysis output
+.output StaticallyGuardedBlock
+.output Dominates
+
+
+// more required outputs (see greed's TAC_parser.py)
+// .output IRInFunctionFiltered(IO="file", filename="InFunction.csv", delimiter="\t")
+// .output PublicFunction(IO="file", filename="PublicFunction.csv", delimiter="\t")
+// .output TAC_Block
+// .output TAC_Op
+// .output TAC_OriginalStatement_Block
+// .output TAC_Variable_Value
+// .output TAC_Def
+// .output TAC_Use
+// .output ConstantPossibleSigHash
+// .output CallToSignature
+// .output CallToSignatureFromSHA3
+// .output IRFallthroughEdge
+// .output HighLevelFunctionName
+// .output LocalBlockEdge
+// .output IRFunctionEntry
+// .output FormalArgs
+// .output StaticallyGuardedBlock
\ No newline at end of file
20 changes: 0 additions & 20 deletions resources/patches/gigahorse_guards_client.patch

This file was deleted.

11 changes: 0 additions & 11 deletions resources/patches/gigahorse_loops_semantics_client.patch

This file was deleted.

23 changes: 0 additions & 23 deletions resources/patches/gigahorse_memlimit.patch

This file was deleted.

9 changes: 6 additions & 3 deletions resources/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import logging

import IPython
import web3

from web3 import Web3

from greed import Project
from greed import options
Expand All @@ -27,8 +28,10 @@ def main(args):
options.OPTIMISTIC_CALL_RESULTS = True
options.DEFAULT_EXTCODESIZE = True

w3 = web3.Web3(web3.Web3.HTTPProvider(options.WEB3_PROVIDER))
block_number = w3.eth.blockNumber
w3 = Web3(Web3.HTTPProvider(options.WEB3_PROVIDER))
assert w3.is_connected()

block_number = w3.eth.block_number
block_info = w3.eth.get_block(block_number)

init_ctx = {
Expand Down
9 changes: 5 additions & 4 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if [ -z $NO_GIGAHORSE ]; then
if [ ! -d $GREED_DIR/gigahorse-toolchain ]; then
git clone --recursive https://github.com/nevillegrech/gigahorse-toolchain.git $GIGAHORSE_DIR
cd $GIGAHORSE_DIR
git checkout 59599ecb2397c42e342140189593cabdcce1a2d6
git checkout c5bce4d3495fc10f503b49368504efee3c676d03
fi

# apply patches
Expand Down Expand Up @@ -83,9 +83,10 @@ if [ -z $NO_GIGAHORSE ]; then
echo "Successfully compiled $1.."
}
compile "main.dl" "logic/main.dl"
compile "function_inliner.dl" "clientlib/function_inliner.dl"
compile "loops_semantics.dl" "clientlib/loops_semantics.dl"
compile "guards.dl" "clientlib/guards.dl"
compile "greed_client.dl" "clientlib/greed_client.dl"
# compile "function_inliner.dl" "clientlib/function_inliner.dl"
# compile "loops_semantics.dl" "clientlib/loops_semantics.dl"
# compile "guards.dl" "clientlib/guards.dl"

command -v >&- mkisofs || echo "${bold}${red}mkisofs is not installed. solc-select might not work correctly (e.g., sudo apt install mkisofs)${normal}"
solc-select versions | grep -q 0.8.7 || { echo "Installing solc 0.8.7"; solc-select install 0.8.7; }
Expand Down

0 comments on commit 5ca5c3f

Please sign in to comment.