Skip to content

Commit

Permalink
add debug logs for datastreamer
Browse files Browse the repository at this point in the history
  • Loading branch information
agnusmor committed Apr 22, 2024
1 parent e10b4a9 commit 2b972bc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sequencer/datastreamer.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package sequencer

import (
"github.com/0xPolygonHermez/zkevm-node/log"
"github.com/0xPolygonHermez/zkevm-node/state"
)

Expand Down Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions sequencer/l2block.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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 {
Expand Down
17 changes: 17 additions & 0 deletions sequencer/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 2b972bc

Please sign in to comment.