initc3 / HoneyBadgerMPC

Robust MPC-based confidentiality layer for blockchains
GNU General Public License v3.0
131 stars 64 forks source link

Asynchromix app: TransactionNotFound error #394

Closed sbellem closed 4 years ago

sbellem commented 4 years ago

When trying out the AsynchroMix applications apps/asynchromix/asynchromix.py mentioned under Blockchain Integration in the README.md the following error occurs:

web3.exceptions.TransactionNotFound: Transaction with hash: b'\xa3=\x15+\xc8\xd48\xf0\xc8\xf2\xbd$W\x0e\xd8\xc6O\xa8\xce\x05R\x12(\xb5\xf3$\xd6\xf0\xba\x95\x069' not found.

The complete stack trace:

$ python apps/asynchromix/asynchromix.py

Failed to import bitcoin. This is not a fatal error but does
mean that you will not be able to determine the address from
your wallet file.
2019-11-07 19:43:16,482:[asynchromix.py:531]:[INFO]: Running ganache-cli -p 8545 -a 50 -b 1 > acctKeys.json 2>&1
2019-11-07 19:43:21,500:[asynchromix.py:517]:[INFO]: entering loop
2019-11-07 19:43:22,347:[asynchromix.py:520]:[INFO]: closing
2019-11-07 19:43:22,347:[asynchromix.py:505]:[INFO]: Killing ganache-cli 8
2019-11-07 19:43:22,347:[asynchromix.py:509]:[INFO]: done
Traceback (most recent call last):
  File "apps/asynchromix/asynchromix.py", line 539, in <module>
    test_asynchromix()
  File "apps/asynchromix/asynchromix.py", line 534, in test_asynchromix
    run_eth()
  File "apps/asynchromix/asynchromix.py", line 518, in run_eth
    loop.run_until_complete(asyncio.gather(main_loop(w3)))
  File "/usr/local/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "apps/asynchromix/asynchromix.py", line 464, in main_loop
    tx_receipt = await wait_for_receipt(w3, tx_hash)
  File "apps/asynchromix/asynchromix.py", line 39, in wait_for_receipt
    tx_receipt = w3.eth.getTransactionReceipt(tx_hash)
  File "/opt/venv/lib/python3.7/site-packages/web3/eth.py", line 274, in getTransactionReceipt
    raise TransactionNotFound(f"Transaction with hash: {transaction_hash} not found.")
web3.exceptions.TransactionNotFound: Transaction with hash: b'\xa3=\x15+\xc8\xd48\xf0\xc8\xf2\xbd$W\x0e\xd8\xc6O\xa8\xce\x05R\x12(\xb5\xf3$\xd6\xf0\xba\x95\x069' not found.
sbellem commented 4 years ago

Just need to handle TransactionNotFound exception, due to changes in web3 versions > 5.0.0:

async def wait_for_receipt(w3, tx_hash):
    while True:
        try:
            tx_receipt = w3.eth.getTransactionReceipt(tx_hash)
        except TransactionNotFound:
            tx_receipt = None
        if tx_receipt is not None:
            break
        await asyncio.sleep(5)
    return tx_receipt
sbellem commented 4 years ago

Fix was merged via #424.