vana
Advanced tools
+2
-3
@@ -1,6 +0,5 @@ | ||
| Metadata-Version: 2.1 | ||
| Metadata-Version: 2.3 | ||
| Name: vana | ||
| Version: 0.41.0 | ||
| Version: 0.42.0 | ||
| Summary: | ||
| Home-page: https://github.com/vana-com/vana-framework | ||
| Author: Tim Nunamaker | ||
@@ -7,0 +6,0 @@ Author-email: tim@vana.com |
+1
-1
| [tool.poetry] | ||
| name = "vana" | ||
| version = "0.41.0" | ||
| version = "0.42.0" | ||
| description = "" | ||
@@ -5,0 +5,0 @@ authors = ["Tim Nunamaker <tim@vana.com>", "Volodymyr Isai <volod@vana.com>", "Kahtaf Alam <kahtaf@vana.com>"] |
+1
-1
@@ -18,3 +18,3 @@ # The MIT License (MIT) | ||
| __version__ = "0.41.0" | ||
| __version__ = "0.42.0" | ||
@@ -21,0 +21,0 @@ import rich |
@@ -52,3 +52,3 @@ import json | ||
| if network not in contracts: | ||
| network = "satori" | ||
| network = "vana" | ||
@@ -55,0 +55,0 @@ for contract_name, contract_hash in contracts[network].items(): |
@@ -37,20 +37,32 @@ from threading import Lock | ||
| # Start with current gas price and use increasing multiplier for each retry | ||
| base_gas_price = self.web3.eth.gas_price | ||
| gas_multiplier = 5 # Higher initial multiplier to ensure replacement | ||
| # Send replacement transactions with higher gas price | ||
| for nonce in range(confirmed_nonce, pending_nonce): | ||
| replacement_tx = { | ||
| 'from': self.account.address, | ||
| 'to': self.account.address, | ||
| 'value': 0, | ||
| 'nonce': nonce, | ||
| 'gas': eth_transfer_gas, | ||
| 'gasPrice': self.web3.eth.gas_price * 4, | ||
| 'chainId': self.chain_id | ||
| } | ||
| # For each failed attempt, increase the multiplier | ||
| for attempt in range(3): # Try up to 3 times with increasing gas price | ||
| replacement_tx = { | ||
| 'from': self.account.address, | ||
| 'to': self.account.address, | ||
| 'value': 0, | ||
| 'nonce': nonce, | ||
| 'gas': eth_transfer_gas, | ||
| 'gasPrice': int(base_gas_price * (gas_multiplier + attempt * 2)), # Increase gas price on each attempt | ||
| 'chainId': self.chain_id | ||
| } | ||
| signed_tx = self.web3.eth.account.sign_transaction(replacement_tx, self.account.key) | ||
| try: | ||
| tx_hash = self.web3.eth.send_raw_transaction(signed_tx.rawTransaction) | ||
| vana.logging.info(f"Sent replacement transaction for nonce {nonce}: {tx_hash.hex()}") | ||
| except Exception as e: | ||
| vana.logging.warning(f"Failed to replace transaction with nonce {nonce}: {str(e)}") | ||
| try: | ||
| signed_tx = self.web3.eth.account.sign_transaction(replacement_tx, self.account.key) | ||
| tx_hash = self.web3.eth.send_raw_transaction(signed_tx.rawTransaction) | ||
| vana.logging.info(f"Sent replacement transaction for nonce {nonce}: {tx_hash.hex()}") | ||
| break # Success, break the retry loop | ||
| except Exception as e: | ||
| if 'replacement transaction underpriced' in str(e) and attempt < 2: | ||
| vana.logging.warning(f"Attempt {attempt+1}: Transaction with nonce {nonce} needs higher gas price: {str(e)}") | ||
| continue # Try again with higher gas price | ||
| else: | ||
| vana.logging.warning(f"Failed to replace transaction with nonce {nonce}: {str(e)}") | ||
| break # Give up on this nonce after max attempts or different error | ||
@@ -99,3 +111,3 @@ # Wait for transactions to be processed by monitoring the latest nonce | ||
| timeout: int = 30, | ||
| clear_pending_transactions: bool = False | ||
| max_pending_transactions: int = 10 | ||
| ) -> Tuple[HexBytes, TxReceipt]: | ||
@@ -114,3 +126,3 @@ """ | ||
| timeout: Timeout in seconds to wait for transaction receipt (default: 30) | ||
| clear_pending_transactions: Attempt to clear pending transactions before sending (default: False) | ||
| max_pending_transactions: Clear transactions when pending count exceeds this threshold; set to 0 to disable (default: 10) | ||
@@ -125,9 +137,11 @@ Returns: | ||
| """ | ||
| if clear_pending_transactions: | ||
| pending_count = (self.web3.eth.get_transaction_count(self.account.address, 'pending') - | ||
| self.web3.eth.get_transaction_count(self.account.address, 'latest')) | ||
| if pending_count > 0: | ||
| vana.logging.warning(f"Found {pending_count} pending transactions, attempting to clear...") | ||
| self._clear_pending_transactions() | ||
| # Check for a gap between pending and latest nonce | ||
| pending_count = (self.web3.eth.get_transaction_count(self.account.address, 'pending') - | ||
| self.web3.eth.get_transaction_count(self.account.address, 'latest')) | ||
| # Clear pending transactions if count exceeds threshold (disable by setting threshold to 0) | ||
| if max_pending_transactions > 0 and pending_count > max_pending_transactions: | ||
| vana.logging.warning(f"Found {pending_count} pending transactions (threshold: {max_pending_transactions}), attempting to clear...") | ||
| self._clear_pending_transactions() | ||
| retry_count = 0 | ||
@@ -134,0 +148,0 @@ last_error = None |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
457104
0.26%12259
0.1%