From 82efc76eb5fa32101886fe825f3d70faa27d76fe Mon Sep 17 00:00:00 2001 From: tilacog Date: Thu, 2 Feb 2023 15:46:16 -0300 Subject: [PATCH 1/3] refactor: don't use exponential backoff for signing transactions The transaction monitor does not play well with our current exponengial backoff implementation for JRPC endpoints. For effective monitoring, we must access any errors as soon as they happen, so we must strip out the implicit retry strategies. --- crates/oracle/src/runner/oracle.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/oracle/src/runner/oracle.rs b/crates/oracle/src/runner/oracle.rs index de8aa357..e8212470 100644 --- a/crates/oracle/src/runner/oracle.rs +++ b/crates/oracle/src/runner/oracle.rs @@ -9,13 +9,14 @@ 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, indexed_chains: Vec>, - contracts: Contracts, + contracts: Contracts, } impl Oracle { @@ -23,7 +24,7 @@ impl Oracle { 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, @@ -299,6 +300,13 @@ fn protocol_chain(config: &Config) -> JrpcProviderForChain { JrpcProviderForChain::new(config.protocol_chain.id.clone(), transport) } +fn contracts_web3(config: &Config) -> Web3 { + // 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> { config .indexed_chains From 6e10a92285a54486edb86c8ee704637625629535 Mon Sep 17 00:00:00 2001 From: tilacog Date: Fri, 3 Feb 2023 12:09:59 -0300 Subject: [PATCH 2/3] chore: comments --- crates/oracle/src/runner/transaction_monitor.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/oracle/src/runner/transaction_monitor.rs b/crates/oracle/src/runner/transaction_monitor.rs index 07121c81..0024ea27 100644 --- a/crates/oracle/src/runner/transaction_monitor.rs +++ b/crates/oracle/src/runner/transaction_monitor.rs @@ -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)); } From d2e46607fc6e23f50d52312951aa537016074f61 Mon Sep 17 00:00:00 2001 From: tilacog Date: Wed, 15 Feb 2023 15:54:29 -0300 Subject: [PATCH 3/3] chore: formatting --- crates/oracle/src/runner/transaction_monitor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/oracle/src/runner/transaction_monitor.rs b/crates/oracle/src/runner/transaction_monitor.rs index 0024ea27..cac61cb4 100644 --- a/crates/oracle/src/runner/transaction_monitor.rs +++ b/crates/oracle/src/runner/transaction_monitor.rs @@ -105,7 +105,7 @@ impl<'a, T: Transport> TransactionMonitor<'a, T> { // Await and check if any of those transactions have a receipt while let Some(result) = futures.next().await { match result { - Ok(None) => { /* no confirmations */} + Ok(None) => { /* no confirmations */ } Ok(Some(receipt)) => { return Ok(Some(receipt)); }