Skip to content

Commit

Permalink
chore(das/share): Change log from DAH.Hash() to DAH.String()
Browse files Browse the repository at this point in the history
Changes log input to use the string method for both the
DataAvailabilityHeader and Root.

Fixes #1898
  • Loading branch information
Ray-Escobar committed Mar 27, 2023
1 parent 359f3a6 commit 6fe5f69
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
6 changes: 3 additions & 3 deletions das/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,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 @@ -127,7 +127,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 @@ -165,7 +165,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

0 comments on commit 6fe5f69

Please sign in to comment.