From 2984b5986e78e67dd893c568e7c8b83e78c61a45 Mon Sep 17 00:00:00 2001 From: Konrad Feldmeier Date: Mon, 31 Oct 2016 17:02:25 +0100 Subject: [PATCH] Implement EIP160 #417 --- ethereum/opcodes.py | 2 ++ ethereum/processblock.py | 2 ++ ethereum/vm.py | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ethereum/opcodes.py b/ethereum/opcodes.py index 4377f05be..e1a12276c 100644 --- a/ethereum/opcodes.py +++ b/ethereum/opcodes.py @@ -120,3 +120,5 @@ CALL_CHILD_LIMIT_NUM = 63 CALL_CHILD_LIMIT_DENOM = 64 SUICIDE_SUPPLEMENTAL_GAS = 5000 +# Spurious dragon HF changes +GEXPONENTBYTE_SUPPLEMENTAL_GAS = 40 diff --git a/ethereum/processblock.py b/ethereum/processblock.py index 47ca60338..5ab490e06 100644 --- a/ethereum/processblock.py +++ b/ethereum/processblock.py @@ -250,6 +250,8 @@ def __init__(self, block, tx): self.account_exists = block.account_exists self.post_homestead_hardfork = block.number >= block.config['HOMESTEAD_FORK_BLKNUM'] self.post_anti_dos_hardfork = block.number >= block.config['ANTI_DOS_FORK_BLKNUM'] + self.post_spurious_dragon_hardfork = \ + block.number >= block.config['SPURIOUS_DRAGON_FORK_BLKNUM'] def apply_msg(ext, msg): diff --git a/ethereum/vm.py b/ethereum/vm.py index a1b3edad5..570ae0961 100644 --- a/ethereum/vm.py +++ b/ethereum/vm.py @@ -281,7 +281,10 @@ def vm_execute(ext, msg, code): # fee for exponent is dependent on its bytes # calc n bytes to represent exponent nbytes = len(utils.encode_int(exponent)) - expfee = nbytes * opcodes.GEXPONENTBYTE + expfee = nbytes * (opcodes.GEXPONENTBYTE + + ext.post_spurious_dragon_hardforkf() * opcodes.GEXPONENTBYTE_SUPPLEMENTAL_GAS) + # ^ EIP160: increase the gas cost of EXP from 10 + 10 per + # byte in the exponent to 10 + 50 per byte in the exponent. if compustate.gas < expfee: compustate.gas = 0 return vm_exception('OOG EXPONENT')