Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Commit

Permalink
Move Eth2 plugins out of base plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
cburgdorf committed Jun 13, 2019
1 parent fece800 commit 00acc52
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
14 changes: 3 additions & 11 deletions trinity/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import (
Any,
Dict,
Iterable,
Tuple,
Type,
)
Expand Down Expand Up @@ -40,17 +39,14 @@
TrinityEventBusEndpoint,
)
from trinity.extensibility import (
BasePlugin,
PluginManager,
SharedProcessScope,
)
from trinity.initialization import (
ensure_eth1_dirs,
)
from trinity.plugins.registry import (
BASE_PLUGINS,
discover_plugins,
ETH1_NODE_PLUGINS,
get_plugins_for_eth1_client,
)
from trinity._utils.ipc import (
wait_for_ipc,
Expand All @@ -73,12 +69,8 @@
)


def get_all_plugins() -> Iterable[Type[BasePlugin]]:
return BASE_PLUGINS + ETH1_NODE_PLUGINS + discover_plugins()


def main() -> None:
main_entry(trinity_boot, APP_IDENTIFIER_ETH1, get_all_plugins(), (Eth1AppConfig,))
main_entry(trinity_boot, APP_IDENTIFIER_ETH1, get_plugins_for_eth1_client(), (Eth1AppConfig,))


def trinity_boot(args: Namespace,
Expand Down Expand Up @@ -161,7 +153,7 @@ async def launch_node_coro(args: Namespace, trinity_config: TrinityConfig) -> No
await endpoint.announce_endpoint()

# This is a second PluginManager instance governing plugins in a shared process.
plugin_manager = PluginManager(SharedProcessScope(endpoint), get_all_plugins())
plugin_manager = PluginManager(SharedProcessScope(endpoint), get_plugins_for_eth1_client())
plugin_manager.prepare(args, trinity_config)

asyncio.ensure_future(handle_networking_exit(node, plugin_manager, endpoint))
Expand Down
9 changes: 7 additions & 2 deletions trinity/main_beacon.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
ensure_beacon_dirs,
)
from trinity.plugins.registry import (
BASE_PLUGINS,
get_plugins_for_beacon_client,
)
from trinity._utils.ipc import (
wait_for_ipc,
Expand All @@ -62,7 +62,12 @@


def main_beacon() -> None:
main_entry(trinity_boot, APP_IDENTIFIER_BEACON, BASE_PLUGINS, (BeaconAppConfig,))
main_entry(
trinity_boot,
APP_IDENTIFIER_BEACON,
get_plugins_for_beacon_client(),
(BeaconAppConfig,)
)


def trinity_boot(args: Namespace,
Expand Down
19 changes: 17 additions & 2 deletions trinity/plugins/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,19 @@

BASE_PLUGINS: Tuple[Type[BasePlugin], ...] = (
AttachPlugin,
NetworkGeneratorPlugin,
FixUncleanShutdownPlugin,
JsonRpcServerPlugin,
NetworkDBPlugin,
PeerDiscoveryPlugin,
RequestServerPlugin,
BeaconNodePlugin,
UpnpPlugin,
)

BEACON_NODE_PLUGINS: Tuple[Type[BasePlugin], ...] = (
NetworkGeneratorPlugin,
BeaconNodePlugin,
)


ETH1_NODE_PLUGINS: Tuple[Type[BasePlugin], ...] = (
DbShellPlugin,
Expand All @@ -74,3 +77,15 @@ def discover_plugins() -> Tuple[Type[BasePlugin], ...]:
return tuple(
entry_point.load() for entry_point in pkg_resources.iter_entry_points('trinity.plugins')
)


def get_all_plugins(*extra_plugins: Type[BasePlugin]) -> Tuple[Type[BasePlugin], ...]:
return BASE_PLUGINS + extra_plugins + discover_plugins()


def get_plugins_for_eth1_client() -> Tuple[Type[BasePlugin], ...]:
return get_all_plugins(*ETH1_NODE_PLUGINS)


def get_plugins_for_beacon_client() -> Tuple[Type[BasePlugin], ...]:
return get_all_plugins(*BEACON_NODE_PLUGINS)

0 comments on commit 00acc52

Please sign in to comment.