diff --git a/chain/actors/actor_miner.go b/chain/actors/actor_miner.go index d1e4ad4d3..f8a4cd8f3 100644 --- a/chain/actors/actor_miner.go +++ b/chain/actors/actor_miner.go @@ -16,6 +16,7 @@ import ( cbor "github.com/ipfs/go-ipld-cbor" "github.com/libp2p/go-libp2p-core/peer" cbg "github.com/whyrusleeping/cbor-gen" + "go.opencensus.io/trace" "golang.org/x/xerrors" ) @@ -337,7 +338,7 @@ func (sma StorageMinerActor) ProveCommitSector(act *types.Actor, vmctx types.VMC return nil, aerrors.Wrap(err, "failed to compute data commitment") } - if ok, err := ValidatePoRep(maddr, mi.SectorSize, commD, us.Info.CommR, ticket, params.Proof, seed, params.SectorID); err != nil { + if ok, err := ValidatePoRep(ctx, maddr, mi.SectorSize, commD, us.Info.CommR, ticket, params.Proof, seed, params.SectorID); err != nil { return nil, err } else if !ok { return nil, aerrors.Newf(2, "porep proof was invalid (t:%x; s:%x(%d); p:%x)", ticket, seed, us.ReceivedEpoch+build.InteractivePoRepDelay, params.Proof) @@ -493,7 +494,7 @@ func (sma StorageMinerActor) SubmitPoSt(act *types.Actor, vmctx types.VMContext, faults := self.CurrentFaultSet.All() - if ok, lerr := sectorbuilder.VerifyPost(mi.SectorSize, + if ok, lerr := sectorbuilder.VerifyPost(vmctx.Context(), mi.SectorSize, sectorbuilder.NewSortedSectorInfo(sectorInfos), seed, params.Proof, faults); !ok || lerr != nil { if lerr != nil { @@ -613,7 +614,9 @@ func GetFromSectorSet(ctx context.Context, s types.Storage, ss cid.Cid, sectorID return true, comms[0], comms[1], nil } -func ValidatePoRep(maddr address.Address, ssize uint64, commD, commR, ticket, proof, seed []byte, sectorID uint64) (bool, ActorError) { +func ValidatePoRep(ctx context.Context, maddr address.Address, ssize uint64, commD, commR, ticket, proof, seed []byte, sectorID uint64) (bool, ActorError) { + _, span := trace.StartSpan(ctx, "ValidatePoRep") + defer span.End() ok, err := sectorbuilder.VerifySeal(ssize, commR, commD, maddr, ticket, seed, sectorID, proof) if err != nil { return false, aerrors.Absorb(err, 25, "verify seal failed") 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/chain/store/store.go b/chain/store/store.go index f78e24beb..018b5bbc8 100644 --- a/chain/store/store.go +++ b/chain/store/store.go @@ -768,6 +768,7 @@ func (cs *ChainStore) TryFillTipSet(ts *types.TipSet) (*FullTipSet, error) { func (cs *ChainStore) GetRandomness(ctx context.Context, blks []cid.Cid, tickets []*types.Ticket, lb int64) ([]byte, error) { ctx, span := trace.StartSpan(ctx, "store.GetRandomness") defer span.End() + span.AddAttributes(trace.Int64Attribute("lb", lb)) if lb < 0 { return nil, fmt.Errorf("negative lookback parameters are not valid (got %d)", lb) diff --git a/chain/sync.go b/chain/sync.go index 929b967e1..7232d732d 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -445,6 +445,7 @@ func (syncer *Syncer) minerIsValid(ctx context.Context, maddr address.Address, b func (syncer *Syncer) validateTickets(ctx context.Context, mworker address.Address, tickets []*types.Ticket, base *types.TipSet) error { ctx, span := trace.StartSpan(ctx, "validateTickets") defer span.End() + span.AddAttributes(trace.Int64Attribute("tickets", int64(len(tickets)))) if len(tickets) == 0 { return xerrors.Errorf("block had no tickets") diff --git a/chain/vm/vm.go b/chain/vm/vm.go index d090e5f8d..d25eae45d 100644 --- a/chain/vm/vm.go +++ b/chain/vm/vm.go @@ -586,6 +586,13 @@ func (vm *VM) SetBlockHeight(h uint64) { func (vm *VM) Invoke(act *types.Actor, vmctx *VMContext, method uint64, params []byte) ([]byte, aerrors.ActorError) { ctx, span := trace.StartSpan(vmctx.ctx, "vm.Invoke") defer span.End() + if span.IsRecordingEvents() { + span.AddAttributes( + trace.StringAttribute("to", vmctx.Message().To.String()), + trace.Int64Attribute("method", int64(method)), + trace.StringAttribute("value", vmctx.Message().Value.String()), + ) + } var oldCtx context.Context oldCtx, vmctx.ctx = vmctx.ctx, ctx diff --git a/lib/sectorbuilder/sectorbuilder.go b/lib/sectorbuilder/sectorbuilder.go index 716cefe15..4383ddb57 100644 --- a/lib/sectorbuilder/sectorbuilder.go +++ b/lib/sectorbuilder/sectorbuilder.go @@ -1,6 +1,7 @@ package sectorbuilder import ( + "context" "fmt" "io" "os" @@ -12,6 +13,7 @@ import ( sectorbuilder "github.com/filecoin-project/go-sectorbuilder" "github.com/ipfs/go-datastore" logging "github.com/ipfs/go-log" + "go.opencensus.io/trace" "golang.org/x/xerrors" "github.com/filecoin-project/lotus/chain/address" @@ -358,7 +360,9 @@ func NewSortedSectorInfo(sectors []SectorInfo) SortedSectorInfo { return sectorbuilder.NewSortedSectorInfo(sectors...) } -func VerifyPost(sectorSize uint64, sectorInfo SortedSectorInfo, challengeSeed [CommLen]byte, proof []byte, faults []uint64) (bool, error) { +func VerifyPost(ctx context.Context, sectorSize uint64, sectorInfo SortedSectorInfo, challengeSeed [CommLen]byte, proof []byte, faults []uint64) (bool, error) { + _, span := trace.StartSpan(ctx, "VerifyPoSt") + defer span.End() return sectorbuilder.VerifyPoSt(sectorSize, sectorInfo, challengeSeed, proof, faults) } 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) }