Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(blob/trace): cover blob service with traces #3113

Merged
merged 7 commits into from
Jan 30, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions blob/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@ import (
"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/types"
logging "github.com/ipfs/go-log/v2"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/trace"

"github.com/celestiaorg/celestia-app/pkg/shares"

"github.com/celestiaorg/celestia-node/header"
"github.com/celestiaorg/celestia-node/libs/utils"
"github.com/celestiaorg/celestia-node/share"
)

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")
)

// Submitter is an interface that allows submitting blobs to the celestia-core. It is used to
Expand Down Expand Up @@ -165,7 +170,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).
Expand Down Expand Up @@ -193,16 +202,28 @@ 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())

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)),
)

header, err := s.headerGetter(ctx, height)
vgonkivs marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
return nil, nil, err
}

span.AddEvent("received eds", trace.WithAttributes(
attribute.Int64("eds-size", int64(len(header.DAH.RowRoots)))))

namespacedShares, err := s.shareGetter.GetSharesByNamespace(ctx, header, namespace)
if err != nil {
if errors.Is(err, share.ErrNotFound) {
Expand Down Expand Up @@ -240,6 +261,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
Expand Down Expand Up @@ -276,7 +298,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
Expand Down
Loading