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

Commit 6d1258f

Browse files
authored
Merge pull request #154 from luongnt95/update
Update
2 parents 52bf194 + 5b7aa94 commit 6d1258f

File tree

8 files changed

+41
-34
lines changed

8 files changed

+41
-34
lines changed

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,25 @@ and you are done!
2020

2121
Note - If need the [version of Oyente](https://github.com/melonproject/oyente/tree/290f1ae1bbb295b8e61cbf0eed93dbde6f287e69) referred to in the paper, run the container from [here](https://hub.docker.com/r/hrishioa/oyente/)
2222

23+
## Installation
24+
25+
To install Oyente, simply:
26+
27+
```
28+
$ pip install oyente
29+
```
30+
2331
## Full install
2432

2533
### Install the following dependencies
26-
#### solc v0.4.13
34+
#### solc version 0.4.13
2735
```
2836
$ sudo add-apt-repository ppa:ethereum/ethereum
2937
$ sudo apt-get update
3038
$ sudo apt-get install solc
3139
```
3240

33-
#### evm from [go-ethereum](https://github.com/ethereum/go-ethereum) version 1.6.1.
41+
#### evm from [go-ethereum](https://github.com/ethereum/go-ethereum) version 1.6.1.
3442

3543
1. https://geth.ethereum.org/downloads/ or
3644
2. By from PPA if your using Ubuntu
@@ -72,6 +80,9 @@ pip install web3
7280
#evaluate a local solidity contract
7381
python oyente.py -s <contract filename>
7482
83+
#evaluate a local solidity with option -a to verify assertions in the contract
84+
pyhon oyente.py -a -s <contract filename>
85+
7586
#evaluate a local evm contract
7687
python oyente.py -s <contract filename> -b
7788
@@ -107,4 +118,4 @@ Some analytics regarding the number of contracts tested, number of contracts ana
107118

108119
## Contributing
109120

110-
Checkout out our [contribution guide](https://github.com/melonproject/oyente/blob/master/CONTRIBUTING.md) and the code structure [here](https://github.com/melonproject/oyente/blob/master/code.md).
121+
Checkout out our [contribution guide](https://github.com/melonproject/oyente/blob/master/CONTRIBUTING.md) and the code structure [here](https://github.com/melonproject/oyente/blob/master/code.md).

oyente/assertion.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,11 @@ def __str__(self):
8080
def display(self):
8181
print self.__str__()
8282

83+
def display_on_web(self):
84+
s = "================\n"
85+
s += "Assertion failure from function: "
86+
if self.function == None:
87+
s += "?\n"
88+
else:
89+
s += self.function + "\n"
90+
return s

oyente/global_params.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
CHECK_CONCURRENCY_FP = 0
1818

1919
# Timeout for z3 in ms
20-
TIMEOUT = 1000
20+
TIMEOUT = 100
2121

2222
# Set this flag to 1 if we want to do unit test from file unit_test.json
2323
# Set this flag to 2 if we want to do evm real value unit test
@@ -40,11 +40,11 @@
4040
STORE_RESULT = 0
4141

4242
# depth limit for DFS
43-
DEPTH_LIMIT = 1000
43+
DEPTH_LIMIT = 50
4444

4545
GAS_LIMIT = 4000000
4646

47-
LOOP_LIMIT = 100
47+
LOOP_LIMIT = 10
4848

4949
# Use a public blockchain to speed up the symbolic execution
5050
USE_GLOBAL_BLOCKCHAIN = 0

oyente/oyente.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def analyze(processed_evm_file, disasm_file):
8787

8888
# Run symExec
8989
symExec.main(disasm_file, args.source)
90-
90+
9191
def main():
9292
# TODO: Implement -o switch.
9393

@@ -100,6 +100,7 @@ def main():
100100
group.add_argument("-ru", "--remoteURL", type=str,
101101
help="Get contract from remote URL. Solidity by default. Use -b to process evm instead.", dest="remote_URL")
102102

103+
parser.add_argument("--version", action="version", version="oyente one-north 0.2.0")
103104
parser.add_argument(
104105
"-b", "--bytecode", help="read bytecode in source instead of solidity file.", action="store_true")
105106

oyente/run_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def status(exit_code):
2727

2828
def main():
2929
test_dir = 'test_evm/test_data'
30-
files = glob.glob(test_dir + '/vmArithmeticTest.json')
30+
files = glob.glob(test_dir + '/*.json')
3131
test_cases = {}
3232

3333
num_tests = num_passes = num_fails = \

oyente/symExec.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ def compare_stack_unit_test(stack):
127127
log.warning("FAILED UNIT-TEST")
128128
log.warning(e.message)
129129

130-
def compare_storage_and_memory_unit_test(global_state, mem, analysis):
130+
def compare_storage_and_gas_unit_test(global_state, analysis):
131131
unit_test = pickle.load(open(PICKLE_PATH, 'rb'))
132-
test_status = unit_test.compare_with_symExec_result(global_state, mem, analysis)
132+
test_status = unit_test.compare_with_symExec_result(global_state, analysis)
133133
exit(test_status)
134134

135135
def handler(signum, frame):
@@ -166,8 +166,9 @@ def detect_bugs():
166166
results['assertion_failure'] = is_fail
167167
if not isTesting():
168168
log.info("\t Assertion fails: \t %s", str(is_fail))
169-
for asrt in assertion_fails:
170-
asrt.display()
169+
if not global_params.WEB:
170+
for asrt in assertion_fails:
171+
asrt.display()
171172

172173
def check_assertions():
173174
global assertions
@@ -293,6 +294,9 @@ def results_for_web():
293294
if not results.has_key("assertion_failure"):
294295
results["assertion_failure"] = False
295296
print "Assertion failure:", results['assertion_failure']
297+
assertion_fails = [assertion for assertion in assertions if assertion.is_violated()]
298+
for asrt in assertion_fails:
299+
print asrt.display_on_web()
296300

297301

298302
def closing_message():
@@ -802,7 +806,7 @@ def sym_exec_block(block, pre_block, visited, depth, stack, mem, memory, global_
802806
if global_params.UNIT_TEST == 1:
803807
compare_stack_unit_test(stack)
804808
if global_params.UNIT_TEST == 2 or global_params.UNIT_TEST == 3:
805-
compare_storage_and_memory_unit_test(global_state, mem, analysis)
809+
compare_storage_and_gas_unit_test(global_state, analysis)
806810

807811
elif jump_type[block] == "unconditional": # executing "JUMP"
808812
successor = vertices[block].get_jump_target()

oyente/test_evm/evm_unit_test.py

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,6 @@ def storage(self):
2020
storage = self.data['post'].values()[0]['storage']
2121
return storage if storage != None else {"0": "0"}
2222

23-
def mem(self):
24-
memory = self.data['out']
25-
if memory == "0x":
26-
return memory + "00"
27-
else:
28-
return memory
29-
3023
def gas_info(self):
3124
gas_limit = long(self.data['exec']['gas'], 0)
3225
gas_remaining = long(self.data['gas'], 0)
@@ -47,16 +40,14 @@ def _create_bytecode_file(self, bytecode):
4740
code_file.write('\n')
4841
code_file.close()
4942

50-
def compare_with_symExec_result(self, global_state, mem, analysis):
51-
if UNIT_TEST == 2: return self.compare_real_value(global_state, mem, analysis)
43+
def compare_with_symExec_result(self, global_state, analysis):
44+
if UNIT_TEST == 2: return self.compare_real_value(global_state, analysis)
5245
if UNIT_TEST == 3: return self.compare_symbolic(global_state)
5346

54-
def compare_real_value(self, global_state, mem, analysis):
47+
def compare_real_value(self, global_state, analysis):
5548
storage_status = self._compare_storage_value(global_state)
56-
mem_status = self._compare_memory_value(mem)
5749
gas_status = self._compare_gas_value(analysis)
5850
if storage_status != PASS: return storage_status
59-
if mem_status != PASS: return mem_status
6051
if gas_status != PASS: return gas_status
6152
return PASS
6253

@@ -73,14 +64,6 @@ def _compare_storage_value(self, global_state):
7364
return FAIL
7465
return PASS
7566

76-
def _compare_memory_value(self, mem):
77-
memory = 0 if not mem else mem.values()[0]
78-
memory = to_unsigned(long(memory))
79-
80-
if memory != long(self.mem(), 0):
81-
return FAIL
82-
return PASS
83-
8467
def _compare_gas_value(self, analysis):
8568
gas_used = analysis['gas']
8669
gas_limit, gas_remaining = self.gas_info()

web/app/controllers/home_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def analyze
1111
begin
1212
file.write oyente_params[:source]
1313
file.close
14-
@output += `python #{ENV['OYENTE']}/oyente.py -s #{file.path} -w#{options} `
14+
@output += `python #{ENV['OYENTE']}/oyente.py -s #{file.path} -w#{options} -a`
1515
UserMailer.analyzer_result_notification(oyente_params[:filename], file.path, @output, oyente_params[:email]).deliver_later
1616
rescue
1717
file.close

0 commit comments

Comments
 (0)