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

examples: add examples of using reth-provider and instantiating an RPC on top of the DB #3533

Merged
merged 8 commits into from
Jul 3, 2023

Conversation

gakonst
Copy link
Member

@gakonst gakonst commented Jul 2, 2023

As title, adds 2 examples:

  • Showcases how to open a Reth DB in RO mode and talk to it via reth-provider. Pretty neat / powerful. cc @joshstevens19 for this to improve your abstractions' usage
  • Showcases how to instantiate a very thin ETH JSON RPC server using the RpcModules builder. This currently feels still too verbose, cc @mattsse in case I'm doing something wrong.

cc @onbjerg I am not 100% sure if this is the best way to do examples/ in the current repository structure, opening this as-is, and we can either merge it or defer to you on best integration path

ref #3533

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.

can we instead have a single examples/Cargo.toml and then all the examples are:

[[example]]
name = "<>"
path = "<>.rs"

ref: https://github.com/tokio-rs/tokio/tree/master/examples

Comment on lines 37 to 46
// 2. Setup blcokchain tree to be able to receive live notifs
// TODO: Make this easier to configure
let provider = {
let consensus = Arc::new(BeaconConsensus::new(spec.clone()));
let exec_factory = ExecutionFactory::new(spec.clone());

let externals = TreeExternals::new(db.clone(), consensus, exec_factory, spec.clone());
let tree_config = BlockchainTreeConfig::default();
let (canon_state_notification_sender, _receiver) =
tokio::sync::broadcast::channel(tree_config.max_reorg_depth() as usize * 2);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this seems not necessary at all, we shouldn't be needing this here and instead should be able to use the db as provider,

perhaps there are a few things missing, but all of this should not be needed here

Copy link
Member Author

@gakonst gakonst Jul 2, 2023

Choose a reason for hiding this comment

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

yeah that's what i thought was just not sure how to set up the DB for the RPC Module w/o a tree for the pending queries - seems like the abstraction did not support it

@gakonst
Copy link
Member Author

gakonst commented Jul 2, 2023

can we instead have a single examples/Cargo.toml and then all the examples are:

I guess yeah, altho it does require writing everything included. I'm fine with it.

@codecov
Copy link

codecov bot commented Jul 2, 2023

Codecov Report

Merging #3533 (9d9fb1a) into main (4f32f56) will not change coverage.
The diff coverage is n/a.

❗ Current head 9d9fb1a differs from pull request most recent head cd1ddb7. Consider uploading reports for the commit cd1ddb7 to get more accurate results

Impacted file tree graph

see 8 files with indirect coverage changes

Flag Coverage Δ
integration-tests 16.25% <ø> (+0.01%) ⬆️
unit-tests 64.01% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
reth binary 23.01% <ø> (ø)
blockchain tree 81.25% <ø> (ø)
pipeline 86.98% <ø> (ø)
storage (db) 73.82% <ø> (ø)
trie 95.64% <ø> (ø)
txpool 51.14% <ø> (ø)
networking 77.88% <ø> (+0.01%) ⬆️
rpc 57.86% <ø> (-0.02%) ⬇️
consensus 62.58% <ø> (ø)
revm 34.99% <ø> (ø)
payload builder 6.83% <ø> (ø)
primitives 88.49% <ø> (-0.01%) ⬇️

will be added in followup
@gakonst gakonst merged commit 766f520 into main Jul 3, 2023
@gakonst gakonst deleted the docs/examples branch July 3, 2023 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants