Skip to content

Commit 4281ecb

Browse files
committed
update event watcher
1 parent eee8c49 commit 4281ecb

File tree

4 files changed

+38
-20
lines changed

4 files changed

+38
-20
lines changed

Jenkinsfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ pipeline {
4747
sh 'make -C bridge docker'
4848
}
4949
}
50-
stage('Check Coordinator Docker Build') {
51-
steps {
52-
sh 'make -C coordinator docker'
53-
}
54-
}
50+
//stage('Check Coordinator Docker Build') {
51+
// steps {
52+
// sh 'make -C coordinator docker'
53+
// }
54+
//}
5555
stage('Check Database Docker Build') {
5656
steps {
5757
sh 'make -C database docker'

bridge/abi/bridge_abi.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ const (
2323
// CommitBatchEventSignature = keccak256("CommitBatch(bytes32)")
2424
CommitBatchEventSignature = "2cdc615c74452778c0fb6184735e014c13aad2b62774fe0b09bd1dcc2cc14a62"
2525

26+
// CommitBatchesEventSignature = keccak256("CommitBatches(bytes32)")
27+
CommitBatchesEventSignature = "188adc06d38d0173d973ad47531a02ad89cd941508eab21b3d41f3bb41bf9eb9"
28+
2629
// FinalizedBatchEventSignature = keccak256("FinalizeBatch(bytes32)")
2730
FinalizedBatchEventSignature = "6be443154c959a7a1645b4392b6fa97d8e8ab6e8fd853d7085e8867083737d79"
2831
)

bridge/l1/watcher.go

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ func (w *Watcher) FetchContractEvent(blockHeight uint64) error {
222222
query.Topics[0][1] = common.HexToHash(bridge_abi.RelayedMessageEventSignature)
223223
query.Topics[0][2] = common.HexToHash(bridge_abi.FailedRelayedMessageEventSignature)
224224
query.Topics[0][3] = common.HexToHash(bridge_abi.CommitBatchEventSignature)
225-
query.Topics[0][4] = common.HexToHash(bridge_abi.FinalizedBatchEventSignature)
225+
query.Topics[0][4] = common.HexToHash(bridge_abi.CommitBatchesEventSignature)
226+
query.Topics[0][5] = common.HexToHash(bridge_abi.FinalizedBatchEventSignature)
226227

227228
logs, err := w.client.FilterLogs(w.ctx, query)
228229
if err != nil {
@@ -365,10 +366,8 @@ func (w *Watcher) parseBridgeEventLogs(logs []geth_types.Log) ([]*types.L1Messag
365366
})
366367
case common.HexToHash(bridge_abi.CommitBatchEventSignature):
367368
event := struct {
368-
BatchID common.Hash
369-
BatchHash common.Hash
370-
BatchIndex *big.Int
371-
ParentHash common.Hash
369+
BatchID common.Hash
370+
BatchHash common.Hash
372371
}{}
373372
// BatchID is in topics[1]
374373
event.BatchID = common.HexToHash(vLog.Topics[1].String())
@@ -378,17 +377,33 @@ func (w *Watcher) parseBridgeEventLogs(logs []geth_types.Log) ([]*types.L1Messag
378377
return l1Messages, relayedMessages, rollupEvents, err
379378
}
380379

380+
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+
381398
rollupEvents = append(rollupEvents, rollupEvent{
382399
batchID: event.BatchID,
383400
txHash: vLog.TxHash,
384401
status: types.RollupCommitted,
385402
})
386403
case common.HexToHash(bridge_abi.FinalizedBatchEventSignature):
387404
event := struct {
388-
BatchID common.Hash
389-
BatchHash common.Hash
390-
BatchIndex *big.Int
391-
ParentHash common.Hash
405+
BatchID common.Hash
406+
BatchHash common.Hash
392407
}{}
393408
// BatchID is in topics[1]
394409
event.BatchID = common.HexToHash(vLog.Topics[1].String())

bridge/l2/relayer.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,9 @@ func (r *Layer2Relayer) SendCommitTx(batchData []*types.BatchData) error {
352352
calldata, err := r.l1RollupABI.Pack("commitBatches", commitBatches)
353353
if err != nil {
354354
log.Error("Failed to pack commitBatches",
355-
"error", err,
356-
"start_batch_index", commitBatches[0].BatchIndex,
357-
"end_batch_index", commitBatches[len(commitBatches)-1].BatchIndex)
355+
"error", err,
356+
"start_batch_index", commitBatches[0].BatchIndex,
357+
"end_batch_index", commitBatches[len(commitBatches)-1].BatchIndex)
358358
return err
359359
}
360360

@@ -372,9 +372,9 @@ func (r *Layer2Relayer) SendCommitTx(batchData []*types.BatchData) error {
372372
return err
373373
}
374374
log.Info("Sent the commitBatches tx to layer1",
375-
"hash", txHash,
376-
"start_batch_index", commitBatches[0].BatchIndex,
377-
"end_batch_index", commitBatches[len(commitBatches)-1].BatchIndex)
375+
"hash", txHash,
376+
"start_batch_index", commitBatches[0].BatchIndex,
377+
"end_batch_index", commitBatches[len(commitBatches)-1].BatchIndex)
378378

379379
// record and sync with db, @todo handle db error
380380
batchHashes := make([]string, len(batchData))

0 commit comments

Comments
 (0)