Skip to content

Commit

Permalink
Merge pull request #185 from terra-money/fix/pob/module/account
Browse files Browse the repository at this point in the history
fix: pob account to module account
  • Loading branch information
emidev98 committed Oct 13, 2023
2 parents 0bd5f58 + 8286e01 commit 9839cbd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,7 @@ func (app *TerraApp) RegisterUpgradeHandlers(cfg module.Configurator) {
app.configurator,
app.appCodec,
app.IBCKeeper.ClientKeeper,
app.AccountKeeper,
),
)
}
Expand Down
20 changes: 20 additions & 0 deletions app/upgrades/v2.6/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,29 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
clientkeeper "github.com/cosmos/ibc-go/v7/modules/core/02-client/keeper"
ibcclienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
pobtypes "github.com/skip-mev/pob/x/builder/types"
)

func CreateUpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
cdc codec.Codec,
clientKeeper clientkeeper.Keeper,
authKeeper authkeeper.AccountKeeper,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {

// overwrite pob account to a module account for pisco-1
overwritePobModuleAccount(ctx, authKeeper)

// Increase the unbonding period for atlantic-2
err := increaseUnbondingPeriod(ctx, cdc, clientKeeper)
if err != nil {
return nil, err
Expand All @@ -29,6 +38,17 @@ func CreateUpgradeHandler(
}
}

// Overwrite the module account for pisco-1
func overwritePobModuleAccount(ctx sdk.Context, authKeeper authkeeper.AccountKeeper) {
if ctx.ChainID() == "pisco-1" {
macc := authtypes.NewEmptyModuleAccount(pobtypes.ModuleName)
pobaccount := authKeeper.GetAccount(ctx, macc.GetAddress())
macc.AccountNumber = pobaccount.GetAccountNumber()
maccI := (authKeeper.NewAccount(ctx, macc)).(authtypes.ModuleAccountI)
authKeeper.SetModuleAccount(ctx, maccI)
}
}

// Iterate all IBC clients and increase unbonding period for all atlantic-2 clients
func increaseUnbondingPeriod(ctx sdk.Context, cdc codec.BinaryCodec, clientKeeper clientkeeper.Keeper) error {
var clientIDs []string
Expand Down
6 changes: 3 additions & 3 deletions scripts/tests/chain-upgrade/chain-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ VAL_ADDR_1=$($OLD_BINARY keys list emi --output=json | jq .[0].address -r)
echo $WALLET_MNEMONIC_1 | $OLD_BINARY keys add wallet1 --home $CHAIN_HOME --recover --keyring-backend=test
WALLET_ADDR_1=$($OLD_BINARY keys list emi --output=json | jq .[0].address -r)

$OLD_BINARY add-genesis-account $($OLD_BINARY --home $CHAIN_HOME keys show val1 --keyring-backend test -a) 100000000000uluna --home $CHAIN_HOME
$OLD_BINARY gentx val1 1000000000uluna --home $CHAIN_HOME --chain-id $CHAIN_ID --keyring-backend test
$OLD_BINARY collect-gentxs --home $CHAIN_HOME
$OLD_BINARY genesis add-genesis-account $($OLD_BINARY --home $CHAIN_HOME keys show val1 --keyring-backend test -a) 100000000000uluna --home $CHAIN_HOME
$OLD_BINARY genesis gentx val1 1000000000uluna --home $CHAIN_HOME --chain-id $CHAIN_ID --keyring-backend test
$OLD_BINARY genesis collect-gentxs --home $CHAIN_HOME

sed -i -e "s/\"max_deposit_period\": \"172800s\"/\"max_deposit_period\": \"$GOV_PERIOD\"/g" $CHAIN_HOME/config/genesis.json
sed -i -e "s/\"voting_period\": \"172800s\"/\"voting_period\": \"$GOV_PERIOD\"/g" $CHAIN_HOME/config/genesis.json
Expand Down

0 comments on commit 9839cbd

Please sign in to comment.