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

@truffle/contract 'confirmation' listener cannot be configured #2560

Open
nventuro opened this issue Nov 5, 2019 · 4 comments
Open

@truffle/contract 'confirmation' listener cannot be configured #2560

nventuro opened this issue Nov 5, 2019 · 4 comments

Comments

@nventuro
Copy link

nventuro commented Nov 5, 2019

Issue

@truffle/contract registers a 'confirmation' event listener, which gets fired every time there is a new block until the number of requested confirmations is reached. The default number of confirmations is 24, and there is no way to configure this value from the outside.

This means that sending a transaction via a @truffle/contract object will spawn a Node timeout object that will not be removed until 24 confirmations arrive, blocking the event loop and preventing the process from exiting. This is not an issue in truffle test because the CLI calls process.exit() directly.

This also causes performance issues, since 25 receipts will be requested to the provider per transaction, while often (e.g. in testing environments) a single confirmation is sufficient.

It'd be great if @truffle/contract had an API exposing the number of confirmations it requires from web3 (probably at the contract abstraction creation level, so that all instances have this same value).

Additionally, both @truffle/contract and @truffle/interface-adapter should be upgraded to use web3 v1.2.2, which includes a fix for 'confirmation' events on HttpProviders.

Steps to Reproduce

Create a @truffle/contract object and send a transaction from it in a non-truffle environment (outside of truffle test or truffle exec), the process won't end until the contract receives 24 confirmations of the transaction being mined.

Environment

"@truffle/contract": "^4.0.38"

@gnidan
Copy link
Contributor

gnidan commented Nov 6, 2019

I'm in favor of making this configurable, if anyone wants to open a PR

@haltman-at
Copy link
Contributor

Can this be closed now that we have disableConfirmationListener, or does more need to be done here?

@eggplantzzz
Copy link
Contributor

There might be some work to be done if people still want to be able to configure the number of confirmations (I'm not sure if that is supported yet). Like if someone wanted to specify to wait for 5 confirmations, then maybe they should have this option. I'm not sure if the confirmations property under networks here solves this issue? https://www.trufflesuite.com/docs/truffle/reference/configuration#networks

@haltman-at
Copy link
Contributor

That just affects waiting for confirmations after deployments, if I understand correctly; it doesn't affect the confirmation listener more generally.

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

No branches or pull requests

4 participants