Skip to content

Commit 6c25cad

Browse files
committed
fix(hubble): support arbitrum transaction types
1 parent 4f1bf1e commit 6c25cad

File tree

4 files changed

+17
-14
lines changed

4 files changed

+17
-14
lines changed

hubble/src/indexer/eth/block_handle.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use alloy::rpc::types::Block;
1+
use alloy::network::AnyRpcBlock;
22
use axum::async_trait;
33
use color_eyre::eyre::Report;
44
use futures::{stream::FuturesOrdered, Stream};
@@ -21,7 +21,7 @@ use crate::{
2121

2222
#[derive(Clone)]
2323
pub enum BlockDetails {
24-
Lazy(Block),
24+
Lazy(AnyRpcBlock),
2525
Eager(Option<BlockInsert>),
2626
}
2727

@@ -30,7 +30,7 @@ pub enum BlockDetails {
3030
pub struct BlockInsert {
3131
pub chain_id: ChainId,
3232
pub hash: String,
33-
pub header: Block,
33+
pub header: AnyRpcBlock,
3434
pub height: i32,
3535
pub time: OffsetDateTime,
3636
pub transactions: Vec<TransactionInsert>,

hubble/src/indexer/eth/fetcher_client.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ use std::{collections::HashMap, fmt::Display};
22

33
use alloy::{
44
eips::BlockId,
5+
network::AnyRpcBlock,
56
primitives::{Address, BloomInput, FixedBytes},
6-
rpc::types::{Block, BlockTransactionsKind, Filter, Log},
7+
rpc::types::{BlockTransactionsKind, Filter, Log},
78
};
89
use axum::async_trait;
910
use color_eyre::eyre::Report;
@@ -45,7 +46,7 @@ trait BlockReferenceProvider {
4546
fn block_reference(&self) -> Result<BlockReference, Report>;
4647
}
4748

48-
impl BlockReferenceProvider for Block {
49+
impl BlockReferenceProvider for AnyRpcBlock {
4950
fn block_reference(&self) -> Result<BlockReference, Report> {
5051
Ok(BlockReference {
5152
height: self.header.number,
@@ -110,6 +111,8 @@ impl EthFetcherClient {
110111
)
111112
.await;
112113

114+
info!("block: {block:?}");
115+
113116
match block {
114117
Ok(rpc_result) => match rpc_result {
115118
Some(result) => {
@@ -147,7 +150,7 @@ impl EthFetcherClient {
147150

148151
pub async fn fetch_details(
149152
&self,
150-
block: &Block,
153+
block: &AnyRpcBlock,
151154
provider_id: RpcProviderId,
152155
) -> Result<Option<BlockInsert>, IndexerError> {
153156
let block_reference = block.block_reference()?;

hubble/src/indexer/eth/postgres.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use alloy::rpc::types::Block;
1+
use alloy::network::AnyRpcBlock;
22
use itertools::Itertools;
33
use serde::{Deserialize, Serialize};
44
use sqlx::{PgPool, Postgres, Transaction};
@@ -26,7 +26,7 @@ pub struct PgLog {
2626
#[derive(Serialize, Deserialize)]
2727
pub struct PgLogData {
2828
pub transactions: Vec<TransactionInsert>,
29-
pub header: Block,
29+
pub header: AnyRpcBlock,
3030
}
3131

3232
impl From<BlockInsert> for PgLog {

hubble/src/indexer/eth/provider.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use alloy::{
22
eips::BlockId,
3-
network::{Ethereum, Network},
3+
network::{AnyNetwork, AnyRpcBlock, Network},
44
primitives::TxHash,
55
providers::{Provider as AlloyProvider, ProviderBuilder, RootProvider},
6-
rpc::types::{Block, BlockTransactionsKind, Filter, Log},
6+
rpc::types::{BlockTransactionsKind, Filter, Log},
77
transports::{
88
http::{Client, Http},
99
RpcError, TransportErrorKind,
@@ -15,7 +15,7 @@ use crate::race_client::{RaceClient, RaceClientId, RaceClientResponse};
1515

1616
#[derive(Clone, Debug)]
1717
pub struct Provider {
18-
pub rpc_client: RaceClient<RootProvider<Http<Client>>>,
18+
pub rpc_client: RaceClient<RootProvider<Http<Client>, AnyNetwork>>,
1919
}
2020

2121
#[derive(Clone, Debug, Copy)]
@@ -56,7 +56,7 @@ impl Provider {
5656
rpc_client: RaceClient::new(
5757
rpc_urls
5858
.into_iter()
59-
.map(|url| ProviderBuilder::new().on_http(url))
59+
.map(|url| ProviderBuilder::new().network::<AnyNetwork>().on_http(url))
6060
.collect(),
6161
),
6262
}
@@ -77,7 +77,7 @@ impl Provider {
7777
id: BlockId,
7878
kind: BlockTransactionsKind,
7979
provider_id: Option<RpcProviderId>,
80-
) -> Result<Option<RpcResult<Block>>, RpcError<TransportErrorKind>> {
80+
) -> Result<Option<RpcResult<AnyRpcBlock>>, RpcError<TransportErrorKind>> {
8181
self.rpc_client
8282
.race_some(provider_id.map(Into::into), |c| c.get_block(id, kind))
8383
.await
@@ -100,7 +100,7 @@ impl Provider {
100100
tx_hash: TxHash,
101101
provider_id: Option<RpcProviderId>,
102102
) -> Result<
103-
Option<RpcResult<<Ethereum as Network>::TransactionResponse>>,
103+
Option<RpcResult<<AnyNetwork as Network>::TransactionResponse>>,
104104
RpcError<TransportErrorKind>,
105105
> {
106106
self.rpc_client

0 commit comments

Comments
 (0)