From 1aea999eef67a0a01b22422bad94b36e45b9759a Mon Sep 17 00:00:00 2001 From: mmsqe Date: Mon, 8 Apr 2024 12:18:05 +0800 Subject: [PATCH] Problem: no legacy evm param after multi upgrades (#1371) * Problem: no legacy evm param after multi upgrades * rm redudant skip confirm * add missing check * update deps * v3 is pinging v4 * update doc * longer ci --- .github/workflows/build.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/test.yml | 2 +- CHANGELOG.md | 11 ++- app/app.go | 3 +- go.mod | 2 +- go.sum | 4 +- gomod2nix.toml | 4 +- integration_tests/configs/cosmovisor.jsonnet | 41 ++++++--- .../configs/upgrade-test-package.nix | 12 ++- integration_tests/cosmoscli.py | 13 ++- integration_tests/test_gov_update_params.py | 2 + integration_tests/test_upgrade.py | 91 ++++++++++++------- 13 files changed, 128 insertions(+), 61 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 06a471ff87..20f1250215 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -86,7 +86,7 @@ jobs: sed -i.bak "/$(echo $filename | sed 's/\//\\\//g')/d" coverage.txt done if: steps.changed-files.outputs.any_changed == 'true' - - uses: codecov/codecov-action@v3 + - uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} files: ./coverage.txt,./memiavl/coverage.txt,./store/coverage.txt,./versiondb/coverage.txt diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index dd3fb0d3cf..d14f77bde0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,7 +18,7 @@ jobs: golangci: name: Run golangci-lint runs-on: macos-latest - timeout-minutes: 40 + timeout-minutes: 60 steps: - uses: actions/setup-go@v3 with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c3b86b0e0b..c5fc931c6d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -66,7 +66,7 @@ jobs: go tool covdata textfmt -i=integration_tests/coverage -o profile.txt - name: Upload coverage report if: steps.changed-files.outputs.only_changed == 'false' - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} file: ./profile.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a35e0778b..d63b8cf93e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,17 @@ # Changelog +*April 8, 2024* + +## v1.2.0-rc1 + +### Bug Fixes + +* (rpc) [#1371](https://github.com/crypto-org-chain/cronos/pull/1371) Add param keytable in evm for old upgrade. + + *April 2, 2024* -## v1.2.0 +## v1.2.0-rc0 ### Bug Fixes diff --git a/app/app.go b/app/app.go index 987c103492..3e404344bd 100644 --- a/app/app.go +++ b/app/app.go @@ -128,6 +128,7 @@ import ( ethermint "github.com/evmos/ethermint/types" "github.com/evmos/ethermint/x/evm" evmkeeper "github.com/evmos/ethermint/x/evm/keeper" + v0evmtypes "github.com/evmos/ethermint/x/evm/migrations/v0/types" evmtypes "github.com/evmos/ethermint/x/evm/types" "github.com/evmos/ethermint/x/feemarket" feemarketkeeper "github.com/evmos/ethermint/x/feemarket/keeper" @@ -1168,7 +1169,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(ibcexported.ModuleName) paramsKeeper.Subspace(icacontrollertypes.SubModuleName) paramsKeeper.Subspace(icaauthtypes.ModuleName) - paramsKeeper.Subspace(evmtypes.ModuleName) + paramsKeeper.Subspace(evmtypes.ModuleName).WithKeyTable(v0evmtypes.ParamKeyTable()) //nolint: staticcheck paramsKeeper.Subspace(feemarkettypes.ModuleName).WithKeyTable(feemarkettypes.ParamKeyTable()) if !skipGravity { paramsKeeper.Subspace(gravitytypes.ModuleName) diff --git a/go.mod b/go.mod index 417cc3e786..eff8c6253c 100644 --- a/go.mod +++ b/go.mod @@ -239,7 +239,7 @@ replace ( // TODO: remove it: https://github.com/cosmos/cosmos-sdk/issues/13134 github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2 github.com/ethereum/go-ethereum => github.com/crypto-org-chain/go-ethereum v1.10.20-0.20231207063621-43cf32d91c3e - github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20240402062856-028760ed329f + github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20240408020015-27de4edabc79 // Fix upstream GHSA-h395-qcrw-5vmq and GHSA-3vp4-m3rf-835h vulnerabilities. // TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409 github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.9.0 diff --git a/go.sum b/go.sum index cd436443dc..450d0a9c5c 100644 --- a/go.sum +++ b/go.sum @@ -488,8 +488,8 @@ github.com/crypto-org-chain/cometbft-db v0.0.0-20231011055109-57922ac52a63 h1:R1 github.com/crypto-org-chain/cometbft-db v0.0.0-20231011055109-57922ac52a63/go.mod h1:rocwIfnS+kA060x64gkSIRvWB9StSppIkJuo5MWzL24= github.com/crypto-org-chain/cosmos-sdk v0.46.0-beta2.0.20240228013111-9bd1e035ed1d h1:ihUBUAEwQYHZEqf7lXrJithNCUJTjB8q3oSQA6Nevco= github.com/crypto-org-chain/cosmos-sdk v0.46.0-beta2.0.20240228013111-9bd1e035ed1d/go.mod h1:cmAawe8FV/52oPKbgeHLt4UpNkrNu8R5KD+kw0kxJFc= -github.com/crypto-org-chain/ethermint v0.6.1-0.20240402062856-028760ed329f h1:JZ/mnxsQXWaCLgIZHveHJaSB53RK7WCb1NTkMztqavk= -github.com/crypto-org-chain/ethermint v0.6.1-0.20240402062856-028760ed329f/go.mod h1:zJYmx1D+tDggzvXmdJ0/I62TeIykdCMfJBjBxOcniAU= +github.com/crypto-org-chain/ethermint v0.6.1-0.20240408020015-27de4edabc79 h1:X5QvqiJjeBlCXjC6b5kpIL/vo2Honp/crZbCPafFBhA= +github.com/crypto-org-chain/ethermint v0.6.1-0.20240408020015-27de4edabc79/go.mod h1:zJYmx1D+tDggzvXmdJ0/I62TeIykdCMfJBjBxOcniAU= github.com/crypto-org-chain/go-ethereum v1.10.20-0.20231207063621-43cf32d91c3e h1:vnyepPQ/m25+19xcTuBUdRxmltZ/EjVWNqEjhg7Ummk= github.com/crypto-org-chain/go-ethereum v1.10.20-0.20231207063621-43cf32d91c3e/go.mod h1:+a8pUj1tOyJ2RinsNQD4326YS+leSoKGiG/uVVb0x6Y= github.com/crypto-org-chain/gravity-bridge/module/v2 v2.0.1-0.20230825054824-75403cd90c6e h1:rSTc35OBjjCBx47rHPWBCIHNGPbMnEj8f7fNcK2TjVI= diff --git a/gomod2nix.toml b/gomod2nix.toml index ea2bb94cab..2491e98d4f 100644 --- a/gomod2nix.toml +++ b/gomod2nix.toml @@ -216,8 +216,8 @@ schema = 3 hash = "sha256-lDIqRLUrXYCb9mmFBY/+WW+ee69+IkxOgqjHVyo4ij0=" replaced = "github.com/crypto-org-chain/go-ethereum" [mod."github.com/evmos/ethermint"] - version = "v0.6.1-0.20240402062856-028760ed329f" - hash = "sha256-beJ+wpYSJ5OW8u72RsoEUo4PvECMtRnMXis8bDw6qgE=" + version = "v0.6.1-0.20240408020015-27de4edabc79" + hash = "sha256-kzUbVz9+KPFFoauHmSgywEvhPeKtU2EinyxPTVrqsWE=" replaced = "github.com/crypto-org-chain/ethermint" [mod."github.com/felixge/httpsnoop"] version = "v1.0.2" diff --git a/integration_tests/configs/cosmovisor.jsonnet b/integration_tests/configs/cosmovisor.jsonnet index 337c22e678..51c9c7c3bd 100644 --- a/integration_tests/configs/cosmovisor.jsonnet +++ b/integration_tests/configs/cosmovisor.jsonnet @@ -8,23 +8,20 @@ config { 'iavl-lazy-loading':: super['iavl-lazy-loading'], }, genesis+: { - consensus_params+: { - block+: { - max_gas: '60000000', - }, - }, app_state+: { bank+: { - send_enabled+: [ - { - denom: 'stake', - enabled: true, - }, - { - denom: 'basetcro', - enabled: false, - }, - ], + params: { + send_enabled: [ + { + denom: 'stake', + enabled: true, + }, + { + denom: 'basetcro', + enabled: false, + }, + ], + }, }, feemarket+: { params+: { @@ -32,6 +29,20 @@ config { base_fee:: super.base_fee, }, }, + gov: { + voting_params: { + voting_period: '10s', + }, + deposit_params: { + max_deposit_period: '10s', + min_deposit: [ + { + denom: 'basetcro', + amount: '1', + }, + ], + }, + }, }, }, }, diff --git a/integration_tests/configs/upgrade-test-package.nix b/integration_tests/configs/upgrade-test-package.nix index b628d99c12..2d06b77080 100644 --- a/integration_tests/configs/upgrade-test-package.nix +++ b/integration_tests/configs/upgrade-test-package.nix @@ -1,5 +1,14 @@ let pkgs = import ../../nix { }; + fetchFlake0 = repo: rev: (pkgs.flake-compat { + src = { + outPath = builtins.fetchTarball "https://github.com/${repo}/archive/${rev}.tar.gz"; + inherit rev; + shortRev = builtins.substring 0 7 rev; + }; + }).defaultNix; + # v1.0.15 + released0 = (fetchFlake0 "crypto-org-chain/cronos" "1f5e2618362303d91f621b47cbc1115cf4fa0195").default; fetchFlake = repo: rev: (pkgs.flake-compat { src = { outPath = builtins.fetchTarball "https://github.com/${repo}/archive/${rev}.tar.gz"; @@ -12,6 +21,7 @@ let current = pkgs.callPackage ../../. { }; in pkgs.linkFarm "upgrade-test-package" [ - { name = "genesis"; path = released; } + { name = "genesis"; path = released0; } + { name = "v1.1.0"; path = released; } { name = "v1.2"; path = current; } ] diff --git a/integration_tests/cosmoscli.py b/integration_tests/cosmoscli.py index a8d301894f..920fe15a87 100644 --- a/integration_tests/cosmoscli.py +++ b/integration_tests/cosmoscli.py @@ -1061,8 +1061,16 @@ def set_delegate_keys(self, val_addr, acc_addr, eth_addr, signature, **kwargs): def query_gravity_params(self): return self.query_params("gravity") - def query_params(self, module="cronos"): - return json.loads(self.raw("query", module, "params", home=self.data_dir)) + def query_params(self, module="cronos", **kwargs): + return json.loads( + self.raw( + "query", + module, + "params", + home=self.data_dir, + **kwargs, + ) + ) def query_signer_set_txs(self): return json.loads( @@ -1798,7 +1806,6 @@ def event_query_tx_for(self, hash): "query", "event-query-tx-for", hash, - "-y", home=self.data_dir, stderr=subprocess.DEVNULL, ) diff --git a/integration_tests/test_gov_update_params.py b/integration_tests/test_gov_update_params.py index a2c63f6985..cc9d6651cc 100644 --- a/integration_tests/test_gov_update_params.py +++ b/integration_tests/test_gov_update_params.py @@ -41,6 +41,8 @@ def test_evm_update_param(cronos, tmp_path): approve_proposal(cronos, rsp) print("check params have been updated now") p = cli.query_params("evm")["params"] + assert not p["chain_config"]["merge_netsplit_block"] + assert not p["chain_config"]["shanghai_time"] invalid_msg = "invalid opcode: PUSH0" with pytest.raises(ValueError) as e_info: contract.caller.randomTokenId() diff --git a/integration_tests/test_upgrade.py b/integration_tests/test_upgrade.py index 3db9e1f3e1..de48ead79f 100644 --- a/integration_tests/test_upgrade.py +++ b/integration_tests/test_upgrade.py @@ -16,6 +16,7 @@ deploy_contract, edit_ini_sections, get_consensus_params, + get_send_enable, send_transaction, wait_for_block, wait_for_new_blocks, @@ -97,22 +98,70 @@ def exec(c, tmp_path_factory): {"denom": "basetcro", "enabled": False}, {"denom": "stake", "enabled": True}, ] - p = cli.query_bank_send() + p = get_send_enable(port) assert sorted(p, key=lambda x: x["denom"]) == send_enable # export genesis from old version c.supervisorctl("stop", "all") migrate = tmp_path_factory.mktemp("migrate") file_path0 = Path(migrate / "old.json") - cli.export(output_document=str(file_path0)) + with open(file_path0, "w") as fp: + json.dump(json.loads(cli.export()), fp) + fp.flush() c.supervisorctl("start", "cronos_777-1-node0", "cronos_777-1-node1") wait_for_port(ports.evmrpc_port(c.base_port(0))) wait_for_new_blocks(cli, 1) height = cli.block_height() - target_height = height + 15 - print("upgrade height", target_height) + target_height0 = height + 15 + print("upgrade v1.1 height", target_height0) + + def do_upgrade(plan_name, target, mode=None): + rsp = cli.gov_propose_legacy( + "community", + "software-upgrade", + { + "name": plan_name, + "title": "upgrade test", + "description": "ditto", + "upgrade-height": target, + "deposit": "10000basetcro", + }, + mode=mode, + ) + assert rsp["code"] == 0, rsp["raw_log"] + approve_proposal(c, rsp) + + # update cli chain binary + c.chain_binary = ( + Path(c.chain_binary).parent.parent.parent / f"{plan_name}/bin/cronosd" + ) + # block should pass the target height + wait_for_block(c.cosmos_cli(), target + 2, timeout=480) + wait_for_port(ports.rpc_port(c.base_port(0))) + + do_upgrade("v1.1.0", target_height0, "block") + cli = c.cosmos_cli() + + # test migrate keystore + cli.migrate_keystore() + + # check basic tx works + wait_for_port(ports.evmrpc_port(c.base_port(0))) + receipt = send_transaction( + c.w3, + { + "to": ADDRS["community"], + "value": 1000, + "maxFeePerGas": 10000000000000, + "maxPriorityFeePerGas": 10000, + }, + ) + assert receipt.status == 1 + height = cli.block_height() + target_height1 = height + 15 + print("upgrade v1.2 height", target_height1) w3 = c.w3 random_contract = deploy_contract( @@ -131,34 +180,7 @@ def exec(c, tmp_path_factory): ) print("old values", old_height, old_balance, old_base_fee) - plan_name = "v1.2" - rsp = cli.gov_propose_legacy( - "community", - "software-upgrade", - { - "name": plan_name, - "title": "upgrade test", - "description": "ditto", - "upgrade-height": target_height, - "deposit": "10000basetcro", - }, - mode=None, - ) - assert rsp["code"] == 0, rsp["raw_log"] - approve_proposal(c, rsp, event_query_tx=True) - - # update cli chain binary - c.chain_binary = ( - Path(c.chain_binary).parent.parent.parent / f"{plan_name}/bin/cronosd" - ) - cli = c.cosmos_cli() - - # block should pass the target height - wait_for_block(cli, target_height + 2, timeout=480) - wait_for_port(ports.rpc_port(c.base_port(0))) - - # test migrate keystore - cli.migrate_keystore() + do_upgrade("v1.2", target_height1) # check basic tx works wait_for_port(ports.evmrpc_port(c.base_port(0))) @@ -203,6 +225,11 @@ def exec(c, tmp_path_factory): max_callback_gas = cli.query_params()["max_callback_gas"] assert max_callback_gas == "50000", max_callback_gas + e = cli.query_params("evm", height=target_height0 - 1)["params"]["evm_denom"] + assert e == "basetcro", e + e = cli.query_params("evm", height=target_height1 - 1)["params"]["evm_denom"] + assert e == "basetcro", e + # update the genesis time = current time + 5 secs newtime = datetime.utcnow() + timedelta(seconds=5) newtime = newtime.replace(tzinfo=None).isoformat("T") + "Z"