diff --git a/tools/datastreamer/Makefile b/tools/datastreamer/Makefile index b57f6a3adc..902451eab0 100644 --- a/tools/datastreamer/Makefile +++ b/tools/datastreamer/Makefile @@ -35,7 +35,7 @@ decode-batch: ## Runs the tool to decode a given batch go run main.go decode-batch -cfg config/tool.config.toml -batch $(arguments) .PHONY: decode-batchl2data -decode-batchl2data: ## Runs the tool to decode a given batch and show its l2 data +decode-batchl2data: ## Runs the tool to decode a given batch and shows its l2 data go run main.go decode-batchl2data -cfg config/tool.config.toml -batch $(arguments) .PHONY: dump-batch diff --git a/tools/datastreamer/README.md b/tools/datastreamer/README.md index 5fe42f0b8e..2770db8318 100644 --- a/tools/datastreamer/README.md +++ b/tools/datastreamer/README.md @@ -61,6 +61,7 @@ To see avalible options type `make` once in the tool folder. ``` decode-batch Runs the tool to decode a given batch decode-batch-offline Runs the offline tool to decode a given batch +decode-batchl2data Runs the tool to decode a given batch and shows its l2 data decode-entry Runs the tool to decode a given entry number decode-entry-offline Runs the offline tool to decode a given entry number decode-l2block Runs the tool to decode a given L2 block @@ -72,9 +73,10 @@ help Prints this help truncate Runs the offline tool to truncate the stream file ``` -All the decode options can work online, connecting to a node serving the stream, or offline, accessing the data stream files directly. +Almost all the decode options can work online, connecting to a node serving the stream, or offline, accessing the data stream files directly. The only one that only works online is `decode-batchl2data`. - **Decode Batch**: Decodes a Batch from a given number and shows all its data, l2blocks and transactions. +- **Decode BatchL2Data**: Decodes a Batch from a given number and shows its BatchL2Data. It may be useful to compare results against the RPC endpoint `zkevm_getBatchByNumber` - **Decode Entry**: Decodes an entry and shows its content. Entry can be anything: bookmark, batch start, batch end, l2block, updateGER or transaction. - **Decode L2Block**: Decodes a L2Block from a given number and shows all its data and transactions. - **Truncate**: Truncates the file to a given entry number. Useful in case of unwinding the network. @@ -138,6 +140,14 @@ State Root......: 0xada6af5a8bf491712d5ba14c67283a7b516245cd571151c5ade13f82532a Local Exit Root.: 0x0000000000000000000000000000000000000000000000000000000000000000 ``` +### Get BatchL2Data from Batch 2 in the Data Stream + +`make decode-batchl2data 1` + +``` + +``` + ### Get content of L2Block 1 from an online Data Stream `make decode-l2block 1` diff --git a/tools/datastreamer/main.go b/tools/datastreamer/main.go index 5c00cfb385..d13665204e 100644 --- a/tools/datastreamer/main.go +++ b/tools/datastreamer/main.go @@ -806,28 +806,16 @@ func (h *handler) handleReceivedDataStream(entry *datastreamer.FileEntry, client } // Print batch data - if h.currentStreamBatch.BatchNumber != 0 { - var batchl2Data []byte - - batchl2Data, err = state.EncodeBatchV2(&h.currentStreamBatchRaw) - if err != nil { - log.Errorf("Error encoding batch: %v", err) - return err - } - - // Log batchL2Data as hex string - printColored(color.FgGreen, "BatchL2Data.....: ") - printColored(color.FgHiWhite, fmt.Sprintf("%s\n", common.Bytes2Hex(batchl2Data))) + batchl2Data, err := state.EncodeBatchV2(&h.currentStreamBatchRaw) + if err != nil { + log.Errorf("Error encoding batch: %v", err) + return err } - // Finish the process - /* - err = client.ExecCommandStop() - if err != nil { - log.Errorf("Error stopping the data stream: %v", err) - return err - } - */ + // Log batchL2Data as hex string + printColored(color.FgGreen, "BatchL2Data.....: ") + printColored(color.FgHiWhite, fmt.Sprintf("%s\n", "0x"+common.Bytes2Hex(batchl2Data))) + os.Exit(0) return nil case datastreamer.EntryType(datastream.EntryType_ENTRY_TYPE_L2_BLOCK):