Skip to content

Commit

Permalink
Update default vm rules
Browse files Browse the repository at this point in the history
  • Loading branch information
njgheorghita committed Apr 12, 2019
1 parent 5d1ba6d commit bd329d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 51 deletions.
49 changes: 4 additions & 45 deletions eth_tester/backends/pyevm/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,6 @@
GENESIS_INITIAL_ALLOC = {}


SUPPORTED_FORKS = {
FORK_HOMESTEAD,
FORK_DAO,
FORK_SPURIOUS_DRAGON,
FORK_TANGERINE_WHISTLE,
FORK_BYZANTIUM,
}

MINIMUM_GAS_ESTIMATE = 30000
# A buffer of 1.1 would mean allocate 10% more gas than estimated
GAS_ESTIMATE_BUFFER = 1.5
Expand Down Expand Up @@ -160,17 +152,17 @@ def get_default_genesis_params(overrides=None):
def setup_tester_chain(genesis_params=None, genesis_state=None, num_accounts=None):
from eth.chains.base import MiningChain
from eth.db import get_db_backend
from eth.vm.forks.byzantium import ByzantiumVM
from eth.vm.forks.constantinople import ConstantinopleVM

class ByzantiumNoProofVM(ByzantiumVM):
"""Byzantium VM rules, without validating any miner proof of work"""
class ConstantinopleNoProofVM(ConstantinopleVM):
"""Constantinople VM rules, without validating any miner proof of work"""

@classmethod
def validate_seal(self, header):
pass

class MainnetTesterNoProofChain(MiningChain):
vm_configuration = ((0, ByzantiumNoProofVM), )
vm_configuration = ((0, ConstantinopleNoProofVM), )

@classmethod
def validate_seal(cls, block):
Expand Down Expand Up @@ -260,39 +252,6 @@ def _get_vm_for_block_number(chain, block_number):
return vm


FORK_NAME_MAPPING = {
FORK_HOMESTEAD: 'homestead',
FORK_TANGERINE_WHISTLE: 'tangerine-whistle',
FORK_SPURIOUS_DRAGON: 'spurious-dragon',
FORK_BYZANTIUM: 'byzantium',
}


def _mk_fork_configuration_params(fork_config):
all_block_numbers = tuple(fork_config.values())
if len(all_block_numbers) != len(set(all_block_numbers)):
duplicates = tuple(sorted(
blk_num for blk_num, freq
in frequencies(all_block_numbers).items()
if freq > 1
))
raise ValueError("Duplicate block numbers: {0}".format(duplicates))

args = {
(block_number, FORK_NAME_MAPPING[fork_name])
for fork_name, block_number
in fork_config.items()
if (block_number is not None and fork_name != FORK_DAO)
}

if FORK_DAO in fork_config:
kwargs = {'dao_start_block': fork_config[FORK_DAO]}
else:
kwargs = {}

return args, kwargs


class PyEVMBackend(BaseChainBackend):
chain = None
fork_config = None
Expand Down
6 changes: 0 additions & 6 deletions eth_tester/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ def proxy_method(self, *args, **kwargs):
return proxy_method


@to_dict
def get_default_fork_blocks(supported_forks):
for fork_name in supported_forks:
yield (fork_name, None)


def handle_auto_mining(func):
@functools.wraps(func)
def func_wrapper(self, *args, **kwargs):
Expand Down

0 comments on commit bd329d0

Please sign in to comment.