Skip to content

Commit

Permalink
[bridge indexer] increase the max elapsed time for the eth query retr…
Browse files Browse the repository at this point in the history
…y loops (MystenLabs#18435)

## Description 

This change makes the exponential backoff to duration longer hence
reduce the amount of queries we send to eth providers.

## 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:
  • Loading branch information
longbowlu authored Jun 27, 2024
1 parent e5f6b04 commit f1089ab
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions crates/sui-bridge-indexer/src/latest_eth_syncer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ where
interval.tick().await;
let Ok(Ok(new_block)) = retry_with_max_elapsed_time!(
provider.get_block_number(),
time::Duration::from_secs(10)
time::Duration::from_secs(600)
) else {
error!("Failed to get latest block from eth client after retry");
continue;
Expand All @@ -125,7 +125,7 @@ where
let timer = Instant::now();
let Ok(Ok(events)) = retry_with_max_elapsed_time!(
eth_client.get_events_in_range(contract_address, start_block, end_block),
Duration::from_secs(30)
Duration::from_secs(600)
) else {
error!("Failed to get events from eth client after retry");
continue;
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-bridge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ pub mod e2e_tests;
macro_rules! retry_with_max_elapsed_time {
($func:expr, $max_elapsed_time:expr) => {{
// The following delay sequence (in secs) will be used, applied with jitter
// 0.4, 0.8, 1.6, 3.2, 6.4, 12.8, 25.6, 30, 30, 30 ...
// 0.4, 0.8, 1.6, 3.2, 6.4, 12.8, 25.6, 30, 60, 120, 120 ...
let backoff = backoff::ExponentialBackoff {
initial_interval: Duration::from_millis(400),
randomization_factor: 0.1,
multiplier: 2.0,
max_interval: Duration::from_secs(30),
max_interval: Duration::from_secs(120),
max_elapsed_time: Some($max_elapsed_time),
..Default::default()
};
Expand Down
1 change: 1 addition & 0 deletions docker/sui-tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ RUN apt-get update && apt-get install -y libpq5 libpq-dev ca-certificates
COPY --from=builder /sui/target/release/sui-node /usr/local/bin
COPY --from=builder /sui/target/release/stress /usr/local/bin
COPY --from=builder /sui/target/release/sui-bridge /usr/local/bin
COPY --from=builder /sui/target/release/bridge-indexer /usr/local/bin
COPY --from=builder /sui/target/release/sui-bridge-cli /usr/local/bin
COPY --from=builder /sui/target/release/sui-analytics-indexer /usr/local/bin
COPY --from=builder /sui/target/release/sui-proxy /usr/local/bin
Expand Down

0 comments on commit f1089ab

Please sign in to comment.