diff --git a/manticore/platforms/evm.py b/manticore/platforms/evm.py index c188f3776..c833ff1fd 100644 --- a/manticore/platforms/evm.py +++ b/manticore/platforms/evm.py @@ -1954,10 +1954,13 @@ def SSTORE_gas(self, offset, value): self.fail_if(Operators.ULT(self.gas, SSSTORESENTRYGAS)) # Get the storage from the snapshot took before this call + original_value = 0 try: - original_value = self.world._callstack[-1][-2].get(offset, 0) - except AttributeError: - original_value = 0 + storage = self.world._callstack[-1][-2] + if storage is not None: + original_value = storage.get(offset, 0) + except IndexError: + pass current_value = self.world.get_storage_data(storage_address, offset) @@ -2634,7 +2637,7 @@ def _open_transaction(self, sort, address, price, bytecode_or_data, caller, valu vm = self._make_vm_for_tx(tx) self._callstack.append( - (tx, self.logs, self.deleted_accounts, copy.copy(self.get_storage(address)), vm,) + (tx, self.logs, self.deleted_accounts, copy.copy(self.get_storage(address)), vm) ) self.forward_events_from(vm) self._publish("did_open_transaction", tx) diff --git a/manticore/platforms/evm_world_state.py b/manticore/platforms/evm_world_state.py index face8ca12..8d538932b 100644 --- a/manticore/platforms/evm_world_state.py +++ b/manticore/platforms/evm_world_state.py @@ -1,4 +1,5 @@ import logging +import copy from abc import abstractmethod from eth_typing import ChecksumAddress, URI from io import TextIOBase @@ -33,6 +34,11 @@ def __init__(self, constraints: ConstraintSet, address: int): # default=0, ) + def __copy__(self): + other = Storage.__new__(Storage) + other._data = copy.copy(self._data) + return other + def __getitem__(self, offset: Union[int, BitVec]) -> Union[int, BitVec]: return self.get(offset, 0)