diff --git a/resources/analyze_hex.sh b/resources/analyze_hex.sh index 3535b27..18342dc 100755 --- a/resources/analyze_hex.sh +++ b/resources/analyze_hex.sh @@ -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/* . diff --git a/resources/download_contract.py b/resources/download_contract.py index 4938c61..44099cd 100755 --- a/resources/download_contract.py +++ b/resources/download_contract.py @@ -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='') diff --git a/resources/patches/gigahorse_data_structures.patch b/resources/patches/gigahorse_data_structures.patch deleted file mode 100644 index d17d873..0000000 --- a/resources/patches/gigahorse_data_structures.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/clientlib/data_structures.dl b/clientlib/data_structures.dl -index 819a95b..2290e21 100644 ---- a/clientlib/data_structures.dl -+++ b/clientlib/data_structures.dl -@@ -641,6 +641,7 @@ StorageVariableInfo(storVar, storVar, 0, 31):- - **/ - - .decl StorageVariableType(storVar:symbol, type:symbol) -+.output StorageVariableType - - .decl SpecialStorageVariableType(storVar:symbol, type:symbol) - diff --git a/resources/patches/gigahorse_greed_client.patch b/resources/patches/gigahorse_greed_client.patch new file mode 100644 index 0000000..867b72f --- /dev/null +++ b/resources/patches/gigahorse_greed_client.patch @@ -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 diff --git a/resources/patches/gigahorse_guards_client.patch b/resources/patches/gigahorse_guards_client.patch deleted file mode 100644 index 3efa5c7..0000000 --- a/resources/patches/gigahorse_guards_client.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff --git a/clientlib/guards.dl b/clientlib/guards.dl -index 40a0403..246979b 100644 ---- a/clientlib/guards.dl -+++ b/clientlib/guards.dl -@@ -1,5 +1,6 @@ - #pragma once - -+#include "decompiler_imports.dl" - #include "memory_modeling/memory_modeling.dl" - #include "data_structures.dl" - #include "flows.dl" -@@ -15,7 +16,7 @@ - - `require(msg.sender == storageVar.owner())` - */ - .decl StaticallyGuardedBlock(guardedBlock: Block, globalVal: Value) -- -+.output StaticallyGuardedBlock, Dominates - StaticallyGuardedBlock(guardedBlock, globalVal) :- - ControlsWith(_, guardedBlock, predicate), - SenderGuard(globalVal, predicate). diff --git a/resources/patches/gigahorse_loops_semantics_client.patch b/resources/patches/gigahorse_loops_semantics_client.patch deleted file mode 100644 index 0aa21b4..0000000 --- a/resources/patches/gigahorse_loops_semantics_client.patch +++ /dev/null @@ -1,11 +0,0 @@ -diff --git a/clientlib/loops_semantics.dl b/clientlib/loops_semantics.dl -index a14d148..28b1427 100644 ---- a/clientlib/loops_semantics.dl -+++ b/clientlib/loops_semantics.dl -@@ -1,4 +1,6 @@ - #pragma once -+ -+#include "decompiler_imports.dl" - #include "loops.dl" - #include "flows.dl" - diff --git a/resources/patches/gigahorse_memlimit.patch b/resources/patches/gigahorse_memlimit.patch deleted file mode 100644 index 6041292..0000000 --- a/resources/patches/gigahorse_memlimit.patch +++ /dev/null @@ -1,23 +0,0 @@ -diff --git a/gigahorse.py b/gigahorse.py -index 65d267f..4b4cc6d 100755 ---- a/gigahorse.py -+++ b/gigahorse.py -@@ -70,8 +70,8 @@ DEFAULT_NUM_JOBS = max(int(cpu_count() * 0.9), 1) - - """The number of subprocesses to run at once.""" - --DEFAULT_MEMORY_LIMIT = 45 * 1_000_000_000 --"""Hard capped memory limit for analyses processes (30 GB)""" -+DEFAULT_MEMORY_LIMIT = 50 * 1_000_000_000 -+"""Hard capped memory limit for analyses processes (50 GB)""" - - # Command Line Arguments - -@@ -548,6 +548,7 @@ def get_gigahorse_analytics(out_dir, analytics): - analytics[key] = analytics.get(key, 0) + 1 - - def set_memory_limit(memory_limit): -+ return - resource.setrlimit(resource.RLIMIT_AS, (memory_limit, memory_limit)) - - class TimeoutException(Exception): diff --git a/resources/run.py b/resources/run.py index e3b79c5..59f1925 100755 --- a/resources/run.py +++ b/resources/run.py @@ -3,7 +3,8 @@ import logging import IPython -import web3 + +from web3 import Web3 from greed import Project from greed import options @@ -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 = { diff --git a/setup.sh b/setup.sh index fd6f9a5..70be98c 100755 --- a/setup.sh +++ b/setup.sh @@ -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 @@ -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; }