From ba4ef7bd9d78a1efbb9a5258a3ee413e1ec70f6e Mon Sep 17 00:00:00 2001 From: evan-forbes Date: Mon, 28 Oct 2024 16:24:14 -0500 Subject: [PATCH] refactor: use arabica-11 instead of all arabica networks --- pkg/appconsts/chain_ids.go | 5 +++++ pkg/appconsts/versioned_consts.go | 16 +++++++++------- pkg/appconsts/versioned_consts_test.go | 5 +++++ 3 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 pkg/appconsts/chain_ids.go diff --git a/pkg/appconsts/chain_ids.go b/pkg/appconsts/chain_ids.go new file mode 100644 index 0000000000..50c26932f9 --- /dev/null +++ b/pkg/appconsts/chain_ids.go @@ -0,0 +1,5 @@ +package appconsts + +const ( + ArabicaChainID = "arabica-11" +) diff --git a/pkg/appconsts/versioned_consts.go b/pkg/appconsts/versioned_consts.go index 8f99d8c3bb..6034453598 100644 --- a/pkg/appconsts/versioned_consts.go +++ b/pkg/appconsts/versioned_consts.go @@ -2,7 +2,6 @@ package appconsts import ( "strconv" - "strings" "time" v1 "github.com/celestiaorg/celestia-app/v3/pkg/appconsts/v1" @@ -88,13 +87,16 @@ func UpgradeHeightDelay(chainID string, v uint64) int64 { } return parsedValue } - switch { - case v == v1.Version: + switch v { + case v1.Version: return v1.UpgradeHeightDelay - // ONLY ON ARABICA: don't return the v2 value even when the app version is - // v2 on arabica. This is due to a bug that was shipped on arabica, where - // the next version was used. - case v == v2.Version && !strings.Contains(chainID, "arabica"): + case v2.Version: + // ONLY ON ARABICA: don't return the v2 value even when the app version is + // v2 on arabica. This is due to a bug that was shipped on arabica, where + // the next version was used. + if chainID == ArabicaChainID { + return v3.UpgradeHeightDelay + } return v2.UpgradeHeightDelay default: return v3.UpgradeHeightDelay diff --git a/pkg/appconsts/versioned_consts_test.go b/pkg/appconsts/versioned_consts_test.go index 249dd99805..1fc6c75cb0 100644 --- a/pkg/appconsts/versioned_consts_test.go +++ b/pkg/appconsts/versioned_consts_test.go @@ -105,6 +105,11 @@ func TestUpgradeHeightDelay(t *testing.T) { chainID: "celestia", version: v2.Version, expectedUpgradeHeightDelay: v2.UpgradeHeightDelay, + }, { + name: "v2 upgrade delay on an arabica network other than arabica-11", + chainID: "arabica-11", + version: v2.Version, + expectedUpgradeHeightDelay: v3.UpgradeHeightDelay, // falls back to v3 because of arabica bug }, { name: "v2 upgrade delay on arabica",