Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
colinlyguo committed Jan 17, 2024
1 parent af946ed commit 7b0495c
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions common/types/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ const (
TxStatusReplaced
// TxStatusConfirmed indicates that the transaction has been successfully processed and confirmed.
TxStatusConfirmed
// TxStatusFailed indicates that the transaction has failed during processing.
TxStatusFailed
// TxStatusConfirmedFailed indicates that the transaction has failed during processing.
TxStatusConfirmedFailed
)

// String returns a string representation of the TxStatus.
Expand All @@ -288,8 +288,8 @@ func (s TxStatus) String() string {
return "TxStatusReplaced"
case TxStatusConfirmed:
return "TxStatusConfirmed"
case TxStatusFailed:
return "TxStatusFailed"
case TxStatusConfirmedFailed:
return "TxStatusConfirmedFailed"
default:
return fmt.Sprintf("Unknown (%d)", int32(s))
}
Expand Down
6 changes: 3 additions & 3 deletions common/types/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ func TestTxStatus(t *testing.T) {
"TxStatusConfirmed",
},
{
"TxStatusFailed",
TxStatusFailed,
"TxStatusFailed",
"TxStatusConfirmedFailed",
TxStatusConfirmedFailed,
"TxStatusConfirmedFailed",
},
{
"Invalid Value",
Expand Down
2 changes: 1 addition & 1 deletion database/migrate/migrations/00015_pending_transaction.sql
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ CREATE INDEX idx_pending_transaction_on_sender_address_nonce ON pending_transact

COMMENT ON COLUMN pending_transaction.type IS 'unknown, commit batch, finalize batch, L1 gas oracle, L2 gas oracle';

COMMENT ON COLUMN pending_transaction.status IS 'unknown, pending, confirmed, failed';
COMMENT ON COLUMN pending_transaction.status IS 'unknown, pending, confirmed, confirmed failed';

-- +goose StatementEnd

Expand Down
2 changes: 1 addition & 1 deletion rollup/internal/controller/sender/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ func (s *Sender) checkPendingTransaction() {
log.Error("failed to get transaction status by tx hash", "hash", tx.Hash().String(), "err", err)
return
}
if status == types.TxStatusFailed {
if status == types.TxStatusConfirmedFailed {
log.Warn("transaction already marked as failed, skipping resubmission", "hash", tx.Hash().String())
return
}
Expand Down
2 changes: 1 addition & 1 deletion rollup/internal/controller/sender/sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func testSendAndRetrieveTransaction(t *testing.T) {
assert.Equal(t, "0", txs[0].ContextID)
assert.Equal(t, hash.String(), txs[0].Hash)
assert.Equal(t, uint8(i), txs[0].Type)
assert.Equal(t, types.TxStatusPending, types.TxStatus(txs[0].Status))
assert.Equal(t, types.TxStatusPending, txs[0].Status)
assert.Equal(t, "0x1C5A77d9FA7eF466951B2F01F724BCa3A5820b63", txs[0].SenderAddress)
assert.Equal(t, types.SenderTypeUnknown, txs[0].SenderType)
assert.Equal(t, "test", txs[0].SenderService)
Expand Down
2 changes: 1 addition & 1 deletion rollup/internal/orm/orm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func TestTransactionOrm(t *testing.T) {

status, err := pendingTransactionOrm.GetTxStatusByTxHash(context.Background(), tx1.Hash().String())
assert.NoError(t, err)
assert.Equal(t, types.TxStatusFailed, status)
assert.Equal(t, types.TxStatusConfirmedFailed, status)
}

func createTestTransaction(nonce uint64, gasTipCap, gasFeeCap *big.Int) *gethTypes.Transaction {
Expand Down
4 changes: 2 additions & 2 deletions rollup/internal/orm/pending_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (o *PendingTransaction) UpdatePendingTransactionStatusByTxHash(ctx context.
return nil
}

// UpdateOtherTransactionsAsFailedByNonce updates the status of all transactions to TxStatusFailed for a specific nonce and sender address, excluding a specified transaction hash.
// UpdateOtherTransactionsAsFailedByNonce updates the status of all transactions to TxStatusConfirmedFailed for a specific nonce and sender address, excluding a specified transaction hash.
func (o *PendingTransaction) UpdateOtherTransactionsAsFailedByNonce(ctx context.Context, senderAddress string, nonce uint64, txHash string, dbTX ...*gorm.DB) error {
db := o.db
if len(dbTX) > 0 && dbTX[0] != nil {
Expand All @@ -147,7 +147,7 @@ func (o *PendingTransaction) UpdateOtherTransactionsAsFailedByNonce(ctx context.
db = db.Where("sender_address = ?", senderAddress)
db = db.Where("nonce = ?", nonce)
db = db.Where("hash != ?", txHash)
if err := db.Update("status", types.TxStatusFailed).Error; err != nil {
if err := db.Update("status", types.TxStatusConfirmedFailed).Error; err != nil {
return fmt.Errorf("failed to update other transactions as failed by nonce, senderAddress: %s, nonce: %d, txHash: %s, error: %w", senderAddress, nonce, txHash, err)
}
return nil
Expand Down

0 comments on commit 7b0495c

Please sign in to comment.