@@ -1483,7 +1483,13 @@ func revertV2ContractFormation(tx *txn, reverted []types.V2FileContractElement)
1483
1483
return fmt .Errorf ("failed to delete contract state element %q: %w" , fce .ID , err )
1484
1484
}
1485
1485
1486
- if state .Status != contracts .V2ContractStatusActive {
1486
+ if state .Status == contracts .V2ContractStatusRenewed || state .Status == contracts .V2ContractStatusSuccessful {
1487
+ // note: special case due to a bug in revert handling. This should not happen, but we need to account for it
1488
+ // in the revert logic.
1489
+ if err := updateV2EarnedRevenueMetrics (state .Usage , true , incrementCurrencyStat ); err != nil {
1490
+ return fmt .Errorf ("failed to update earned revenue metrics: %w" , err )
1491
+ }
1492
+ } else if state .Status != contracts .V2ContractStatusActive {
1487
1493
// if the contract is not active, panic. Applies should have ensured
1488
1494
// that this never happens.
1489
1495
panic (fmt .Errorf ("unexpected contract state transition %q -> %q" , state .Status , contracts .ContractStatusPending ))
@@ -1715,7 +1721,7 @@ func revertSuccessfulV2Contracts(tx *txn, status contracts.V2ContractStatus, suc
1715
1721
}
1716
1722
1717
1723
// update the contract's resolution index and status
1718
- if res , err := updateStmt .Exec (status , state .ID ); err != nil {
1724
+ if res , err := updateStmt .Exec (contracts . V2ContractStatusActive , state .ID ); err != nil {
1719
1725
return fmt .Errorf ("failed to update contract %q: %w" , contractID , err )
1720
1726
} else if n , err := res .RowsAffected (); err != nil {
1721
1727
return fmt .Errorf ("failed to get rows affected: %w" , err )
0 commit comments