State cleanup

pull/404/head
Joran Honig 6 years ago
parent 9108f48b88
commit b28130cb8e
  1. 10
      mythril/laser/ethereum/state.py

@ -143,7 +143,7 @@ class GlobalState:
""" """
GlobalState represents the current globalstate GlobalState represents the current globalstate
""" """
def __init__(self, world_state, environment, node, machine_state=None, transaction_stack=None, ret_data=None): def __init__(self, world_state, environment, node, machine_state=None, transaction_stack=None, last_return_data=None):
""" Constructor for GlobalState""" """ Constructor for GlobalState"""
self.node = node self.node = node
self.world_state = world_state self.world_state = world_state
@ -151,20 +151,21 @@ class GlobalState:
self.mstate = machine_state if machine_state else MachineState(gas=10000000) self.mstate = machine_state if machine_state else MachineState(gas=10000000)
self.transaction_stack = transaction_stack if transaction_stack else [] self.transaction_stack = transaction_stack if transaction_stack else []
self.op_code = "" self.op_code = ""
self.last_return_data = ret_data self.last_return_data = last_return_data
def __copy__(self): def __copy__(self):
world_state = copy(self.world_state) world_state = copy(self.world_state)
environment = copy(self.environment) environment = copy(self.environment)
mstate = deepcopy(self.mstate) mstate = deepcopy(self.mstate)
transaction_stack = copy(self.transaction_stack) transaction_stack = copy(self.transaction_stack)
return GlobalState(world_state, environment, self.node, mstate, transaction_stack=transaction_stack, ret_data=self.last_return_data) return GlobalState(world_state, environment, self.node, mstate, transaction_stack=transaction_stack,
last_return_data=self.last_return_data)
@property @property
def accounts(self): def accounts(self):
return self.world_state.accounts return self.world_state.accounts
#TODO: remove this, as two instructions are confusing # TODO: remove this, as two instructions are confusing
def get_current_instruction(self): def get_current_instruction(self):
""" Gets the current instruction for this GlobalState""" """ Gets the current instruction for this GlobalState"""
instructions = self.environment.code.instruction_list instructions = self.environment.code.instruction_list
@ -177,6 +178,7 @@ class GlobalState:
except IndexError: except IndexError:
return None return None
class WorldState: class WorldState:
""" """
The WorldState class represents the world state as described in the yellow paper The WorldState class represents the world state as described in the yellow paper

Loading…
Cancel
Save