Skip to content

Commit

Permalink
Multithreading nonce fix (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
volod-vana authored Dec 17, 2024
1 parent f46ebae commit 79f1bdb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "vana"
version = "0.36.0"
version = "0.37.0"
description = ""
authors = ["Tim Nunamaker <[email protected]>", "Volodymyr Isai <[email protected]>", "Kahtaf Alam <[email protected]>"]
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion vana/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

__version__ = "0.36.0"
__version__ = "0.37.0"

import rich

Expand Down
17 changes: 11 additions & 6 deletions vana/chain_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,20 @@ def state(

return state_

def send_transaction(self, function: ContractFunction, account: LocalAccount, value=0, max_retries=3,
base_gas_multiplier=1.5):
def send_transaction(self,
function: ContractFunction,
account: LocalAccount,
value=0,
max_retries=3,
base_gas_multiplier=1.5,
tx_manager=None
):
"""
Send a transaction using the TransactionManager
"""
"""
Send a transaction using the TransactionManager
"""
tx_manager = TransactionManager(self.web3, account)
if tx_manager is None:
# Create new TransactionManager only if not provided
tx_manager = TransactionManager(self.web3, account)
return tx_manager.send_transaction(
function=function,
value=self.web3.to_wei(value, 'ether'),
Expand Down
9 changes: 8 additions & 1 deletion vana/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Optional
from vana.chain_data import Proof, ProofData
from vana.contracts import contracts
from vana.utils.transaction import TransactionManager
from vana.utils.web3 import as_wad


Expand Down Expand Up @@ -47,6 +48,7 @@ def __init__(self, config: vana.Config):
self.wallet = vana.Wallet(config=self.config)
self.chain_manager = vana.ChainManager(config=self.config)
self.network = self.config.chain.network
self.tx_manager = TransactionManager(self.chain_manager.web3, self.wallet.hotkey)

# Load contracts
data_registry_contract_path = os.path.join(
Expand Down Expand Up @@ -172,7 +174,12 @@ def add_proof(self, proof_data: ProofData, file_id: int | None = None, job_id: i
add_proof_fn = self.data_registry_contract.functions.addProof(file_id, proof_tuple)
else:
add_proof_fn = self.tee_pool_contract.functions.addProof(job_id, proof_tuple)
return self.chain_manager.send_transaction(add_proof_fn, self.wallet.hotkey)
return self.tx_manager.send_transaction(
function=add_proof_fn,
value=0,
max_retries=3,
base_gas_multiplier=1.5
)

def claim(self):
"""
Expand Down

0 comments on commit 79f1bdb

Please sign in to comment.