Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

progress saver #19239

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions crates/sui-bridge-indexer/src/eth_bridge_indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,6 @@ impl Datasource<RawEthData> for EthSubscriptionDatasource {
fn get_tasks_processed_checkpoints_metric(&self) -> &IntCounterVec {
&self.indexer_metrics.tasks_processed_checkpoints
}

fn get_live_task_checkpoint_metric(&self) -> &IntGaugeVec {
&self.indexer_metrics.live_task_current_checkpoint
}
}

pub struct EthSyncDatasource {
Expand Down Expand Up @@ -288,10 +284,6 @@ impl Datasource<RawEthData> for EthSyncDatasource {
fn get_tasks_processed_checkpoints_metric(&self) -> &IntCounterVec {
&self.indexer_metrics.tasks_processed_checkpoints
}

fn get_live_task_checkpoint_metric(&self) -> &IntGaugeVec {
&self.indexer_metrics.live_task_current_checkpoint
}
}

#[derive(Clone)]
Expand Down
1 change: 1 addition & 0 deletions crates/sui-bridge-indexer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub mod metrics;
pub mod models;
pub mod postgres_manager;
pub mod schema;
pub mod storage;
pub mod sui_transaction_handler;
pub mod sui_transaction_queries;
pub mod types;
Expand Down
25 changes: 21 additions & 4 deletions crates/sui-bridge-indexer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ use sui_bridge_indexer::config::IndexerConfig;
use sui_bridge_indexer::eth_bridge_indexer::EthDataMapper;
use sui_bridge_indexer::metrics::BridgeIndexerMetrics;
use sui_bridge_indexer::postgres_manager::{get_connection_pool, read_sui_progress_store};
use sui_bridge_indexer::sui_bridge_indexer::{PgBridgePersistent, SuiBridgeDataMapper};
use sui_bridge_indexer::storage::{
OutOfOrderSaveAfterDurationPolicy, PgBridgePersistent, ProgressSavingPolicy,
SaveAfterDurationPolicy,
};
use sui_bridge_indexer::sui_bridge_indexer::SuiBridgeDataMapper;
use sui_bridge_indexer::sui_datasource::SuiCheckpointDatasource;
use sui_bridge_indexer::sui_transaction_handler::handle_sui_transactions_loop;
use sui_bridge_indexer::sui_transaction_queries::start_sui_tx_polling_task;
Expand Down Expand Up @@ -71,7 +75,20 @@ async fn main() -> Result<()> {
let bridge_metrics = Arc::new(BridgeMetrics::new(&registry));

let db_url = config.db_url.clone();
let datastore = PgBridgePersistent::new(get_connection_pool(db_url.clone()).await);
let datastore = PgBridgePersistent::new(
get_connection_pool(db_url.clone()).await,
ProgressSavingPolicy::SaveAfterDuration(SaveAfterDurationPolicy::new(
tokio::time::Duration::from_secs(30),
)),
indexer_meterics.clone(),
);
let datastore_with_out_of_order_source = PgBridgePersistent::new(
get_connection_pool(db_url.clone()).await,
ProgressSavingPolicy::OutOfOrderSaveAfterDuration(OutOfOrderSaveAfterDurationPolicy::new(
tokio::time::Duration::from_secs(30),
)),
indexer_meterics.clone(),
);

let eth_client: Arc<EthClient<MeteredEthHttpProvier>> = Arc::new(
EthClient::<MeteredEthHttpProvier>::new(
Expand Down Expand Up @@ -118,7 +135,7 @@ async fn main() -> Result<()> {
EthDataMapper {
metrics: indexer_meterics.clone(),
},
datastore.clone(),
datastore,
)
.with_backfill_strategy(BackfillStrategy::Partitioned { task_size: 1000 })
.disable_live_task()
Expand All @@ -145,7 +162,7 @@ async fn main() -> Result<()> {
SuiBridgeDataMapper {
metrics: indexer_meterics.clone(),
},
datastore,
datastore_with_out_of_order_source,
)
.build();
indexer.start().await?;
Expand Down
8 changes: 4 additions & 4 deletions crates/sui-bridge-indexer/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct BridgeIndexerMetrics {
pub(crate) last_synced_eth_block: IntGauge,
pub(crate) tasks_remaining_checkpoints: IntGaugeVec,
pub(crate) tasks_processed_checkpoints: IntCounterVec,
pub(crate) live_task_current_checkpoint: IntGaugeVec,
pub(crate) tasks_current_checkpoints: IntGaugeVec,
}

impl BridgeIndexerMetrics {
Expand Down Expand Up @@ -115,9 +115,9 @@ impl BridgeIndexerMetrics {
registry,
)
.unwrap(),
live_task_current_checkpoint: register_int_gauge_vec_with_registry!(
"bridge_indexer_live_task_current_checkpoint",
"Current checkpoint of live task",
tasks_current_checkpoints: register_int_gauge_vec_with_registry!(
"bridge_indexer_tasks_current_checkpoints",
"Current checkpoint for each task",
&["task_name"],
registry,
)
Expand Down
Loading
Loading