Skip to content

Commit d7937ce

Browse files
authored
Merge pull request #14 from graphprotocol/mde/remove-fixed-gas-limit
fix: remove fixed gas limit, use estimated instead
2 parents d933a19 + fd5b5d8 commit d7937ce

File tree

1 file changed

+4
-26
lines changed

1 file changed

+4
-26
lines changed

availability-oracle/src/contract.rs

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -94,26 +94,15 @@ impl SubgraphAvailabilityManagerContract {
9494
#[async_trait]
9595
impl StateManager for RewardsManagerContract {
9696
async fn deny_many(&self, denied_status: Vec<([u8; 32], bool)>) -> Result<(), Error> {
97-
// Based on this gas profile data for `setDeniedMany`:
98-
// gas-used,items
99-
// 4517721,200
100-
// 2271420,100
101-
// 474431,20
102-
// 47642,1
103-
//
10497
// 100 is considered as a good chunk size.
10598
for chunk in denied_status.chunks(100) {
10699
let ids: Vec<[u8; 32usize]> = chunk.iter().map(|s| s.0).collect();
107100
let statuses: Vec<bool> = chunk.iter().map(|s| s.1).collect();
108101
let num_subgraphs = ids.len() as u64;
109-
let tx = self
110-
.contract
111-
.set_denied_many(ids, statuses)
112-
// To avoid gas estimation errors, we use a high enough gas limit for 100 items
113-
.gas(ethers::core::types::U256::from(3_000_000u64));
102+
let tx = self.contract.set_denied_many(ids, statuses);
114103

115104
if let Err(err) = tx.call().await {
116-
let message = err.decode_revert::<String>().unwrap();
105+
let message = err.decode_revert::<String>().unwrap_or(err.to_string());
117106
error!(self.logger, "Transaction failed";
118107
"message" => message,
119108
);
@@ -130,27 +119,16 @@ impl StateManager for RewardsManagerContract {
130119
#[async_trait]
131120
impl StateManager for SubgraphAvailabilityManagerContract {
132121
async fn deny_many(&self, denied_status: Vec<([u8; 32], bool)>) -> Result<(), Error> {
133-
// Based on this gas profile data for `setDeniedMany`:
134-
// gas-used,items
135-
// 4517721,200
136-
// 2271420,100
137-
// 474431,20
138-
// 47642,1
139-
//
140122
// 100 is considered as a good chunk size.
141123
for chunk in denied_status.chunks(100) {
142124
let ids: Vec<[u8; 32usize]> = chunk.iter().map(|s| s.0).collect();
143125
let statuses: Vec<bool> = chunk.iter().map(|s| s.1).collect();
144126
let num_subgraphs = ids.len() as u64;
145127
let oracle_index = U256::from(self.oracle_index);
146-
let tx = self
147-
.contract
148-
.vote_many(ids, statuses, oracle_index)
149-
// To avoid gas estimation errors, we use a high enough gas limit for 100 items
150-
.gas(U256::from(3_000_000u64));
128+
let tx = self.contract.vote_many(ids, statuses, oracle_index);
151129

152130
if let Err(err) = tx.call().await {
153-
let message = err.decode_revert::<String>().unwrap();
131+
let message = err.decode_revert::<String>().unwrap_or(err.to_string());
154132
error!(self.logger, "Transaction failed";
155133
"message" => message,
156134
);

0 commit comments

Comments
 (0)