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

remove transaction forwarder trait #9678

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

nkysg
Copy link
Contributor

@nkysg nkysg commented Jul 21, 2024

Closes #9562

Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

awesome
some design suggestion,

needs input from @emhane on how to include the sequencer URL in the nodeaddon / op-ethapi builder

bin/reth/src/optimism.rs Outdated Show resolved Hide resolved
crates/rpc/rpc-builder/src/lib.rs Outdated Show resolved Hide resolved
@emhane
Copy link
Member

emhane commented Jul 23, 2024

not sure if we can remove the trait UpdateTxForwarder since the type of the field on OpEthApi is a generic, however we could remove the trait as super trait from FullEthApiServer and just specify it as trait bound for the impl of BuilderProvider for OpEthApi.

@mattsse
Copy link
Collaborator

mattsse commented Jul 26, 2024

I see,

@nkysg I'll try something with this to get this unblocked and will get back to you

@mattsse mattsse self-assigned this Jul 26, 2024
@nkysg
Copy link
Contributor Author

nkysg commented Aug 8, 2024

I have tried add pub ext_args: Addons::ExtArgs in pub struct Addons

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>>)>,
    /// Additional RPC add-ons.
    pub rpc: RpcAddOns<Node, AddOns::EthApi>,
    /// Additional node add-ons args.
    + pub ext_args: AddOns::ExtArgs,
}

pub trait NodeAddOns<N: FullNodeComponents>: Send + Sync + Unpin + Clone + 'static {
    /// The core `eth` namespace API type to install on the RPC server (see
    /// `reth_rpc_eth_api::EthApiServer`).
    type EthApi: Send + Clone;
    /// The extent arguments required for the node add-ons.
   + type ExtArgs: Send + Clone + Default;
}

impl<N: FullNodeComponents> NodeAddOns<N> for OptimismAddOns {
    type EthApi = OpEthApi<N>;
   + type ExtArgs = Option<String>;
}

And I have defined func update_ext_args in WithLaunchContext and NodeBuilderWithComponents

impl<T, CB, AO> WithLaunchContext<NodeBuilderWithComponents<T, CB, AO>>
where
    T: FullNodeTypes,
    CB: NodeComponentsBuilder<T>,
    AO: NodeAddOns<NodeAdapter<T, CB::Components>>,
    AO::EthApi: FullEthApiServer + AddDevSigners,
{
   
    /// Update Addons extent args
    pub fn update_ext_args(self, args: AO::ExtArgs) -> Self {
        Self { builder: self.builder.update_ext_args(args), task_executor: self.task_executor }
    }
}

impl<T, CB, AO> NodeBuilderWithComponents<T, CB, AO>
where
    T: FullNodeTypes,
    CB: NodeComponentsBuilder<T>,
    AO: NodeAddOns<NodeAdapter<T, CB::Components>>,
{
          /// update the  AddOns extent args
    pub fn update_ext_args(mut self, args: AO::ExtArgs) -> Self {
        self.add_ons.ext_args = args;
        self
    }
}

right now I need to process the ext_args into EngineApi::new,

 async fn launch_node(
        self,
        target: NodeBuilderWithComponents<T, CB, AO>,
    ) -> eyre::Result<Self::Node> {
       let NodeBuilderWithComponents {
            adapter: NodeTypesAdapter { database },
            components_builder,
            add_ons: AddOns { hooks, rpc, exexs: installed_exex, ext_args: ext_args },
            config,
        } = target;

....
        
        let engine_api = EngineApi::new(
            ctx.blockchain_db().clone(),
            ctx.chain_spec(),
            beacon_engine_handle,
            ctx.components().payload_builder().clone().into(),
            Box::new(ctx.task_executor().clone()),
            client,
            EngineCapabilities::default(),
        );

one q, How to pass the ext_args and then I can call below func as your mentioned

type Ctx<'a> = <Eth as BuilderProvider<N>>::Ctx<'a>;
fn builder() -> Box<dyn for<'a> Fn(Self::Ctx<'a>) -> Self + Send> {
Box::new(|ctx| Self { inner: Eth::builder()(ctx) })
}

@mattsse please take look at it. Thx

@nkysg nkysg requested a review from mattsse August 8, 2024 05:58
@emhane
Copy link
Member

emhane commented Aug 8, 2024

one q, How to pass the ext_args and then I can call below func as your mentioned

you need to add the EngineApi type to be built as AT to NodeAddOns. It then has its own builder, with its own context type. Let the NodeAddOns::EngineApi provide its args instead. so remove the AT NodeAddOns::ExtArgs.

@mattsse
Copy link
Collaborator

mattsse commented Aug 8, 2024

sorry @nkysg I didn't find capacity just yet,

bumping prio and will look into how we should do this, in the meantime you could try proceeding with #10028

@nkysg
Copy link
Contributor Author

nkysg commented Aug 8, 2024

@mattsse Thx. I will try proceeding with #10028

@nkysg
Copy link
Contributor Author

nkysg commented Aug 8, 2024

one q, How to pass the ext_args and then I can call below func as your mentioned

