This repository has been archived by the owner on Sep 26, 2019. It is now read-only.
Unwrap DelegatingBytes32 and prevent Hash from wrapping other Hash instances #1423
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.
PR description
When blocks are generated without any change to the world state (only possible with empty blocks in Clique or IBFT where there's no block reward), the world state root hash was being repeatedly wrapped in a new
Hash
instance until eventually it triggered a stack overflow. The sameHash
instance survives because the actualBlockHeader
instance is cached by the blockchain and the state root hash round trips through the block creator, world state Merkle trie entirely unchanged except for being wrapped an additional time.Fix is to apply the same
unwrap
process toDelegatingBytes32
as already existed inDelegatingBytesValue
. To save creating a new object at all a check has also been added toHash.wrap
so that it just casts the existing value if it's already aHash
.