Skip to content

Commit

Permalink
dirty
Browse files Browse the repository at this point in the history
  • Loading branch information
pipermerriam committed Oct 2, 2017
1 parent fc0427d commit e222a3f
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 13 deletions.
4 changes: 3 additions & 1 deletion evm/chains/mainnet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
EIP150VM,
FrontierVM,
HomesteadVM,
SpuriousDragonVM,
)


Expand All @@ -13,6 +14,7 @@
vm_configuration=(
(0, FrontierVM),
(constants.HOMESTEAD_MAINNET_BLOCK, HomesteadVM),
(constants.EIP150_MAINNET_BLOCK, EIP150VM)
(constants.EIP150_MAINNET_BLOCK, EIP150VM),
(constants.SPURIOUS_DRAGON_MAINNET_BLOCK, SpuriousDragonVM),
)
)
6 changes: 6 additions & 0 deletions evm/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,9 @@
# EIP150
#
EIP150_MAINNET_BLOCK = 2463000


#
# Spurious Dragon
#
SPURIOUS_DRAGON_MAINNET_BLOCK = 2675000
3 changes: 3 additions & 0 deletions evm/vm/forks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@
from .homestead import ( # noqa: F401
HomesteadVM,
)
from .spurious_dragon import ( # noqa: F401
SpuriousDragonVM,
)
9 changes: 9 additions & 0 deletions evm/vm/forks/spurious_dragon/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from ..homestead import HomesteadVM

from .blocks import SpuriousDragonBlock


SpuriousDragonVM = HomesteadVM.configure(
name='SpuriousDragonVM',
_block_class=SpuriousDragonBlock,
)
21 changes: 21 additions & 0 deletions evm/vm/forks/spurious_dragon/blocks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from rlp.sedes import (
CountableList,
)
from evm.rlp.headers import (
BlockHeader,
)
from evm.vm.forks.homestead.blocks import (
HomesteadBlock,
)
from .transactions import (
SpuriousDragonTransaction,
)


class SpuriousDragonBlock(HomesteadBlock):
transaction_class = SpuriousDragonTransaction
fields = [
('header', BlockHeader),
('transactions', CountableList(SpuriousDragonTransaction)),
('uncles', CountableList(BlockHeader))
]
31 changes: 19 additions & 12 deletions evm/vm/forks/spurious_dragon/transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from evm.utils.transactions import (
create_transaction_signature,
create_eip155_transaction_signature,
is_eip_155_signed_transaction,
validate_eip155_transaction_signature,
validate_transaction_signature,
Expand All @@ -22,6 +23,12 @@ def as_unsigned_transaction(self):
data=self.data,
)

def check_signature_validity(self):
if is_eip_155_signed_transaction(self):
validate_eip155_transaction_signature(self)
else:
validate_transaction_signature(self)

@classmethod
def create_unsigned_transaction(cls, nonce, gas_price, gas, to, value, data):
return HomesteadUnsignedTransaction(nonce, gas_price, gas, to, value, data)
Expand All @@ -31,16 +38,16 @@ class SpuriousDragonUnsignedTransaction(HomesteadUnsignedTransaction):
def as_signed_transaction(self, private_key, chain_id=None):
if chain_id is None:
v, r, s = create_transaction_signature(self, private_key)
return SpuriousDragonTransaction(
nonce=self.nonce,
gas_price=self.gas_price,
gas=self.gas,
to=self.to,
value=self.value,
data=self.data,
v=v,
r=r,
s=s,
)
else:
raise NotImplementedError("Have not implemented EIP155 signing")
v, r, s = create_eip155_transaction_signature(self, private_key)
return SpuriousDragonTransaction(
nonce=self.nonce,
gas_price=self.gas_price,
gas=self.gas,
to=self.to,
value=self.value,
data=self.data,
v=v,
r=r,
s=s,
)
1 change: 1 addition & 0 deletions tests/json-fixtures/test_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
EIP150VM,
FrontierVM,
HomesteadVM,
SpuriousDragonVM,
)
from evm.rlp.headers import (
BlockHeader,
Expand Down
6 changes: 6 additions & 0 deletions tests/json-fixtures/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
EIP150VM,
FrontierVM,
HomesteadVM,
SpuriousDragonVM,
)
from evm.rlp.headers import (
BlockHeader,
Expand Down Expand Up @@ -134,6 +135,10 @@ def get_block_hash_for_testing(self, block_number):
name='EIP150VMForTesting',
get_ancestor_hash=get_block_hash_for_testing,
)
SpuriousDragonVMForTesting = SpuriousDragonVM.configure(
name='SpuriousDragonVMForTesting',
get_ancestor_hash=get_block_hash_for_testing,
)


ChainForTesting = Chain.configure(
Expand All @@ -142,6 +147,7 @@ def get_block_hash_for_testing(self, block_number):
(constants.GENESIS_BLOCK_NUMBER, FrontierVMForTesting),
(constants.HOMESTEAD_MAINNET_BLOCK, HomesteadVMForTesting),
(constants.EIP150_MAINNET_BLOCK, EIP150VMForTesting),
(constants.SPURIOUS_DRAGON_MAINNET_BLOCK, SpuriousDragonVMForTesting),
),
)

Expand Down

0 comments on commit e222a3f

Please sign in to comment.