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

das/share: Change log from DAH.Hash() to DAH.String() #1971

Merged
merged 2 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions das/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func (w *worker) sample(ctx context.Context, timeout time.Duration, height uint6
"height", h.Height(),
"hash", h.Hash(),
"square width", len(h.DAH.RowsRoots),
"data root", h.DAH.Hash(),
"data root", h.DAH.String(),
"err", err,
"finished (s)", time.Since(start),
)
Expand All @@ -125,7 +125,7 @@ func (w *worker) sample(ctx context.Context, timeout time.Duration, height uint6
"height", h.Height(),
"hash", h.Hash(),
"square width", len(h.DAH.RowsRoots),
"data root", h.DAH.Hash(),
"data root", h.DAH.String(),
"finished (s)", time.Since(start),
)

Expand Down Expand Up @@ -166,7 +166,7 @@ func (w *worker) getHeader(ctx context.Context, height uint64) (*header.Extended
"height", h.Height(),
"hash", h.Hash(),
"square width", len(h.DAH.RowsRoots),
"data root", h.DAH.Hash(),
"data root", h.DAH.String(),
"finished (s)", time.Since(start),
)
return h, nil
Expand Down
2 changes: 1 addition & 1 deletion share/availability/full/availability.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (fa *ShareAvailability) SharesAvailable(ctx context.Context, root *share.Ro

_, err := fa.getter.GetEDS(ctx, root)
if err != nil {
log.Errorw("availability validation failed", "root", root.Hash(), "err", err.Error())
log.Errorw("availability validation failed", "root", root.String(), "err", err.Error())
var byzantineErr *byzantine.ErrByzantine
if ipldFormat.IsNotFound(err) || errors.Is(err, context.DeadlineExceeded) && !errors.As(err, &byzantineErr) {
return share.ErrNotAvailable
Expand Down
10 changes: 5 additions & 5 deletions share/availability/light/availability.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func NewShareAvailability(getter share.Getter) *ShareAvailability {
// SharesAvailable randomly samples DefaultSampleAmount amount of Shares committed to the given
// Root. This way SharesAvailable subjectively verifies that Shares are available.
func (la *ShareAvailability) SharesAvailable(ctx context.Context, dah *share.Root) error {
log.Debugw("Validate availability", "root", dah.Hash())
log.Debugw("Validate availability", "root", dah.String())
// We assume the caller of this method has already performed basic validation on the
// given dah/root. If for some reason this has not happened, the node should panic.
if err := dah.ValidateBasic(); err != nil {
Expand All @@ -47,14 +47,14 @@ func (la *ShareAvailability) SharesAvailable(ctx context.Context, dah *share.Roo
// functionality is optional and must be supported by the used share.Getter.
ctx = getters.WithSession(ctx)

log.Debugw("starting sampling session", "root", dah.Hash())
log.Debugw("starting sampling session", "root", dah.String())
errs := make(chan error, len(samples))
for _, s := range samples {
go func(s Sample) {
log.Debugw("fetching share", "root", dah.Hash(), "row", s.Row, "col", s.Col)
log.Debugw("fetching share", "root", dah.String(), "row", s.Row, "col", s.Col)
_, err := la.getter.GetShare(ctx, dah, s.Row, s.Col)
if err != nil {
log.Debugw("error fetching share", "root", dah.Hash(), "row", s.Row, "col", s.Col)
log.Debugw("error fetching share", "root", dah.String(), "row", s.Row, "col", s.Col)
}
// we don't really care about Share bodies at this point
// it also means we now saved the Share in local storage
Expand All @@ -75,7 +75,7 @@ func (la *ShareAvailability) SharesAvailable(ctx context.Context, dah *share.Roo

if err != nil {
if !errors.Is(err, context.Canceled) {
log.Errorw("availability validation failed", "root", dah.Hash(), "err", err.Error())
log.Errorw("availability validation failed", "root", dah.String(), "err", err.Error())
}
if ipldFormat.IsNotFound(err) || errors.Is(err, context.DeadlineExceeded) {
return share.ErrNotAvailable
Expand Down
7 changes: 3 additions & 4 deletions share/eds/retriever.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package eds

import (
"context"
"encoding/hex"
"errors"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -65,10 +64,10 @@ func (r *Retriever) Retrieve(ctx context.Context, dah *da.DataAvailabilityHeader
defer span.End()
span.SetAttributes(
attribute.Int("size", len(dah.RowsRoots)),
attribute.String("data_hash", hex.EncodeToString(dah.Hash())),
attribute.String("data_hash", dah.String()),
)

log.Debugw("retrieving data square", "data_hash", hex.EncodeToString(dah.Hash()), "size", len(dah.RowsRoots))
log.Debugw("retrieving data square", "data_hash", dah.String(), "size", len(dah.RowsRoots))
ses, err := r.newSession(ctx, dah)
if err != nil {
return nil, err
Expand Down Expand Up @@ -175,7 +174,7 @@ func (rs *retrievalSession) Reconstruct(ctx context.Context) (*rsmt2d.ExtendedDa
span.RecordError(err)
return nil, err
}
log.Infow("data square reconstructed", "data_hash", hex.EncodeToString(rs.dah.Hash()), "size", len(rs.dah.RowsRoots))
log.Infow("data square reconstructed", "data_hash", rs.dah.String(), "size", len(rs.dah.RowsRoots))
close(rs.squareDn)
return rs.square, nil
}
Expand Down