Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit f713daa

Browse files
committed
Make post_*_fork a property #415
1 parent ca7e22a commit f713daa

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

ethereum/processblock.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ def __init__(self, block, tx):
248248
self.create = lambda msg: create_contract(self, msg)
249249
self.msg = lambda msg: _apply_msg(self, msg, self.get_code(msg.code_address))
250250
self.account_exists = block.account_exists
251-
self.post_homestead_hardfork = lambda: block.number >= block.config['HOMESTEAD_FORK_BLKNUM']
252-
self.post_anti_dos_hardfork = lambda: block.number >= block.config['ANTI_DOS_FORK_BLKNUM']
251+
self.post_homestead_hardfork = block.number >= block.config['HOMESTEAD_FORK_BLKNUM']
252+
self.post_anti_dos_hardfork = block.number >= block.config['ANTI_DOS_FORK_BLKNUM']
253253

254254

255255
def apply_msg(ext, msg):

ethereum/vm.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def vm_execute(ext, msg, code):
344344
stk.append(utils.coerce_to_int(msg.to))
345345
elif op == 'BALANCE':
346346
# EIP150: Increase the gas cost of BALANCE to 400
347-
if ext.post_anti_dos_hardfork():
347+
if ext.post_anti_dos_hardfork:
348348
if not eat_gas(compustate, opcodes.BALANCE_SUPPLEMENTAL_GAS):
349349
return vm_exception("OUT OF GAS")
350350
addr = utils.coerce_addr_to_hex(stk.pop() % 2 ** 160)
@@ -383,14 +383,14 @@ def vm_execute(ext, msg, code):
383383
stk.append(ext.tx_gasprice)
384384
elif op == 'EXTCODESIZE':
385385
# EIP150: Increase the gas cost of EXTCODESIZE to 700
386-
if ext.post_anti_dos_hardfork():
386+
if ext.post_anti_dos_hardfork:
387387
if not eat_gas(compustate, opcodes.EXTCODELOAD_SUPPLEMENTAL_GAS):
388388
return vm_exception("OUT OF GAS")
389389
addr = utils.coerce_addr_to_hex(stk.pop() % 2 ** 160)
390390
stk.append(len(ext.get_code(addr) or b''))
391391
elif op == 'EXTCODECOPY':
392392
# EIP150: Increase the base gas cost of EXTCODECOPY to 700
393-
if ext.post_anti_dos_hardfork():
393+
if ext.post_anti_dos_hardfork:
394394
if not eat_gas(compustate, opcodes.EXTCODELOAD_SUPPLEMENTAL_GAS):
395395
return vm_exception("OUT OF GAS")
396396
addr = utils.coerce_addr_to_hex(stk.pop() % 2 ** 160)
@@ -443,7 +443,7 @@ def vm_execute(ext, msg, code):
443443
mem[s0] = s1 % 256
444444
elif op == 'SLOAD':
445445
# EIP150: Increase the gas cost of SLOAD to 200
446-
if ext.post_anti_dos_hardfork():
446+
if ext.post_anti_dos_hardfork:
447447
if not eat_gas(compustate, opcodes.SLOAD_SUPPLEMENTAL_GAS):
448448
return vm_exception("OUT OF GAS")
449449
stk.append(ext.get_storage_data(msg.to, stk.pop()))
@@ -526,7 +526,7 @@ def vm_execute(ext, msg, code):
526526
ingas = compustate.gas
527527
# EIP150(1b) CREATE only provides all but one 64th of the
528528
# parent gas to the child call
529-
if ext.post_anti_dos_hardfork():
529+
if ext.post_anti_dos_hardfork:
530530
ingas = max_call_gas(ingas)
531531

532532
create_msg = Message(msg.to, b'', value, ingas, cd, msg.depth + 1)
@@ -549,10 +549,10 @@ def vm_execute(ext, msg, code):
549549
to = ((b'\x00' * (32 - len(to))) + to)[12:]
550550
extra_gas = (not ext.account_exists(to)) * opcodes.GCALLNEWACCOUNT + \
551551
(value > 0) * opcodes.GCALLVALUETRANSFER + \
552-
ext.post_anti_dos_hardfork() * opcodes.CALL_SUPPLEMENTAL_GAS
552+
ext.post_anti_dos_hardfork * opcodes.CALL_SUPPLEMENTAL_GAS
553553
# ^ EIP150 Increase the gas cost of CALL to 700
554554

555-
if ext.post_anti_dos_hardfork():
555+
if ext.post_anti_dos_hardfork:
556556
# EIP150(1b) if a call asks for more gas than all but one 64th of
557557
# the maximum allowed amount, call with all but one 64th of the
558558
# maximum allowed amount of gas
@@ -592,10 +592,10 @@ def vm_execute(ext, msg, code):
592592
not mem_extend(mem, compustate, op, memoutstart, memoutsz):
593593
return vm_exception('OOG EXTENDING MEMORY')
594594
extra_gas = (value > 0) * opcodes.GCALLVALUETRANSFER + \
595-
ext.post_anti_dos_hardfork() * opcodes.CALL_SUPPLEMENTAL_GAS
595+
ext.post_anti_dos_hardfork * opcodes.CALL_SUPPLEMENTAL_GAS
596596
# ^ EIP150 Increase the gas cost of CALLCODE, DELEGATECALL to 700
597597

598-
if ext.post_anti_dos_hardfork():
598+
if ext.post_anti_dos_hardfork:
599599
# EIP150(1b) if a call asks for more gas than all but one 64th of
600600
# the maximum allowed amount, call with all but one 64th of the
601601
# maximum allowed amount of gas
@@ -612,7 +612,7 @@ def vm_execute(ext, msg, code):
612612
to = utils.encode_int(to)
613613
to = ((b'\x00' * (32 - len(to))) + to)[12:]
614614
cd = CallData(mem, meminstart, meminsz)
615-
if ext.post_homestead_hardfork() and op == 'DELEGATECALL':
615+
if ext.post_homestead_hardfork and op == 'DELEGATECALL':
616616
call_msg = Message(msg.sender, msg.to, msg.value, submsg_gas, cd,
617617
msg.depth + 1, code_address=to, transfers_value=False)
618618
elif op == 'DELEGATECALL':
@@ -640,7 +640,7 @@ def vm_execute(ext, msg, code):
640640
to = utils.encode_int(stk.pop())
641641
to = ((b'\x00' * (32 - len(to))) + to)[12:]
642642

643-
if ext.post_anti_dos_hardfork():
643+
if ext.post_anti_dos_hardfork:
644644
# EIP150 Increase the gas cost of SUICIDE to 5000
645645
extra_gas = opcodes.SUICIDE_SUPPLEMENTAL_GAS + \
646646
(not ext.account_exists(to)) * opcodes.GCALLNEWACCOUNT

0 commit comments

Comments
 (0)