mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore(deps): bump alloy (#10537)
Co-authored-by: Oliver <onbjerg@users.noreply.github.com>
This commit is contained in:
@ -3,10 +3,7 @@
|
||||
|
||||
use crate::{authenticated_transport::AuthenticatedTransportConnect, bench_mode::BenchMode};
|
||||
use alloy_eips::BlockNumberOrTag;
|
||||
use alloy_provider::{
|
||||
network::{AnyNetwork, Ethereum},
|
||||
Provider, ProviderBuilder, RootProvider,
|
||||
};
|
||||
use alloy_provider::{network::AnyNetwork, Provider, ProviderBuilder, RootProvider};
|
||||
use alloy_rpc_client::ClientBuilder;
|
||||
use alloy_rpc_types_engine::JwtSecret;
|
||||
use alloy_transport::BoxTransport;
|
||||
@ -24,7 +21,7 @@ pub(crate) struct BenchContext {
|
||||
/// The auth provider used for engine API queries.
|
||||
pub(crate) auth_provider: RootProvider<BoxTransport, AnyNetwork>,
|
||||
/// The block provider used for block queries.
|
||||
pub(crate) block_provider: RootProvider<Http<Client>, Ethereum>,
|
||||
pub(crate) block_provider: RootProvider<Http<Client>, AnyNetwork>,
|
||||
/// The benchmark mode, which defines whether the benchmark should run for a closed or open
|
||||
/// range of blocks.
|
||||
pub(crate) benchmark_mode: BenchMode,
|
||||
@ -46,7 +43,8 @@ impl BenchContext {
|
||||
}
|
||||
|
||||
// set up alloy client for blocks
|
||||
let block_provider = ProviderBuilder::new().on_http(rpc_url.parse()?);
|
||||
let block_provider =
|
||||
ProviderBuilder::new().network::<AnyNetwork>().on_http(rpc_url.parse()?);
|
||||
|
||||
// If neither `--from` nor `--to` are provided, we will run the benchmark continuously,
|
||||
// starting at the latest block.
|
||||
@ -95,17 +93,7 @@ impl BenchContext {
|
||||
}
|
||||
};
|
||||
|
||||
let next_block = match first_block.header.number {
|
||||
Some(number) => {
|
||||
// fetch next block
|
||||
number + 1
|
||||
}
|
||||
None => {
|
||||
// this should never happen
|
||||
return Err(eyre::eyre!("First block number is None"));
|
||||
}
|
||||
};
|
||||
|
||||
let next_block = first_block.header.number + 1;
|
||||
Ok(Self { auth_provider, block_provider, benchmark_mode, next_block })
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,17 +45,8 @@ impl Command {
|
||||
while benchmark_mode.contains(next_block) {
|
||||
let block_res = block_provider.get_block_by_number(next_block.into(), true).await;
|
||||
let block = block_res.unwrap().unwrap();
|
||||
let block = match block.header.hash {
|
||||
Some(block_hash) => {
|
||||
// we can reuse the hash in the response
|
||||
Block::try_from(block).unwrap().seal(block_hash)
|
||||
}
|
||||
None => {
|
||||
// we don't have the hash, so let's just hash it
|
||||
Block::try_from(block).unwrap().seal_slow()
|
||||
}
|
||||
};
|
||||
|
||||
let block_hash = block.header.hash;
|
||||
let block = Block::try_from(block.inner).unwrap().seal(block_hash);
|
||||
let head_block_hash = block.hash();
|
||||
let safe_block_hash = block_provider
|
||||
.get_block_by_number(block.number.saturating_sub(32).into(), false);
|
||||
@ -65,18 +56,9 @@ impl Command {
|
||||
|
||||
let (safe, finalized) = tokio::join!(safe_block_hash, finalized_block_hash,);
|
||||
|
||||
let safe_block_hash = safe
|
||||
.unwrap()
|
||||
.expect("finalized block exists")
|
||||
.header
|
||||
.hash
|
||||
.expect("finalized block has hash");
|
||||
let finalized_block_hash = finalized
|
||||
.unwrap()
|
||||
.expect("finalized block exists")
|
||||
.header
|
||||
.hash
|
||||
.expect("finalized block has hash");
|
||||
let safe_block_hash = safe.unwrap().expect("finalized block exists").header.hash;
|
||||
let finalized_block_hash =
|
||||
finalized.unwrap().expect("finalized block exists").header.hash;
|
||||
|
||||
next_block += 1;
|
||||
sender
|
||||
|
||||
@ -45,16 +45,8 @@ impl Command {
|
||||
while benchmark_mode.contains(next_block) {
|
||||
let block_res = block_provider.get_block_by_number(next_block.into(), true).await;
|
||||
let block = block_res.unwrap().unwrap();
|
||||
let block = match block.header.hash {
|
||||
Some(block_hash) => {
|
||||
// we can reuse the hash in the response
|
||||
Block::try_from(block).unwrap().seal(block_hash)
|
||||
}
|
||||
None => {
|
||||
// we don't have the hash, so let's just hash it
|
||||
Block::try_from(block).unwrap().seal_slow()
|
||||
}
|
||||
};
|
||||
let block_hash = block.header.hash;
|
||||
let block = Block::try_from(block.inner).unwrap().seal(block_hash);
|
||||
|
||||
next_block += 1;
|
||||
sender.send(block).await.unwrap();
|
||||
|
||||
Reference in New Issue
Block a user