Skip to content

Commit 8dc17db

Browse files
committed
improved logs for Web3Advanced init testing of RPC capabilities
1 parent 9c39059 commit 8dc17db

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

IceCreamSwapWeb3/Web3Advanced.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ def __init__(
7070
self.rpc_batch_max_size = self._find_max_batch_size()
7171
self.revert_reason_available: bool = self._check_revert_reason_available()
7272
self.is_archive = self._check_is_archive()
73-
if not self.revert_reason_available:
74-
print(f"RPC {self.node_url} does not return revert reasons")
7573
self.overwrites_available: bool = self._check_overwrites_available()
7674
self.subsquid_available: bool = self._check_subsquid_available()
7775

@@ -132,9 +130,11 @@ def _find_max_filter_range(self) -> int:
132130
})
133131
assert result == []
134132
return filter_range
135-
except Exception:
136-
sleep(0.1)
137-
print(f"Can not use eth_getLogs with RPC {self.node_url}")
133+
except Exception as e:
134+
if filter_range == self.FILTER_RANGES_TO_TRY[-1]:
135+
print(f"Can not use eth_getLogs, got: {repr(e)}")
136+
else:
137+
sleep(0.1)
138138
return 0
139139

140140
def _find_max_batch_size(self) -> int:
@@ -148,8 +148,10 @@ def _find_max_batch_size(self) -> int:
148148
assert len(result) == batch_size
149149
working_size = batch_size
150150
sleep(0.1)
151-
except Exception:
152-
pass
151+
except Exception as e:
152+
if working_size == 0:
153+
print(f"RPC does not support batch requests, got: {repr(e)}")
154+
153155
return working_size
154156

155157
def _check_is_archive(self):
@@ -159,7 +161,8 @@ def _check_is_archive(self):
159161
"data": f"{0:064x}"
160162
}, block_identifier=1, no_retry=True)
161163
return True
162-
except Exception:
164+
except Exception as e:
165+
print(f"RPC does not support archive requests, got: {repr(e)}")
163166
return False
164167

165168
def _check_revert_reason_available(self):
@@ -173,11 +176,16 @@ def _check_revert_reason_available(self):
173176
"data": revert_tester_contract.constructor().data_in_transaction
174177
}, no_retry=True)
175178
# should revert, if not, reverts are useless
179+
print(f"RPC does not revert besides it should")
176180
return False
177181
except Exception as e:
178182
if not isinstance(e, ContractLogicError):
183+
print(f"RPC does not properly return revert reasons, got: {repr(e)}")
179184
return False
180-
return e.message == "execution reverted: abc"
185+
available = e.message == "execution reverted: abc"
186+
if not available:
187+
print(f"RPC does not return expected revert reasons, got: {repr(e)}")
188+
return available
181189

182190
def _check_overwrites_available(self) -> bool:
183191
with files("IceCreamSwapWeb3").joinpath("./abi/OverwriteTester.abi").open('r') as f:

0 commit comments

Comments
 (0)