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

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

@nventuro

Description

@nventuro

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"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions