From 9c0a5fb0626ada6e6cdb8bcd816d01a3aa5043ad Mon Sep 17 00:00:00 2001 From: PV <44137386+Ray-Escobar@users.noreply.github.com> Date: Thu, 6 Apr 2023 13:53:39 +0200 Subject: [PATCH] das/share: Change log from DAH.Hash() to DAH.String() (#1971) ## Overview Changes log input to use the string method for both the DataAvailabilityHeader and Root. Fixes #1898 ## Checklist - [x] Required CI checks are passing - [x] Linked issues closed with keywords --- das/worker.go | 6 +++--- share/availability/full/availability.go | 2 +- share/availability/light/availability.go | 10 +++++----- share/eds/retriever.go | 7 +++---- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/das/worker.go b/das/worker.go index 258ea539e8..c73ad235f8 100644 --- a/das/worker.go +++ b/das/worker.go @@ -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), ) @@ -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), ) @@ -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 diff --git a/share/availability/full/availability.go b/share/availability/full/availability.go index 76476f3824..9eef8d1372 100644 --- a/share/availability/full/availability.go +++ b/share/availability/full/availability.go @@ -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 diff --git a/share/availability/light/availability.go b/share/availability/light/availability.go index 57f044526c..c947e65e63 100644 --- a/share/availability/light/availability.go +++ b/share/availability/light/availability.go @@ -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 { @@ -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 @@ -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 diff --git a/share/eds/retriever.go b/share/eds/retriever.go index 68390ea7d6..5d3c61cabb 100644 --- a/share/eds/retriever.go +++ b/share/eds/retriever.go @@ -2,7 +2,6 @@ package eds import ( "context" - "encoding/hex" "errors" "sync" "sync/atomic" @@ -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 @@ -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 }