eigen_client_eth::instrumented_client

Struct InstrumentedClient

Source
pub struct InstrumentedClient { /* private fields */ }
Expand description

This struct represents an instrumented client that can be used to interact with an Ethereum node. It provides a set of methods to interact with the node and measures the duration of the calls.

Implementations§

Source§

impl InstrumentedClient

Source

pub async fn new(url: &str) -> Result<Self, InstrumentedClientError>

Creates a new instance of the InstrumentedClient.

§Arguments
  • url - The URL of the RPC server.
§Returns

A new instance of the InstrumentedClient.

§Errors

Returns an error if the URL is invalid or if there is an error getting the version.

Source

pub async fn new_ws(url: &str) -> Result<Self, InstrumentedClientError>

Creates a new instance of the InstrumentedClient that supports ws connection.

§Arguments
  • url - The ws URL of the RPC server .
§Returns

A new instance of the InstrumentedClient.

§Errors

Returns an error if the URL is invalid or if there is an error getting the version.

Source

pub async fn new_from_client( client: RootProvider<Http<Client>>, ) -> Result<Self, InstrumentedClientError>

Creates a new instance of the InstrumentedClient from an existing client (RootProvider).

§Arguments
  • client - The existing client (RootProvider).
§Returns

A new instance of the InstrumentedClient.

§Errors

Returns an error if there is an error getting the version.

Source

pub async fn chain_id(&self) -> TransportResult<ChainId>

Returns the chain ID.

§Returns

The chain ID.

§Errors

Returns an error if the RPC call fails.

Source

pub async fn balance_at( &self, account: Address, block_number: BlockNumberOrTag, ) -> TransportResult<U256>

Returns the balance of the account at the given block number.

§Arguments
  • account - The account address.
  • block_number - The block number.
§Returns

The balance of the account at the given block number.

Source

pub async fn block_by_hash( &self, hash: BlockHash, ) -> TransportResult<Option<Block>>

Returns the block having the given block hash.

§Arguments
  • hash - The block hash.
§Returns

The block having the given block hash.

Source

pub async fn call_contract( &self, call: TransactionRequest, block_number: BlockNumberOrTag, ) -> TransportResult<Bytes>

Executes a message call transaction.

§Arguments
  • call - The message call to be executed
  • block_number - The block height at which the call runs. Note: in case this argument is n
§Returns

The returned value of the executed contract.

Source

pub async fn code_at( &self, address: Address, block_number: BlockNumberOrTag, ) -> TransportResult<Bytes>

Returns the compiled bytecode of a smart contract given its address and block number.

§Arguments
  • address - The address of the smart contract.
  • block_number - The block number.
§Returns

The compiled bytecode of the smart contract with the given address and block number.

Source

pub async fn estimate_gas(&self, tx: TransactionRequest) -> TransportResult<u64>

Estimates the gas needed to execute a specific transaction.

§Arguments
  • tx - The transaction from which the gas consumption is estimated.
§Returns

The estimated gas.

Source

pub async fn fee_history( &self, block_count: u64, last_block: BlockNumberOrTag, reward_percentiles: &[f64], ) -> TransportResult<FeeHistory>

Returns a collection of historical gas information.

§Arguments
  • block_count - The number of blocks to include in the collection.
  • last_block - The last block number to include in the collection.
  • reward_percentiles - A sorted list of percentage points used to sample the effective priority fees per gas from each block. The samples are taken in ascending order and weighted by gas usage. The list is sorted increasingly.
Source

pub async fn filter_logs(&self, filter: Filter) -> TransportResult<Vec<Log>>

Executes a filter query.

§Arguments
  • filter - The filter query to be executed.
§Returns

A vector of logs.

Source

pub async fn header_by_hash(&self, hash: B256) -> TransportResult<Header>

Returns the block header with the given hash.

§Arguments
  • hash - The block hash.
§Returns

The block header.

Source

pub async fn header_by_number( &self, block_number: BlockNumberOrTag, ) -> TransportResult<Header>

Returns a block header with the given block number.

§Arguments
  • block_number - The block number.
§Returns

The block header.

Source

pub async fn nonce_at( &self, account: Address, block_number: BlockNumberOrTag, ) -> TransportResult<u64>

Returns the nonce of the given account.

§Arguments
  • account - The address of the account.
  • block_number - The block number from where the nonce is taken.
§Returns

The nonce of the account.

Source

pub async fn pending_balance_at( &self, account: Address, ) -> TransportResult<U256>

Returns the wei balance of the given account in the pending state.

§Arguments
  • account - The address of the account.
§Returns

The wei balance of the account.

Source

pub async fn pending_call_contract( &self, call: TransactionRequest, ) -> TransportResult<Bytes>

