From 86624c8ed4e0a1bbce5632177eb5c3be15db620b Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Tue, 12 Nov 2019 22:44:29 -0800 Subject: [PATCH] fix tests and add some more trace attributes --- chain/blocksync/blocksync_client.go | 8 ++++++++ chain/stmgr/stmgr.go | 3 +++ lib/sectorbuilder/sectorbuilder_test.go | 12 +++++++----- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/chain/blocksync/blocksync_client.go b/chain/blocksync/blocksync_client.go index 6af46a592..52e17f7a3 100644 --- a/chain/blocksync/blocksync_client.go +++ b/chain/blocksync/blocksync_client.go @@ -159,6 +159,7 @@ func (bs *BlockSync) GetChainMessages(ctx context.Context, h *types.TipSet, coun } err = bs.processStatus(req, res) if err != nil { + log.Warnf("BlockSync peer %s response was an error: %s", peers[p].String(), err) } } @@ -192,6 +193,13 @@ func (bs *BlockSync) sendRequestToPeer(ctx context.Context, p peer.ID, req *Bloc return nil, err } + if span.IsRecordingEvents() { + span.AddAttributes( + trace.Int64Attribute("resp_status", int64(res.Status)), + trace.StringAttribute("msg", res.Message), + trace.Int64Attribute("chain_len", int64(len(res.Chain))), + ) + } return &res, nil } diff --git a/chain/stmgr/stmgr.go b/chain/stmgr/stmgr.go index 16aef7631..e827727e0 100644 --- a/chain/stmgr/stmgr.go +++ b/chain/stmgr/stmgr.go @@ -49,6 +49,9 @@ func cidsToKey(cids []cid.Cid) string { func (sm *StateManager) TipSetState(ctx context.Context, ts *types.TipSet) (cid.Cid, cid.Cid, error) { ctx, span := trace.StartSpan(ctx, "tipSetState") defer span.End() + if span.IsRecordingEvents() { + span.AddAttributes(trace.StringAttribute("tipset", fmt.Sprint(ts.Cids()))) + } ck := cidsToKey(ts.Cids()) sm.stlk.Lock() diff --git a/lib/sectorbuilder/sectorbuilder_test.go b/lib/sectorbuilder/sectorbuilder_test.go index a5e394b36..45d7569e7 100644 --- a/lib/sectorbuilder/sectorbuilder_test.go +++ b/lib/sectorbuilder/sectorbuilder_test.go @@ -1,15 +1,17 @@ package sectorbuilder_test import ( - "github.com/ipfs/go-datastore" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" + "context" "io" "io/ioutil" "math/rand" "os" "testing" + "github.com/ipfs/go-datastore" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/lib/sectorbuilder" ) @@ -100,7 +102,7 @@ func TestSealAndVerify(t *testing.T) { t.Fatalf("%+v", err) } - ok, err = sectorbuilder.VerifyPost(sb.SectorSize(), ssi, cSeed, postProof, []uint64{}) + ok, err = sectorbuilder.VerifyPost(context.TODO(), sb.SectorSize(), ssi, cSeed, postProof, []uint64{}) if err != nil { t.Fatalf("%+v", err) } @@ -120,7 +122,7 @@ func TestSealAndVerify(t *testing.T) { t.Fatalf("%+v", err) } - ok, err = sectorbuilder.VerifyPost(sb.SectorSize(), ssi, cSeed, postProof, []uint64{}) + ok, err = sectorbuilder.VerifyPost(context.TODO(), sb.SectorSize(), ssi, cSeed, postProof, []uint64{}) if err != nil { t.Fatalf("%+v", err) }