Repository: celestiaorg/celestia-app

Issue:
v4 upgrade height delay is 7 days for testnets
## Context

On v4

https://github.com/celestiaorg/celestia-app/blob/e3444fa21966306a3885afea6ca0c8b1db90a3db/pkg/appconsts/versioned_consts.go#L29-L36

## Problem

On v3, we reduced the upgrade height delay for testnets:
- Arabica 1 day
- Mocha 2 days

 That change didn't got included on v4.x.

## Proposal

On v4.x:
- [ ] Decrease upgrade height delay on Arabica to 1 day
- [ ] Decrease upgrade height delay on Mocha to 2 days

Discussion:
@evan-forbes: 😭 

damn... since this is consensus breaking, does that mean we're stuck with 7 days?@rootulp: It is consensus breaking but we'll fix it before Arabica or Mocha upgrade from v4 -> v5. 

Solution patch:
diff --git a/pkg/appconsts/v4/app_consts.go b/pkg/appconsts/v4/app_consts.go
index afd28df3..cfe2c464 100644
--- a/pkg/appconsts/v4/app_consts.go
+++ b/pkg/appconsts/v4/app_consts.go
@@ -20,8 +20,22 @@ const (
 	MaxTxSize            int    = 2097152 // 2 MiB in bytes
 	TimeoutPropose              = time.Millisecond * 3500
 	TimeoutCommit               = time.Millisecond * 4200
-	// UpgradeHeightDelay is the number of blocks after a quorum has been
-	// reached that the chain should upgrade to the new version. Assuming a block
-	// interval of 6 seconds, this is 7 days.
-	UpgradeHeightDelay = int64(7 * 24 * 60 * 60 / 6) // 7 days * 24 hours * 60 minutes * 60 seconds / 6 seconds per block = 100,800 blocks.
+
+	// TestUpgradeHeightDelay is the number of blocks that chain-id "test" waits
+	// after a MsgTryUpgrade to activate the next version.
+	TestUpgradeHeightDelay = int64(3)
+	// ArabicaUpgradeHeightDelay is the number of blocks that Arabica waits
+	// after a MsgTryUpgrade to activate the next version. Assuming a block
+	// interval of 6 seconds, this is 1 day.
+	ArabicaUpgradeHeightDelay = int64(14_400)
+	// MochaUpgradeHeightDelay is the number of blocks that Mocha waits
+	// after a MsgTryUpgrade to activate the next version. Assuming a block
+	// interval of 6 seconds, this is 2 days.
+	MochaUpgradeHeightDelay = int64(28_800)
+	// MainnetUpgradeHeightDelay is the number of blocks that Mainnet waits
+	// after a MsgTryUpgrade to activate the next version. Assuming a block
+	// interval of 6 seconds, this is 7 day.
+	MainnetUpgradeHeightDelay = int64(100_800)
+	// Deprecated: Use MainnetUpgradeHeightDelay instead.
+	UpgradeHeightDelay = MainnetUpgradeHeightDelay
 )
