openzeppelin-test-helpers icon indicating copy to clipboard operation
openzeppelin-test-helpers copied to clipboard

Gas price is zero for 0.08 eth send (EIP1820)

Open mrwillis opened this issue 5 years ago • 4 comments

In send.js as part of the EIP1820 deploy steps:

function ether (from, to, value) {
  return web3.eth.sendTransaction({ from, to, value, gasPrice: 0 });
}

The gas price here is hardcoded. I'm on a chain where I require non-zero gas price. Can this be configurable?

mrwillis avatar Oct 17 '19 15:10 mrwillis

Thank you for reporting @mrwillis!

We can definitely change this, it was kind of crazy to hardcode 0 there. The reason we use gasPrice: 0 sometimes is because it makes it easier to test changes in an account's balance. I wonder if we can make balance.tracker smarter so that it can account for gas itself... or perhaps that would be too smart for a test helper.

Regardless, a couple options that come to mind: 1) add a gasPrice argument to ether and to ERC1820Registry as well as anything that uses send.ether, 2) add a gasPrice option to configure. @nventuro What do you think?

@mrwillis Can you also tell us a bit more about your use case? What chain are you working with? Are you using the library for testing your contracts or something else?

frangio avatar Oct 17 '19 16:10 frangio

Using it to deploy EIP1820 on a sidechain with non-zero gas price (to prevent spam). I'm deploying ERC777 contracts on the sidechain and need the EIP1820 registry to get everything to work properly.

mrwillis avatar Oct 17 '19 17:10 mrwillis

Hm, to be honest I had not considered the case of using singletons to deploy to sidechains. The requirement to have a non-zero gasPrice is valid however.

I worry that send receiving it will make the interface leaky due to us having to bubble it up in multiple callsites, such as singletons, so while I'm usually against global variables/configuration, it may make sense here.

Note that send.ether returns a transaction receipt, so it is easy to compute gas * gasPrice when calculating balances, though not ideal.

nventuro avatar Oct 18 '19 00:10 nventuro

Would global configuration suffice without each helper having the option to override it? I feel like this may be opening a can of worms. We should experiment a bit and see how things work with that change.

frangio avatar Oct 18 '19 02:10 frangio