@@ -93,12 +93,6 @@ func action(ctx *cli.Context) error {
9393 }
9494
9595 startL2BlockHeight := ctx .Uint64 (utils .StartL2BlockFlag .Name )
96- startL2Block , err := l2Client .BlockByNumber (context .Background (), big .NewInt (int64 (startL2BlockHeight )))
97- if err != nil {
98- log .Crit ("failed to get start l2 block" , "startL2BlockHeight" , startL2BlockHeight , "error" , err )
99- }
100-
101- chunk := & encoding.Chunk {Blocks : []* encoding.Block {{Header : startL2Block .Header ()}}}
10296
10397 prevChunk , err := orm .NewChunk (dbForReplay ).GetParentChunkByBlockNumber (subCtx , startL2BlockHeight )
10498 if err != nil {
@@ -110,12 +104,32 @@ func action(ctx *cli.Context) error {
110104 startQueueIndex = prevChunk .TotalL1MessagesPoppedBefore + prevChunk .TotalL1MessagesPoppedInChunk
111105 }
112106
113- for _ , tx := range startL2Block .Transactions () {
114- if tx .Type () == gethTypes .L1MessageTxType {
115- startQueueIndex ++
107+ startBlock := uint64 (0 )
108+ if prevChunk != nil {
109+ startBlock = prevChunk .EndBlockNumber + 1
110+ }
111+
112+ var chunk * encoding.Chunk
113+ for blockNum := startBlock ; blockNum <= startL2BlockHeight ; blockNum ++ {
114+ block , err := l2Client .BlockByNumber (context .Background (), big .NewInt (int64 (blockNum )))
115+ if err != nil {
116+ log .Crit ("failed to get block" , "block number" , blockNum , "error" , err )
117+ }
118+
119+ for _ , tx := range block .Transactions () {
120+ if tx .Type () == gethTypes .L1MessageTxType {
121+ startQueueIndex ++
122+ }
123+ }
124+
125+ if blockNum == startL2BlockHeight {
126+ chunk = & encoding.Chunk {Blocks : []* encoding.Block {{Header : block .Header ()}}}
116127 }
117128 }
118129
130+ // Setting empty hash as the post_l1_message_queue_hash of the first chunk,
131+ // i.e., treating the first L1 message after this chunk as the first L1 message in message queue v2.
132+ // Though this setting is different from mainnet, it's simple yet sufficient for data analysis usage.
119133 _ , err = orm .NewChunk (db ).InsertTestChunkForProposerTool (subCtx , chunk , encoding .CodecV0 , startQueueIndex )
120134 if err != nil {
121135 log .Crit ("failed to insert chunk" , "error" , err )
0 commit comments