Skip to content

Commit 010b840

Browse files
committed
Fix some failing tests
1 parent 04ac2a5 commit 010b840

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

eth/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#
2222
# Ensure we can reach 1024 frames of recursion
2323
#
24-
EVM_RECURSION_LIMIT = 1024 * 10
24+
EVM_RECURSION_LIMIT = 1024 * 12
2525
sys.setrecursionlimit(max(EVM_RECURSION_LIMIT, sys.getrecursionlimit()))
2626

2727

eth/vm/logic/system.py

+26-7
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,9 @@
2020
ceil32,
2121
)
2222
from eth.vm import mnemonics
23-
from eth.vm.computation import (
24-
BaseComputation
25-
)
26-
from eth.vm.opcode import (
27-
Opcode,
28-
)
23+
from eth.vm.computation import BaseComputation
24+
from eth.vm.message import Message
25+
from eth.vm.opcode import Opcode
2926

3027
from .call import max_child_gas_eip150
3128

@@ -193,13 +190,16 @@ def __call__(self, computation: BaseComputation) -> None:
193190
code=call_data,
194191
create_address=contract_address,
195192
)
193+
self.apply_create_message(computation, child_msg)
196194

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

199198
if child_computation.is_error:
200199
computation.stack_push(0)
201200
else:
202-
computation.stack_push(contract_address)
201+
computation.stack_push(child_msg.storage_address)
202+
203203
computation.return_gas(child_computation.get_gas_remaining())
204204

205205

@@ -240,3 +240,22 @@ def generate_contract_address(self,
240240
stack_data.salt,
241241
call_data
242242
)
243+
244+
def apply_create_message(self, computation: BaseComputation, child_msg: Message) -> None:
245+
# We need to ensure that creation operates on empty storage **and**
246+
# that if the initialization code fails that we revert the account back
247+
# to its original state root.
248+
snapshot = computation.state.snapshot()
249+
250+
computation.state.account_db.delete_storage(child_msg.storage_address)
251+
252+
child_computation = computation.apply_child_computation(child_msg)
253+
254+
if child_computation.is_error:
255+
computation.state.revert(snapshot)
256+
computation.stack_push(0)
257+
else:
258+
computation.state.commit(snapshot)
259+
computation.stack_push(child_msg.storage_address)
260+
261+
computation.return_gas(child_computation.get_gas_remaining())

0 commit comments

Comments
 (0)