Beispiel #1
0
    def start(self) -> None:
        self.logger.info('JSON-RPC Server started')
        self.context.event_bus.connect()

        db_manager = create_db_manager(
            self.context.chain_config.database_ipc_path)
        db_manager.connect()

        chain_class = self.context.chain_config.node_class.chain_class

        if self.context.chain_config.sync_mode == SYNC_LIGHT:
            header_db = db_manager.get_headerdb()  # type: ignore
            event_bus_light_peer_chain = EventBusLightPeerChain(
                self.context.event_bus)
            chain = chain_class(header_db,
                                peer_chain=event_bus_light_peer_chain)
        else:
            db = db_manager.get_db()  # type: ignore
            chain = chain_class(db)

        rpc = RPCServer(chain, self.context.event_bus)
        ipc_server = IPCServer(rpc, self.context.chain_config.jsonrpc_ipc_path)

        loop = asyncio.get_event_loop()
        asyncio.ensure_future(
            exit_on_signal(ipc_server, self.context.event_bus))
        asyncio.ensure_future(ipc_server.run())
        loop.run_forever()
        loop.close()
Beispiel #2
0
    def do_start(self) -> None:
        db_manager = create_db_manager(
            self.context.trinity_config.database_ipc_path)
        db_manager.connect()

        trinity_config = self.context.trinity_config
        eth1_app_config = self.context.trinity_config.get_app_config(
            Eth1AppConfig)
        chain_config = trinity_config.get_chain_config()

        chain: BaseAsyncChain

        if eth1_app_config.is_light_mode:
            header_db = db_manager.get_headerdb()  # type: ignore
            event_bus_light_peer_chain = EventBusLightPeerChain(
                self.context.event_bus)
            chain = chain_config.light_chain_class(
                header_db, peer_chain=event_bus_light_peer_chain)
        elif eth1_app_config.is_full_mode:
            db = db_manager.get_db()  # type: ignore
            chain = chain_config.full_chain_class(db)
        else:
            raise NotImplementedError(
                f"Unsupported mode: {trinity_config.sync_mode}")

        rpc = RPCServer(chain, self.context.event_bus)
        ipc_server = IPCServer(rpc,
                               self.context.trinity_config.jsonrpc_ipc_path)

        loop = asyncio.get_event_loop()
        asyncio.ensure_future(
            exit_with_service_and_endpoint(ipc_server, self.context.event_bus))
        asyncio.ensure_future(ipc_server.run())
        loop.run_forever()
        loop.close()
Beispiel #3
0
    def do_start(self) -> None:
        trinity_config = self.boot_info.trinity_config
        chain = self.chain_for_config(trinity_config)

        if trinity_config.has_app_config(Eth1AppConfig):
            modules = initialize_eth1_modules(chain, self.event_bus)
        elif trinity_config.has_app_config(BeaconAppConfig):
            modules = initialize_beacon_modules(chain, self.event_bus)
        else:
            raise Exception("Unsupported Node Type")

        rpc = RPCServer(modules, chain, self.event_bus)

        # Run IPC Server
        ipc_server = IPCServer(rpc,
                               self.boot_info.trinity_config.jsonrpc_ipc_path)
        asyncio.ensure_future(ipc_server.run())
        services_to_exit: Tuple[BaseService, ...] = (
            ipc_server,
            self._event_bus_service,
        )

        # Run HTTP Server
        if self.boot_info.args.enable_http:
            http_server = HTTPServer(rpc, port=self.boot_info.args.rpcport)
            asyncio.ensure_future(http_server.run())
            services_to_exit += (http_server, )

        asyncio.ensure_future(exit_with_services(*services_to_exit))
