From 514a6b014b86bd8793846553d76bc344f2ac817b Mon Sep 17 00:00:00 2001 From: bout3fiddy <11488427+bout3fiddy@users.noreply.github.com> Date: Wed, 25 Oct 2023 12:57:20 +0200 Subject: [PATCH 1/2] catch missing baseFee --- boa/network.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/boa/network.py b/boa/network.py index f8e87ebe..ce75082d 100644 --- a/boa/network.py +++ b/boa/network.py @@ -156,7 +156,7 @@ def get_gas_price(self) -> int: return self._gas_price return to_int(self._rpc.fetch("eth_gasPrice", [])) - def get_fee_info(self) -> tuple[str, str, str, str]: + def estimate_eip1559_fee(self) -> tuple[str, str, str, str]: # returns: base_fee, max_fee, max_priority_fee reqs = [ ("eth_getBlockByNumber", ["pending", False]), @@ -367,11 +367,11 @@ def _send_txn(self, from_, to=None, gas=None, value=None, data=None): try: # eip-1559 txn - base_fee, max_priority_fee, max_fee, chain_id = self.get_fee_info() + base_fee, max_priority_fee, max_fee, chain_id = self.estimate_eip1559_fee() tx_data["maxPriorityFeePerGas"] = max_priority_fee tx_data["maxFeePerGas"] = max_fee tx_data["chainId"] = chain_id - except RPCError: + except (RPCError, KeyError): tx_data["gasPrice"] = to_hex(self.get_gas_price()) tx_data["nonce"] = self._get_nonce(from_) From c68148c9b8dcca75ef5c774bfe221cdb9b4370b1 Mon Sep 17 00:00:00 2001 From: bout3fiddy <11488427+bout3fiddy@users.noreply.github.com> Date: Wed, 25 Oct 2023 13:23:06 +0200 Subject: [PATCH 2/2] add chainId to static fee info --- boa/network.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/boa/network.py b/boa/network.py index ce75082d..bafb38f4 100644 --- a/boa/network.py +++ b/boa/network.py @@ -156,7 +156,7 @@ def get_gas_price(self) -> int: return self._gas_price return to_int(self._rpc.fetch("eth_gasPrice", [])) - def estimate_eip1559_fee(self) -> tuple[str, str, str, str]: + def get_eip1559_fee(self) -> tuple[str, str, str, str]: # returns: base_fee, max_fee, max_priority_fee reqs = [ ("eth_getBlockByNumber", ["pending", False]), @@ -175,6 +175,9 @@ def estimate_eip1559_fee(self) -> tuple[str, str, str, str]: max_fee = to_hex(base_fee_estimate + to_int(max_priority_fee)) return to_hex(base_fee_estimate), max_priority_fee, max_fee, chain_id + def get_static_fee(self) -> tuple[str, str]: + return self._rpc.fetch_multi([("eth_gasPrice", []), ("eth_chainId", [])]) + def _check_sender(self, address): if address is None: raise ValueError("No sender!") @@ -367,12 +370,14 @@ def _send_txn(self, from_, to=None, gas=None, value=None, data=None): try: # eip-1559 txn - base_fee, max_priority_fee, max_fee, chain_id = self.estimate_eip1559_fee() + (base_fee, max_priority_fee, max_fee, chain_id) = self.get_eip1559_fee() tx_data["maxPriorityFeePerGas"] = max_priority_fee tx_data["maxFeePerGas"] = max_fee tx_data["chainId"] = chain_id except (RPCError, KeyError): - tx_data["gasPrice"] = to_hex(self.get_gas_price()) + gas_price, chain_id = self.get_static_fee() + tx_data["gasPrice"] = gas_price + tx_data["chainId"] = chain_id tx_data["nonce"] = self._get_nonce(from_)