Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

fix: set default crytic-compile version #431

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ bytecode.1

!oyente/tests/contracts/*/*
web/vendor/
/build
.idea
8 changes: 4 additions & 4 deletions oyente/batch_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

cjson = {}

print "Loading contracts..."
print ("Loading contracts...")

for cfile in tqdm(cfiles):
cjson.update(json.loads(open(cfile).read()))

results = {}
missed = []

print "Running analysis..."
print ("Running analysis...")

contracts = cjson.keys()

Expand All @@ -35,7 +35,7 @@
cores = int(sys.argv[1])
job = int(sys.argv[2])
contracts = contracts[(len(contracts)/cores)*job:(len(contracts)/cores)*(job+1)]
print "Job %d: Running on %d contracts..." % (job, len(contracts))
print ("Job %d: Running on %d contracts..." % (job, len(contracts)))

for c in tqdm(contracts):
with open('tmp.evm','w') as of:
Expand All @@ -51,4 +51,4 @@
of.write(json.dumps(missed,indent=1))
# urllib2.urlopen('https://dweet.io/dweet/for/oyente-%d-%d?completed=%d&missed=%d&remaining=%d' % (job,cores,len(results),len(missed),len(contracts)-len(results)-len(missed)))

print "Completed."
print ("Completed.")
14 changes: 8 additions & 6 deletions oyente/input_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from utils import run_command, run_command_with_err
from crytic_compile import CryticCompile, InvalidCompilation


class InputHelper:
BYTECODE = 0
SOLIDITY = 1
Expand Down Expand Up @@ -75,7 +76,8 @@ def get_inputs(self, targetContracts=None):
continue
c_source = re.sub(self.root_path, "", c_source)
if self.input_type == InputHelper.SOLIDITY:
source_map = SourceMap(contract, self.source, 'solidity', self.root_path, self.remap, self.allow_paths)
source_map = SourceMap(contract, self.source, 'solidity', self.root_path, self.remap,
self.allow_paths)
else:
source_map = SourceMap(contract, self.source, 'standard json', self.root_path)
disasm_file = self._get_temporary_files(contract)['disasm']
Expand Down Expand Up @@ -109,21 +111,22 @@ def _get_compiled_contracts(self):
return self.compiled_contracts

def _extract_bin_obj(self, com: CryticCompile):
return [(com.contracts_filenames[name].absolute + ':' + name, com.bytecode_runtime(name)) for name in com.contracts_names if com.bytecode_runtime(name)]
return [(com.contracts_filenames[name].absolute + ':' + name, com.bytecode_runtime(name)) for name in
com.contracts_names if com.bytecode_runtime(name)]

def _compile_solidity(self):
try:
options = []
if self.allow_paths:
options.append(F"--allow-paths {self.allow_paths}")

com = CryticCompile(self.source, solc_remaps=self.remap, solc_args=' '.join(options))
contracts = self._extract_bin_obj(com)

libs = com.contracts_names.difference(com.contracts_names_without_libraries)
if libs:
return self._link_libraries(self.source, libs)

return contracts
except InvalidCompilation as err:
if not self.compilation_err:
Expand All @@ -138,7 +141,6 @@ def _compile_solidity(self):
six.print_({"error": err})
exit(1)


def _compile_standard_json(self):
FNULL = open(os.devnull, 'w')
cmd = "cat %s" % self.source
Expand Down Expand Up @@ -171,7 +173,7 @@ def _removeSwarmHash(self, evm):
def _link_libraries(self, filename, libs):
options = []
for idx, lib in enumerate(libs):
lib_address = "0x" + hex(idx+1)[2:].zfill(40)
lib_address = "0x" + hex(idx + 1)[2:].zfill(40)
options.append("--libraries %s:%s" % (lib, lib_address))
if self.allow_paths:
options.append(F"--allow-paths {self.allow_paths}")
Expand Down
48 changes: 24 additions & 24 deletions oyente/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ def main():
for f in files:
test_cases.update(json.loads(open(f).read()))

print "*****************************************************"
print " ************* "
print " Start "
print ("*****************************************************")
print (" ************* ")
print (" Start ")
for testname, testdata in list(test_cases.items()):
print
print
print "===============Loading: %s====================" % testname
print()
print()
print ("===============Loading: %s====================" % testname)

current_test = EvmUnitTest(testname, testdata)

Expand All @@ -69,9 +69,9 @@ def main():
exit_code = PASS

if exit_code:
print "===============%s!====================" % status(exit_code).upper()
print ("===============%s!====================" % status(exit_code).upper())
else:
print "no exit code returned"
print ("no exit code returned")

testname = testname.encode('utf8')
num_tests += 1
Expand All @@ -97,22 +97,22 @@ def main():
num_incorrect_gas += 1
remove_temporary_files()

print "Done!"
print "Total: ", num_tests
print
print "Pass: ", num_passes
print
print "Fail: ", num_fails, fails
print
print "Time out: ", num_time_outs, time_outs
print
print "Unkown instruction: ", num_unkown_instrs, unkown_instrs
print
print "Exception: ", num_exceptions, exceptions
print
print "Empty result: ", num_empty_res, empty_res
print
print "Incorrect gas tracked", num_incorrect_gas, incorrect_gas
print ("Done!")
print ("Total: ", num_tests)
print()
print ("Pass: ", num_passes)
print()
print ("Fail: ", num_fails, fails)
print()
print ("Time out: ", num_time_outs, time_outs)
print()
print ("Unkown instruction: ", num_unkown_instrs, unkown_instrs)
print()
print ("Exception: ", num_exceptions, exceptions)
print()
print ("Empty result: ", num_empty_res, empty_res)
print()
print ("Incorrect gas tracked", num_incorrect_gas, incorrect_gas)


if __name__ == '__main__':
Expand Down
Loading