ganache
ganache copied to clipboard
Add something like hardhat's `evm_setAutomine`
User request: https://twitter.com/DerekBarrera/status/1483187817182375941?s=20
Seems like HH's "automine" is the same as Ganache's "instamine"? (albeit without eager/strict differentiation ;)
Is the ask here, then, to provide a means by which users can switch mining modes while the application is running?
Just chirping up to say that I am in the process of writing a test where I would very much like this. A large amount of setup (which I'm happy with and indeed want eager for speed purposes), but then needing strict to reproduce the behaviour I would like to test.
@area , eager isn't actually faster than strict (it should be negligibly slower).
The problem stems from using an HTTP provider instead of WebSockets, which must use polling. But even if WebSockets is used, if the library that sends the transaction doesn't eth_subscribe and provider.on("message", ...) immediately before the transaction is sent, it will fall back to polling.
While in strict mode Ganache does returns the transaction hash and then/simultaneously "mines" the transaction, but it mines it so quickly that if the caller eth_subscribes after sending the transaction it is often too late, and the subscription message won't be received since it has already been broadcast.
Possible workaround: while waiting for this feature you can roughly reproduce "strict" mode behavior while in eager mode by calling miner_stop, eth_sendTransaction, and then miner_start once the hash has been received. Obviously this isn't ideal when using Web3 to send the transaction, as you'll have to do some gymnastics with the web3 PromiEvent, so we'll take your requests for altering the instamine mode via evm_setAutomine (or a similar method, since we probably need to clone HH's RPC signature for this one) when we do implement this feature.