Merge pull request #2419 from filecoin-project/schomatis/fix/newtipset/mismatch-lengths

fix: NewTipSet: check mismatch in number of parents
This commit is contained in:
Łukasz Magiera 2020-07-15 17:49:39 +02:00 committed by GitHub
commit 6b9fd74f8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -112,6 +112,10 @@ func NewTipSet(blks []*BlockHeader) (*TipSet, error) {
return nil, fmt.Errorf("cannot create tipset with mismatching heights")
}
if len(blks[0].Parents) != len(b.Parents) {
return nil, fmt.Errorf("cannot create tipset with mismatching number of parents")
}
for i, cid := range b.Parents {
if cid != blks[0].Parents[i] {
return nil, fmt.Errorf("cannot create tipset with mismatching parents")