Skip to content

Commit

Permalink
Fix some failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pipermerriam authored and veox committed Dec 12, 2018
1 parent 429dc86 commit 14fe819
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion eth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#
# Ensure we can reach 1024 frames of recursion
#
EVM_RECURSION_LIMIT = 1024 * 10
EVM_RECURSION_LIMIT = 1024 * 12
sys.setrecursionlimit(max(EVM_RECURSION_LIMIT, sys.getrecursionlimit()))


Expand Down
33 changes: 26 additions & 7 deletions eth/vm/logic/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@
ceil32,
)
from eth.vm import mnemonics
from eth.vm.computation import (
BaseComputation
)
from eth.vm.opcode import (
Opcode,
)
from eth.vm.computation import BaseComputation
from eth.vm.message import Message
from eth.vm.opcode import Opcode

from .call import max_child_gas_eip150

Expand Down Expand Up @@ -193,13 +190,16 @@ def __call__(self, computation: BaseComputation) -> None:
code=call_data,
create_address=contract_address,
)
self.apply_create_message(computation, child_msg)

def apply_create_message(self, computation: BaseComputation, child_msg: Message) -> None:
child_computation = computation.apply_child_computation(child_msg)

if child_computation.is_error:
computation.stack_push(0)
else:
computation.stack_push(contract_address)
computation.stack_push(child_msg.storage_address)

computation.return_gas(child_computation.get_gas_remaining())


Expand Down Expand Up @@ -240,3 +240,22 @@ def generate_contract_address(self,
stack_data.salt,
call_data
)

def apply_create_message(self, computation: BaseComputation, child_msg: Message) -> None:
# We need to ensure that creation operates on empty storage **and**
# that if the initialization code fails that we revert the account back
# to its original state root.
snapshot = computation.state.snapshot()

computation.state.account_db.delete_storage(child_msg.storage_address)

child_computation = computation.apply_child_computation(child_msg)

if child_computation.is_error:
computation.state.revert(snapshot)
computation.stack_push(0)
else:
computation.state.commit(snapshot)
computation.stack_push(child_msg.storage_address)

computation.return_gas(child_computation.get_gas_remaining())

0 comments on commit 14fe819

Please sign in to comment.