Skip to content

Commit

Permalink
Problem: no upgrade handler for v0.8.0-gravity-alpha2 (#742)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-nguy authored Oct 18, 2022
1 parent f3e063a commit 6ae1f7c
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### State Machine Breaking
- [cronos#695](https://github.com/crypto-org-chain/cronos/pull/695) Implement ADR-007, generic events format with indexed params.
- [cronos#728](https://github.com/crypto-org-chain/cronos/pull/728) Upgrade gravity bridge latest bugfix, including multi attestation processing and double spend check.
- [cronos#742](https://github.com/crypto-org-chain/cronos/pull/742) Add upgrade handler for v0.8.0-gravity-alpha2.

### Improvements

Expand Down
25 changes: 23 additions & 2 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package app
import (
"fmt"

evmtypes "github.com/evmos/ethermint/x/evm/types"

storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
Expand All @@ -17,10 +19,29 @@ func (app *App) RegisterUpgradeHandlers(experimental bool) {
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
})

gravityPlanName := "v0.8.0-gravity-alpha3"
gravityPlanName := "v0.8.0-gravity-alpha2"
if experimental {
app.UpgradeKeeper.SetUpgradeHandler(gravityPlanName, func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
updatedVM, err := app.mm.RunMigrations(ctx, app.configurator, fromVM)
if err != nil {
return nil, err
}
// set new gravity id
gravParams := app.GravityKeeper.GetParams(ctx)
gravParams.GravityId = "cronos_gravity_pioneer_v3"
app.GravityKeeper.SetParams(ctx, gravParams)

// Estimate time upgrade take place
// 100% is not necessary here because it will be tuned by relayer later on
// it is set to georli height at Wed Oct 26 2022 03:33:28 GMT+0900
app.GravityKeeper.MigrateGravityContract(
ctx, "0x0000000000000000000000000000000000000000", 7832100)

// Fix bug on ethermint due to cutting the binary before official release
evmParamStore := app.GetSubspace(evmtypes.ModuleName)
evmParamStore.Set(ctx, evmtypes.ParamStoreKeyAllowUnprotectedTxs, false)

return updatedVM, nil
})
}

Expand Down
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ replace (
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1

// TODO: remove when gravity update dependencies
github.com/peggyjv/gravity-bridge/module/v2 => github.com/crypto-org-chain/gravity-bridge/module/v2 v2.0.1-0.20221004054346-17ff40b2b361
github.com/peggyjv/gravity-bridge/module/v2 => github.com/crypto-org-chain/gravity-bridge/module/v2 v2.0.1-0.20221016022038-e581164e2889

// TODO: remove after fixed https://github.com/cosmos/cosmos-sdk/issues/11364
github.com/zondax/hid => github.com/zondax/hid v0.9.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,8 @@ github.com/creachadair/taskgroup v0.3.2/go.mod h1:wieWwecHVzsidg2CsUnFinW1faVN4+
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/crypto-org-chain/gravity-bridge/module/v2 v2.0.1-0.20221004054346-17ff40b2b361 h1:lA6lx9Luny3v8Bsd2zZapXJ9Es2c4DzrZXVDFnd4F1Q=
github.com/crypto-org-chain/gravity-bridge/module/v2 v2.0.1-0.20221004054346-17ff40b2b361/go.mod h1:w/nb6f8UbrqqevKYQm/r+qjRl4WgxRlTC+l9dQ1wDfg=
github.com/crypto-org-chain/gravity-bridge/module/v2 v2.0.1-0.20221016022038-e581164e2889 h1:2ET/g4Gwx5DOAJBz49EgYBjB8Tj89nkbHQD2esbZXf0=
github.com/crypto-org-chain/gravity-bridge/module/v2 v2.0.1-0.20221016022038-e581164e2889/go.mod h1:w/nb6f8UbrqqevKYQm/r+qjRl4WgxRlTC+l9dQ1wDfg=
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4=
github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
Expand Down
4 changes: 2 additions & 2 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ schema = 3
version = "v0.0.5"
hash = "sha256-/5i70IkH/qSW5KjGzv8aQNKh9tHoz98tqtL0K2DMFn4="
[mod."github.com/peggyjv/gravity-bridge/module/v2"]
version = "v2.0.1-0.20221004054346-17ff40b2b361"
hash = "sha256-95P6X7gc9tBoOAkTI+iy7F6/M3ZkYL8/ZsT5wWAwHlI="
version = "v2.0.1-0.20221016022038-e581164e2889"
hash = "sha256-/6G+UNaP+O8g9viH5CxYO0fe48Qsw8WRujm2p/VDDNI="
replaced = "github.com/crypto-org-chain/gravity-bridge/module/v2"
[mod."github.com/pelletier/go-toml"]
version = "v1.9.5"
Expand Down
6 changes: 3 additions & 3 deletions integration_tests/configs/upgrade-test-package-gravity.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ let
shortRev = builtins.substring 0 7 rev;
};
}).defaultNix;
# tag: v0.8.0-gravity-alpha2
released = (fetchFlake "crypto-org-chain/cronos" "57260c7c21cdedffd75480e8cb4e8838ea6a16b5").default;
# tag: v0.8.0-gravity-alpha1
released = (fetchFlake "crypto-org-chain/cronos" "a485dffc48975acbb792945f76b52ae6ab2ce543").default;
current = pkgs.callPackage ../../. { };
in
pkgs.linkFarm "upgrade-test-package" [
{ name = "genesis"; path = released; }
{ name = "v0.8.0-gravity-alpha3"; path = current; }
{ name = "v0.8.0-gravity-alpha2"; path = current; }
]
3 changes: 3 additions & 0 deletions integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,9 @@ def set_delegate_keys(self, val_addr, acc_addr, eth_addr, signature, **kwargs):
def query_gravity_params(self):
return json.loads(self.raw("query", "gravity", "params", home=self.data_dir))

def query_evm_params(self):
return json.loads(self.raw("query", "evm", "params", home=self.data_dir))

def query_signer_set_txs(self):
return json.loads(
self.raw("query", "gravity", "signer-set-txs", home=self.data_dir)
Expand Down
35 changes: 33 additions & 2 deletions integration_tests/test_upgrade_gravity.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_cosmovisor_upgrade_gravity(custom_cronos: Cronos):
height = cli.block_height()
target_height = height + 15
print("upgrade height", target_height)
plan_name = "v0.8.0-gravity-alpha3"
plan_name = "v0.8.0-gravity-alpha2"
rsp = cli.gov_propose_v0_7(
"community",
"software-upgrade",
Expand Down Expand Up @@ -127,7 +127,7 @@ def test_cosmovisor_upgrade_gravity(custom_cronos: Cronos):
# check ica controller is enabled
assert cli.query_gravity_params() == {
"params": {
"gravity_id": "defaultgravityid",
"gravity_id": "cronos_gravity_pioneer_v3",
"contract_source_hash": "",
"bridge_ethereum_address": "0x0000000000000000000000000000000000000000",
"bridge_chain_id": "0",
Expand All @@ -148,3 +148,34 @@ def test_cosmovisor_upgrade_gravity(custom_cronos: Cronos):
"observe_ethereum_height_period": "50",
}
}

# check evm params
assert cli.query_evm_params() == {
"params": {
"evm_denom": "basetcro",
"enable_create": True,
"enable_call": True,
"extra_eips": [],
"chain_config": {
"homestead_block": "0",
"dao_fork_block": "0",
"dao_fork_support": True,
"eip150_block": "0",
"eip150_hash": "0x0000000000000000000000000000000000000000000000000000"
"000000000000",
"eip155_block": "0",
"eip158_block": "0",
"gray_glacier_block": "0",
"byzantium_block": "0",
"constantinople_block": "0",
"petersburg_block": "0",
"istanbul_block": "0",
"muir_glacier_block": "0",
"berlin_block": "0",
"london_block": "0",
"arrow_glacier_block": "0",
"merge_netsplit_block": "0",
},
"allow_unprotected_txs": False,
}
}

0 comments on commit 6ae1f7c

Please sign in to comment.