Skip to content

Commit

Permalink
fix(hubble): improve reorg handling - modules
Browse files Browse the repository at this point in the history
  • Loading branch information
qlp committed Sep 12, 2024
1 parent 182b266 commit e60515f
Show file tree
Hide file tree
Showing 20 changed files with 33 additions and 34 deletions.
4 changes: 2 additions & 2 deletions hubble/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ pub enum IndexerConfig {
#[serde(rename = "scroll")]
Scroll(crate::scroll::Config),
#[serde(rename = "dummy-fetcher")]
DummyFetcher(crate::fetcher::dummy::config::Config),
DummyFetcher(crate::indexer::dummy::config::Config),
#[serde(rename = "eth-fetcher")]
EthFetcher(crate::fetcher::eth::config::Config),
EthFetcher(crate::indexer::eth::config::Config),
}

impl IndexerConfig {
Expand Down
6 changes: 0 additions & 6 deletions hubble/src/fetcher/eth/mod.rs

This file was deleted.

8 changes: 0 additions & 8 deletions hubble/src/fetcher/mod.rs

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use sqlx::PgPool;
use unionlabs::aptos::block_info::BlockHeight;

use super::dummy::{DummyContext, DummyFetcherClient};
use crate::fetcher::{api::IndexerId, indexer::Indexer};
use crate::indexer::{api::IndexerId, Indexer};

#[derive(Clone, Debug, serde::Deserialize)]
pub struct Config {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use time::OffsetDateTime;
use tokio::{sync::mpsc::Sender, task::JoinSet};
use tracing::{debug, info, info_span, warn, Instrument};

use crate::fetcher::api::{
use crate::indexer::api::{
BlockHandle, BlockHash, BlockHeight, BlockRange, BlockReference, BlockTimestamp, FetchMessage,
FetcherClient, FetcherError,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
pub mod config;
pub mod dummy;
mod dummy;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use tracing::{debug, info, trace, warn};
use super::fetcher_client::EthFetcherClient;
use crate::{
eth::{BlockInsert, EventInsert, FromProviderError, ToLowerHex, TransactionInsert},
fetcher::{
indexer::{
api::{
BlockHandle, BlockHash, BlockHeight, BlockRange, BlockReference, BlockTimestamp,
FetchMessage, FetcherError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use sqlx::PgPool;
use url::Url;

use super::{context::EthContext, fetcher_client::EthFetcherClient};
use crate::fetcher::{
use crate::indexer::{
api::{BlockHeight, IndexerId},
indexer::Indexer,
Indexer,
};

const DEFAULT_CHUNK_SIZE: usize = 200;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use tracing::{debug, info, info_span, warn, Instrument};

use super::{block_handle::EthBlockHandle, context::EthContext};
use crate::{
fetcher::{
indexer::{
api::{BlockReference, FetcherClient},
eth::create_client_tracker::schedule_create_client_checker,
},
Expand Down
6 changes: 6 additions & 0 deletions hubble/src/indexer/eth/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pub mod config;
mod block_handle;
mod context;
mod create_client_tracker;
mod fetcher_client;
mod postgres;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use sqlx::{Postgres, Transaction};

use crate::fetcher::api::BlockHeight;
use crate::indexer::api::BlockHeight;

pub async fn delete_eth_log(
tx: &mut Transaction<'_, Postgres>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use tracing::{debug, error, info, info_span, Instrument};

use super::{
api::{BlockHeight, FetchMessage, FetcherClient},
indexer::Indexer,
Indexer,
};
use crate::fetcher::{
use crate::indexer::{
api::{BlockHandle, BlockRange, BlockReference, FetcherError},
postgres::{get_current_height, update_block_status, update_current_height},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use tracing::{debug, error, info, info_span, trace, warn, Instrument};

use super::{
api::{BlockRange, FetcherClient},
indexer::Indexer,
Indexer,
postgres::get_next_block_to_refresh,
};
use crate::fetcher::{
use crate::indexer::{
api::{BlockHandle, BlockHeight, BlockReference, FetchMessage, FetcherError},
postgres::{
delete_block_status, get_block_range_to_finalize, get_block_status_hash,
Expand Down
5 changes: 2 additions & 3 deletions hubble/src/fetcher/fixer.rs → hubble/src/indexer/fixer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ use tracing::{debug, error, info, info_span, trace, Instrument};

use super::{
api::{BlockRange, FetcherClient},
indexer::Indexer,
postgres::{get_block_range_to_fix, update_block_range_to_fix},
postgres::{get_block_range_to_fix, update_block_range_to_fix}, Indexer,
};
use crate::fetcher::api::{BlockHandle, BlockHeight, BlockReference, FetchMessage, FetcherError};
use crate::indexer::api::{BlockHandle, BlockHeight, BlockReference, FetchMessage, FetcherError};

impl<T: FetcherClient> Indexer<T> {
pub async fn run_fixer(&self, fetcher_client: T) -> Result<(), Report> {
Expand Down
10 changes: 9 additions & 1 deletion hubble/src/fetcher/indexer.rs → hubble/src/indexer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
pub mod api;
pub mod dummy;
pub mod eth;
mod fetcher;
mod finalizer;
mod fixer;
mod postgres;

use std::time::Duration;

use color_eyre::eyre::Report;
use tokio::{task::JoinSet, time::sleep};
use tracing::{error, info};

use super::api::{BlockHeight, FetcherClient, IndexerId};
use api::{BlockHeight, FetcherClient, IndexerId};

enum EndOfRunResult {
Exit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::ops::Range;
use sqlx::Postgres;
use time::OffsetDateTime;

use crate::fetcher::api::{BlockHash, BlockHeight, BlockRange, IndexerId};
use crate::indexer::api::{BlockHash, BlockHeight, BlockRange, IndexerId};

pub async fn get_current_height(
tx: &mut sqlx::Transaction<'_, Postgres>,
Expand Down
2 changes: 1 addition & 1 deletion hubble/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mod chain_id_query;
mod cli;
mod consensus;
mod eth;
mod fetcher;
mod indexer;
mod healthz;
mod logging;
mod metrics;
Expand Down

0 comments on commit e60515f

Please sign in to comment.