Estimate gas at pending block to fix FailedToObtainBlockhash#507
Open
Estimate gas at pending block to fix FailedToObtainBlockhash#507
FailedToObtainBlockhash#507Conversation
Collaborator
|
Do we also need to remove the logic that waits for one slot before calling estimateGas? |
Collaborator
Author
Done. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR is another solution as an alternative to #506.
Rationale
The EVM specification requires that
BLOCKHASHcan only access the most recent 256 generated blocks, i.e.,[block.number - 256, block.number - 1], excluding the current block itself.eth_estimateGasexecutes in the context of the latest chain head blockNby default, soblock.number = N.If
BLOCKHASH(N)is called, sinceN >= block.number, it returns0.When explicitly using the
pendingblock tag, the execution context changes. In Geth,block.number = N + 1, i.e., the next block being constructed. Therefore,BLOCKHASH(N)becomes valid (sinceN = block.number - 1).In real execution, the transaction is included in block
N + k(wherek ≥ 1), soblock.number = N + k. In the common case wherek = 1, this matches thependingcontext.Tests
Tests have been performed on the local testnet using extra temporary debug messages to confirm that the mining tx is completed successfully in the case of mining and estimation occurring in the same slot.