you need to add the EngineApi type to be built as AT to NodeAddOns. It then has its own builder, with its own context type. Let the NodeAddOns::EngineApi provide its args instead. so remove the AT NodeAddOns::ExtArgs.

Thanks for your guiding. After #10028, I will try this.

@emhane
Copy link
Member

emhane commented Aug 12, 2024

on second look, addressing issue #9562 shouldn't have to touch EngineApi. we can make a new type OpEthApiBuilderCtx, which wraps the EthApiBuilderCtx and the sequencer url string. then the tx forwarder can be set in the OpEthApi builder function, this is possible since #9879. we don't need to touch NodeAddOns.

@nkysg
Copy link
Contributor Author

nkysg commented Aug 13, 2024

Got it. I will try this.

@emhane
Copy link
Member

emhane commented Aug 13, 2024

actually @nkysg, there should be no need for an OpEthApiBuilderCtx type for now. just hard code the sequencer url in the OpEthApi builder function for this pr.

@nkysg
Copy link
Contributor Author

nkysg commented Aug 13, 2024

@emhane I have this mind. Let's do it.

@emhane
Copy link
Member

emhane commented Aug 13, 2024

check it out @nkysg, at this point, it should be known that the eth api type returned by RpcRegistryInner::eth_api is OpEthApi,

.extend_rpc_modules(move |ctx| {
// register sequencer tx forwarder
if let Some(sequencer_http) = sequencer_http_arg {
ctx.registry.set_eth_raw_transaction_forwarder(Arc::new(
SequencerClient::new(sequencer_http),
));
}
Ok(())
})

so we should be able to add method OpEthApi::set_eth_raw_transaction_forwarder, and do this here

// register sequencer tx forwarder
if let Some(sequencer_http) = sequencer_http_arg {
    ctx.registry.eth_api().set_eth_raw_transaction_forwarder(Arc::new(
         SequencerClient::new(sequencer_http),
     ));
}

@emhane
Copy link
Member

emhane commented Aug 21, 2024

need any help here @nkysg ?

@emhane emhane added C-debt Refactor of code section that is hard to understand or maintain A-rpc Related to the RPC implementation A-op-reth Related to Optimism and op-reth labels Aug 21, 2024
@nkysg
Copy link
Contributor Author

nkysg commented Aug 22, 2024

@emhane Thanks for your help. I need to look into it again. Something I forget it.

@nkysg nkysg force-pushed the remove_transaction_forwarder_trait branch 2 times, most recently from b55284f to e56582c Compare August 25, 2024 13:50
@nkysg nkysg marked this pull request as draft August 25, 2024 13:55
@nkysg
Copy link
Contributor Author

nkysg commented Aug 25, 2024

so we should be able to add method OpEthApi::set_eth_raw_transaction_forwarder, and do this here

// register sequencer tx forwarder
if let Some(sequencer_http) = sequencer_http_arg {
    ctx.registry.eth_api().set_eth_raw_transaction_forwarder(Arc::new(
         SequencerClient::new(sequencer_http),
     ));
}

I don't understand it. At #9562, Want to remove the two traits RawTransactionForwarder and UpdateRawTxForwarder @emhane

@nkysg nkysg marked this pull request as ready for review August 25, 2024 14:14
Copy link
Member

@emhane emhane left a comment

Choose a reason for hiding this comment

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

you're doing great!

crates/optimism/rpc/src/eth/transaction.rs Show resolved Hide resolved
crates/optimism/rpc/src/eth/mod.rs Outdated Show resolved Hide resolved
@nkysg nkysg requested a review from emhane August 25, 2024 23:34
@nkysg nkysg force-pushed the remove_transaction_forwarder_trait branch from b7b422a to cff0512 Compare August 26, 2024 09:01
Copy link
Member

@emhane emhane left a comment

Choose a reason for hiding this comment

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

killing it!

Comment on lines +48 to +53
// submit the transaction to the pool with a `Local` origin
let hash = self
.pool()
.add_transaction(TransactionOrigin::Local, pool_transaction)
.await
.map_err(Self::Error::from_eth_err)?;
Copy link
Member

Choose a reason for hiding this comment

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

wonder if this code can be deleted for op? I'm aware it is executed also for op on main...will open issue for it though

@nkysg nkysg force-pushed the remove_transaction_forwarder_trait branch from cff0512 to e245a00 Compare August 26, 2024 16:49
 ref fields by name

add set_sequencer_client
@nkysg nkysg force-pushed the remove_transaction_forwarder_trait branch from e245a00 to 6083862 Compare August 26, 2024 17:05
@emhane emhane added this pull request to the merge queue Aug 26, 2024
Merged via the queue into paradigmxyz:main with commit a24fe46 Aug 26, 2024
35 checks passed
@nkysg nkysg deleted the remove_transaction_forwarder_trait branch August 26, 2024 23:51
@nkysg
Copy link
Contributor Author

nkysg commented Aug 31, 2024

I see, we can unassigned mattse. @emhane .Thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-op-reth Related to Optimism and op-reth A-rpc Related to the RPC implementation C-debt Refactor of code section that is hard to understand or maintain
Projects
None yet
Development

Successfully merging this pull request may close these issues.

remove transaction forwarder trait
3 participants