diff --git a/core/metrics.go b/core/metrics.go index 00520ca..c4d8d27 100644 --- a/core/metrics.go +++ b/core/metrics.go @@ -63,35 +63,35 @@ func StartMetrics(ctx context.Context, cfg *Config, l1Client *ethclient.Client, ScannedBlockNumber.Set(float64(scannedBlock.Number)) var unprovenCnt int64 - result = db.Table("withdrawal_initiated_logs").Where("proven_time IS NULL AND failure_reason IS NULL").Count(&unprovenCnt) + result = db.Table("withdrawal_initiated_log_v2").Where("proven_time IS NULL AND failure_reason IS NULL").Count(&unprovenCnt) if result.Error != nil { logger.Error("failed to count withdrawals", "error", result.Error) } UnprovenWithdrawals.Set(float64(unprovenCnt)) var unfinalizedCnt int64 - result = db.Table("withdrawal_initiated_logs").Where("finalized_time IS NULL AND proven_time IS NOT NULL AND failure_reason IS NULL").Count(&unfinalizedCnt) + result = db.Table("withdrawal_initiated_log_v2").Where("finalized_time IS NULL AND proven_time IS NOT NULL AND failure_reason IS NULL").Count(&unfinalizedCnt) if result.Error != nil { logger.Error("failed to count withdrawals", "error", result.Error) } UnfinalizedWithdrawals.Set(float64(unfinalizedCnt)) var failedCnt int64 - result = db.Table("withdrawal_initiated_logs").Where("failure_reason IS NOT NULL").Count(&failedCnt) + result = db.Table("withdrawal_initiated_log_v2").Where("failure_reason IS NOT NULL").Count(&failedCnt) if result.Error != nil { logger.Error("failed to count withdrawals", "error", result.Error) } FailedWithdrawals.Set(float64(failedCnt)) firstUnproven := WithdrawalInitiatedLogV2{} - result = db.Table("withdrawal_initiated_logs").Order("id asc").Where("proven_time IS NULL AND failure_reason IS NULL").First(&firstUnproven) + result = db.Table("withdrawal_initiated_log_v2").Order("id asc").Where("proven_time IS NULL AND failure_reason IS NULL").First(&firstUnproven) if result.Error != nil && !errors.Is(result.Error, gorm.ErrRecordNotFound) { logger.Error("failed to query withdrawals", "error", result.Error) } EarliestUnProvenWithdrawalBlockNumber.Set(float64(firstUnproven.InitiatedBlockNumber)) firstUnfinalized := WithdrawalInitiatedLogV2{} - result = db.Table("withdrawal_initiated_logs").Order("id asc").Where("finalized_time IS NULL AND proven_time IS NOT NULL AND failure_reason IS NULL").First(&firstUnfinalized) + result = db.Table("withdrawal_initiated_log_v2").Order("id asc").Where("finalized_time IS NULL AND proven_time IS NOT NULL AND failure_reason IS NULL").First(&firstUnfinalized) if result.Error != nil && !errors.Is(result.Error, gorm.ErrRecordNotFound) { logger.Error("failed to query withdrawals", "error", result.Error) } diff --git a/core/types.go b/core/types.go index abe533b..21585a5 100644 --- a/core/types.go +++ b/core/types.go @@ -14,17 +14,17 @@ type WithdrawalInitiatedLogV2 struct { ID uint `gorm:"primarykey"` // TransactionHash and LogIndex are the L2 transaction hash and log index of the withdrawal event. - TransactionHash string `gorm:"type:varchar(256);not null;uniqueIndex:idx_withdrawal_initiated_logs_transaction_hash_log_index_key,priority:1"` - LogIndex int `gorm:"type:integer;not null;uniqueIndex:idx_withdrawal_initiated_logs_transaction_hash_log_index_key,priority:2"` + TransactionHash string `gorm:"type:varchar(256);not null;uniqueIndex:idx_withdrawal_initiated_log_v2_transaction_hash_log_index_key,priority:1"` + LogIndex int `gorm:"type:integer;not null;uniqueIndex:idx_withdrawal_initiated_log_v2_transaction_hash_log_index_key,priority:2"` // InitiatedBlockNumber is the l2 block number at which the withdrawal was initiated on L2. - InitiatedBlockNumber int64 `gorm:"type:integer;not null;index:idx_withdrawal_initiated_logs_initiated_block_number"` + InitiatedBlockNumber int64 `gorm:"type:integer;not null;index:idx_withdrawal_initiated_log_v2_initiated_block_number"` // ProvenTime is the local time at which the withdrawal was proven on L1. NULL if not yet proven. - ProvenTime *time.Time `gorm:"type:datetime;index:idx_withdrawal_initiated_logs_proven_time"` + ProvenTime *time.Time `gorm:"type:datetime;index:idx_withdrawal_initiated_log_v2_proven_time"` // FinalizedTime is the local time at which the withdrawal was finalized on L1. NULL if not yet finalized. - FinalizedTime *time.Time `gorm:"type:datetime;index:idx_withdrawal_initiated_logs_finalized_time"` + FinalizedTime *time.Time `gorm:"type:datetime;index:idx_withdrawal_initiated_log_v2_finalized_time"` // FailureReason is the reason for the withdrawal failure, including sending transaction error and off-chain configured filter error. NULL if not yet failed. FailureReason *string `gorm:"type:text"`