Skip to content

Extend AddOns with functions that can modify the StageSet #16032

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

Open
mattsse opened this issue May 2, 2025 · 1 comment · May be fixed by #16039
Open

Extend AddOns with functions that can modify the StageSet #16032

mattsse opened this issue May 2, 2025 · 1 comment · May be fixed by #16039
Assignees
Labels
A-sdk Related to reth's use as a library C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started

Comments

@mattsse
Copy link
Collaborator

mattsse commented May 2, 2025

Describe the feature

we store install functions for exexs in Addons:

/// Additional node extensions.
///
/// At this point we consider all necessary components defined.
pub struct AddOns<Node: FullNodeComponents, AddOns: NodeAddOns<Node>> {
/// Additional `NodeHooks` that are called at specific points in the node's launch lifecycle.
pub hooks: NodeHooks<Node, AddOns>,
/// The `ExExs` (execution extensions) of the node.
pub exexs: Vec<(String, Box<dyn BoxedLaunchExEx<Node>>)>,

we can do something similar for custom stages, for this we need something similar to this type erased boxed future

/// A version of [`LaunchExEx`] that returns a boxed future. Makes the trait object-safe.
pub trait BoxedLaunchExEx<Node: FullNodeComponents>: Send {
/// Launches the `ExEx` and returns a boxed future.
fn launch(self: Box<Self>, ctx: ExExContext<Node>)
-> BoxFuture<'static, eyre::Result<BoxExEx>>;
}

but operating on

pub struct StageSetBuilder<Provider> {

pub trait BoxedInstallStages<Node: ProviderNodetypes>: Send { 

  fn on_stages(mut self: Box<Self>, stages &mut StagesBuilder<Node>) 
         -> BoxFuture<'static, eyre::Result<()>>;
}

and additional trait functions for this that are not boxed, similar to:

pub trait LaunchExEx<Node: FullNodeComponents>: Send {

then we need something like:

/// Installs an `ExEx` (Execution Extension) in the node.
///
/// # Note
///
/// The `ExEx` ID must be unique.
pub fn install_exex<F, R, E>(self, exex_id: impl Into<String>, exex: F) -> Self
where
F: FnOnce(ExExContext<NodeAdapter<T, CB::Components>>) -> R + Send + 'static,
R: Future<Output = eyre::Result<E>> + Send,
E: Future<Output = eyre::Result<()>> + Send,
{
Self {
builder: self.builder.install_exex(exex_id, exex),
task_executor: self.task_executor,
}
}

but for stages

TODO

  • Introduce a similar install abstraction for modifying stages, modeled after the exex traits and types
  • this should be added in a new file next to:
    //! Types for launching execution extensions (ExEx).
    , starting with the trait, the boxed trait and impl and then an additional field in the AddOns type

Additional context

No response

@mattsse mattsse added C-enhancement New feature or request S-needs-triage This issue needs to be labelled labels May 2, 2025
@github-project-automation github-project-automation bot moved this to Backlog in Reth Tracker May 2, 2025
@mattsse mattsse added A-sdk Related to reth's use as a library and removed S-needs-triage This issue needs to be labelled labels May 2, 2025
@Rimeeeeee
Copy link
Contributor

May I do this :)?

@mattsse mattsse added the D-good-first-issue Nice and easy! A great choice to get started label May 2, 2025
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 C-enhancement New feature or request D-good-first-issue Nice and easy! A great choice to get started
Projects
Status: Backlog
Development

Successfully merging a pull request may close this issue.

2 participants