Skip to content

Commit

Permalink
IMPORTANT: force reindex in WithdrawalInitiatedLogV2
Browse files Browse the repository at this point in the history
  • Loading branch information
bendanzhentan committed Mar 14, 2024
1 parent dcb58d8 commit 270d0fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions core/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
10 changes: 5 additions & 5 deletions core/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit 270d0fa

Please sign in to comment.