From 2d93accedf37bbbf5c8da880a60c9fd39d74c5dd Mon Sep 17 00:00:00 2001 From: Miguel de Elias Date: Wed, 10 Apr 2024 11:44:18 -0300 Subject: [PATCH 1/2] fix: remove fixed gas limit, use estiamted instead --- availability-oracle/src/contract.rs | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/availability-oracle/src/contract.rs b/availability-oracle/src/contract.rs index 26ca33a..cdb2392 100644 --- a/availability-oracle/src/contract.rs +++ b/availability-oracle/src/contract.rs @@ -94,13 +94,6 @@ impl SubgraphAvailabilityManagerContract { #[async_trait] impl StateManager for RewardsManagerContract { async fn deny_many(&self, denied_status: Vec<([u8; 32], bool)>) -> Result<(), Error> { - // Based on this gas profile data for `setDeniedMany`: - // gas-used,items - // 4517721,200 - // 2271420,100 - // 474431,20 - // 47642,1 - // // 100 is considered as a good chunk size. for chunk in denied_status.chunks(100) { let ids: Vec<[u8; 32usize]> = chunk.iter().map(|s| s.0).collect(); @@ -108,12 +101,10 @@ impl StateManager for RewardsManagerContract { let num_subgraphs = ids.len() as u64; let tx = self .contract - .set_denied_many(ids, statuses) - // To avoid gas estimation errors, we use a high enough gas limit for 100 items - .gas(ethers::core::types::U256::from(3_000_000u64)); + .set_denied_many(ids, statuses); if let Err(err) = tx.call().await { - let message = err.decode_revert::().unwrap(); + let message = err.decode_revert::().unwrap_or(err.to_string()); error!(self.logger, "Transaction failed"; "message" => message, ); @@ -130,13 +121,6 @@ impl StateManager for RewardsManagerContract { #[async_trait] impl StateManager for SubgraphAvailabilityManagerContract { async fn deny_many(&self, denied_status: Vec<([u8; 32], bool)>) -> Result<(), Error> { - // Based on this gas profile data for `setDeniedMany`: - // gas-used,items - // 4517721,200 - // 2271420,100 - // 474431,20 - // 47642,1 - // // 100 is considered as a good chunk size. for chunk in denied_status.chunks(100) { let ids: Vec<[u8; 32usize]> = chunk.iter().map(|s| s.0).collect(); @@ -145,12 +129,10 @@ impl StateManager for SubgraphAvailabilityManagerContract { let oracle_index = U256::from(self.oracle_index); let tx = self .contract - .vote_many(ids, statuses, oracle_index) - // To avoid gas estimation errors, we use a high enough gas limit for 100 items - .gas(U256::from(3_000_000u64)); + .vote_many(ids, statuses, oracle_index); if let Err(err) = tx.call().await { - let message = err.decode_revert::().unwrap(); + let message = err.decode_revert::().unwrap_or(err.to_string()); error!(self.logger, "Transaction failed"; "message" => message, ); From fd5b5d8103eb0d85b5437f292822ab7efaac7f23 Mon Sep 17 00:00:00 2001 From: Miguel de Elias Date: Wed, 10 Apr 2024 11:47:11 -0300 Subject: [PATCH 2/2] fix: fmt errors --- availability-oracle/src/contract.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/availability-oracle/src/contract.rs b/availability-oracle/src/contract.rs index cdb2392..450516c 100644 --- a/availability-oracle/src/contract.rs +++ b/availability-oracle/src/contract.rs @@ -99,9 +99,7 @@ impl StateManager for RewardsManagerContract { let ids: Vec<[u8; 32usize]> = chunk.iter().map(|s| s.0).collect(); let statuses: Vec = chunk.iter().map(|s| s.1).collect(); let num_subgraphs = ids.len() as u64; - let tx = self - .contract - .set_denied_many(ids, statuses); + 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()); @@ -127,9 +125,7 @@ impl StateManager for SubgraphAvailabilityManagerContract { let statuses: Vec = chunk.iter().map(|s| s.1).collect(); let num_subgraphs = ids.len() as u64; let oracle_index = U256::from(self.oracle_index); - let tx = self - .contract - .vote_many(ids, statuses, 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());