Skip to content

Commit

Permalink
[bridge] remove disable-eth (#19923)
Browse files Browse the repository at this point in the history
## Description 

Describe the changes or additions included in this PR.

## Test plan 

How did you test the new or updated feature?

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
longbowlu authored Oct 20, 2024
1 parent cc167f6 commit 4e79cd1
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 64 deletions.
3 changes: 0 additions & 3 deletions crates/sui-bridge-indexer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ pub struct IndexerConfig {
pub eth_sui_bridge_contract_address: String,

pub metric_port: u16,

/// A temporary flag to disable the eth indexer to test mainnet before eth contracts are deployed.
pub disable_eth: Option<bool>,
}

impl sui_config::Config for IndexerConfig {}
Expand Down
118 changes: 57 additions & 61 deletions crates/sui-bridge-indexer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,70 +110,66 @@ async fn main() -> Result<()> {
);
let eth_bridge_proxy_address = EthAddress::from_str(&config.eth_sui_bridge_contract_address)?;
let mut tasks = vec![];
if Some(true) == config.disable_eth {
info!("Eth indexer is disabled");
} else {
// Start the eth subscription indexer
let bridge_address = EthAddress::from_str(&config.eth_sui_bridge_contract_address)?;
let provider = Arc::new(
Provider::<Http>::try_from(&config.eth_rpc_url)?
.interval(std::time::Duration::from_millis(2000)),
);
let bridge_addresses = get_eth_contract_addresses(bridge_address, &provider).await?;
let bridge_addresses: Vec<EthAddress> = vec![
bridge_address,
bridge_addresses.0,
bridge_addresses.1,
bridge_addresses.2,
bridge_addresses.3,
];
// Start the eth subscription indexer
let bridge_address = EthAddress::from_str(&config.eth_sui_bridge_contract_address)?;
let provider = Arc::new(
Provider::<Http>::try_from(&config.eth_rpc_url)?
.interval(std::time::Duration::from_millis(2000)),
);
let bridge_addresses = get_eth_contract_addresses(bridge_address, &provider).await?;
let bridge_addresses: Vec<EthAddress> = vec![
bridge_address,
bridge_addresses.0,
bridge_addresses.1,
bridge_addresses.2,
bridge_addresses.3,
];

// Start the eth subscription indexer
let eth_subscription_datasource = EthSubscriptionDatasource::new(
bridge_addresses.clone(),
eth_client.clone(),
config.eth_ws_url.clone(),
indexer_meterics.clone(),
config.eth_bridge_genesis_block,
)
.await?;
let eth_subscription_indexer = IndexerBuilder::new(
"EthBridgeSubscriptionIndexer",
eth_subscription_datasource,
EthDataMapper {
metrics: indexer_meterics.clone(),
},
datastore.clone(),
)
.with_backfill_strategy(BackfillStrategy::Disabled)
.build();
tasks.push(spawn_logged_monitored_task!(
eth_subscription_indexer.start()
));
// Start the eth subscription indexer
let eth_subscription_datasource = EthSubscriptionDatasource::new(
bridge_addresses.clone(),
eth_client.clone(),
config.eth_ws_url.clone(),
indexer_meterics.clone(),
config.eth_bridge_genesis_block,
)
.await?;
let eth_subscription_indexer = IndexerBuilder::new(
"EthBridgeSubscriptionIndexer",
eth_subscription_datasource,
EthDataMapper {
metrics: indexer_meterics.clone(),
},
datastore.clone(),
)
.with_backfill_strategy(BackfillStrategy::Disabled)
.build();
tasks.push(spawn_logged_monitored_task!(
eth_subscription_indexer.start()
));

// Start the eth sync data source
let eth_sync_datasource = EthFinalizedSyncDatasource::new(
bridge_addresses.clone(),
eth_client.clone(),
config.eth_rpc_url.clone(),
indexer_meterics.clone(),
bridge_metrics.clone(),
config.eth_bridge_genesis_block,
)
.await?;
// Start the eth sync data source
let eth_sync_datasource = EthFinalizedSyncDatasource::new(
bridge_addresses.clone(),
eth_client.clone(),
config.eth_rpc_url.clone(),
indexer_meterics.clone(),
bridge_metrics.clone(),
config.eth_bridge_genesis_block,
)
.await?;

let eth_sync_indexer = IndexerBuilder::new(
"EthBridgeFinalizedSyncIndexer",
eth_sync_datasource,
EthDataMapper {
metrics: indexer_meterics.clone(),
},
datastore,
)
.with_backfill_strategy(BackfillStrategy::Partitioned { task_size: 1000 })
.build();
tasks.push(spawn_logged_monitored_task!(eth_sync_indexer.start()));
}
let eth_sync_indexer = IndexerBuilder::new(
"EthBridgeFinalizedSyncIndexer",
eth_sync_datasource,
EthDataMapper {
metrics: indexer_meterics.clone(),
},
datastore,
)
.with_backfill_strategy(BackfillStrategy::Partitioned { task_size: 1000 })
.build();
tasks.push(spawn_logged_monitored_task!(eth_sync_indexer.start()));

let sui_client = Arc::new(
SuiClientBuilder::default()
Expand Down

0 comments on commit 4e79cd1

Please sign in to comment.