From 21ffe188f452e2eb59452ea6adcf462052de935f Mon Sep 17 00:00:00 2001 From: Lucas Molas Date: Wed, 15 Jul 2020 08:17:50 -0300 Subject: [PATCH] fix: NewTipSet: check mismatch in number of parents --- chain/types/tipset.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/chain/types/tipset.go b/chain/types/tipset.go index 09483dc5e..57ab91787 100644 --- a/chain/types/tipset.go +++ b/chain/types/tipset.go @@ -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")