Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Transaction can't be replaced, mining has already started #2680

Closed
teknoxic opened this issue Mar 23, 2022 · 2 comments
Closed

Transaction can't be replaced, mining has already started #2680

teknoxic opened this issue Mar 23, 2022 · 2 comments

Comments

@teknoxic
Copy link

Hi,

ganache v7.0.2 (@ganache/cli: 0.1.3, @ganache/core: 0.1.3)
node v14.10.0
Ubuntu 20 Sever

I'm building an ERC20 token DEX, i'm currently using ganache, it uses an order book system. Everything works well, but when i make multiple transactions within a quick succession i get the following error:

Error: Returned error: transaction can't be replaced, mining has already started. (please open an issue with reproduction steps: https://github.com/trufflesuite/ganache/issues/new)
    at Object.ErrorResponse (/opt/backend2/node_modules/web3-core-helpers/lib/errors.js:28:19)
    at /opt/backend2/node_modules/web3-core-requestmanager/lib/index.js:302:36
    at XMLHttpRequest.request.onreadystatechange (/opt/backend2/node_modules/web3-providers-http/lib/index.js:98:13)
    at XMLHttpRequestEventTarget.dispatchEvent (/opt/backend2/node_modules/xhr2-cookies/dist/xml-http-request-event-target.js:34:22)
    at XMLHttpRequest._setReadyState (/opt/backend2/node_modules/xhr2-cookies/dist/xml-http-request.js:208:14)
    at XMLHttpRequest._onHttpResponseEnd (/opt/backend2/node_modules/xhr2-cookies/dist/xml-http-request.js:318:14)
    at IncomingMessage.<anonymous> (/opt/backend2/node_modules/xhr2-cookies/dist/xml-http-request.js:289:61)
    at IncomingMessage.emit (node:events:402:35)
    at endReadableNT (node:internal/streams/readable:1343:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

The error doesn't appear on ganache-cli itself, it appears on my backend script that sends transactions to ganache, I would guess that ganache is returning this error because it thinks the transactions are the same.

any idea what could be causing this problem and how to fix?

@davidmurdoch
Copy link
Member

Probably a duplicate of #2509. We're working on a fix. In the meantime you may be able to work around this race condition if you can keep track of account nonces locally and set the nonce property on the transactions before sending to ganache.

@haltman-at
Copy link
Contributor

Closing for now as probable duplicate of #2509, but @teknoxic if you have more info that gives us reason to think this is different we can perhaps reopen this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants