diff --git a/src/dexorder/base/account.py b/src/dexorder/base/account.py index d0a91ef..4bc4b32 100644 --- a/src/dexorder/base/account.py +++ b/src/dexorder/base/account.py @@ -62,6 +62,7 @@ class Account (LocalAccount): Account._all.append(account) metric.account_available.set(Account._pool.qsize()) metric.account_total.set(len(Account._all)) + log.info(f'Account pool {[a.address for a in Account._all]}') def __init__(self, local_account: LocalAccount): # todo chain_id? super().__init__(local_account._key_obj, local_account._publicapi) # from digging into the source code diff --git a/src/dexorder/transactions.py b/src/dexorder/transactions.py index 5fb8686..5ad41fc 100644 --- a/src/dexorder/transactions.py +++ b/src/dexorder/transactions.py @@ -108,7 +108,11 @@ async def create_and_send_transactions(): if account is None: warningAlert(f'No account available for job {job.id} type "{handler.tag}"', 'no account available') continue - await ctx.sign(account) + try: + await ctx.sign(account) + except Exception: + await handler.release_account(account) + raise log.info(f'servicing job {job.request.__class__.__name__} {job.id} with account {account.address} nonce {ctx.tx["nonce"]} tx {ctx.id}') # noinspection PyBroadException try: @@ -121,6 +125,7 @@ async def create_and_send_transactions(): if msg.startswith('nonce too low'): # Nonce too low log.warning(f'Account {account.address} nonce too low') + log.info(f'Account nonce is {account._nonce} ({ctx.tx["nonce"]}) but should be {await current_w3.get().eth.get_transaction_count(account.address, 'pending')}') account.reset_nonce() elif msg.startswith('insufficient funds'): warningAlert('Account Empty', f'Account {account.address} is out of funds!')