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

fix: pob account to module account #185

Merged
merged 3 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,8 @@ func (app *TerraApp) RegisterUpgradeHandlers(cfg module.Configurator) {
app.configurator,
app.appCodec,
app.IBCKeeper.ClientKeeper,
app.BuilderKeeper,
app.AccountKeeper,
),
)
}
Expand Down
22 changes: 22 additions & 0 deletions app/upgrades/v2.6/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,31 @@ 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"
pobkeeper "github.com/skip-mev/pob/x/builder/keeper"
pobtypes "github.com/skip-mev/pob/x/builder/types"
)

func CreateUpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
cdc codec.Codec,
clientKeeper clientkeeper.Keeper,
pobKeeper pobkeeper.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, pobKeeper)

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

// Overwrite the module account for pisco-1
func overwritePobModuleAccount(ctx sdk.Context, authKeeper authkeeper.AccountKeeper, pobKeeper pobkeeper.Keeper) {
emidev98 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading