Skip to content

Race condition exception in wait_for_transaction_receipt #443

@paultiplady

Description

@paultiplady
  • Populus Version: 2.2.0
  • OS: osx

What was wrong?

When deploying a contract to Rinkeby, and immediately starting a wait for the transaction receipt, an exception is raised:

gateway/contract/tests/e2e/e2e_test_deploy.py:9 (test_deploy)
gateway/contract/tests/e2e/e2e_test_deploy.py:36: in test_deploy
    contract_address = chain.wait.for_contract_address(deploy_tx_hash)
../../.virtualenvs/ethereum-xPw_EAxE/lib/python3.5/site-packages/populus/wait.py:33: in for_contract_address
    txn_receipt = self.for_receipt(txn_hash, **kwargs)
../../.virtualenvs/ethereum-xPw_EAxE/lib/python3.5/site-packages/populus/wait.py:47: in for_receipt
    return wait_for_transaction_receipt(self.web3, txn_hash, **kwargs)
../../.virtualenvs/ethereum-xPw_EAxE/lib/python3.5/site-packages/populus/utils/wait.py:94: in wait_for_transaction_receipt
    poll_interval_fn=lambda: poll_interval if poll_interval is not None else random.random(),
../../.virtualenvs/ethereum-xPw_EAxE/lib/python3.5/site-packages/populus/utils/wait.py:77: in poll_until
    value = poll_fn()
../../.virtualenvs/ethereum-xPw_EAxE/lib/python3.5/site-packages/web3/eth.py:192: in getTransactionReceipt
    [transaction_hash],
../../.virtualenvs/ethereum-xPw_EAxE/lib/python3.5/site-packages/web3/manager.py:96: in request_blocking
    raise ValueError(response["error"])
E   ValueError: {'code': -32000, 'message': 'unknown transaction'}

The code in question is:

Token = chain.provider.get_contract_factory('Token')
deploy_tx_hash = Token.deploy(
    transaction={
        'from': owner,
    },
    kwargs={
        'totalSupply': 1000,
        'name': 'TestToken',
    },
)
contract_address = chain.wait.for_contract_address(deploy_tx_hash)

If I insert a sleep(60) or sit in the debugger until the txn has committed on Etherscan, the call succeeds.

The exception is being raised from here: https://github.com/ethereum/web3.py/blob/master/web3/manager.py#L102

Looks like wait_for_transaction_receipt should perhaps handle exceptions generated in web3.py?

https://github.com/ethereum/populus/blob/master/populus/utils/wait.py#L89-L95

Cute Animal Picture

put a cute animal picture here.
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions