Handle new black format

pull/1261/head
Nikhil Parasaram 5 years ago
parent bb31cd2aca
commit d20e601a6b
  1. 2
      mythril/analysis/modules/integer.py
  2. 4
      mythril/ethereum/interface/leveldb/client.py
  3. 9
      mythril/laser/ethereum/call.py
  4. 84
      mythril/laser/ethereum/instructions.py
  5. 2
      mythril/laser/ethereum/state/global_state.py
  6. 7
      mythril/laser/ethereum/svm.py

@ -343,7 +343,7 @@ def _get_address_from_state(state):
def _get_overflowunderflow_state_annotation( def _get_overflowunderflow_state_annotation(
state: GlobalState state: GlobalState,
) -> OverUnderflowStateAnnotation: ) -> OverUnderflowStateAnnotation:
state_annotations = cast( state_annotations = cast(
List[OverUnderflowStateAnnotation], List[OverUnderflowStateAnnotation],

@ -23,8 +23,8 @@ body_prefix = b"b" # body_prefix + num (uint64 big endian) + hash -> block body
num_suffix = b"n" # header_prefix + num (uint64 big endian) + num_suffix -> hash num_suffix = b"n" # header_prefix + num (uint64 big endian) + num_suffix -> hash
block_hash_prefix = b"H" # block_hash_prefix + hash -> num (uint64 big endian) block_hash_prefix = b"H" # block_hash_prefix + hash -> num (uint64 big endian)
block_receipts_prefix = ( block_receipts_prefix = (
b"r" b"r" # block_receipts_prefix + num (uint64 big endian) + hash -> block receipts
) # block_receipts_prefix + num (uint64 big endian) + hash -> block receipts )
# known geth keys # known geth keys
head_header_key = b"LastBlock" # head (latest) header hash head_header_key = b"LastBlock" # head (latest) header hash
# custom prefixes # custom prefixes

@ -42,9 +42,12 @@ def get_call_parameters(
""" """
gas, to = global_state.mstate.pop(2) gas, to = global_state.mstate.pop(2)
value = global_state.mstate.pop() if with_value else 0 value = global_state.mstate.pop() if with_value else 0
memory_input_offset, memory_input_size, memory_out_offset, memory_out_size = global_state.mstate.pop( (
4 memory_input_offset,
) memory_input_size,
memory_out_offset,
memory_out_size,
) = global_state.mstate.pop(4)
callee_address = get_callee_address(global_state, dynamic_loader, to) callee_address = get_callee_address(global_state, dynamic_loader, to)

@ -1858,9 +1858,15 @@ class Instruction:
environment = global_state.environment environment = global_state.environment
try: try:
callee_address, callee_account, call_data, value, gas, memory_out_offset, memory_out_size = get_call_parameters( (
global_state, self.dynamic_loader, True callee_address,
) callee_account,
call_data,
value,
gas,
memory_out_offset,
memory_out_size,
) = get_call_parameters(global_state, self.dynamic_loader, True)
if callee_account is not None and callee_account.code.bytecode == "": if callee_account is not None and callee_account.code.bytecode == "":
log.debug("The call is related to ether transfer between accounts") log.debug("The call is related to ether transfer between accounts")
@ -1939,9 +1945,15 @@ class Instruction:
environment = global_state.environment environment = global_state.environment
try: try:
callee_address, callee_account, call_data, value, gas, _, _ = get_call_parameters( (
global_state, self.dynamic_loader, True callee_address,
) callee_account,
call_data,
value,
gas,
_,
_,
) = get_call_parameters(global_state, self.dynamic_loader, True)
if callee_account is not None and callee_account.code.bytecode == "": if callee_account is not None and callee_account.code.bytecode == "":
log.debug("The call is related to ether transfer between accounts") log.debug("The call is related to ether transfer between accounts")
sender = global_state.environment.active_account.address sender = global_state.environment.active_account.address
@ -1988,9 +2000,15 @@ class Instruction:
instr = global_state.get_current_instruction() instr = global_state.get_current_instruction()
try: try:
callee_address, _, _, value, _, memory_out_offset, memory_out_size = get_call_parameters( (
global_state, self.dynamic_loader, True callee_address,
) _,
_,
value,
_,
memory_out_offset,
memory_out_size,
) = get_call_parameters(global_state, self.dynamic_loader, True)
except ValueError as e: except ValueError as e:
log.debug( log.debug(
"Could not determine required parameters for call, putting fresh symbol on the stack. \n{}".format( "Could not determine required parameters for call, putting fresh symbol on the stack. \n{}".format(
@ -2054,9 +2072,15 @@ class Instruction:
environment = global_state.environment environment = global_state.environment
try: try:
callee_address, callee_account, call_data, value, gas, _, _ = get_call_parameters( (
global_state, self.dynamic_loader callee_address,
) callee_account,
call_data,
value,
gas,
_,
_,
) = get_call_parameters(global_state, self.dynamic_loader)
if callee_account is not None and callee_account.code.bytecode == "": if callee_account is not None and callee_account.code.bytecode == "":
log.debug("The call is related to ether transfer between accounts") log.debug("The call is related to ether transfer between accounts")
@ -2104,9 +2128,15 @@ class Instruction:
instr = global_state.get_current_instruction() instr = global_state.get_current_instruction()
try: try:
callee_address, _, _, value, _, memory_out_offset, memory_out_size = get_call_parameters( (
global_state, self.dynamic_loader callee_address,
) _,
_,
value,
_,
memory_out_offset,
memory_out_size,
) = get_call_parameters(global_state, self.dynamic_loader)
except ValueError as e: except ValueError as e:
log.debug( log.debug(
"Could not determine required parameters for call, putting fresh symbol on the stack. \n{}".format( "Could not determine required parameters for call, putting fresh symbol on the stack. \n{}".format(
@ -2169,9 +2199,15 @@ class Instruction:
instr = global_state.get_current_instruction() instr = global_state.get_current_instruction()
environment = global_state.environment environment = global_state.environment
try: try:
callee_address, callee_account, call_data, value, gas, memory_out_offset, memory_out_size = get_call_parameters( (
global_state, self.dynamic_loader callee_address,
) callee_account,
call_data,
value,
gas,
memory_out_offset,
memory_out_size,
) = get_call_parameters(global_state, self.dynamic_loader)
if callee_account is not None and callee_account.code.bytecode == "": if callee_account is not None and callee_account.code.bytecode == "":
log.debug("The call is related to ether transfer between accounts") log.debug("The call is related to ether transfer between accounts")
@ -2225,9 +2261,15 @@ class Instruction:
try: try:
with_value = function_name is not "staticcall" with_value = function_name is not "staticcall"
callee_address, callee_account, call_data, value, gas, memory_out_offset, memory_out_size = get_call_parameters( (
global_state, self.dynamic_loader, with_value callee_address,
) callee_account,
call_data,
value,
gas,
memory_out_offset,
memory_out_size,
) = get_call_parameters(global_state, self.dynamic_loader, with_value)
except ValueError as e: except ValueError as e:
log.debug( log.debug(
"Could not determine required parameters for {}, putting fresh symbol on the stack. \n{}".format( "Could not determine required parameters for {}, putting fresh symbol on the stack. \n{}".format(

@ -102,7 +102,7 @@ class GlobalState:
@property @property
def current_transaction( def current_transaction(
self self,
) -> Union["MessageCallTransaction", "ContractCreationTransaction", None]: ) -> Union["MessageCallTransaction", "ContractCreationTransaction", None]:
""" """

@ -354,9 +354,10 @@ class LaserEVM:
return [new_global_state], op_code return [new_global_state], op_code
except TransactionEndSignal as end_signal: except TransactionEndSignal as end_signal:
transaction, return_global_state = end_signal.global_state.transaction_stack[ (
-1 transaction,
] return_global_state,
) = end_signal.global_state.transaction_stack[-1]
log.debug("Ending transaction %s.", transaction) log.debug("Ending transaction %s.", transaction)
if return_global_state is None: if return_global_state is None:

Loading…
Cancel
Save