Avoid generating genesis state in blockchain test runner #536
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
blockchain tests don't need to generate the gensis state as they come with their own
pre
world state. Avoiding this extra generation resulted in the duration ofnpm run testBlockchain
going from 17m down to 2m on my local machine 😁This is done via a trick:
runBlockchain
generates the genesis state when current state root doesn't match with the genesis state's root. So I manually manipulatevm._common.genesis().stateRoot
to avoid generating the state.I checked the source code, and this shouldn't have a side-effect (
common.genesis().stateRoot
doesn't seem to be used elsewhere). But still this is a trick and ideallyrunBlockchain
would accept an option to disable generating genesis state (which would be a breaking change because it changes the parameter ordering, so I didn't go for it).