Beispiel #4
0
async def ipc_server(monkeypatch, event_bus, jsonrpc_ipc_pipe_path, event_loop,
                     chain_with_block_validation):
    '''
    This fixture runs a single RPC server over IPC over
    the course of all tests. It yields the IPC server only for monkeypatching purposes
    '''
    rpc = RPCServer(chain_with_block_validation, event_bus)
    ipc_server = IPCServer(rpc, jsonrpc_ipc_pipe_path, loop=event_loop)

    asyncio.ensure_future(ipc_server.run(), loop=event_loop)

    try:
        yield ipc_server
    finally:
        await ipc_server.cancel()
Beispiel #5
0
def ipc_server(jsonrpc_ipc_pipe_path, event_loop, chain_with_block_validation):
    '''
    This fixture runs a single RPC server over IPC over
    the course of all tests. It never needs to be actually
    used as a fixture, so it doesn't return (yield) a value.
    '''
    rpc = RPCServer(chain_with_block_validation)
    ipc_server = IPCServer(rpc, jsonrpc_ipc_pipe_path)

    asyncio.ensure_future(ipc_server.run(loop=event_loop), loop=event_loop)

    try:
        yield
    finally:
        event_loop.run_until_complete(ipc_server.stop())
Beispiel #6
0
    def do_start(self) -> None:

        trinity_config = self.boot_info.trinity_config

        if trinity_config.has_app_config(Eth1AppConfig):
            modules = self.setup_eth1_modules(trinity_config)
        elif trinity_config.has_app_config(BeaconAppConfig):
            modules = self.setup_beacon_modules()
        else:
            raise Exception("Unsupported Node Type")

        rpc = RPCServer(modules, self.event_bus)
        ipc_server = IPCServer(rpc, self.boot_info.trinity_config.jsonrpc_ipc_path)

        asyncio.ensure_future(exit_with_endpoint_and_services(self.event_bus, ipc_server))
        asyncio.ensure_future(ipc_server.run())
Beispiel #7
0
async def ipc_server(monkeypatch, p2p_server, jsonrpc_ipc_pipe_path,
                     event_loop, chain_with_block_validation):
    '''
    This fixture runs a single RPC server over IPC over
    the course of all tests. It never needs to be actually
    used as a fixture, so it doesn't return (yield) a value.
    '''

    rpc = RPCServer(chain_with_block_validation, p2p_server.peer_pool)
    ipc_server = IPCServer(rpc, jsonrpc_ipc_pipe_path, loop=event_loop)

    asyncio.ensure_future(ipc_server.run(), loop=event_loop)

    try:
        yield
    finally:
        await ipc_server.cancel()
Beispiel #8
0
    def do_start(self) -> None:

        trinity_config = self.context.trinity_config

        if trinity_config.has_app_config(Eth1AppConfig):
            modules = self.setup_eth1_modules(trinity_config)
        elif trinity_config.has_app_config(BeaconAppConfig):
            modules = self.setup_beacon_modules()
        else:
            raise Exception("Unsupported Node Type")

        rpc = RPCServer(modules, self.context.event_bus)
        ipc_server = IPCServer(rpc, self.context.trinity_config.jsonrpc_ipc_path)

        loop = asyncio.get_event_loop()
        asyncio.ensure_future(exit_with_service_and_endpoint(ipc_server, self.context.event_bus))
        asyncio.ensure_future(ipc_server.run())
        loop.run_forever()
        loop.close()
Beispiel #9
0
    def do_start(self) -> None:
        trinity_config = self.boot_info.trinity_config
        chain = self.chain_for_config(trinity_config)

        if trinity_config.has_app_config(Eth1AppConfig):
            modules = initialize_eth1_modules(chain, self.event_bus)
        elif trinity_config.has_app_config(BeaconAppConfig):
            modules = initialize_beacon_modules(chain, self.event_bus)
        else:
            raise Exception("Unsupported Node Type")

        rpc = RPCServer(modules, chain, self.event_bus)
        ipc_server = IPCServer(rpc, self.boot_info.trinity_config.jsonrpc_ipc_path)

        asyncio.ensure_future(exit_with_services(
            ipc_server,
            self._event_bus_service,
        ))
        asyncio.ensure_future(ipc_server.run())