core: do not hash header if header is still changing #462
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.
Description
In the block-building code (triggered by
miner
packagecommitTransaction
, which is used by engine-API) it runs this code-path where every time a transaction is applied, it takes the template block-header and re-encodes and hashes it.This same function is also used by the op-program version of the engine-API.
This is inefficient in the same way in upstream L1 geth block-building code too.
One way to temporay-fix it, is to not compute the block-hash, when the state-root is still not set. A zero state-root implies that the block-building is not done.
This is a temporary fix. Ideally we improve the geth block-building API, so it's not running into this thing to begin with. Constructing receipts on the way is one thing, but trying to hydrate the metadata before the block is even finished is just bad.
This PR is a draft to help track this optimization until upstream block-building is improved.