dao: don't treat zero stateroot as valid during MPT init

Because it's not really valid and MPT state should be the same as if it was
initialized at height 0. Fixes #1870
This commit is contained in:
Roman Khimov 2021-04-19 12:39:43 +03:00
parent d8c8593410
commit bcc2d1bb8f

View file

@ -531,7 +531,11 @@ func (dao *Simple) InitMPT(height uint32, enableRefCount bool) error {
if err != nil {
return err
}
dao.MPT = mpt.NewTrie(mpt.NewHashNode(r.Root), enableRefCount, dao.Store)
var rootnode mpt.Node
if !r.Root.Equals(util.Uint256{}) { // some initial blocks can have root == 0 and it's not a valid root
rootnode = mpt.NewHashNode(r.Root)
}
dao.MPT = mpt.NewTrie(rootnode, enableRefCount, dao.Store)
return nil
}