Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for custom genesis via EIP1085 #1299

Merged
merged 6 commits into from
Nov 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ include requirements.txt

recursive-exclude * __pycache__
recursive-exclude * *.py[co]

include trinity/assets/*
1 change: 0 additions & 1 deletion eth/chains/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from .base import ( # noqa: F401
AsyncChain,
Chain,
)
from .mainnet import ( # noqa: F401
Expand Down
40 changes: 0 additions & 40 deletions eth/chains/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ def __init__(self) -> None:
def get_chaindb_class(cls) -> Type[BaseChainDB]:
raise NotImplementedError("Chain classes must implement this method")

@classmethod
def get_vm_configuration(cls) -> Tuple[Tuple[int, Type['BaseVM']], ...]:
return cls.vm_configuration

#
# Chain API
#
Expand Down Expand Up @@ -918,39 +914,3 @@ def get_vm(self, at_header: BlockHeader=None) -> 'BaseVM':
at_header = self.header

return super().get_vm(at_header)


# This class is a work in progress; its main purpose is to define the API of an asyncio-compatible
# Chain implementation.
class AsyncChain(Chain):
# TODO: this really belongs in the `trinity` module.

async def coro_import_block(self,
block: BlockHeader,
perform_validation: bool=True,
) -> Tuple[BaseBlock, Tuple[BaseBlock, ...], Tuple[BaseBlock, ...]]:
raise NotImplementedError()

async def coro_validate_chain(
self,
parent: BlockHeader,
chain: Tuple[BlockHeader, ...],
seal_check_random_sample_rate: int = 1) -> None:
raise NotImplementedError()

async def coro_validate_receipt(self,
receipt: Receipt,
at_header: BlockHeader) -> None:
raise NotImplementedError()

async def coro_get_block_by_hash(self,
block_hash: Hash32) -> BaseBlock:
raise NotImplementedError()

async def coro_get_block_by_header(self,
header: BlockHeader) -> BaseBlock:
raise NotImplementedError()

async def coro_get_canonical_block_by_number(self,
block_number: BlockNumber) -> BaseBlock:
raise NotImplementedError()
8 changes: 4 additions & 4 deletions eth/chains/mainnet/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# Homestead Block
#
HOMESTEAD_MAINNET_BLOCK = 1150000
HOMESTEAD_MAINNET_BLOCK = BlockNumber(1150000)


#
Expand All @@ -24,16 +24,16 @@
#
# Tangerine Whistle Block
#
TANGERINE_WHISTLE_MAINNET_BLOCK = 2463000
TANGERINE_WHISTLE_MAINNET_BLOCK = BlockNumber(2463000)


#
# Spurious Dragon Block
#
SPURIOUS_DRAGON_MAINNET_BLOCK = 2675000
SPURIOUS_DRAGON_MAINNET_BLOCK = BlockNumber(2675000)


#
# Byzantium Block
#
BYZANTIUM_MAINNET_BLOCK = 4370000
BYZANTIUM_MAINNET_BLOCK = BlockNumber(4370000)
15 changes: 9 additions & 6 deletions eth/chains/ropsten/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from eth_typing import BlockNumber


# https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md
ROPSTEN_CHAIN_ID = 3

Expand All @@ -6,34 +9,34 @@
#
# DAO Block
#
DAO_FORK_ROPSTEN_BLOCK = 0
DAO_FORK_ROPSTEN_BLOCK = BlockNumber(0)


#
# Tangerine Whistle Block
#
TANGERINE_WHISTLE_ROPSTEN_BLOCK = 0
TANGERINE_WHISTLE_ROPSTEN_BLOCK = BlockNumber(0)


#
# Homestead Block
#
HOMESTEAD_ROPSTEN_BLOCK = 0
HOMESTEAD_ROPSTEN_BLOCK = BlockNumber(0)


#
# Spurious Dragon Block
#
SPURIOUS_DRAGON_ROPSTEN_BLOCK = 10
SPURIOUS_DRAGON_ROPSTEN_BLOCK = BlockNumber(10)


#
# Byzantium Block
#
BYZANTIUM_ROPSTEN_BLOCK = 1700000
BYZANTIUM_ROPSTEN_BLOCK = BlockNumber(1700000)


#
# Constantinople
#
CONSTANTINOPLE_ROPSTEN_BLOCK = 4230000
CONSTANTINOPLE_ROPSTEN_BLOCK = BlockNumber(4230000)
13 changes: 6 additions & 7 deletions eth/tools/builder/chain/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
from eth.typing import (
AccountState,
GeneralState,
VMFork,
VMConfiguration,
)
from eth.validation import (
validate_vm_configuration,
Expand All @@ -71,9 +73,6 @@
)


VMConfiguration = Iterable[Tuple[int, Type[BaseVM]]]


def build(obj: Any, *applicators: Callable[..., Any]) -> Any:
"""
Run the provided object through the series of applicator functions.
Expand Down Expand Up @@ -159,7 +158,7 @@ def _is_homestead(vm_class: Type[BaseVM]) -> bool:


@to_tuple
def _set_vm_dao_support_false(vm_configuration: VMConfiguration) -> VMConfiguration:
def _set_vm_dao_support_false(vm_configuration: VMConfiguration) -> Iterable[VMFork]:
for fork_block, vm_class in vm_configuration:
if _is_homestead(vm_class):
yield fork_block, vm_class.configure(support_dao_fork=False)
Expand Down Expand Up @@ -187,7 +186,7 @@ def disable_dao_fork(chain_class: Type[BaseChain]) -> Type[BaseChain]:

@to_tuple
def _set_vm_dao_fork_block_number(dao_fork_block_number: BlockNumber,
vm_configuration: VMConfiguration) -> VMConfiguration:
vm_configuration: VMConfiguration) -> Iterable[VMFork]:
for fork_block, vm_class in vm_configuration:
if _is_homestead(vm_class):
yield fork_block, vm_class.configure(
Expand Down Expand Up @@ -257,7 +256,7 @@ def _get_default_genesis_params(genesis_state: AccountState) -> Iterable[Tuple[s


@to_tuple
def _mix_in_pow_mining(vm_configuration: VMConfiguration) -> VMConfiguration:
def _mix_in_pow_mining(vm_configuration: VMConfiguration) -> Iterable[VMFork]:
for fork_block, vm_class in vm_configuration:
vm_class_with_pow_mining = type(vm_class.__name__, (POWMiningMixin, vm_class), {})
yield fork_block, vm_class_with_pow_mining
Expand Down Expand Up @@ -289,7 +288,7 @@ def validate_seal(cls, header: BlockHeader) -> None:


@to_tuple
def _mix_in_disable_seal_validation(vm_configuration: VMConfiguration) -> VMConfiguration:
def _mix_in_disable_seal_validation(vm_configuration: VMConfiguration) -> Iterable[VMFork]:
for fork_block, vm_class in vm_configuration:
vm_class_without_seal_validation = type(
vm_class.__name__,
Expand Down
26 changes: 23 additions & 3 deletions eth/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@
Iterable,
List,
NewType,
Sequence,
Tuple,
Union,
Type,
TypeVar,
TYPE_CHECKING,
Union,
)

from eth_typing import (
Address,
BlockNumber,
Hash32,
HexStr,
)
from mypy_extensions import (
Expand All @@ -27,6 +31,9 @@
from eth.utils.spoof import ( # noqa: F401
SpoofTransaction
)
from eth.vm.base import ( # noqa: F401
BaseVM
)


# TODO: Move into eth_typing
Expand All @@ -48,6 +55,17 @@
List[Tuple[Address, Dict[str, Union[int, bytes, Dict[int, int]]]]]
]

GenesisDict = Dict[str, Union[int, BlockNumber, bytes, Hash32]]

Normalizer = Callable[[Dict[Any, Any]], Dict[str, Any]]

RawAccountDetails = TypedDict('RawAccountDetails',
{'balance': HexStr,
'nonce': HexStr,
'code': HexStr,
'storage': Dict[HexStr, HexStr]
})

TransactionDict = TypedDict('TransactionDict',
{'nonce': int,
'gasLimit': int,
Expand All @@ -58,10 +76,12 @@
'secretKey': bytes,
})

Normalizer = Callable[[Dict[Any, Any]], Dict[str, Any]]

TransactionNormalizer = Callable[[TransactionDict], TransactionDict]

VMFork = Tuple[BlockNumber, Type['BaseVM']]

VMConfiguration = Sequence[VMFork]

VRS = NewType("VRS", Tuple[int, int, int])

IntConvertible = Union[int, bytes, HexStr, str]
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"termcolor>=1.1.0,<2.0.0",
"uvloop==0.11.2;platform_system=='Linux' or platform_system=='Darwin' or platform_system=='FreeBSD'",
"websockets==5.0.1",
"jsonschema==2.6.0",
],
'test': [
"hypothesis==3.69.5",
Expand Down
11 changes: 0 additions & 11 deletions tests/p2p/test_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@

from cancel_token import CancelToken

from eth.chains.ropsten import ROPSTEN_GENESIS_HEADER

from trinity.protocol.les.proto import LESProtocol, LESProtocolV2

from p2p import discovery
from p2p import kademlia

Expand Down Expand Up @@ -370,13 +366,6 @@ def test_topic_table():
assert node2 not in table.get_nodes(topic)


def test_get_v5_topic():
les_topic = discovery.get_v5_topic(LESProtocol, ROPSTEN_GENESIS_HEADER.hash)
assert les_topic == b'LES@41941023680923e0'
les2_topic = discovery.get_v5_topic(LESProtocolV2, ROPSTEN_GENESIS_HEADER.hash)
assert les2_topic == b'LES2@41941023680923e0'


def remove_whitespace(s):
return re.sub(r"\s+", "", s)

Expand Down
92 changes: 0 additions & 92 deletions tests/trinity/core/config/test_trinity_config_object.py

This file was deleted.

Loading