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

Rpc <> Exex example #8112

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

supernovahs
Copy link
Contributor

closes #8008

I am trying to write a custom rpc to calculate the no of deposits in op bridge . But getting some errors. Can u point me to correct it. Thanks

@supernovahs
Copy link
Contributor Author

@onbjerg @mattsse

@@ -0,0 +1,111 @@
`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
`

Copy link
Member

@onbjerg onbjerg left a comment

Choose a reason for hiding this comment

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

pls also add the example to examples/readme.md

Comment on lines 80 to 109
let filter = Filter::new().select(0u64..).event("ETHBridgeFinalized(address,address,uint256)");
let filter_res = self.provider.new_filter(filter).await;

match filter_res{
Ok(id) =>{
let data = self.provider.filter_logs(id).await;
let mut deposit_count = 0;
match data{
Ok(logs) =>{
for log in logs{
let val = log.log_decode::<L1StandardBridge::ETHBridgeFinalized>().ok();

if let Some(finalized_data) = val{
// let's see what to do with this data later.
let da = finalized_data.data();
deposit_count += 1;
}
}
Ok(deposit_count)
},
Err(_) =>{
Ok(0)
}
}
},
Err(_)=>{
Ok(0)
}

}
Copy link
Member

Choose a reason for hiding this comment

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

this is not correct, we want this to ask the exex what the deposit count is, we don't want to calculate it ourselves on each call

.await?;

handle.wait_for_node_exit().await
})
Copy link
Member

Choose a reason for hiding this comment

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

the exex is missing, pls see the other examples

Comment on lines 55 to 57
#[rpc[server, namespace="onDepositCount"]]
pub trait OpDepositCountExtApi {
#[method(name = "opdepositCount")]
Copy link
Member

Choose a reason for hiding this comment

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

please follow the naming convention of the other namespaces

@supernovahs
Copy link
Contributor Author

yeah , the exex is missing . I was first trying to get an idea on how to get a custom rpc .

@gakonst
Copy link
Member

gakonst commented May 6, 2024

Clarifying that we'd like the ExEx to spawn the RPC in a custom port or path in the JSON-RPC, this is not a task for opening an additional JSON RPC namespace in the same port!

@supernovahs
Copy link
Contributor Author

@onbjerg thought? Please ignore the small nits for now. Just looking for more context from u

@emhane emhane added A-exex Execution Extensions C-example Examples labels May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-exex Execution Extensions C-example Examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an example of using an RPC with an ExEx
4 participants