@@ -33,9 +33,9 @@ type relayedMessage struct {
33
33
}
34
34
35
35
type rollupEvent struct {
36
- batchID common.Hash
37
- txHash common.Hash
38
- status types.RollupStatus
36
+ batchHash common.Hash
37
+ txHash common.Hash
38
+ status types.RollupStatus
39
39
}
40
40
41
41
// Watcher will listen for smart contract events from Eth L1.
@@ -222,8 +222,7 @@ func (w *Watcher) FetchContractEvent(blockHeight uint64) error {
222
222
query .Topics [0 ][1 ] = common .HexToHash (bridge_abi .RelayedMessageEventSignature )
223
223
query .Topics [0 ][2 ] = common .HexToHash (bridge_abi .FailedRelayedMessageEventSignature )
224
224
query .Topics [0 ][3 ] = common .HexToHash (bridge_abi .CommitBatchEventSignature )
225
- query .Topics [0 ][4 ] = common .HexToHash (bridge_abi .CommitBatchesEventSignature )
226
- query .Topics [0 ][5 ] = common .HexToHash (bridge_abi .FinalizedBatchEventSignature )
225
+ query .Topics [0 ][4 ] = common .HexToHash (bridge_abi .FinalizedBatchEventSignature )
227
226
228
227
logs , err := w .client .FilterLogs (w .ctx , query )
229
228
if err != nil {
@@ -245,22 +244,22 @@ func (w *Watcher) FetchContractEvent(blockHeight uint64) error {
245
244
log .Info ("L1 events types" , "SentMessageCount" , len (sentMessageEvents ), "RelayedMessageCount" , len (relayedMessageEvents ), "RollupEventCount" , len (rollupEvents ))
246
245
247
246
// use rollup event to update rollup results db status
248
- var batchIDs []string
247
+ var batchHashes []string
249
248
for _ , event := range rollupEvents {
250
- batchIDs = append (batchIDs , event .batchID .String ())
249
+ batchHashes = append (batchHashes , event .batchHash .String ())
251
250
}
252
- statuses , err := w .db .GetRollupStatusByIDList (batchIDs )
251
+ statuses , err := w .db .GetRollupStatusByIDList (batchHashes )
253
252
if err != nil {
254
253
log .Error ("Failed to GetRollupStatusByIDList" , "err" , err )
255
254
return err
256
255
}
257
- if len (statuses ) != len (batchIDs ) {
258
- log .Error ("RollupStatus.Length mismatch with BatchIDs .Length" , "RollupStatus.Length" , len (statuses ), "BatchIDs .Length" , len (batchIDs ))
256
+ if len (statuses ) != len (batchHashes ) {
257
+ log .Error ("RollupStatus.Length mismatch with batchHashes .Length" , "RollupStatus.Length" , len (statuses ), "batchHashes .Length" , len (batchHashes ))
259
258
return nil
260
259
}
261
260
262
261
for index , event := range rollupEvents {
263
- batchID := event .batchID .String ()
262
+ batchID := event .batchHash .String ()
264
263
status := statuses [index ]
265
264
// only update when db status is before event status
266
265
if event .status > status {
@@ -366,57 +365,37 @@ func (w *Watcher) parseBridgeEventLogs(logs []geth_types.Log) ([]*types.L1Messag
366
365
})
367
366
case common .HexToHash (bridge_abi .CommitBatchEventSignature ):
368
367
event := struct {
369
- BatchID common.Hash
370
368
BatchHash common.Hash
371
369
}{}
372
370
// BatchID is in topics[1]
373
- event .BatchID = common .HexToHash (vLog .Topics [1 ].String ())
371
+ event .BatchHash = common .HexToHash (vLog .Topics [1 ].String ())
374
372
err := w .scrollchainABI .UnpackIntoInterface (& event , "CommitBatch" , vLog .Data )
375
373
if err != nil {
376
374
log .Warn ("Failed to unpack layer1 CommitBatch event" , "err" , err )
377
375
return l1Messages , relayedMessages , rollupEvents , err
378
376
}
379
377
380
378
rollupEvents = append (rollupEvents , rollupEvent {
381
- batchID : event .BatchID ,
382
- txHash : vLog .TxHash ,
383
- status : types .RollupCommitted ,
384
- })
385
- case common .HexToHash (bridge_abi .CommitBatchesEventSignature ):
386
- event := struct {
387
- BatchID common.Hash
388
- BatchHash common.Hash
389
- }{}
390
- // BatchID is in topics[1]
391
- event .BatchID = common .HexToHash (vLog .Topics [1 ].String ())
392
- err := w .scrollchainABI .UnpackIntoInterface (& event , "CommitBatches" , vLog .Data )
393
- if err != nil {
394
- log .Warn ("Failed to unpack layer1 CommitBatches event" , "err" , err )
395
- return l1Messages , relayedMessages , rollupEvents , err
396
- }
397
-
398
- rollupEvents = append (rollupEvents , rollupEvent {
399
- batchID : event .BatchID ,
400
- txHash : vLog .TxHash ,
401
- status : types .RollupCommitted ,
379
+ batchHash : event .BatchHash ,
380
+ txHash : vLog .TxHash ,
381
+ status : types .RollupCommitted ,
402
382
})
403
383
case common .HexToHash (bridge_abi .FinalizedBatchEventSignature ):
404
384
event := struct {
405
- BatchID common.Hash
406
385
BatchHash common.Hash
407
386
}{}
408
- // BatchID is in topics[1]
409
- event .BatchID = common .HexToHash (vLog .Topics [1 ].String ())
387
+ // BatchHash is in topics[1]
388
+ event .BatchHash = common .HexToHash (vLog .Topics [1 ].String ())
410
389
err := w .scrollchainABI .UnpackIntoInterface (& event , "FinalizeBatch" , vLog .Data )
411
390
if err != nil {
412
391
log .Warn ("Failed to unpack layer1 FinalizeBatch event" , "err" , err )
413
392
return l1Messages , relayedMessages , rollupEvents , err
414
393
}
415
394
416
395
rollupEvents = append (rollupEvents , rollupEvent {
417
- batchID : event .BatchID ,
418
- txHash : vLog .TxHash ,
419
- status : types .RollupFinalized ,
396
+ batchHash : event .BatchHash ,
397
+ txHash : vLog .TxHash ,
398
+ status : types .RollupFinalized ,
420
399
})
421
400
default :
422
401
log .Error ("Unknown event" , "topic" , vLog .Topics [0 ], "txHash" , vLog .TxHash )
0 commit comments