Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
ToniRamirezM committed Jun 19, 2024
1 parent 30a7eea commit 1fbe854
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 22 deletions.
2 changes: 1 addition & 1 deletion tools/datastreamer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion tools/datastreamer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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`
Expand Down
28 changes: 8 additions & 20 deletions tools/datastreamer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 1fbe854

Please sign in to comment.