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

New opcodes #410

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

New opcodes #410

wants to merge 8 commits into from

Conversation

Mayur1496
Copy link
Contributor

This pr introduces support for new opcodes :

  • SHR
  • SHL
  • SAR
  • EXTCODEHASH
  • CREATE2

@Mayur1496 Mayur1496 changed the title {WIP] New opcodes [WIP] New opcodes Sep 19, 2020
@Mayur1496 Mayur1496 changed the title [WIP] New opcodes New opcodes Sep 24, 2020
@Mayur1496 Mayur1496 marked this pull request as ready for review September 24, 2020 11:50
Copy link
Contributor

@yxliang01 yxliang01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just small bit and this is ready for merging :)

@@ -1301,6 +1301,42 @@ def sym_exec_ins(params, block, instr, func_call, current_func_name):
stack.insert(0, computed)
else:
raise ValueError('STACK underflow')
elif opcode == "SHL":
if len(stack) > 1:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if len(stack) > 1:
if len(stack) >= 2:

For readability

else:
raise ValueError('STACK underflow')
elif opcode == "SHR":
if len(stack) > 1:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if len(stack) > 1:
if len(stack) >= 2:

@@ -1549,6 +1585,19 @@ def sym_exec_ins(params, block, instr, func_call, current_func_name):
global_state["miu_i"] = current_miu_i
else:
raise ValueError('STACK underflow')
elif opcode == "EXTCODEHASH":
if len(stack) > 0:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if len(stack) > 0:
if len(stack) >= 1:

if len(stack) > 0:
global_state["pc"] = global_state["pc"] + 1
stack.pop(0)
new_var_name = "IH_codehash"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For better modelling, can you create a variable for each requested address?

@@ -1992,6 +2041,18 @@ def sym_exec_ins(params, block, instr, func_call, current_func_name):
analysis["time_dependency_bug"][last_idx] = global_state["pc"] - 1
else:
raise ValueError('STACK underflow')
elif opcode == "CREATE2":
if len(stack) > 3:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if len(stack) > 3:
if len(stack) >= 4:

@@ -1301,6 +1301,42 @@ def sym_exec_ins(params, block, instr, func_call, current_func_name):
stack.insert(0, computed)
else:
raise ValueError('STACK underflow')
elif opcode == "SHL":
if len(stack) > 1:
global_state["pc"] = global_state["pc"] + 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use += 1 for all such occurrences

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

2 participants