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

Don't use exponential backoff for signed transactions #232

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 10 additions & 2 deletions crates/oracle/src/runner/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,22 @@ use crate::{
use epoch_encoding::{BlockPtr, Encoder, Message, CURRENT_ENCODING_VERSION};
use std::{cmp::Ordering, collections::BTreeMap};
use tracing::{debug, error, info, warn};
use web3::{transports::Http, Web3};

/// The main application in-memory state.
pub struct Oracle {
config: Config,
protocol_chain: JrpcProviderForChain<JrpcExpBackoff>,
indexed_chains: Vec<JrpcProviderForChain<JrpcExpBackoff>>,
contracts: Contracts<JrpcExpBackoff>,
contracts: Contracts<Http>,
}

impl Oracle {
pub fn new(config: Config) -> Self {
let protocol_chain = protocol_chain(&config);
let indexed_chains = indexed_chains(&config);
let contracts = Contracts::new(
protocol_chain.web3.clone(),
contracts_web3(&config),
config.data_edge_address,
config.epoch_manager_address,
config.transaction_monitoring_options,
Expand Down Expand Up @@ -299,6 +300,13 @@ fn protocol_chain(config: &Config) -> JrpcProviderForChain<JrpcExpBackoff> {
JrpcProviderForChain::new(config.protocol_chain.id.clone(), transport)
}

fn contracts_web3(config: &Config) -> Web3<Http> {
// Unwrap/Expect: the URL string value we pass to Http::new will be parsed into an URL again.
// Since that value already comes from a parsed (and thus, valid) URL, we can assume it won't panic.
let transport = Http::new(config.protocol_chain.jrpc_url.as_str()).expect("URL to be valid");
Web3::new(transport)
}

fn indexed_chains(config: &Config) -> Vec<JrpcProviderForChain<JrpcExpBackoff>> {
config
.indexed_chains
Expand Down
4 changes: 2 additions & 2 deletions crates/oracle/src/runner/transaction_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ impl<'a, T: Transport> TransactionMonitor<'a, T> {
futures.push(future)
}

// Await and check if any of those transactions has a receipt
// Await and check if any of those transactions have a receipt
while let Some(result) = futures.next().await {
match result {
Ok(None) => {}
Ok(None) => { /* no confirmations */ }
Ok(Some(receipt)) => {
return Ok(Some(receipt));
}
Expand Down