diff --git a/blob/service.go b/blob/service.go index 6a70772797..fc1d630e62 100644 --- a/blob/service.go +++ b/blob/service.go @@ -11,12 +11,17 @@ import ( "github.com/cosmos/cosmos-sdk/types" auth "github.com/cosmos/cosmos-sdk/x/auth/types" logging "github.com/ipfs/go-log/v2" + "go.opentelemetry.io/otel" + "go.opentelemetry.io/otel/attribute" + "go.opentelemetry.io/otel/codes" + "go.opentelemetry.io/otel/trace" "github.com/celestiaorg/celestia-app/pkg/appconsts" "github.com/celestiaorg/celestia-app/pkg/shares" blobtypes "github.com/celestiaorg/celestia-app/x/blob/types" "github.com/celestiaorg/celestia-node/header" + "github.com/celestiaorg/celestia-node/libs/utils" "github.com/celestiaorg/celestia-node/share" ) @@ -24,7 +29,8 @@ var ( ErrBlobNotFound = errors.New("blob: not found") ErrInvalidProof = errors.New("blob: invalid proof") - log = logging.Logger("blob") + log = logging.Logger("blob") + tracer = otel.Tracer("blob/service") ) // GasPrice represents the amount to be paid per gas unit. Fee is set by @@ -185,7 +191,11 @@ func (s *Service) Included( namespace share.Namespace, proof *Proof, com Commitment, -) (bool, error) { +) (_ bool, err error) { + ctx, span := tracer.Start(ctx, "included") + defer func() { + utils.SetStatusAndEnd(span, err) + }() // In the current implementation, LNs will have to download all shares to recompute the commitment. // To achieve 1. we need to modify Proof structure and to store all subtree roots, that were // involved in commitment creation and then call `merkle.HashFromByteSlices`(tendermint package). @@ -213,24 +223,47 @@ func (s *Service) getByCommitment( height uint64, namespace share.Namespace, commitment Commitment, -) (*Blob, *Proof, error) { +) (_ *Blob, _ *Proof, err error) { log.Infow("requesting blob", "height", height, "namespace", namespace.String()) - header, err := s.headerGetter(ctx, height) + ctx, span := tracer.Start(ctx, "get-by-commitment") + defer func() { + utils.SetStatusAndEnd(span, err) + }() + span.SetAttributes( + attribute.Int64("height", int64(height)), + attribute.String("commitment", string(commitment)), + ) + + getCtx, headerGetterSpan := tracer.Start(ctx, "header-getter") + + header, err := s.headerGetter(getCtx, height) if err != nil { + headerGetterSpan.SetStatus(codes.Error, err.Error()) return nil, nil, err } - namespacedShares, err := s.shareGetter.GetSharesByNamespace(ctx, header, namespace) + headerGetterSpan.SetStatus(codes.Ok, "") + headerGetterSpan.AddEvent("received eds", trace.WithAttributes( + attribute.Int64("eds-size", int64(len(header.DAH.RowRoots))))) + + getCtx, getSharesSpan := tracer.Start(ctx, "get-shares-by-namespace") + + namespacedShares, err := s.shareGetter.GetSharesByNamespace(getCtx, header, namespace) if err != nil { if errors.Is(err, share.ErrNotFound) { err = ErrBlobNotFound } + getSharesSpan.SetStatus(codes.Error, err.Error()) return nil, nil, err } + getSharesSpan.SetStatus(codes.Ok, "") + getSharesSpan.AddEvent("received shares", trace.WithAttributes( + attribute.Int64("eds-size", int64(len(header.DAH.RowRoots))))) + var ( rawShares = make([]shares.Share, 0) proofs = make(Proof, 0) @@ -260,6 +293,7 @@ func (s *Service) getByCommitment( } for _, b := range blobs { if b.Commitment.Equal(commitment) { + span.AddEvent("blob reconstructed") return b, &proofs, nil } // Falling under this flag means that the data from the last row @@ -296,7 +330,11 @@ func (s *Service) getBlobs( ctx context.Context, namespace share.Namespace, header *header.ExtendedHeader, -) ([]*Blob, error) { +) (_ []*Blob, err error) { + ctx, span := tracer.Start(ctx, "get-blobs") + defer func() { + utils.SetStatusAndEnd(span, err) + }() namespacedShares, err := s.shareGetter.GetSharesByNamespace(ctx, header, namespace) if err != nil { return nil, err