Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v20 host zone migration (add community pool treasury) #1154

Merged
merged 5 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions app/upgrades/v20/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@ import (
ccvtypes "github.com/cosmos/interchain-security/v4/x/ccv/types"

stakeibckeeper "github.com/Stride-Labs/stride/v19/x/stakeibc/keeper"
stakeibctypes "github.com/Stride-Labs/stride/v19/x/stakeibc/types"
)

const (
UpgradeName = "v20"
dydxCPTreasuryAddress = "dydx15ztc7xy42tn2ukkc0qjthkucw9ac63pgp70urn"
dydxChainId = "dydx-mainnet-1"
UpgradeName = "v20"
DydxCommunityPoolTreasuryAddress = "dydx15ztc7xy42tn2ukkc0qjthkucw9ac63pgp70urn"
sampocs marked this conversation as resolved.
Show resolved Hide resolved
DydxChainId = "dydx-mainnet-1"
)

// CreateUpgradeHandler creates an SDK upgrade handler for v20
func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
consumerKeeper ccvconsumerkeeper.Keeper,
stakeIbcKeeper stakeibckeeper.Keeper,
stakeibcKeeper stakeibckeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("Starting upgrade v20...")
Expand All @@ -42,19 +43,27 @@ func CreateUpgradeHandler(
MigrateICSParams(ctx, consumerKeeper)

ctx.Logger().Info("Adding DYDX Community Pool Treasury Address...")
if err := SetDydxCommunityPoolTreasuryAddress(ctx, stakeibcKeeper); err != nil {
return newVm, err
}

return newVm, nil
}
}

// Write the Community Pool Treasury Address to the DYDX host_zone struct
func SetDydxCommunityPoolTreasuryAddress(ctx sdk.Context, stakeIbcKeeper stakeibckeeper.Keeper) error {

func SetDydxCommunityPoolTreasuryAddress(ctx sdk.Context, k stakeibckeeper.Keeper) error {
// Get the dydx host_zone
hostZone, found := k.GetHostZone(ctx, DydxChainId)
if !found {
return stakeibctypes.ErrHostZoneNotFound.Wrapf("dydx host zone not found")
}

// Set the treasury address
hostZone.CommunityPoolTreasuryAddress = DydxCommunityPoolTreasuryAddress

// Save the dydx host_zone
k.SetHostZone(ctx, hostZone)

return nil
}
Expand Down
17 changes: 17 additions & 0 deletions app/upgrades/v20/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"github.com/stretchr/testify/suite"

"github.com/Stride-Labs/stride/v19/app/apptesting"
v20 "github.com/Stride-Labs/stride/v19/app/upgrades/v20"
stakeibctypes "github.com/Stride-Labs/stride/v19/x/stakeibc/types"
)

type UpgradeTestSuite struct {
Expand All @@ -21,4 +23,19 @@ func TestKeeperTestSuite(t *testing.T) {
}

func (s *UpgradeTestSuite) TestUpgrade() {
dummyUpgradeHeight := int64(5)

// Create a dydx host zone
s.App.StakeibcKeeper.SetHostZone(s.Ctx, stakeibctypes.HostZone{
ChainId: v20.DydxChainId,
})

// Run the upgrade
s.ConfirmUpgradeSucceededs("v20", dummyUpgradeHeight)

// Confirm the treasury address was added to dydx
hostZone, found := s.App.StakeibcKeeper.GetHostZone(s.Ctx, v20.DydxChainId)
s.Require().True(found, "host zone should have been found")
s.Require().Equal(v20.DydxCommunityPoolTreasuryAddress, hostZone.CommunityPoolTreasuryAddress,
"community pool treasury address")
}