From 699abe2e284d5e4b4c13b3b699e027d83427c23b Mon Sep 17 00:00:00 2001 From: zhouop0 <11733741+zhouop0@users.noreply.github.com> Date: Sun, 31 Aug 2025 15:55:55 +0800 Subject: [PATCH 1/4] fix bugs --- internal/handler/syncFrontendMove.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/handler/syncFrontendMove.go b/internal/handler/syncFrontendMove.go index 1056c4c..7a33fb0 100644 --- a/internal/handler/syncFrontendMove.go +++ b/internal/handler/syncFrontendMove.go @@ -1,6 +1,7 @@ package handler import ( + "strconv" "time" "github.com/optimism-java/dispute-explorer/internal/schema" @@ -72,8 +73,13 @@ func syncSingleTransaction(ctx *svc.ServiceContext, transaction *schema.Frontend } // 2. update game_claim_data is_from_frontend column to true + parentIndexUint32, err := strconv.ParseUint(transaction.ParentIndex, 10, 32) + if err != nil { + return err + } + err = tx.Model(&schema.GameClaimData{}). - Where("game_contract = ? AND parent_index = ?", transaction.GameContract, transaction.ParentIndex). + Where("game_contract = ? AND parent_index = ?", transaction.GameContract, uint32(parentIndexUint32)). Update("is_from_frontend", true).Error if err != nil { tx.Rollback() From 84da115156d18c304e2096100d2f41b75126416d Mon Sep 17 00:00:00 2001 From: zhouop0 <11733741+zhouop0@users.noreply.github.com> Date: Sun, 31 Aug 2025 16:12:05 +0800 Subject: [PATCH 2/4] fix bugs --- internal/handler/frontend_move.go | 6 +++--- internal/handler/syncFrontendMove.go | 30 ++++++++++++++++------------ 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/internal/handler/frontend_move.go b/internal/handler/frontend_move.go index 5d7aff7..e5bb0f8 100644 --- a/internal/handler/frontend_move.go +++ b/internal/handler/frontend_move.go @@ -138,9 +138,9 @@ func (h *FrontendMoveHandler) monitorTransactionStatus(recordID int64, txHash st log.Infof("[FrontendMoveHandler] Transaction %s status updated to %s", txHash, status) // If transaction is successful, mark related records - if receipt.Status == 1 { - h.markRelatedRecords(txHash, receipt.BlockNumber.Int64()) - } + //if receipt.Status == 1 { + // h.markRelatedRecords(txHash, receipt.BlockNumber.Int64()) + //} return } diff --git a/internal/handler/syncFrontendMove.go b/internal/handler/syncFrontendMove.go index 7a33fb0..8f6e48b 100644 --- a/internal/handler/syncFrontendMove.go +++ b/internal/handler/syncFrontendMove.go @@ -1,7 +1,7 @@ package handler import ( - "strconv" + "fmt" "time" "github.com/optimism-java/dispute-explorer/internal/schema" @@ -44,10 +44,12 @@ func processFrontendMoveTransactions(ctx *svc.ServiceContext) error { for i := range unsyncedTransactions { transaction := &unsyncedTransactions[i] - err := syncSingleTransaction(ctx, transaction) - if err != nil { - log.Errorf("[Handler.SyncFrontendMoveTransactions] Failed to sync transaction %s: %s", transaction.TxHash, err) - continue + if transaction.Status == schema.FrontendMoveStatusConfirmed { + err := syncSingleTransaction(ctx, transaction) + if err != nil { + log.Errorf("[Handler.SyncFrontendMoveTransactions] Failed to sync transaction %s: %s", transaction.TxHash, err) + continue + } } } @@ -73,17 +75,19 @@ func syncSingleTransaction(ctx *svc.ServiceContext, transaction *schema.Frontend } // 2. update game_claim_data is_from_frontend column to true - parentIndexUint32, err := strconv.ParseUint(transaction.ParentIndex, 10, 32) - if err != nil { - return err + result := tx.Model(&schema.GameClaimData{}). + Where("game_contract = ? AND parent_index = ?", transaction.GameContract, transaction.ParentIndex). + Update("is_from_frontend", true) + if result.Error != nil { + tx.Rollback() + return result.Error } - err = tx.Model(&schema.GameClaimData{}). - Where("game_contract = ? AND parent_index = ?", transaction.GameContract, uint32(parentIndexUint32)). - Update("is_from_frontend", true).Error - if err != nil { + if result.RowsAffected == 0 { tx.Rollback() - return err + log.Warnf("[Handler.SyncFrontendMoveTransactions] No matching game_claim_data found for transaction %s (game: %s, parent_index: %s), will retry later", + transaction.TxHash, transaction.GameContract, transaction.ParentIndex) + return fmt.Errorf("no matching game_claim_data found, will retry later") } // 3. update frontend_move_transactions is_synced column to true From 0fe20ef1d6c9c53e3c52cf2285a4c6fac006ab95 Mon Sep 17 00:00:00 2001 From: zhouop0 <11733741+zhouop0@users.noreply.github.com> Date: Sun, 31 Aug 2025 16:25:22 +0800 Subject: [PATCH 3/4] format --- internal/handler/frontend_move.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/handler/frontend_move.go b/internal/handler/frontend_move.go index e5bb0f8..f80825e 100644 --- a/internal/handler/frontend_move.go +++ b/internal/handler/frontend_move.go @@ -138,9 +138,9 @@ func (h *FrontendMoveHandler) monitorTransactionStatus(recordID int64, txHash st log.Infof("[FrontendMoveHandler] Transaction %s status updated to %s", txHash, status) // If transaction is successful, mark related records - //if receipt.Status == 1 { + // if receipt.Status == 1 { // h.markRelatedRecords(txHash, receipt.BlockNumber.Int64()) - //} + // } return } From 364ce874346af351495ca611b9d64843c05ea8c6 Mon Sep 17 00:00:00 2001 From: zhouop0 <11733741+zhouop0@users.noreply.github.com> Date: Sun, 31 Aug 2025 16:30:25 +0800 Subject: [PATCH 4/4] format --- internal/handler/frontend_move.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/handler/frontend_move.go b/internal/handler/frontend_move.go index f80825e..43a6aa2 100644 --- a/internal/handler/frontend_move.go +++ b/internal/handler/frontend_move.go @@ -159,7 +159,7 @@ func (h *FrontendMoveHandler) monitorTransactionStatus(recordID int64, txHash st log.Warnf("[FrontendMoveHandler] Transaction %s monitoring timeout", txHash) } -// markRelatedRecords marks related block and event records +//nolint:unused func (h *FrontendMoveHandler) markRelatedRecords(txHash string, blockNumber int64) { // Mark related blocks err := h.svc.DB.Model(&schema.DisputeGame{}).