chore: sync: cleanup sync serve and reduce log noise (#11543)
* chore: cleanup sync serve and reduce log noise 1. Demote a noisy blocksync request error to debug. All this warning means is that someone is requesting a tipset we don't have. 2. Add a separate warning if we fail to collect a chain. If we have the tipsets but fail to collect the chain, something is actually wrong. 3. Fix a TODO and return a single CompactedMessages rather than 4 separate values. * generally reduce the warning to info It turns out we do fail to gather messages frequently as well, likely because we have written the tipsets but haven't fetched the messages...
This commit is contained in:
parent
6cbeb9aad6
commit
4d73febaf7
@ -137,7 +137,7 @@ func (s *server) serviceRequest(ctx context.Context, req *validatedRequest) (*Re
|
||||
|
||||
chain, err := collectChainSegment(ctx, s.cs, req)
|
||||
if err != nil {
|
||||
log.Warn("block sync request: collectChainSegment failed: ", err)
|
||||
log.Info("block sync request: collectChainSegment failed: ", err)
|
||||
return &Response{
|
||||
Status: InternalError,
|
||||
ErrorMessage: err.Error(),
|
||||
@ -171,17 +171,11 @@ func collectChainSegment(ctx context.Context, cs *store.ChainStore, req *validat
|
||||
}
|
||||
|
||||
if req.options.IncludeMessages {
|
||||
bmsgs, bmincl, smsgs, smincl, err := gatherMessages(ctx, cs, ts)
|
||||
bst.Messages, err = gatherMessages(ctx, cs, ts)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("gather messages failed: %w", err)
|
||||
}
|
||||
|
||||
// FIXME: Pass the response to `gatherMessages()` and set all this there.
|
||||
bst.Messages = &CompactedMessages{}
|
||||
bst.Messages.Bls = bmsgs
|
||||
bst.Messages.BlsIncludes = bmincl
|
||||
bst.Messages.Secpk = smsgs
|
||||
bst.Messages.SecpkIncludes = smincl
|
||||
}
|
||||
|
||||
bstips = append(bstips, &bst)
|
||||
@ -196,16 +190,16 @@ func collectChainSegment(ctx context.Context, cs *store.ChainStore, req *validat
|
||||
}
|
||||
}
|
||||
|
||||
func gatherMessages(ctx context.Context, cs *store.ChainStore, ts *types.TipSet) ([]*types.Message, [][]uint64, []*types.SignedMessage, [][]uint64, error) {
|
||||
func gatherMessages(ctx context.Context, cs *store.ChainStore, ts *types.TipSet) (*CompactedMessages, error) {
|
||||
msgs := new(CompactedMessages)
|
||||
blsmsgmap := make(map[cid.Cid]uint64)
|
||||
secpkmsgmap := make(map[cid.Cid]uint64)
|
||||
var secpkincl, blsincl [][]uint64
|
||||
|
||||
var blscids, secpkcids []cid.Cid
|
||||
for _, block := range ts.Blocks() {
|
||||
bc, sc, err := cs.ReadMsgMetaCids(ctx, block.Messages)
|
||||
if err != nil {
|
||||
return nil, nil, nil, nil, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// FIXME: DRY. Use `chain.Message` interface.
|
||||
@ -220,7 +214,7 @@ func gatherMessages(ctx context.Context, cs *store.ChainStore, ts *types.TipSet)
|
||||
|
||||
bmi = append(bmi, i)
|
||||
}
|
||||
blsincl = append(blsincl, bmi)
|
||||
msgs.BlsIncludes = append(msgs.BlsIncludes, bmi)
|
||||
|
||||
smi := make([]uint64, 0, len(sc))
|
||||
for _, m := range sc {
|
||||
@ -233,18 +227,19 @@ func gatherMessages(ctx context.Context, cs *store.ChainStore, ts *types.TipSet)
|
||||
|
||||
smi = append(smi, i)
|
||||
}
|
||||
secpkincl = append(secpkincl, smi)
|
||||
msgs.SecpkIncludes = append(msgs.SecpkIncludes, smi)
|
||||
}
|
||||
|
||||
blsmsgs, err := cs.LoadMessagesFromCids(ctx, blscids)
|
||||
var err error
|
||||
msgs.Bls, err = cs.LoadMessagesFromCids(ctx, blscids)
|
||||
if err != nil {
|
||||
return nil, nil, nil, nil, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
secpkmsgs, err := cs.LoadSignedMessagesFromCids(ctx, secpkcids)
|
||||
msgs.Secpk, err = cs.LoadSignedMessagesFromCids(ctx, secpkcids)
|
||||
if err != nil {
|
||||
return nil, nil, nil, nil, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return blsmsgs, blsincl, secpkmsgs, secpkincl, nil
|
||||
return msgs, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user