mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat: gas price oracle (#2600)
This commit is contained in:
@ -14,8 +14,8 @@ use reth_provider::{
|
||||
BlockProviderIdExt, EvmEnvProvider, HeaderProvider, ReceiptProviderIdExt, StateProviderFactory,
|
||||
};
|
||||
use reth_rpc::{
|
||||
eth::cache::EthStateCache, AuthLayer, Claims, EngineEthApi, EthApi, EthFilter,
|
||||
JwtAuthValidator, JwtSecret,
|
||||
eth::{cache::EthStateCache, gas_oracle::GasPriceOracle},
|
||||
AuthLayer, Claims, EngineEthApi, EthApi, EthFilter, JwtAuthValidator, JwtSecret,
|
||||
};
|
||||
use reth_rpc_api::{servers::*, EngineApiServer};
|
||||
use reth_tasks::TaskSpawner;
|
||||
@ -51,8 +51,9 @@ where
|
||||
EngineApi: EngineApiServer,
|
||||
{
|
||||
// spawn a new cache task
|
||||
let eth_cache = EthStateCache::spawn_with(client.clone(), Default::default(), executor);
|
||||
let eth_api = EthApi::new(client.clone(), pool.clone(), network, eth_cache.clone());
|
||||
let eth_cache = EthStateCache::spawn_with(client.clone(), Default::default(), executor.clone());
|
||||
let gas_oracle = GasPriceOracle::new(client.clone(), Default::default(), eth_cache.clone());
|
||||
let eth_api = EthApi::new(client.clone(), pool.clone(), network, eth_cache.clone(), gas_oracle);
|
||||
let eth_filter = EthFilter::new(client, pool, eth_cache.clone(), DEFAULT_MAX_LOGS_IN_RESPONSE);
|
||||
launch_with_eth_api(eth_api, eth_filter, engine_api, socket_addr, secret).await
|
||||
}
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
use reth_rpc::{
|
||||
eth::cache::{EthStateCache, EthStateCacheConfig},
|
||||
eth::{
|
||||
cache::{EthStateCache, EthStateCacheConfig},
|
||||
gas_oracle::GasPriceOracleConfig,
|
||||
},
|
||||
EthApi, EthFilter, EthPubSub,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -25,6 +28,8 @@ pub struct EthHandlers<Client, Pool, Network, Events> {
|
||||
pub struct EthConfig {
|
||||
/// Settings for the caching layer
|
||||
pub cache: EthStateCacheConfig,
|
||||
/// Settings for the gas price oracle
|
||||
pub gas_oracle: GasPriceOracleConfig,
|
||||
/// The maximum number of tracing calls that can be executed in concurrently.
|
||||
pub max_tracing_requests: usize,
|
||||
/// Maximum number of logs that can be returned in a single response in `eth_getLogs` calls.
|
||||
@ -35,6 +40,7 @@ impl Default for EthConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
cache: EthStateCacheConfig::default(),
|
||||
gas_oracle: GasPriceOracleConfig::default(),
|
||||
max_tracing_requests: 10,
|
||||
max_logs_per_response: DEFAULT_MAX_LOGS_IN_RESPONSE,
|
||||
}
|
||||
|
||||
@ -110,8 +110,9 @@ use reth_provider::{
|
||||
StateProviderFactory,
|
||||
};
|
||||
use reth_rpc::{
|
||||
eth::cache::EthStateCache, AdminApi, DebugApi, EngineEthApi, EthApi, EthFilter, EthPubSub,
|
||||
EthSubscriptionIdProvider, NetApi, TraceApi, TracingCallGuard, TxPoolApi, Web3Api,
|
||||
eth::{cache::EthStateCache, gas_oracle::GasPriceOracle},
|
||||
AdminApi, DebugApi, EngineEthApi, EthApi, EthFilter, EthPubSub, EthSubscriptionIdProvider,
|
||||
NetApi, TraceApi, TracingCallGuard, TxPoolApi, Web3Api,
|
||||
};
|
||||
use reth_rpc_api::{servers::*, EngineApiServer};
|
||||
use reth_tasks::TaskSpawner;
|
||||
@ -826,6 +827,11 @@ where
|
||||
self.config.eth.cache.clone(),
|
||||
self.executor.clone(),
|
||||
);
|
||||
let gas_oracle = GasPriceOracle::new(
|
||||
self.client.clone(),
|
||||
self.config.eth.gas_oracle.clone(),
|
||||
cache.clone(),
|
||||
);
|
||||
let new_canonical_blocks = self.events.canonical_state_stream();
|
||||
let c = cache.clone();
|
||||
self.executor.spawn_critical(
|
||||
@ -840,6 +846,7 @@ where
|
||||
self.pool.clone(),
|
||||
self.network.clone(),
|
||||
cache.clone(),
|
||||
gas_oracle,
|
||||
);
|
||||
let filter = EthFilter::new(
|
||||
self.client.clone(),
|
||||
|
||||
@ -97,8 +97,8 @@ where
|
||||
EthApiClient::send_transaction(client, transaction_request).await.unwrap_err();
|
||||
EthApiClient::hashrate(client).await.unwrap();
|
||||
EthApiClient::submit_hashrate(client, U256::default(), H256::default()).await.unwrap();
|
||||
EthApiClient::gas_price(client).await.unwrap();
|
||||
EthApiClient::max_priority_fee_per_gas(client).await.unwrap();
|
||||
EthApiClient::gas_price(client).await.unwrap_err();
|
||||
EthApiClient::max_priority_fee_per_gas(client).await.unwrap_err();
|
||||
|
||||
// Unimplemented
|
||||
assert!(is_unimplemented(
|
||||
|
||||
Reference in New Issue
Block a user