diff --git a/chain/sync.go b/chain/sync.go index ccc52cf57..66bb8318c 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -349,6 +349,10 @@ func zipTipSetAndMessages(bs cbor.IpldStore, ts *types.TipSet, allbmsgs []*types fts := &store.FullTipSet{} for bi, b := range ts.Blocks() { + if msgc := len(bmi[bi]) + len(smi[bi]); msgc > build.BlockMessageLimit { + return nil, fmt.Errorf("block %q has too many messages (%d)", b.Cid(), msgc) + } + var smsgs []*types.SignedMessage var smsgCids []cbg.CBORMarshaler for _, m := range smi[bi] { @@ -365,10 +369,6 @@ func zipTipSetAndMessages(bs cbor.IpldStore, ts *types.TipSet, allbmsgs []*types bmsgCids = append(bmsgCids, &c) } - if msgc := len(bmsgCids) + len(smsgCids); msgc > build.BlockMessageLimit { - return nil, fmt.Errorf("block %q has too many messages (%d)", b.Cid(), msgc) - } - mrcid, err := computeMsgMeta(bs, bmsgCids, smsgCids) if err != nil { return nil, err