Executes a message call transaction using the EVM. The state seen by the contract call is the pending state.

§Arguments
  • call - The message call to be executed
§Returns

The returned value of the executed contract.

Source

pub async fn pending_code_at(&self, account: Address) -> TransportResult<Bytes>

Returns the contract code of the given account in the pending state.

§Arguments
  • account - The address of the contract.
§Returns

The contract code.

Source

pub async fn pending_nonce_at(&self, account: Address) -> TransportResult<u64>

Returns the account nonce of the given account in the pending state. This is the nonce that should be used for the next transaction.

§Arguments
  • account - The address of the account.
§Returns
  • The nonce of the account in the pending state.
Source

pub async fn pending_storage_at( &self, account: Address, key: U256, ) -> TransportResult<U256>

Returns the value of key in the contract storage of the given account in the pending state.

§Arguments
  • account - The address of the contract.
  • key - The position in the storage.
§Returns

The value of the storage position at the provided address.

Source

pub async fn pending_transaction_count(&self) -> TransportResult<u64>

Returns the total number of transactions in the pending state.

§Returns

The number of pending transactions.

Source

pub async fn send_transaction(&self, tx: TxEnvelope) -> TransportResult<B256>

Sends a signed transaction into the pending pool for execution.

§Arguments
  • tx - The transaction to be executed.
§Returns

The hash of the given transaction.

Source

pub async fn storage_at( &self, account: Address, key: U256, block_number: U256, ) -> TransportResult<U256>

Returns the value of key in the contract storage of the given account.

§Arguments
  • account - The address of the contract.
  • key - The position in the storage.
  • block_number - The block number from which the storage is taken.
§Returns

The value of the storage position at the provided address.

Source

pub async fn subscribe_filter_logs<R: RpcReturn>( &self, filter: Filter, ) -> TransportResult<Subscription<R>>

Subscribes to the results of a streaming filter query. Note: this method fails if the InstrumentedClient does not use a web socket client.

§Arguments
  • filter - A filter query.
§Returns

The subscription.

§Errors
  • If ws_client is None.
Source

pub async fn subscribe_new_head<R: RpcReturn>( &self, ) -> TransportResult<Subscription<R>>

Subscribes to notifications about the current blockchain head. Note: this method fails if the InstrumentedClient does not use a web socket client.

§Returns

The subscription.

§Errors
  • If ws_client is None.
Source

pub async fn suggest_gas_price(&self) -> TransportResult<u64>

Retrieves the currently suggested gas price.

§Returns

The currently suggested gas price.

Source

pub async fn suggest_gas_tip_cap(&self) -> TransportResult<u64>

Retrieves the currently suggested gas tip cap after EIP1559.

§Returns

The currently suggested gas price.

Source

pub async fn sync_progress(&self) -> TransportResult<SyncStatus>

Retrieves the current progress of the sync algorithm. If there’s no sync currently running, it returns None.

§Returns

The current progress of the sync algorithm.

Source

pub async fn transaction_by_hash( &self, tx_hash: B256, ) -> TransportResult<Transaction>

Returns the transaction with the given hash.

§Arguments
  • tx_hash - The transaction hash.
§Returns

The transaction with the given hash.

Source

pub async fn transaction_count(&self, block_hash: B256) -> TransportResult<u64>

Returns the total number of transactions in the given block.

§Arguments
  • block_hash - The block hash.
§Returns

The number of transactions in the given block.

Source

pub async fn transaction_in_block( &self, block_hash: B256, index: u64, ) -> TransportResult<Transaction>

Returns a single transaction at index in the given block.

§Arguments
  • block_hash - The block hash.
  • index - The index of the transaction in the block.
§Returns

The transaction at index in the given block.

Source

pub async fn transaction_receipt( &self, tx_hash: B256, ) -> TransportResult<TransactionReceipt>

Returns the receipt of a transaction by transaction hash. Note: the receipt is not available for pending transactions.

§Arguments
  • tx_hash - The hash of the transaction.
§Returns

The transaction receipt.

Trait Implementations§

Source§

impl BackendClient for InstrumentedClient

Source§

fn block_number<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<BlockNumber, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the latest block number.

§Returns

The latest block number.

§Errors

Returns an error if the RPC call fails.

Source§

fn block_by_number<'life0, 'async_trait>( &'life0 self, number: BlockNumberOrTag, ) -> Pin<Box<dyn Future<Output = Result<Option<Block>, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Returns the block having the given block number.

§Arguments
  • number - The block number.
§Returns

The block having the given block number.

§Errors

Returns an error if the RPC call fails.

Source§

type Error = InstrumentedClientError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T