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): default trait methods EthTransactions #8639

Merged
merged 37 commits into from
Jun 8, 2024

Conversation

emhane
Copy link
Member

@emhane emhane commented Jun 6, 2024

  • Moves EthTransactions impl involving state to default trait methods
  • Adds new trait EthState for rpc methods related to state
  • Adds new helper trait LoadState used in EthTransactions, EthState, debug, trace and call rpc methods

Leaves methods in EthTransactions impl, that are yet to be moved to default trait method impls so that they are ported to any network by default:

  • involving pending block
  • methods associated with call rpc methods (for sending txns)

@emhane emhane added A-rpc Related to the RPC implementation A-op-reth Related to Optimism and op-reth labels Jun 6, 2024
@emhane emhane requested review from mattsse and Rjected as code owners June 6, 2024 13:04
@emhane emhane requested a review from DaniPopes June 6, 2024 13:06
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.

I think this is very useful,
this pushes a lot of commonly used operations to traits and stacks them so functionality can be reused easily

@emhane emhane requested a review from mattsse June 6, 2024 21:09
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.

I like this a lot because this pushes lots of logic behind proper traits which should make reusing this a lot easier

crates/rpc/rpc/src/eth/api/traits/state.rs Outdated Show resolved Hide resolved
crates/rpc/rpc/src/eth/api/traits/state.rs Outdated Show resolved Hide resolved
TransactionSource,
};
use std::sync::Arc;

Copy link
Collaborator

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 Author

Choose a reason for hiding this comment

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

removing the whitespace makes fmt order the std deps alphabetically with the other deps. I think it's very helpful to see which std deps are used easily by having it up top. kind of, in order of generality, since std lib is dep of most other deps.

use std::*;

use reth_dep::*;

use crate::*;

use super::*;

crates/rpc/rpc/src/eth/api/traits/transaction.rs Outdated Show resolved Hide resolved
/// Returns a handle for reading evm config.
///
/// Data access in default (L1) trait method implementations.
fn evm_config(&self) -> &impl ConfigureEvm;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd also like to auto_impl for & if possible

Copy link
Member Author

Choose a reason for hiding this comment

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

it's not possible, but not because atuo_impl fails (which is the case for SpawnBlocking, which has methods taking a closure with Self as arg). I get this error, which I have a hunch is related to this rust-lang/rust#100013, since ConfigureEvm trait uses GAT of specific lifetime.

error: lifetime may not live long enough
  --> crates/rpc/rpc/src/eth/api/transactions.rs:80:9
   |
79 |     fn evm_config(&self) -> impl ConfigureEvm + '_ {
   |                   - let's call the lifetime of this reference `'1`
80 |         self.inner.evm_config()
   |         ^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'1` must outlive `'static`

@emhane emhane merged commit a30c184 into matt/scaffold-ethapi Jun 8, 2024
18 of 25 checks passed
@emhane emhane deleted the emhane/ethapi-txns branch June 8, 2024 15:24
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants