Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 596741e

Browse files
Merge pull request #3791 from 0xPolygonHermez/jhilliard/datastreamer-json-logs
Datastreamer Tool JSON Stream
2 parents 741b9b0 + 20ecde6 commit 596741e

File tree

2 files changed

+247
-200
lines changed

2 files changed

+247
-200
lines changed

tools/datastreamer/README.md

Lines changed: 105 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -93,89 +93,124 @@ Almost all the decode options can work online, connecting to a node serving the
9393
Note: `Version` and `ChainID` fields from the Offline section of the config file are used during generation, so make sure they both are correct. Current Value for Version should be `3`.
9494

9595

96-
### Get contents of Batch 1 from the local files
96+
### Get contents of Batch 201 from the local files
9797

98-
`make decode-batch-offline 1`
98+
`make decode-batch-offline 201`
9999

100100
```
101-
Entry Type......: Batch Start
102-
Entry Number....: 6
103-
Batch Number....: 1
104-
Batch Type......: BATCH_TYPE_INJECTED
105-
Fork ID.........: 9
106-
Chain ID........: 6969
107-
Entry Type......: BookMark
108-
Entry Number....: 7
109-
Type............: 2 (BOOKMARK_TYPE_L2_BLOCK)
110-
Value...........: 1
111-
Entry Type......: L2 Block
112-
Entry Number....: 8
113-
L2 Block Number.: 1
114-
Batch Number....: 1
115-
Timestamp.......: 1714380108 (2024-04-29 08:41:48 +0000 UTC)
116-
Delta Timestamp.: 1714380108
117-
Min. Timestamp..: 0
118-
L1 Block Hash...: 0xdeaef97f8a5c6f056d08e162073d720c035a25adcaa2cd868124543ea54fb185
119-
L1 InfoTree Idx.: 0
120-
Block Hash......: 0xeeb2b1e810770dc1dcdd71a7ffa2a81ae77642d1e3c389919464100b3f70e366
121-
State Root......: 0xada6af5a8bf491712d5ba14c67283a7b516245cd571151c5ade13f82532a398d
122-
Global Exit Root: 0xad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5
123-
Coinbase........: 0x5BD65BF6e084ECC10565EED59b838E82aBc28083
124-
Block Gas Limit.: 0
125-
Block Info Root.: 0x5dfdd92c4436374df99c4532ca7b8b1732faa10e9a6e31e0868bd4bfb6e8303d
126-
Entry Type......: L2 Transaction
127-
Entry Number....: 9
128-
L2 Block Number.: 1
129-
Index...........: 0
130-
Is Valid........: true
131-
Data............: 0xf9010f80808401c9c38094ca127484cda2b723c4c03558b94749184d3cfa9880b8e4f811bff7000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a40d5f56745a118d0906a34e69aec8c0db1cb8fa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000001b8505ca1ab1e0845ca1ab1e
132-
Effec. Gas Price: 255
133-
IM State Root...: 0xeb6b784c61931c8d188ce19298799000615de174e17850ae53feb496b4a5a6ca
134-
Sender..........: 0x2CfbeDbE634712c0Cec2Cd929DcB8c23B0038F2A
135-
Nonce...........: 0
136-
Entry Type......: Batch End
137-
Entry Number....: 10
138-
Batch Number....: 1
139-
State Root......: 0xada6af5a8bf491712d5ba14c67283a7b516245cd571151c5ade13f82532a398d
140-
Local Exit Root.: 0x0000000000000000000000000000000000000000000000000000000000000000
101+
Entry Type···············: Batch Start
102+
Batch Number·············: 201
103+
Batch Type···············: BATCH_TYPE_REGULAR
104+
Chain ID ················: 2440
105+
Entry Number·············: 17575
106+
Entry Type···············: Batch Start
107+
Fork ID··················: 7
108+
Entry Type···············: BookMark
109+
Entry Number·············: 17576
110+
Entry Type···············: BookMark
111+
Type·····················: 2 (BOOKMARK_TYPE_L2_BLOCK)
112+
Value····················: 4259
113+
Entry Type···············: L2 Block
114+
Batch Number·············: 201
115+
Block Gas Limit··········: 0
116+
Block Hash···············: 0xbd2fde31c1ba2bb17f6b1edec5e7d3576ae645b4b8095b74152ad28ba4a8bab4
117+
Block Info Root··········: 0x4e63bbbe4d34e6b3d8d531a2da5cffb4e3877414ecfe4dde24d2afaf3fd0d7a0
118+
Coinbase·················: 0x9aeCf44E36f20DC407d1A580630c9a2419912dcB
119+
Delta Timestamp··········: 3
120+
Entry Number·············: 17577
121+
Entry Type···············: L2 Block
122+
Global Exit Root·········: 0x0000000000000000000000000000000000000000000000000000000000000000
123+
L1 Block Hash············: 0x0000000000000000000000000000000000000000000000000000000000000000
124+
L1 InfoTree Idx··········: 0
125+
L2 Block Number··········: 4259
126+
Min. Timestamp···········: 0
127+
State Root···············: 0x0b649d223f59634d612b0b101ada69310f2f1485e7f38d8a392642229a57863b
128+
Timestamp················: 1706276938 (2024-01-26 08:48:58 -0500 EST)
129+
Entry Type···············: BookMark
130+
Entry Number·············: 17579
131+
Entry Type···············: BookMark
132+
Type·····················: 2 (BOOKMARK_TYPE_L2_BLOCK)
133+
Value····················: 4260
134+
Entry Type···············: BookMark
135+
Entry Number·············: 17582
136+
Entry Type···············: BookMark
137+
Type·····················: 2 (BOOKMARK_TYPE_L2_BLOCK)
138+
Value····················: 4261
139+
Entry Type···············: BookMark
140+
Entry Number·············: 17586
141+
Entry Type···············: BookMark
142+
Type·····················: 1 (BOOKMARK_TYPE_BATCH)
143+
Value····················: 202
144+
Entry Type···············: BookMark
145+
Entry Number·············: 17591
146+
Entry Type···············: BookMark
147+
Type·····················: 2 (BOOKMARK_TYPE_L2_BLOCK)
148+
Value····················: 4263
149+
Entry Type···············: Batch End
150+
Batch Number·············: 202
151+
Entry Number·············: 17597
152+
Entry Type···············: Batch End
153+
Local Exit Root··········: 0x4c907345c62b48529ce718f3a32e8be63a3ae02831386a638419c6cbe6606558
154+
State Root···············: 0x7d2fbae3341b01aa6acb39e113fb98797f3e3da0cddb80b333ae5f8dcb916c7b
141155
```
142156

143157
### Get BatchL2Data from Batch 2 in the Data Stream
144158

145-
`make decode-batchl2data 1`
159+
`make decode-batchl2data 201`
146160

147161
```
148-
BatchL2Data.....: 0x0b662f5d4c00000000f9010380808401c9c38094ca127484cda2b723c4c03558b94749184d3cfa9880b8e4f811bff7000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a40d5f56745a118d0906a34e69aec8c0db1cb8fa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005ca1ab1e0000000000000000000000000000000000000000000000000000000005ca1ab1e1bff
162+
BatchL2Data.....: 0x0b00000003000000000b00000003000000000b0000000300000000
149163
```
150164

151165
### Get content of L2Block 1 from an online Data Stream
152166

153167
`make decode-l2block 1`
154168

155169
```
156-
Entry Type......: L2 Block
157-
Entry Number....: 8
158-
L2 Block Number.: 1
159-
Batch Number....: 1
160-
Timestamp.......: 1714380108 (2024-04-29 08:41:48 +0000 UTC)
161-
Delta Timestamp.: 1714380108
162-
Min. Timestamp..: 0
163-
L1 Block Hash...: 0xdeaef97f8a5c6f056d08e162073d720c035a25adcaa2cd868124543ea54fb185
164-
L1 InfoTree Idx.: 0
165-
Block Hash......: 0xeeb2b1e810770dc1dcdd71a7ffa2a81ae77642d1e3c389919464100b3f70e366
166-
State Root......: 0xada6af5a8bf491712d5ba14c67283a7b516245cd571151c5ade13f82532a398d
167-
Global Exit Root: 0xad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5
168-
Coinbase........: 0x5BD65BF6e084ECC10565EED59b838E82aBc28083
169-
Block Gas Limit.: 0
170-
Block Info Root.: 0x5dfdd92c4436374df99c4532ca7b8b1732faa10e9a6e31e0868bd4bfb6e8303d
171-
Entry Type......: L2 Transaction
172-
Entry Number....: 9
173-
L2 Block Number.: 1
174-
Index...........: 0
175-
Is Valid........: true
176-
Data............: 0xf9010f80808401c9c38094ca127484cda2b723c4c03558b94749184d3cfa9880b8e4f811bff7000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a40d5f56745a118d0906a34e69aec8c0db1cb8fa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000001b8505ca1ab1e0845ca1ab1e
177-
Effec. Gas Price: 255
178-
IM State Root...: 0x0000000000000000000000000000000000000000000000000000000000000000
179-
Sender..........: 0x2CfbeDbE634712c0Cec2Cd929DcB8c23B0038F2A
180-
Nonce...........: 0
181-
```
170+
Entry Type···············: L2 Block
171+
Batch Number·············: 1
172+
Block Gas Limit··········: 0
173+
Block Hash···············: 0x2d19690496337b8f0048d589c4d82820cd46a63f993cca5fc25cd738cce29dad
174+
Block Info Root··········: 0x0000000000000000000000000000000000000000000000000000000000000000
175+
Coinbase·················: 0x9aeCf44E36f20DC407d1A580630c9a2419912dcB
176+
Delta Timestamp··········: 1701345162
177+
Entry Number·············: 9
178+
Entry Type···············: L2 Block
179+
Global Exit Root·········: 0x0000000000000000000000000000000000000000000000000000000000000000
180+
L1 Block Hash············: 0x0000000000000000000000000000000000000000000000000000000000000000
181+
L1 InfoTree Idx··········: 0
182+
L2 Block Number··········: 1
183+
Min. Timestamp···········: 0
184+
State Root···············: 0x9333321a6e1253c5c12922b2c1fcb4f9b6fac830d80951f4f08a640cd61dfcc4
185+
Timestamp················: 1701345162 (2023-11-30 06:52:42 -0500 EST)
186+
Entry Type···············: L2 Transaction
187+
Data·····················: 0xf86a0884025625008252089488cd377500be9906c46073f54901878d1aedc72f870286db33b3c300801ca0e8941bb474e66cc662ce2cf7f52a8b45596e4bebeafd698dc6b10002ff9e04aca048b0b802b0f442fed738ba74d4d53823b3aa60bd9306002486950208b5d8cd7e
188+
Effec. Gas Price·········: 0
189+
Entry Number·············: 10
190+
Entry Type···············: L2 Transaction
191+
IM State Root ···········: 0xae431fe8723d233e04045201057e257d046ebf6d4ba93baf0d1203209b4de9ea
192+
Index····················: 0
193+
Is Valid·················: true
194+
L2 Block Number··········: 1
195+
Nonce ···················: 8
196+
Sender···················: 0x229A5bDBb09d8555f9214F7a6784804999BA4E0D
197+
Entry Type···············: L2 Block End
198+
Entry Number·············: 11
199+
Entry Type···············: L2 Block End
200+
L2 Block Number··········: 1
201+
```
202+
203+
### Get contents of Batch 201 from the local files as a JSON stream
204+
205+
By default, the make file targets output content in a convenient, human-readable format. The same data can be retrieved as a [newline delimited JSON](https://github.com/ndjson/ndjson-spec) stream by adding the `--json` flag.
206+
207+
`go run main.go decode-batch --cfg config/tool.config.toml --batch 201 --json`
208+
209+
210+
```
211+
{"Batch Number":"201","Batch Type":"BATCH_TYPE_REGULAR","Chain ID ":"10101","Entry Number":"62682","Entry Type":"Batch Start","Fork ID":"12"}
212+
{"Entry Number":"62683","Entry Type":"BookMark","Type":"2 (BOOKMARK_TYPE_L2_BLOCK)","Value":"426"}
213+
{"Batch Number":"201","Block Gas Limit":"0","Block Hash":"0xbc518d2e5a43f165bb0a9946fe5255a6810e638fd709dcd7065db31e6e5111cd","Block Info Root":"0x229bc3f5ea59c0628cf75a80517e0dcdb2e817177cacdf7ffa27ad05ee37d1f9","Coinbase":"0x5b06837A43bdC3dD9F114558DAf4B26ed49842Ed","Delta Timestamp":"2","Entry Number":"62684","Entry Type":"L2 Block","Global Exit Root":"0x0000000000000000000000000000000000000000000000000000000000000000","L1 Block Hash":"0x0000000000000000000000000000000000000000000000000000000000000000","L1 InfoTree Idx":"0","L2 Block Number":"426","Min. Timestamp":"0","State Root":"0x0d43082ea60965b1bf7bccb0001babf0b486390e4bf13cadb6282aae219ea8f5","Timestamp":"1727205926 (2024-09-24 15:25:26 -0400 EDT)"}
214+
{"Data":"0xf86e82ed86843b9aca0082520894deadbeefdeadbeefdeadbeefdeadbeefdeadbeef87038d7ea4c6800080824f0da09fad01f022fa8675a5eb04a9e062eae1efed7c1e0ccac394bd821cc925b2707ba02494a393b3c6720f1c2da44a92296738724cbdbc0c0449e6b2e1e977626dc761","Effec. Gas Price":"255","Entry Number":"62685","Entry Type":"L2 Transaction","IM State Root ":"0x0000000000000000000000000000000000000000000000000000000000000000","Index":"0","Is Valid":"true","L2 Block Number":"426","Nonce ":"60806","Sender":"0xe34aaf64b29273b7d567fcfc40544c014eee9970"}
215+
{"Data":"0xf86e82ed87843b9aca0082520894deadbeefdeadbeefdeadbeefdeadbeefdeadbeef87038d7ea4c6800080824f0da0b39f4f13d0b68095d45bbae09608d264ba09056d905d95d2fa73a5158fa1c0ffa056c06604a5d400784addd5e044f3f4be4aadbeb3d919b77e11c6867c1d53a289","Effec. Gas Price":"255","Entry Number":"62686","Entry Type":"L2 Transaction","IM State Root ":"0x0000000000000000000000000000000000000000000000000000000000000000","Index":"0","Is Valid":"true","L2 Block Number":"426","Nonce ":"60807","Sender":"0xe34aaf64b29273b7d567fcfc40544c014eee9970"}
216+
```

0 commit comments

Comments
 (0)