flashbots / web3-flashbots

Web3.py plugin for using Flashbots' bundle APIs
https://pypi.org/project/flashbots/
MIT License
403 stars 210 forks source link

Web3py is detecting incorrect tx and causing simulations to fail #69

Closed davoice-321 closed 1 year ago

davoice-321 commented 1 year ago

Issue:

Simulator is failing due to incorrect nonce vs transaction.

Description

Tested web3py script using Flashbots code. Simulator consistently detects incorrect tx vs nonce across:

Over previous months (about 11 or 12 based on my read of the Discord), others have also seen this issue/problem, but no support/remediation has been provided.

Error Message

Simulating on block 16020691
Simulation error {'code': -32000, 'message': 'err: nonce too high: address XXXX, tx: 21 state: 20 ... 

Suggestion

davoice-321 commented 1 year ago

Did some additional debugging with the community.

Posting the solution here because others have encountered this problem.

When conducting transactions make sure that you are not sending 2 rather than 1 transaction in the bundle argument.

Like so:

bundle = [
                {"signed_transaction": signed_tx.rawTransaction}
            ]

Also, the nonce was set correctly in my case, but as a reminder. Get the latest nonce with this argument:

nonce = web3.eth.getTransactionCount(address)

Closing issue with this note so other can refer to it in the future.