From 2b972bcc5ec58b0f559419bdf6d5cbaa4903012d Mon Sep 17 00:00:00 2001 From: agnusmor Date: Mon, 22 Apr 2024 16:33:29 +0200 Subject: [PATCH] add debug logs for datastreamer --- sequencer/datastreamer.go | 2 ++ sequencer/l2block.go | 3 +++ sequencer/sequencer.go | 17 +++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/sequencer/datastreamer.go b/sequencer/datastreamer.go index 700b8b3e02..bbbfe14496 100644 --- a/sequencer/datastreamer.go +++ b/sequencer/datastreamer.go @@ -1,6 +1,7 @@ package sequencer import ( + "github.com/0xPolygonHermez/zkevm-node/log" "github.com/0xPolygonHermez/zkevm-node/state" ) @@ -42,6 +43,7 @@ func (f *finalizer) DSSendL2Block(batchNumber uint64, blockResponse *state.Proce l2Transactions = append(l2Transactions, l2Transaction) } + log.Infof("sending l2block %d to datastream channel", blockResponse.BlockNumber) f.dataToStream <- state.DSL2FullBlock{ DSL2Block: l2Block, Txs: l2Transactions, diff --git a/sequencer/l2block.go b/sequencer/l2block.go index a7fd011b09..ed7ae314f6 100644 --- a/sequencer/l2block.go +++ b/sequencer/l2block.go @@ -411,6 +411,7 @@ func (f *finalizer) storeL2Block(ctx context.Context, l2Block *L2Block) error { return err } + //TODO: remove this log log.Infof("l2 block %d [%d] stored in statedb", blockResponse.BlockNumber, l2Block.trackingNum) // Update txs status in the pool @@ -422,6 +423,7 @@ func (f *finalizer) storeL2Block(ctx context.Context, l2Block *L2Block) error { } } + //TODO: remove this log log.Infof("l2 block %d [%d] transactions updated as selected in the pooldb", blockResponse.BlockNumber, l2Block.trackingNum) // Send L2 block to data streamer @@ -431,6 +433,7 @@ func (f *finalizer) storeL2Block(ctx context.Context, l2Block *L2Block) error { log.Errorf("error sending L2 block %d [%d] to data streamer, error: %v", blockResponse.BlockNumber, l2Block.trackingNum, err) } + //TODO: remove this log log.Infof("l2 block %d [%d] sent to datastream", blockResponse.BlockNumber, l2Block.trackingNum) for _, tx := range l2Block.transactions { diff --git a/sequencer/sequencer.go b/sequencer/sequencer.go index 64b5711fae..22201776ce 100644 --- a/sequencer/sequencer.go +++ b/sequencer/sequencer.go @@ -256,6 +256,8 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) { case state.DSL2FullBlock: l2Block := data + //TODO: remove this log + log.Infof("start atomic op for l2block %d", l2Block.L2BlockNumber) err = s.streamServer.StartAtomicOp() if err != nil { log.Errorf("failed to start atomic op for l2block %d, error: %v ", l2Block.L2BlockNumber, err) @@ -267,6 +269,8 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) { Value: l2Block.L2BlockNumber, } + //TODO: remove this log + log.Infof("add stream bookmark for l2block %d", l2Block.L2BlockNumber) _, err = s.streamServer.AddStreamBookmark(bookMark.Encode()) if err != nil { log.Errorf("failed to add stream bookmark for l2block %d, error: %v", l2Block.L2BlockNumber, err) @@ -281,6 +285,8 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) { Value: l2Block.L2BlockNumber - 1, } + //TODO: remove this log + log.Infof("get previous l2block %d", l2Block.L2BlockNumber-1) previousL2BlockEntry, err := s.streamServer.GetFirstEventAfterBookmark(bookMark.Encode()) if err != nil { log.Errorf("failed to get previous l2block %d, error: %v", l2Block.L2BlockNumber-1, err) @@ -303,12 +309,16 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) { ChainID: uint32(chainID), } + //TODO: remove this log + log.Infof("add l2blockStart stream entry for l2block %d", l2Block.L2BlockNumber) _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2BlockStart, blockStart.Encode()) if err != nil { log.Errorf("failed to add stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err) continue } + //TODO: remove this log + log.Infof("adding l2tx stream entries for l2block %d", l2Block.L2BlockNumber) for _, l2Transaction := range l2Block.Txs { _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2Tx, l2Transaction.Encode()) if err != nil { @@ -323,18 +333,25 @@ func (s *Sequencer) sendDataToStreamer(chainID uint64) { StateRoot: l2Block.StateRoot, } + //TODO: remove this log + log.Infof("add l2blockEnd stream entry for l2block %d", l2Block.L2BlockNumber) _, err = s.streamServer.AddStreamEntry(state.EntryTypeL2BlockEnd, blockEnd.Encode()) if err != nil { log.Errorf("failed to add stream entry for l2block %d, error: %v", l2Block.L2BlockNumber, err) continue } + //TODO: remove this log + log.Infof("commit atomic op for l2block %d", l2Block.L2BlockNumber) err = s.streamServer.CommitAtomicOp() if err != nil { log.Errorf("failed to commit atomic op for l2block %d, error: %v ", l2Block.L2BlockNumber, err) continue } + //TODO: remove this log + log.Infof("l2block %d sent to datastream", l2Block.L2BlockNumber) + // Stream a bookmark case state.DSBookMark: bookmark := data