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

chore(rpc): build rpc as OnComponentsInitializedHook #9243

Closed
wants to merge 116 commits into from

Conversation

emhane
Copy link
Member

@emhane emhane commented Jul 2, 2024

Build RPC component as OnComponentsInitializedHook. Part of task to expose EthApi top level, for user to configure, like for different networks.

Exposes extension component builders as Option<OnComponentsInitializedHook<N>>s. The hook takes a mutable reference to the extension component container as param. This is how extension component builders stage their output for installation in the node, as well as how they read state from previously initialised components that they may need to build themselves. This has two main benefits:

  • Since extension components are supposed to be optional, it's better that component inter-dependencies are not modelled with rigid type transitions, e.g. Engine<Node> is the only way to get to Rpc<Engine<Node>>, unlike for core components.
  • This flexibility allows us to implement the extension component builders in several PRs. For this PR, engine is just staged from the scope of DefaultNodeLauncher::launch_node.

mattsse and others added 30 commits May 22, 2024 16:43
@emhane emhane changed the title chore(rpc) chore(rpc): build rpc as OnComponentsInitializedHook Jul 2, 2024
@emhane emhane changed the base branch from main to emhane/rpc-builder July 2, 2024 14:42
Comment on lines 936 to 937
// fn beacon_engine_handle(&self) -> &Self::Node::Engine::Handle;
fn beacon_engine_handle(&self) -> &BeaconConsensusEngineHandle<Self::Node::Engine>;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will just move this getter into RpcBuilder trait, and same for other dependencies getters, and delete these Install traits

Comment on lines 167 to 181
pub trait FullNodeComponentsExt: FullNodeComponents {
type Rpc: Rpc<Self>;

/// Returns the RPC component, if installed.
fn rpc(&self) -> Option<&Self::Rpc>;
}

pub trait Rpc<N: FullNodeComponents>: Send + Sync {
type ServerHandles;
type Registry;

fn handles(&self) -> &Self::ServerHandles;

fn registry(&self) -> &Self::Registry;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think RPC is downstream of components and part of the Node / Launch process.

so I think we want:

  • keep the rpc extension API on nodebuilder
  • make rpc part of the Node helper trait, to embed it into DefaultLauncher

but somehow we'd need to a way to clarify the EthApi type for the nodehooks I assume?

maybe a solution that could work is is replacing the RpcHooks type with the RpcBuilder

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep the rpc extension API on nodebuilder

make new trait NodeComponentsBuilderExt, this is where the rpc builder will be stored, yes?

make rpc part of the Node helper trait, to embed it into DefaultLauncher

node helper trait? I can't find it, need the proper name

maybe a solution that could work is is replacing the RpcHooks type with the RpcBuilder

configuring rpc hooks as part of rpc builder makes sense. still need to have them in NodeAddOnsExt type also, to pass as param in OnComponentsInitializedHook. the hooks param to OnComponentsInitializedHook should be general. alt, have a super trait for all hooks on extension components.

in future we may want to stick to the pattern and start exex as OnComponentsInitializedHook as well. we may also want to separate engine rpc and regular rpc as two components, thereby also separate RpcHooks into RpcEngineHooks and RpcHooks. keeping this in mind, making the NodeAddOnsExt type.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may also want to separate engine rpc and regular rpc as two components

definitely, this behaviour should be entirely node specific, hence I'm thinking this should be a separate thing and perhaps replace

pub(crate) struct RpcHooks<Node: FullNodeComponents> {

and also be configured

pub trait Node<N: FullNodeTypes>: NodeTypes + Clone {

@mattsse mattsse added the A-sdk Related to reth's use as a library label Jul 3, 2024
@emhane emhane requested a review from mattsse July 3, 2024 12:48
Base automatically changed from emhane/rpc-builder to main July 3, 2024 15:44
@emhane emhane requested review from fgimenez and rkrasiuk as code owners July 7, 2024 00:33
@mattsse mattsse mentioned this pull request Jul 10, 2024
@emhane emhane added the S-needs-design This issue requires design work to think about how it would best be accomplished label Jul 10, 2024
@emhane
Copy link
Member Author

emhane commented Jul 10, 2024

closing, needs design

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sdk Related to reth's use as a library S-needs-design This issue requires design work to think about how it would best be accomplished
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants