Fix bug parent hash on BlockV2 upgrade#570
Conversation
The current PR changes the meaning of parent hash though. For the majority of Ethereum dapps, it just shouldn't matter at all, and we can set the parent hash to even I'd prefer you change this PR to a runtime migration (decode
This bug could have been detected if Substrate wasn't silently failing on those should-be-panic cases. It's essentially a migration bug. With above we could have prevented it together with |
|
I agree that runtime migration is preferable. @sorpaas for visibility, as we talked:
That's not the case, as |
|
@sorpaas added the migration functions. I still think reading |
|
Please pull master. |
# Conflicts: # frame/ethereum/src/lib.rs
* Fix bug parent hash on `BlockV2` upgrade * BlockV0 -> BlockV2 migration utility functions
* Fix bug parent hash on `BlockV2` upgrade * BlockV0 -> BlockV2 migration utility functions
This bug can be reproduced after storage upgrade from
BlockV0toBlockV2, and only if the preceding block contained transactions. In that case thecurrent_block_hashfunction will try to decodeBlockV2, failing to do so because the block containsTransactionV0s and returningNone, defaulting toH256::default(), rendering the parent hash useless and of course messing the block hashing of the subsequent blocks.This PR proposes just use the already existing
BlockHashstorage and query it using the previous block number.This is a pretty nasty bug and should merged in asap @sorpaas . Also, do you have any suggestion on how to test this type of situation in frontier?