From 8854f0a22783393abdd185ce289ce5a5aa3b9aa1 Mon Sep 17 00:00:00 2001 From: Miguel de Elias Date: Thu, 11 Apr 2024 09:51:23 -0300 Subject: [PATCH 1/3] fix: increase estimated gas by 20% --- availability-oracle/src/contract.rs | 62 ++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/availability-oracle/src/contract.rs b/availability-oracle/src/contract.rs index 450516c..e30fe89 100644 --- a/availability-oracle/src/contract.rs +++ b/availability-oracle/src/contract.rs @@ -101,15 +101,28 @@ impl StateManager for RewardsManagerContract { let num_subgraphs = ids.len() as u64; let tx = self.contract.set_denied_many(ids, statuses); - if let Err(err) = tx.call().await { - let message = err.decode_revert::().unwrap_or(err.to_string()); - error!(self.logger, "Transaction failed"; - "message" => message, - ); - } else { - tx.send().await?.await?; - METRICS.denied_subgraphs_total.inc_by(num_subgraphs); - } + // Calculate estimated gas + let estimated_gas_tx = tx + .estimate_gas() + .await; + + let estimated_gas = match estimated_gas_tx { + Ok(estimate) => estimate, + Err(err) => { + let message = err.decode_revert::().unwrap_or(err.to_string()); + error!(self.logger, "Transaction failed"; + "message" => message, + ); + // Return `Ok()` to avoid double error logging + return Ok(()); + } + }; + + // Increase the estimated gas by 20% + let increased_estimate = estimated_gas * U256::from(120) / U256::from(100); + + tx.gas(increased_estimate).send().await?.await?; + METRICS.denied_subgraphs_total.inc_by(num_subgraphs); } Ok(()) @@ -127,15 +140,28 @@ impl StateManager for SubgraphAvailabilityManagerContract { let oracle_index = U256::from(self.oracle_index); let tx = self.contract.vote_many(ids, statuses, oracle_index); - if let Err(err) = tx.call().await { - let message = err.decode_revert::().unwrap_or(err.to_string()); - error!(self.logger, "Transaction failed"; - "message" => message, - ); - } else { - tx.send().await?.await?; - METRICS.denied_subgraphs_total.inc_by(num_subgraphs); - } + // Calculate estimated gas + let estimated_gas_tx = tx + .estimate_gas() + .await; + + let estimated_gas = match estimated_gas_tx { + Ok(estimate) => estimate, + Err(err) => { + let message = err.decode_revert::().unwrap_or(err.to_string()); + error!(self.logger, "Transaction failed"; + "message" => message, + ); + // Return `Ok()` to avoid double error logging + return Ok(()); + } + }; + + // Increase the estimated gas by 20% + let increased_estimate = estimated_gas * U256::from(120) / U256::from(100); + + tx.gas(increased_estimate).send().await?.await?; + METRICS.denied_subgraphs_total.inc_by(num_subgraphs); } Ok(()) From a803c8d999ccaa8c9767b6d528de58fab4d9d9f9 Mon Sep 17 00:00:00 2001 From: Miguel de Elias Date: Thu, 11 Apr 2024 10:11:09 -0300 Subject: [PATCH 2/3] fix: fmt errors --- availability-oracle/src/contract.rs | 8 ++------ availability-oracle/src/network_subgraph.rs | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/availability-oracle/src/contract.rs b/availability-oracle/src/contract.rs index e30fe89..3b7a023 100644 --- a/availability-oracle/src/contract.rs +++ b/availability-oracle/src/contract.rs @@ -102,9 +102,7 @@ impl StateManager for RewardsManagerContract { let tx = self.contract.set_denied_many(ids, statuses); // Calculate estimated gas - let estimated_gas_tx = tx - .estimate_gas() - .await; + let estimated_gas_tx = tx.estimate_gas().await; let estimated_gas = match estimated_gas_tx { Ok(estimate) => estimate, @@ -141,9 +139,7 @@ impl StateManager for SubgraphAvailabilityManagerContract { let tx = self.contract.vote_many(ids, statuses, oracle_index); // Calculate estimated gas - let estimated_gas_tx = tx - .estimate_gas() - .await; + let estimated_gas_tx = tx.estimate_gas().await; let estimated_gas = match estimated_gas_tx { Ok(estimate) => estimate, diff --git a/availability-oracle/src/network_subgraph.rs b/availability-oracle/src/network_subgraph.rs index dea6818..4971a6e 100644 --- a/availability-oracle/src/network_subgraph.rs +++ b/availability-oracle/src/network_subgraph.rs @@ -66,7 +66,7 @@ struct GraphqlResponse { const DEPLOYMENTS_QUERY: &str = r#" query($threshold: BigInt!, $max_creation: Int!, $skip: Int!) { - subgraphDeployments(first: 1000, skip: $skip, where: { signalledTokens_gt: $threshold, createdAt_lt: $max_creation }) { + subgraphDeployments(first: 1000, skip: $skip, where: { id: "0x8ac6d590f88f1bd48f5f495b2a56f9a183f9b335d3d3a72807dbf2247c7ee558", signalledTokens_gt: $threshold, createdAt_lt: $max_creation }) { id stakedTokens deniedAt From cf0d9c7d66565a4d3aac685eb9ed59d9271680ac Mon Sep 17 00:00:00 2001 From: Miguel de Elias Date: Thu, 11 Apr 2024 11:23:44 -0300 Subject: [PATCH 3/3] fix: remote testing parameter from query --- availability-oracle/src/network_subgraph.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/availability-oracle/src/network_subgraph.rs b/availability-oracle/src/network_subgraph.rs index 4971a6e..dea6818 100644 --- a/availability-oracle/src/network_subgraph.rs +++ b/availability-oracle/src/network_subgraph.rs @@ -66,7 +66,7 @@ struct GraphqlResponse { const DEPLOYMENTS_QUERY: &str = r#" query($threshold: BigInt!, $max_creation: Int!, $skip: Int!) { - subgraphDeployments(first: 1000, skip: $skip, where: { id: "0x8ac6d590f88f1bd48f5f495b2a56f9a183f9b335d3d3a72807dbf2247c7ee558", signalledTokens_gt: $threshold, createdAt_lt: $max_creation }) { + subgraphDeployments(first: 1000, skip: $skip, where: { signalledTokens_gt: $threshold, createdAt_lt: $max_creation }) { id stakedTokens deniedAt