Skip to content

Commit

Permalink
improving logging
Browse files Browse the repository at this point in the history
  • Loading branch information
srene committed May 16, 2024
1 parent 8777520 commit ad0169b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion block/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,6 @@ func (m *Manager) syncBlockManager() error {
// UpdateSyncParams updates the sync target and state index if necessary
func (m *Manager) UpdateSyncParams(endHeight uint64) {
types.RollappHubHeightGauge.Set(float64(endHeight))
m.logger.Info("Received new syncTarget", "syncTarget", endHeight)
m.logger.Info("SyncTarget updated", "syncTarget", endHeight)
m.SyncTarget.Store(endHeight)
}
3 changes: 2 additions & 1 deletion block/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (m *Manager) HandleSubmissionTrigger() error {
}

resultSubmitToDA := m.DAClient.SubmitBatch(nextBatch)

m.logger.Info("batch submitted to DA", "start height", nextBatch.StartHeight, "end height", nextBatch.EndHeight)
if resultSubmitToDA.Code != da.StatusSuccess {
return fmt.Errorf("submit next batch to da: %s", resultSubmitToDA.Message)
}
Expand All @@ -135,6 +135,7 @@ func (m *Manager) HandleSubmissionTrigger() error {
if err != nil {
return fmt.Errorf("sl client submit batch: start height: %d: inclusive end height: %d: %w", startHeight, actualEndHeight, err)
}
m.logger.Info("batch submitted to SL", "start height", resultSubmitToDA, "end height", nextBatch.EndHeight)

m.UpdateSyncParams(actualEndHeight)
return nil
Expand Down
24 changes: 11 additions & 13 deletions da/celestia/celestia.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (c *DataAvailabilityLayerClient) Start() (err error) {

// other client has already been set
if c.rpc != nil {
c.logger.Debug("celestia-node client already set")
c.logger.Info("celestia-node client already set")
return nil
}

Expand Down Expand Up @@ -228,7 +228,7 @@ func (c *DataAvailabilityLayerClient) SubmitBatch(batch *types.Batch) da.ResultS
// TODO(srene): Split batch in multiple blobs if necessary if supported
height, commitment, err := c.submit(data)
if err != nil {
c.logger.Error("submit batch", "error", err)
c.logger.Error("submit blob", "error", err)
backoff.Sleep()
continue
}
Expand All @@ -240,7 +240,7 @@ func (c *DataAvailabilityLayerClient) SubmitBatch(batch *types.Batch) da.ResultS
Namespace: c.config.NamespaceID.Bytes(),
}

c.logger.Info("submitted DA batch")
c.logger.Debug("submitted blob to DA successfully")

result := c.CheckBatchAvailability(daMetaData)
if result.Code != da.StatusSuccess {
Expand All @@ -252,7 +252,7 @@ func (c *DataAvailabilityLayerClient) SubmitBatch(batch *types.Batch) da.ResultS
daMetaData.Index = result.CheckMetaData.Index
daMetaData.Length = result.CheckMetaData.Length

c.logger.Debug("Batch accepted")
c.logger.Debug("blob availability check passed successfully")

return da.ResultSubmitBatch{
BaseResult: da.BaseResult{
Expand Down Expand Up @@ -308,7 +308,7 @@ func (c *DataAvailabilityLayerClient) retrieveBatches(daMetaData *da.DASubmitMet
ctx, cancel := context.WithTimeout(c.ctx, c.config.Timeout)
defer cancel()

c.logger.Debug("Celestia DA getting blob", "height", daMetaData.Height, "namespace", hex.EncodeToString(daMetaData.Namespace), "commitment", hex.EncodeToString(daMetaData.Commitment))
c.logger.Debug("getting blob from DA", "height", daMetaData.Height, "namespace", hex.EncodeToString(daMetaData.Namespace), "commitment", hex.EncodeToString(daMetaData.Commitment))
var batches []*types.Batch
blob, err := c.rpc.Get(ctx, daMetaData.Height, daMetaData.Namespace, daMetaData.Commitment)
if err != nil {
Expand Down Expand Up @@ -336,7 +336,7 @@ func (c *DataAvailabilityLayerClient) retrieveBatches(daMetaData *da.DASubmitMet
c.logger.Error("unmarshal block", "daHeight", daMetaData.Height, "error", err)
}

c.logger.Debug("Celestia DA get blob successful", "DA height", daMetaData.Height, "lastBlockHeight", batch.EndHeight)
c.logger.Debug("blob retrieved successfully from DA", "DA height", daMetaData.Height, "lastBlockHeight", batch.EndHeight)

parsedBatch := new(types.Batch)
err = parsedBatch.FromProto(&batch)
Expand Down Expand Up @@ -575,17 +575,15 @@ func (c *DataAvailabilityLayerClient) submit(daBlob da.Blob) (uint64, da.Commitm
return 0, nil, fmt.Errorf("do rpc submit: %w", err)
}

c.logger.Info("Successfully submitted blobs to Celestia", "height", height)

return height, commitments[0], nil
}

func (c *DataAvailabilityLayerClient) getProof(daMetadata *da.DASubmitMetaData) (*blob.Proof, error) {
c.logger.Info("Getting proof via RPC call")
func (c *DataAvailabilityLayerClient) getProof(daMetaData *da.DASubmitMetaData) (*blob.Proof, error) {
c.logger.Debug("getting proof via RPC call", "height", daMetaData.Height, "namespace", daMetaData.Namespace, "commitment", daMetaData.Commitment)
ctx, cancel := context.WithTimeout(c.ctx, c.config.Timeout)
defer cancel()

proof, err := c.rpc.GetProof(ctx, daMetadata.Height, daMetadata.Namespace, daMetadata.Commitment)
proof, err := c.rpc.GetProof(ctx, daMetaData.Height, daMetaData.Namespace, daMetaData.Commitment)
if err != nil {
return nil, err
}
Expand All @@ -612,15 +610,15 @@ func (c *DataAvailabilityLayerClient) blobsAndCommitments(daBlob da.Blob) ([]*bl
}

func (c *DataAvailabilityLayerClient) validateProof(daMetaData *da.DASubmitMetaData, proof *blob.Proof) (bool, error) {
c.logger.Info("Getting inclusion validation via RPC call")
c.logger.Debug("validating proof via RPC call", "height", daMetaData.Height, "namespace", daMetaData.Namespace, "commitment", daMetaData.Commitment)
ctx, cancel := context.WithTimeout(c.ctx, c.config.Timeout)
defer cancel()

return c.rpc.Included(ctx, daMetaData.Height, daMetaData.Namespace, proof, daMetaData.Commitment)
}

func (c *DataAvailabilityLayerClient) getDataAvailabilityHeaders(height uint64) (*header.DataAvailabilityHeader, error) {
c.logger.Info("Getting Celestia extended headers via RPC call")
c.logger.Debug("getting extended headers via RPC call", "height", height)
ctx, cancel := context.WithTimeout(c.ctx, c.config.Timeout)
defer cancel()

Expand Down
4 changes: 2 additions & 2 deletions settlement/dymension/dymension.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func (d *HubClient) PostBatch(batch *types.Batch, daClient da.Client, daResult *
return fmt.Errorf("subscription cancelled")

case <-subscription.Out():
d.logger.Debug("Batch accepted", "startHeight", batch.StartHeight, "endHeight", batch.EndHeight)
d.logger.Info("batch accepted", "startHeight", batch.StartHeight, "endHeight", batch.EndHeight)
return nil

case <-timer.C:
Expand All @@ -282,7 +282,7 @@ func (d *HubClient) PostBatch(batch *types.Batch, daClient da.Client, daResult *
}

// all good
d.logger.Info("Batch accepted", "startHeight", includedBatch.StartHeight, "endHeight", includedBatch.EndHeight)
d.logger.Info("batch accepted", "startHeight", includedBatch.StartHeight, "endHeight", includedBatch.EndHeight, "index", includedBatch.StateIndex)
return nil
}
}
Expand Down

0 comments on commit ad0169b

Please sign in to comment.