feat: Ingest highest_precompile_address

This commit is contained in:
sprites0
2025-07-17 20:59:32 -04:00
parent 39bcc49194
commit dbcd73884e
4 changed files with 20 additions and 6 deletions

View File

@ -12,7 +12,7 @@ use alloy_rpc_types::engine::{
use jsonrpsee::http_client::{transport::HttpBackend, HttpClient}; use jsonrpsee::http_client::{transport::HttpBackend, HttpClient};
use reth::network::PeersHandleProvider; use reth::network::PeersHandleProvider;
use reth_chainspec::{EthChainSpec, EthereumHardforks}; use reth_chainspec::{EthChainSpec, EthereumHardforks};
use reth_hyperliquid_types::PrecompilesCache; use reth_hyperliquid_types::{PrecompileData, PrecompilesCache};
use reth_node_api::{Block, FullNodeComponents, PayloadTypes}; use reth_node_api::{Block, FullNodeComponents, PayloadTypes};
use reth_node_builder::EngineTypes; use reth_node_builder::EngineTypes;
use reth_node_builder::NodeTypesWithEngine; use reth_node_builder::NodeTypesWithEngine;
@ -191,7 +191,10 @@ impl BlockIngest {
let mut u_cache = cache.lock().await; let mut u_cache = cache.lock().await;
let mut u_pre_cache = precompiles_cache.lock(); let mut u_pre_cache = precompiles_cache.lock();
for blk in new_blocks { for blk in new_blocks {
let precompiles = blk.read_precompile_calls.clone(); let precompiles = PrecompileData {
precompiles: blk.read_precompile_calls.clone(),
highest_precompile_address: blk.highest_precompile_address,
};
let h = match &blk.block { let h = match &blk.block {
EvmBlock::Reth115(b) => { EvmBlock::Reth115(b) => {
let block_number = b.header().number() as u64; let block_number = b.header().number() as u64;

View File

@ -11,6 +11,7 @@ pub(crate) struct BlockAndReceipts {
pub system_txs: Vec<SystemTx>, pub system_txs: Vec<SystemTx>,
#[serde(default)] #[serde(default)]
pub read_precompile_calls: Vec<(Address, Vec<(ReadPrecompileInput, ReadPrecompileResult)>)>, pub read_precompile_calls: Vec<(Address, Vec<(ReadPrecompileInput, ReadPrecompileResult)>)>,
pub highest_precompile_address: Option<Address>,
} }
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]

View File

@ -24,6 +24,7 @@ pub use alloy_evm::EthEvm;
use alloy_primitives::Address; use alloy_primitives::Address;
use alloy_primitives::U160; use alloy_primitives::U160;
use alloy_primitives::U256; use alloy_primitives::U256;
use reth_hyperliquid_types::PrecompileData;
use core::{convert::Infallible, fmt::Debug}; use core::{convert::Infallible, fmt::Debug};
use parking_lot::RwLock; use parking_lot::RwLock;
use reth_chainspec::{ChainSpec, EthChainSpec, MAINNET}; use reth_chainspec::{ChainSpec, EthChainSpec, MAINNET};
@ -200,6 +201,7 @@ impl ConfigureEvmEnv for EthEvmConfig {
pub(crate) struct BlockAndReceipts { pub(crate) struct BlockAndReceipts {
#[serde(default)] #[serde(default)]
pub read_precompile_calls: Vec<(Address, Vec<(ReadPrecompileInput, ReadPrecompileResult)>)>, pub read_precompile_calls: Vec<(Address, Vec<(ReadPrecompileInput, ReadPrecompileResult)>)>,
pub highest_precompile_address: Option<Address>,
} }
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
@ -228,7 +230,7 @@ pub(crate) fn collect_s3_block(ingest_path: PathBuf, height: u64) -> Option<Bloc
pub(crate) fn get_locally_sourced_precompiles_for_height( pub(crate) fn get_locally_sourced_precompiles_for_height(
precompiles_cache: PrecompilesCache, precompiles_cache: PrecompilesCache,
height: u64, height: u64,
) -> Option<Vec<(Address, Vec<(ReadPrecompileInput, ReadPrecompileResult)>)>> { ) -> Option<PrecompileData> {
let mut u_cache = precompiles_cache.lock(); let mut u_cache = precompiles_cache.lock();
u_cache.remove(&height) u_cache.remove(&height)
} }
@ -244,7 +246,10 @@ pub(crate) fn collect_block(
if let Some(calls) = if let Some(calls) =
get_locally_sourced_precompiles_for_height(shared_state.precompiles_cache, height) get_locally_sourced_precompiles_for_height(shared_state.precompiles_cache, height)
{ {
return Some(BlockAndReceipts { read_precompile_calls: calls }); return Some(BlockAndReceipts {
read_precompile_calls: calls.precompiles,
highest_precompile_address: calls.highest_precompile_address,
});
} }
} }
// Fallback to s3 always // Fallback to s3 always

View File

@ -18,5 +18,10 @@ pub enum ReadPrecompileResult {
UnexpectedError, UnexpectedError,
} }
pub type PrecompilesCache = #[derive(Debug, Clone, Serialize, Deserialize)]
Arc<Mutex<BTreeMap<u64, Vec<(Address, Vec<(ReadPrecompileInput, ReadPrecompileResult)>)>>>>; pub struct PrecompileData {
pub precompiles: Vec<(Address, Vec<(ReadPrecompileInput, ReadPrecompileResult)>)>,
pub highest_precompile_address: Option<Address>,
}
pub type PrecompilesCache = Arc<Mutex<BTreeMap<u64, PrecompileData>>>;