-
Notifications
You must be signed in to change notification settings - Fork 117
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
[CORE-538] Add 4.0.0 upgrade handler for Cosmos 0.47 -> 0.50 upgrade handler. #918
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,6 +179,8 @@ import ( | |
ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper" | ||
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types" | ||
ibc "github.com/cosmos/ibc-go/v8/modules/core" | ||
ibcclient "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" // nolint:staticcheck | ||
ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" | ||
ibcporttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types" | ||
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" | ||
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" | ||
|
@@ -511,8 +513,6 @@ func New( | |
govRouter := govv1beta1.NewRouter() | ||
govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). | ||
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)) | ||
/** TODO(CORE-538): Migrate software upgrade type to Cosmos 0.50. | ||
.AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)) */ | ||
govConfig := govtypes.DefaultConfig() | ||
/* | ||
Example of setting gov params: | ||
Comment on lines
513
to
518
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The commented code in lines 513-518 appears to be an example configuration for governance parameters. If this is intended as documentation, it should be clearly marked as such or moved to official documentation. If it's not needed, it should be removed to avoid confusion. |
||
|
@@ -1621,9 +1621,14 @@ func initParamsKeeper( | |
paramsKeeper.Subspace(slashingtypes.ModuleName) | ||
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) //nolint:staticcheck | ||
paramsKeeper.Subspace(crisistypes.ModuleName) | ||
paramsKeeper.Subspace(ibctransfertypes.ModuleName) | ||
paramsKeeper.Subspace(icahosttypes.SubModuleName) | ||
paramsKeeper.Subspace(ibcexported.ModuleName) | ||
|
||
// register the key tables for legacy param subspaces | ||
keyTable := ibcclient.ParamKeyTable() | ||
keyTable.RegisterParamSet(&ibcconnectiontypes.Params{}) | ||
paramsKeeper.Subspace(ibcexported.ModuleName).WithKeyTable(keyTable) | ||
paramsKeeper.Subspace(ibctransfertypes.ModuleName).WithKeyTable(ibctransfertypes.ParamKeyTable()) | ||
paramsKeeper.Subspace(icahosttypes.SubModuleName).WithKeyTable(icahosttypes.ParamKeyTable()) | ||
paramsKeeper.Subspace(icacontrollertypes.SubModuleName).WithKeyTable(icacontrollertypes.ParamKeyTable()) | ||
|
||
return paramsKeeper | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package v_4_0_0 | ||
|
||
import ( | ||
store "cosmossdk.io/store/types" | ||
circuittypes "cosmossdk.io/x/circuit/types" | ||
icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" | ||
icahosttypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/host/types" | ||
"github.com/dydxprotocol/v4-chain/protocol/app/upgrades" | ||
) | ||
|
||
const ( | ||
UpgradeName = "v4.0.0" | ||
) | ||
|
||
var Upgrade = upgrades.Upgrade{ | ||
UpgradeName: UpgradeName, | ||
StoreUpgrades: store.StoreUpgrades{ | ||
Added: []string{ | ||
// Add circuittypes as per 0.47 to 0.50 upgrade handler | ||
// https://github.com/cosmos/cosmos-sdk/blob/b7d9d4c8a9b6b8b61716d2023982d29bdc9839a6/simapp/upgrades.go#L21 | ||
circuittypes.ModuleName, | ||
|
||
// Add new ICA stores that are needed by ICA host types as of v8. | ||
icacontrollertypes.StoreKey, | ||
icahosttypes.StoreKey, | ||
}, | ||
}, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package v_4_0_0 | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
upgradetypes "cosmossdk.io/x/upgrade/types" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
) | ||
|
||
func CreateUpgradeHandler( | ||
mm *module.Manager, | ||
configurator module.Configurator, | ||
) upgradetypes.UpgradeHandler { | ||
return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { | ||
sdkCtx := sdk.UnwrapSDKContext(ctx) | ||
sdkCtx.Logger().Info(fmt.Sprintf("Running %s Upgrade...", UpgradeName)) | ||
|
||
// TODO(CORE-824): Initialize ratelimit module params to desired state. | ||
|
||
return mm.RunMigrations(ctx, configurator, vm) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,6 @@ set -eo pipefail | |
source "./genesis.sh" | ||
|
||
CHAIN_ID="localdydxprotocol" | ||
PREUPGRADE_VERSION="v2.0.0" | ||
|
||
# Define mnemonics for all validators. | ||
MNEMONICS=( | ||
|
@@ -154,27 +153,22 @@ setup_cosmovisor() { | |
done | ||
} | ||
|
||
download_preupgrade_binary() { | ||
copy_preupgrade_binary_arch() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can start using v3.0.0-rc0 binaries (building right now and will be published soon for testnet). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we just swap them for the 3.0.0 binaries once they are qualified. I don't suspect that this swap will cause many issues and then we will only need to do it the one time. |
||
arch="$(apk --print-arch)" | ||
url_arch="" | ||
file_arch="" | ||
case "$arch" in | ||
'x86_64') | ||
url_arch='amd64' | ||
file_arch='amd64' | ||
;; | ||
'aarch64') | ||
url_arch='arm64' | ||
file_arch='arm64' | ||
;; | ||
*) | ||
echo >&2 "unexpected architecture '$arch'" | ||
exit 1 | ||
;; | ||
esac | ||
tar_url="https://github.com/dydxprotocol/v4-chain/releases/download/protocol%2F$PREUPGRADE_VERSION/dydxprotocold-$PREUPGRADE_VERSION-linux-$url_arch.tar.gz" | ||
tar_path='/tmp/dydxprotocold/dydxprotocold.tar.gz' | ||
mkdir -p /tmp/dydxprotocold | ||
curl -vL $tar_url -o $tar_path | ||
dydxprotocold_path=$(tar -xvf $tar_path --directory /tmp/dydxprotocold) | ||
cp /tmp/dydxprotocold/$dydxprotocold_path /bin/dydxprotocold_preupgrade | ||
cp /bin/dydxprotocold_preupgrade_${file_arch} /bin/dydxprotocold_preupgrade | ||
} | ||
|
||
# TODO(DEC-1894): remove this function once we migrate off of persistent peers. | ||
|
@@ -193,5 +187,5 @@ edit_config() { | |
|
||
install_prerequisites | ||
setup_cosmovisor | ||
download_preupgrade_binary | ||
copy_preupgrade_binary_arch | ||
create_validators |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The import of
ibcclient
is marked withnolint:staticcheck
. Please ensure that ignoring lint warnings is justified and documented as to why it's necessary in this case. If the import is unused, consider removing it to keep the code clean.