Skip to content

Commit

Permalink
Executes Prop 256 in Upgrade Handler (#1332)
Browse files Browse the repository at this point in the history
Co-authored-by: sampocs <[email protected]>
Co-authored-by: sampocs <[email protected]>
  • Loading branch information
3 people authored Jan 28, 2025
1 parent 8772a5f commit f9b7a75
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 3 deletions.
23 changes: 23 additions & 0 deletions app/upgrades/v25/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ var (
FailedLSMDepositDenom = "cosmosvaloper1yh089p0cre4nhpdqw35uzde5amg3qzexkeggdn/59223"
)

var (
CommunityPoolGrowthAddress = "stride1lj0m72d70qerts9ksrsphy9nmsd4h0s88ll9gfphmhemh8ewet5qj44jc9"
BnocsCustodian = "stride1ff875h5plrnyumhm3cezn85dj4hzjzjqpz99mg"
BnocsProposalAmount = sdk.NewInt(17_857_000_000)
Ustrd = "ustrd"
)

// CreateUpgradeHandler creates an SDK upgrade handler for v25
func CreateUpgradeHandler(
mm *module.Manager,
Expand All @@ -58,6 +65,11 @@ func CreateUpgradeHandler(
return vm, errorsmod.Wrapf(err, "unable to add celestia validators")
}

// Implement Bnocs Proposal 256
if err := ExecuteProp256(ctx, bankKeeper); err != nil {
return vm, errorsmod.Wrapf(err, "unable to implement Bnocs Proposal")
}

// Update redemption rate bounds
UpdateRedemptionRateBounds(ctx, stakeibcKeeper)

Expand Down Expand Up @@ -93,6 +105,17 @@ func AddCelestiaValidators(ctx sdk.Context, k stakeibckeeper.Keeper) error {
return nil
}

// Execute Prop #256 - Signaling proposal to give a grant to Bnocs
// Sends 17,857 STRD from "Community Pool - Growth" to Bnocs recipient address
// See more here: https://www.mintscan.io/stride/proposals/256
// And here: https://common.xyz/stride/discussion/25922-proposal-for-grant-bnocscom-dashboard-for-the-stride-ecosystem
func ExecuteProp256(ctx sdk.Context, k bankkeeper.Keeper) error {
communityPoolGrowthAddress := sdk.MustAccAddressFromBech32(CommunityPoolGrowthAddress)
bnocsCuostidanAddress := sdk.MustAccAddressFromBech32(BnocsCustodian)
transferCoin := sdk.NewCoin(Ustrd, BnocsProposalAmount)
return k.SendCoins(ctx, communityPoolGrowthAddress, bnocsCuostidanAddress, sdk.NewCoins(transferCoin))
}

// Updates the outer redemption rate bounds
func UpdateRedemptionRateBounds(ctx sdk.Context, k stakeibckeeper.Keeper) {
ctx.Logger().Info("Updating redemption rate outer bounds...")
Expand Down
24 changes: 21 additions & 3 deletions app/upgrades/v25/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
recordtypes "github.com/Stride-Labs/stride/v25/x/records/types"
stakeibctypes "github.com/Stride-Labs/stride/v25/x/stakeibc/types"
oldstaketiatypes "github.com/Stride-Labs/stride/v25/x/staketia/legacytypes"
"github.com/Stride-Labs/stride/v25/x/staketia/types"
staketiatypes "github.com/Stride-Labs/stride/v25/x/staketia/types"
)

Expand Down Expand Up @@ -50,6 +49,7 @@ func (s *UpgradeTestSuite) TestUpgrade() {

// Setup state before upgrade
checkStaketiaMigration := s.SetupStaketiaMigration()
checkProp256 := s.SetupProp256()
checkRedemptionRatesAfterUpgrade := s.SetupTestUpdateRedemptionRateBounds()
checkInnerRedemptionRatesAfterUpgrade := s.SetupTestUpdateInnerRedemptionRateBounds()
checkLSMRecord := s.SetupLSMRecord()
Expand All @@ -59,6 +59,7 @@ func (s *UpgradeTestSuite) TestUpgrade() {

// Validate state after upgrade
checkStaketiaMigration()
checkProp256()
checkRedemptionRatesAfterUpgrade()
checkInnerRedemptionRatesAfterUpgrade()
checkLSMRecord()
Expand Down Expand Up @@ -104,12 +105,12 @@ func (s *UpgradeTestSuite) SetupStaketiaMigration() func() {
// Before we call the migration function, temporarily update the variable to be connection-0 to match the above
// and then set it back after the function call for other tests that use it
mainnetConnectionId := staketiatypes.CelestiaConnectionId
types.CelestiaConnectionId = ibctesting.FirstConnectionID
staketiatypes.CelestiaConnectionId = ibctesting.FirstConnectionID

// Return a callback to check the state after the upgrade
return func() {
// Set back the connectionID
types.CelestiaConnectionId = mainnetConnectionId
staketiatypes.CelestiaConnectionId = mainnetConnectionId

// Confirm the stakeibc host zone was created
hostZone, found := s.App.StakeibcKeeper.GetHostZone(s.Ctx, staketiatypes.CelestiaChainId)
Expand All @@ -122,6 +123,23 @@ func (s *UpgradeTestSuite) SetupStaketiaMigration() func() {
}
}

func (s *UpgradeTestSuite) SetupProp256() func() {
// Fund the community pool growth address
communityGrowthAddress := sdk.MustAccAddressFromBech32(v25.CommunityPoolGrowthAddress)
s.FundAccount(communityGrowthAddress, sdk.NewCoin(v25.Ustrd, v25.BnocsProposalAmount))

// Return a callback to check the state after the upgrade
return func() {
// Check the transfer was successful
communityGrowthBalance := s.App.BankKeeper.GetBalance(s.Ctx, communityGrowthAddress, v25.Ustrd)
s.Require().Zero(communityGrowthBalance.Amount.Int64(), "community growth balance after transfer")

bnocsCuostidanAddress := sdk.MustAccAddressFromBech32(v25.BnocsCustodian)
bnocsCustodianBalance := s.App.BankKeeper.GetBalance(s.Ctx, bnocsCuostidanAddress, v25.Ustrd)
s.Require().Equal(v25.BnocsProposalAmount.Int64(), bnocsCustodianBalance.Amount.Int64(), "bnocs balance")
}
}

func (s *UpgradeTestSuite) SetupTestUpdateRedemptionRateBounds() func() {
// Define test cases consisting of an initial redemption rate and expected bounds
testCases := []UpdateRedemptionRateBounds{
Expand Down

0 comments on commit f9b7a75

Please sign in to comment.