Skip to content

Commit 2d93acc

Browse files
committed
fix: remove fixed gas limit, use estiamted instead
1 parent d933a19 commit 2d93acc

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

availability-oracle/src/contract.rs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -94,26 +94,17 @@ 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;
109102
let tx = self
110103
.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));
104+
.set_denied_many(ids, statuses);
114105

115106
if let Err(err) = tx.call().await {
116-
let message = err.decode_revert::<String>().unwrap();
107+
let message = err.decode_revert::<String>().unwrap_or(err.to_string());
117108
error!(self.logger, "Transaction failed";
118109
"message" => message,
119110
);
@@ -130,13 +121,6 @@ impl StateManager for RewardsManagerContract {
130121
#[async_trait]
131122
impl StateManager for SubgraphAvailabilityManagerContract {
132123
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-
//
140124
// 100 is considered as a good chunk size.
141125
for chunk in denied_status.chunks(100) {
142126
let ids: Vec<[u8; 32usize]> = chunk.iter().map(|s| s.0).collect();
@@ -145,12 +129,10 @@ impl StateManager for SubgraphAvailabilityManagerContract {
145129
let oracle_index = U256::from(self.oracle_index);
146130
let tx = self
147131
.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));
132+
.vote_many(ids, statuses, oracle_index);
151133

152134
if let Err(err) = tx.call().await {
153-
let message = err.decode_revert::<String>().unwrap();
135+
let message = err.decode_revert::<String>().unwrap_or(err.to_string());
154136
error!(self.logger, "Transaction failed";
155137
"message" => message,
156138
);

0 commit comments

Comments
 (0)