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

evm_mine is with thousands of blocks is way too slow #4409

Open
ianrowan opened this issue May 17, 2023 · 3 comments
Open

evm_mine is with thousands of blocks is way too slow #4409

ianrowan opened this issue May 17, 2023 · 3 comments

Comments

@ianrowan
Copy link

Issue

While running the latest version of ganache running in GitHub actions and using the evm_mine with blocks param sometimes does not advance the specified amount of blocks.

Evidence and Usage

Block advancement is currently executed as follows:

 await axios.post(
    providerUrl,
    {
      jsonrpc: '2.0',
      id: 1,
      method: 'evm_mine',
      params: [{ blocks: blocks }],
    },
    {
      headers: {
        'Content-Type': 'application/json',
      },
    }
  );

A typical amount of blocks to advance would be ~27000. Block number is then polled until it reaches expected blocks number before moving to next step in tests. An example of the output after polling for 120 secs is:
image
And block reached before timing out
image
Not this is only ~130 blocks

Ganache is run with the the following config
--fork --miner.blockTime 12

@davidmurdoch
Copy link
Member

davidmurdoch commented May 17, 2023

Hm, I couldn't reproduce.

I ran ganache:

ganache --fork --miner.blockTime 12

and then ran these curl commands:

curl -X post --data '{"jsonrpc":"2.0","id":1,"method":"evm_mine","params":[{"blocks":27000}]}' http://localhost:8545 && curl -X post --data '{"jsonrpc":"2.0","id":1,"method":"eth_blockNumber","params":[]}' http://localhost:8545

and the block number advanced 27000 blocks as expected.

I wonder if there is another bug related to #3248 lurking here.

@ianrowan
Copy link
Author

Hey @davidmurdoch,
It may be difficult to reproduce as it occurs variably, I think the blocks are being mined but the call is taking varying amounts of time, sometimes very long(> 60s). The only reason for the failure is a timeout we have set up. So problem isnt exactly that the blocks arent being mined but the performance

And re: #3248 I believe we are properly awaiting everything and should have a single evm_mine call active at any given time.

@davidmurdoch
Copy link
Member

Ah ok, in that case this is certainly related to the TODO in the code that mines the blocks:

// TODO(perf): add an option to mine a bunch of blocks in a batch so
// we can save them all to the database in one go.
// Developers like to move the blockchain forward by thousands of blocks
// at a time and doing this would make it way faster

@davidmurdoch davidmurdoch changed the title evm_mine does not consistently advance the total # of blocks evm_mine is with thousands of blocks is way too slow May 17, 2023
@github-project-automation github-project-automation bot moved this to Inbox in Ganache May 17, 2023
@davidmurdoch davidmurdoch moved this from Inbox to Backlog in Ganache May 17, 2023
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

2 participants