-
Notifications
You must be signed in to change notification settings - Fork 685
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
Move JSON-RPC server into an isolated plugin #1212
Move JSON-RPC server into an isolated plugin #1212
Conversation
7adbad7
to
cc59287
Compare
trinity/extensibility/plugin.py
Outdated
OWN = auto() | ||
|
||
|
||
class PluginContext: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I vaguely remember at least PluginContext(object)
being recommended somewhere...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that since python3 the two are equivalent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THis looks the same as something else I just reviewed....
Yep, Will probably have something more interesting here tomorrow ;) |
2840d43
to
c5ea88d
Compare
3d598fe
to
baf1e40
Compare
76551d4
to
a7cbf0f
Compare
I moved this to the Ada Lovelace milestone because I think we shouldn't rush it. There's a lot of code to review (not only in this PR but also in the new lahja event bus library) and async problems can be very subtle. |
714080a
to
272e12e
Compare
714080a
to
b86f3e3
Compare
Ok, I think I need a break and I'm reaching out for help. I've been trying whole day to work out the remaining issues but there are two things that stand out that I think are related.
Both issues indicate that there's a problem with the event bus in general. Even the simple test in the lahja repo shows that behaviour. It goes green but never closes. I guess it has to do with the UPDATE: I received an answer on StackOverflow that should help with this. |
@pipermerriam @carver This is pretty much ready but tomorrow I'll write an alternative "less magical" version of the |
Ok I think to make a fair alternative that evaluates @pipermerriam point of letting the type system help us more (in contrast to metaprogramming magic) we first need to fix the 3rd party library typing issue. Because the thing is, the revealed type of foobar = await self.event_bus.request(event)
reveal_type(foobar) I will dig into that now. |
Alright, made the changes to |
bbc1ed6
to
5924042
Compare
@pipermerriam I think the main point left open here is the proper handling of cancellations (also, I moved it to a How do you feel about taking it as is? |
33cc77e
to
5c5dcc4
Compare
@pipermerriam this looks weird. I just rebased this and now the integration test caught this:
Looks totally random to me. https://circleci.com/gh/ethereum/py-evm/77685?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link I'm out of town tomorrow until evening. Guess I'll investigate that when I come home. |
5c5dcc4
to
00c0465
Compare
Ok, turns out that |
two things, I never finished reviewing this (will try to do it tonight so you're clear to move forward tomorrow) second, make an issue for that decryption error as thoseshouldn't escape the trinity process. |
p2p/peer.py
Outdated
@@ -794,6 +804,16 @@ def __init__(self, | |||
self.max_peers = max_peers | |||
self.connected_nodes: Dict[Node, BasePeer] = {} | |||
self._subscribers: List[PeerSubscriber] = [] | |||
self.event_bus = event_bus | |||
self.run_task(self.handle_peer_count_requests()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be using self.run_daemon_task
trinity/chains/light.py
Outdated
header = self._headerdb.get_block_header_by_hash(block_hash) | ||
return self.get_block_by_header(header) | ||
return await self.get_block_by_header(header) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What am missing? The very next function definition is for get_block_by_header
and it is both not a coroutine and raises a NotImplementedError
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, that was meant to go to coro_get_block_by_header
trinity/rpc/format.py
Outdated
return async_formatted_func | ||
else: | ||
@functools.wraps(func) | ||
def formatted_func(self: Any, *args: Any) -> Callable[..., Any]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still necessary, quick glance suggests that all of the wrapped methods are now coroutines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, will change that.
df83846
to
6ee8b1d
Compare
6ee8b1d
to
59dc7c1
Compare
What was wrong?
Currently the
JSON-RPC
server runs in thenetworking
process together the syncing and other messaging. Now that isolated plugins are a thing, it's a good idea to move theJSON-RPC
server because:How was it fixed?
LightPeerChainBridge
plugin that brings anEventBusLightPeerChain
to be consumed from other processesIn addition to the current functionality of the
JSON-RPC
server, the new plugin-based version can be disabled by passing--disable-rpc
at startupCute Animal Picture