diff --git a/pkg/appconsts/versioned_consts.go b/pkg/appconsts/versioned_consts.go
index 2327fa35..d93e606d 100644
--- a/pkg/appconsts/versioned_consts.go
+++ b/pkg/appconsts/versioned_consts.go
@@ -15,11 +15,17 @@ var (
 	TxSizeCostPerByte    = v4.TxSizeCostPerByte
 	GasPerBlobByte       = v4.GasPerBlobByte
 	Version              = v4.Version
-	UpgradeHeightDelay   = v4.UpgradeHeightDelay
 	MaxTxSize            = v4.MaxTxSize
 	SubtreeRootThreshold = v4.SubtreeRootThreshold
 	TimeoutCommit        = v4.TimeoutCommit
 	TimeoutPropose       = v4.TimeoutPropose
+
+	TestUpgradeHeightDelay    = v4.TestUpgradeHeightDelay
+	ArabicaUpgradeHeightDelay = v4.ArabicaUpgradeHeightDelay
+	MochaUpgradeHeightDelay   = v4.MochaUpgradeHeightDelay
+	MainnetUpgradeHeightDelay = v4.MainnetUpgradeHeightDelay
+	// Deprecated: Use MainnetUpgradeHeightDelay instead.
+	UpgradeHeightDelay = v4.MainnetUpgradeHeightDelay
 )
 
 func GetTimeoutCommit(_ uint64) time.Duration {
@@ -30,7 +36,13 @@ func GetTimeoutCommit(_ uint64) time.Duration {
 // reached that the chain should upgrade to the new version.
 func GetUpgradeHeightDelay(chainID string) int64 {
 	if chainID == TestChainID {
-		return 3
+		return v4.TestUpgradeHeightDelay
+	}
+	if chainID == ArabicaChainID {
+		return v4.ArabicaUpgradeHeightDelay
+	}
+	if chainID == MochaChainID {
+		return v4.MochaUpgradeHeightDelay
 	}
-	return v4.UpgradeHeightDelay
+	return v4.MainnetUpgradeHeightDelay
 }



Test patch:
diff --git a/pkg/appconsts/v4/app_consts_test.go b/pkg/appconsts/v4/app_consts_test.go
new file mode 100644
index 00000000..48a86484
--- /dev/null
+++ b/pkg/appconsts/v4/app_consts_test.go
@@ -0,0 +1,25 @@
+package v4
+
+import (
+	"testing"
+
+	"github.com/stretchr/testify/require"
+)
+
+func TestConsts(t *testing.T) {
+	t.Run("TestUpgradeHeightDelay should be 3", func(t *testing.T) {
+		require.Equal(t, int64(3), TestUpgradeHeightDelay)
+	})
+	t.Run("ArabicaUpgradeHeightDelay should be 1 day of 6 second blocks", func(t *testing.T) {
+		require.Equal(t, int64(1*60*60*24/6), ArabicaUpgradeHeightDelay)
+		require.Equal(t, int64(14_400), ArabicaUpgradeHeightDelay)
+	})
+	t.Run("MochaUpgradeHeightDelay should be 2 days of 6 second blocks", func(t *testing.T) {
+		require.Equal(t, int64(2*60*60*24/6), MochaUpgradeHeightDelay)
+		require.Equal(t, int64(28_800), MochaUpgradeHeightDelay)
+	})
+	t.Run("MainnetUpgradeHeightDelay should be 7 days of 6 second blocks", func(t *testing.T) {
+		require.Equal(t, int64(7*60*60*24/6), MainnetUpgradeHeightDelay)
+		require.Equal(t, int64(100_800), MainnetUpgradeHeightDelay)
+	})
+}
diff --git a/pkg/appconsts/versioned_consts_test.go b/pkg/appconsts/versioned_consts_test.go
index f2e7273e..2219cb64 100644
--- a/pkg/appconsts/versioned_consts_test.go
+++ b/pkg/appconsts/versioned_consts_test.go
@@ -7,28 +7,38 @@ import (
 	"github.com/stretchr/testify/require"
 )
 
-func TestUpgradeHeightDelay(t *testing.T) {
+func TestGetUpgradeHeightDelay(t *testing.T) {
 	tests := []struct {
 		name                       string
 		chainID                    string
 		expectedUpgradeHeightDelay int64
 	}{
 		{
-			name:                       "the upgrade delay for chainID 'test' should be 3",
+			name:                       "the upgrade delay for chainID test",
 			chainID:                    appconsts.TestChainID,
-			expectedUpgradeHeightDelay: 3,
+			expectedUpgradeHeightDelay: appconsts.TestUpgradeHeightDelay,
 		},
 		{
-			name:                       "the upgrade delay should be latest value",
-			chainID:                    "arabica-11",
-			expectedUpgradeHeightDelay: appconsts.UpgradeHeightDelay,
+			name:                       "the upgrade delay for arabica",
+			chainID:                    appconsts.ArabicaChainID,
+			expectedUpgradeHeightDelay: appconsts.ArabicaUpgradeHeightDelay,
+		},
+		{
+			name:                       "the upgrade delay for mocha",
+			chainID:                    appconsts.MochaChainID,
+			expectedUpgradeHeightDelay: appconsts.MochaUpgradeHeightDelay,
+		},
+		{
+			name:                       "the upgrade delay for mainnet",
+			chainID:                    appconsts.MainnetChainID,
+			expectedUpgradeHeightDelay: appconsts.MainnetUpgradeHeightDelay,
 		},
 	}
 
 	for _, tc := range tests {
 		t.Run(tc.name, func(t *testing.T) {
-			actual := appconsts.GetUpgradeHeightDelay(tc.chainID)
-			require.Equal(t, tc.expectedUpgradeHeightDelay, actual)
+			got := appconsts.GetUpgradeHeightDelay(tc.chainID)
+			require.Equal(t, tc.expectedUpgradeHeightDelay, got)
 		})
 	}
 }