Skip to content

Commit

Permalink
Problem: testnet binaries are not released together (#988)
Browse files Browse the repository at this point in the history
* Problem: testnet binaries are not released together

Solution:
- release testnet binaries together to make mantainence easier.

* Update CHANGELOG.md

Signed-off-by: yihuang <huang@crypto.com>

* changelog

* upgrade testnet to mainnet version

* cleanup

---------

Signed-off-by: yihuang <huang@crypto.com>
  • Loading branch information
yihuang committed Jun 12, 2023
1 parent 41a1076 commit 135a5d7
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 115 deletions.
15 changes: 13 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
# Changelog

*May 29, 2023*
## UNRELEASED

- [#975](https://github.com/crypto-org-chain/chain-main/pull/975) Integrate local state-sync commands.
- [#988](https://github.com/crypto-org-chain/chain-main/pull/988) Release testnet binaries together.

*Jun 9, 2023*

## v4.2.6

- [#986](https://github.com/crypto-org-chain/chain-main/pull/986) Patch barberry.

*May 30, 2023*

## v4.2.5

- [#974](https://github.com/crypto-org-chain/chain-main/pull/974) Update ibc-go to `v5.2.1`.
- [#975](https://github.com/crypto-org-chain/chain-main/pull/975) Integrate local state-sync commands.
- [#983](https://github.com/crypto-org-chain/chain-main/pull/983) Revert accidental breaking change in `v4.2.4`.

*April 27, 2023*

Expand Down
96 changes: 1 addition & 95 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -685,101 +685,7 @@ func New(
// upgrade.
app.setPostHandler()

planName := "v4.2.0"
app.UpgradeKeeper.SetUpgradeHandler(planName, func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// the minimal commission rate of 5% (0.05)
// (default is needed to be set because of SDK store migrations that set the param)
stakingtypes.DefaultMinCommissionRate = sdk.NewDecWithPrec(5, 2)

stakingKeeper.IterateValidators(ctx, func(index int64, val stakingtypes.ValidatorI) (stop bool) {
if val.GetCommission().LT(stakingtypes.DefaultMinCommissionRate) {
validator, found := stakingKeeper.GetValidator(ctx, val.GetOperator())
if !found {
ctx.Logger().Error("validator not found", val)
return true
}
ctx.Logger().Info("update validator's commission rate to a minimal one", val)
validator.Commission.Rate = stakingtypes.DefaultMinCommissionRate
if validator.Commission.MaxRate.LT(stakingtypes.DefaultMinCommissionRate) {
validator.Commission.MaxRate = stakingtypes.DefaultMinCommissionRate
}
stakingKeeper.SetValidator(ctx, validator)
}
return false
})

// set the ICS27 consensus version so InitGenesis is not run
fromVM[icatypes.ModuleName] = icaModule.ConsensusVersion()

// create ICS27 Controller submodule params
controllerParams := icacontrollertypes.Params{
ControllerEnabled: false,
}

// create ICS27 Host submodule params
hostParams := icahosttypes.Params{
HostEnabled: false,
AllowMessages: []string{
"/cosmos.authz.v1beta1.MsgExec",
"/cosmos.authz.v1beta1.MsgGrant",
"/cosmos.authz.v1beta1.MsgRevoke",
"/cosmos.bank.v1beta1.MsgSend",
"/cosmos.bank.v1beta1.MsgMultiSend",
"/cosmos.distribution.v1beta1.MsgSetWithdrawAddress",
"/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission",
"/cosmos.distribution.v1beta1.MsgFundCommunityPool",
"/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward",
"/cosmos.gov.v1beta1.MsgVoteWeighted",
"/cosmos.gov.v1beta1.MsgSubmitProposal",
"/cosmos.gov.v1beta1.MsgDeposit",
"/cosmos.gov.v1beta1.MsgVote",
"/cosmos.staking.v1beta1.MsgCreateValidator",
"/cosmos.staking.v1beta1.MsgEditValidator",
"/cosmos.staking.v1beta1.MsgDelegate",
"/cosmos.staking.v1beta1.MsgUndelegate",
"/cosmos.staking.v1beta1.MsgBeginRedelegate",
"/cosmos.staking.v1beta1.MsgCancelUnbondingDelegation",
"/cosmos.slashing.v1beta1.MsgUnjail",
"/ibc.applications.transfer.v1.MsgTransfer",
"/chainmain.nft_transfer.v1.MsgTransfer",
"/chainmain.nft.v1.MsgBurnNFT",
"/chainmain.nft.v1.MsgEditNFT",
"/chainmain.nft.v1.MsgIssueDenom",
"/chainmain.nft.v1.MsgMintNFT",
"/chainmain.nft.v1.MsgTransferNFT",
},
}

ctx.Logger().Info("start to init interchain account module...")

// initialize ICS27 module
icaModule.InitModule(ctx, controllerParams, hostParams)

ctx.Logger().Info("start to run module migrations...")

return app.mm.RunMigrations(ctx, app.configurator, fromVM)
})

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(fmt.Sprintf("failed to read upgrade info from disk %s", err))
}

if upgradeInfo.Name == planName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{
group.ModuleName,
icacontrollertypes.StoreKey,
icahosttypes.StoreKey,
icaauthmoduletypes.StoreKey,
ibcfeetypes.StoreKey,
nfttransfertypes.StoreKey,
},
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}
app.RegisterUpgradeHandlers()

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
Expand Down
125 changes: 125 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
package app

import (
"fmt"

storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/group"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ica "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts"
icacontrollertypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/controller/types"
icahosttypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/host/types"
icatypes "github.com/cosmos/ibc-go/v5/modules/apps/27-interchain-accounts/types"
ibcfeetypes "github.com/cosmos/ibc-go/v5/modules/apps/29-fee/types"
icaauthmoduletypes "github.com/crypto-org-chain/chain-main/v4/x/icaauth/types"
nfttransfertypes "github.com/crypto-org-chain/chain-main/v4/x/nft-transfer/types"
)

func (app *ChainApp) RegisterUpgradeHandlers() {
planName := "v4.2.0"
app.UpgradeKeeper.SetUpgradeHandler(planName, func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// the minimal commission rate of 5% (0.05)
// (default is needed to be set because of SDK store migrations that set the param)
stakingtypes.DefaultMinCommissionRate = sdk.NewDecWithPrec(5, 2)

app.StakingKeeper.IterateValidators(ctx, func(index int64, val stakingtypes.ValidatorI) (stop bool) {
if val.GetCommission().LT(stakingtypes.DefaultMinCommissionRate) {
validator, found := app.StakingKeeper.GetValidator(ctx, val.GetOperator())
if !found {
ctx.Logger().Error("validator not found", val)
return true
}
ctx.Logger().Info("update validator's commission rate to a minimal one", val)
validator.Commission.Rate = stakingtypes.DefaultMinCommissionRate
if validator.Commission.MaxRate.LT(stakingtypes.DefaultMinCommissionRate) {
validator.Commission.MaxRate = stakingtypes.DefaultMinCommissionRate
}
app.StakingKeeper.SetValidator(ctx, validator)
}
return false
})

icaModule := app.mm.Modules[icatypes.ModuleName].(ica.AppModule)

// set the ICS27 consensus version so InitGenesis is not run
fromVM[icatypes.ModuleName] = icaModule.ConsensusVersion()

// create ICS27 Controller submodule params
controllerParams := icacontrollertypes.Params{
ControllerEnabled: false,
}

// create ICS27 Host submodule params
hostParams := icahosttypes.Params{
HostEnabled: false,
AllowMessages: []string{
"/cosmos.authz.v1beta1.MsgExec",
"/cosmos.authz.v1beta1.MsgGrant",
"/cosmos.authz.v1beta1.MsgRevoke",
"/cosmos.bank.v1beta1.MsgSend",
"/cosmos.bank.v1beta1.MsgMultiSend",
"/cosmos.distribution.v1beta1.MsgSetWithdrawAddress",
"/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission",
"/cosmos.distribution.v1beta1.MsgFundCommunityPool",
"/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward",
"/cosmos.gov.v1beta1.MsgVoteWeighted",
"/cosmos.gov.v1beta1.MsgSubmitProposal",
"/cosmos.gov.v1beta1.MsgDeposit",
"/cosmos.gov.v1beta1.MsgVote",
"/cosmos.staking.v1beta1.MsgCreateValidator",
"/cosmos.staking.v1beta1.MsgEditValidator",
"/cosmos.staking.v1beta1.MsgDelegate",
"/cosmos.staking.v1beta1.MsgUndelegate",
"/cosmos.staking.v1beta1.MsgBeginRedelegate",
"/cosmos.staking.v1beta1.MsgCancelUnbondingDelegation",
"/cosmos.slashing.v1beta1.MsgUnjail",
"/ibc.applications.transfer.v1.MsgTransfer",
"/chainmain.nft_transfer.v1.MsgTransfer",
"/chainmain.nft.v1.MsgBurnNFT",
"/chainmain.nft.v1.MsgEditNFT",
"/chainmain.nft.v1.MsgIssueDenom",
"/chainmain.nft.v1.MsgMintNFT",
"/chainmain.nft.v1.MsgTransferNFT",
},
}

ctx.Logger().Info("start to init interchain account module...")

// initialize ICS27 module
icaModule.InitModule(ctx, controllerParams, hostParams)

ctx.Logger().Info("start to run module migrations...")

return app.mm.RunMigrations(ctx, app.configurator, fromVM)
})

// testnets need to do a coordinated upgrade to keep in sync with current mainnet version
testnetPlanName := "v4.2.7-testnet"
app.UpgradeKeeper.SetUpgradeHandler(testnetPlanName, func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
})

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(fmt.Sprintf("failed to read upgrade info from disk %s", err))
}

if upgradeInfo.Name == planName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{
group.ModuleName,
icacontrollertypes.StoreKey,
icahosttypes.StoreKey,
icaauthmoduletypes.StoreKey,
ibcfeetypes.StoreKey,
nfttransfertypes.StoreKey,
},
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
cosmossdk.io/math v1.0.0-rc.0
github.com/armon/go-metrics v0.4.1
github.com/cosmos/cosmos-proto v1.0.0-alpha8
github.com/cosmos/cosmos-sdk v0.46.13-rc.0
github.com/cosmos/cosmos-sdk v0.46.13
github.com/cosmos/ibc-go/v5 v5.2.1
// v1.0.8
github.com/crypto-org-chain/cronos/versiondb v0.0.0-20230529083827-565fa417b0f8
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,8 @@ github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk=
github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis=
github.com/cosmos/cosmos-proto v1.0.0-alpha8 h1:d3pCRuMYYvGA5bM0ZbbjKn+AoQD4A7dyNG2wzwWalUw=
github.com/cosmos/cosmos-proto v1.0.0-alpha8/go.mod h1:6/p+Bc4O8JKeZqe0VqUGTX31eoYqemTT4C1hLCWsO7I=
github.com/cosmos/cosmos-sdk v0.46.13-rc.0 h1:WwWcR8ZnuKYfWSQfNRXIzOFT0x5vtCHwzPWOjV5x/Wo=
github.com/cosmos/cosmos-sdk v0.46.13-rc.0/go.mod h1:maYupex8eSZZhw9jow4D/7qWV9XpYB/fyVu7MIbD3RM=
github.com/cosmos/cosmos-sdk v0.46.13 h1:LhL6WDBadczqBuCW0t5BHUzGQR3vbujdOYOfU0ORt+o=
github.com/cosmos/cosmos-sdk v0.46.13/go.mod h1:EfY521ATNEla8eJ6oJuZBdgP5+p360s7InnRqX+TWdM=
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
Expand Down
5 changes: 2 additions & 3 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,8 @@ schema = 3
version = "v1.0.0-alpha8"
hash = "sha256-iXzXoS5Kfh5DBy+PhdFWraDWXda/3M4j7j4VECjv4CA="
[mod."github.com/cosmos/cosmos-sdk"]
version = "v0.46.13-rc.0"
hash = "sha256-TESRQDJ4/YXgCUIU9udOErhem6AupqOnzzev0i18MZs="
replaced = "github.com/cosmos/cosmos-sdk"
version = "v0.46.13"
hash = "sha256-1H/FBfQagIO0Ckr5xBB2rwpPO0HiXpXWyndnarnXIv0="
[mod."github.com/cosmos/go-bip39"]
version = "v1.0.0"
hash = "sha256-Qm2aC2vaS8tjtMUbHmlBSagOSqbduEEDwc51qvQaBmA="
Expand Down
22 changes: 10 additions & 12 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ baseurl="."
build_type="tarball"
build_platform="$(nix eval --impure --raw --expr 'builtins.currentSystem')"
ref_name_clean=$(echo "${GITHUB_REF_NAME:=vdevel}" | sed -e 's/[^A-Za-z0-9._-]/_/g')
NETWORK=${NETWORK:-"mainnet"}

build() {
set -e
host="$1"
name="$2"
if [[ "$NETWORK" == "testnet" ]]; then
pkg="chain-maind-testnet-${build_type}"
else
pkg="chain-maind-${build_type}"
fi
network=$1
host="$2"
name="$3"
pkg="chain-maind${network}-${build_type}"
if [[ "$host" == "native" ]]; then
if [[ "${build_platform: -6}" == "-linux" ]]; then
# static link for linux targets
Expand All @@ -33,7 +29,7 @@ build() {
fi
echo "building $FLAKE"
nix build -L "$FLAKE"
cp result "chain-main_${ref_name_clean:1}_${name}.tar.gz"
cp result "chain-main_${ref_name_clean:1}${network}_${name}.tar.gz"
}

if [[ "$build_platform" == "x86_64-linux" ]]; then
Expand All @@ -47,7 +43,9 @@ else
exit 1
fi

for t in $hosts; do
IFS=',' read -r name host <<< "${t}"
build "$host" "$name"
for network in "" "-testnet"; do
for t in $hosts; do
IFS=',' read -r name host <<< "${t}"
build "$network" "$host" "$name"
done
done

0 comments on commit 135a5d7

Please sign in to comment.