From 9f710720955b962d833574aa1a38005054045a56 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 19 Apr 2024 10:29:03 +0800 Subject: [PATCH] Problem: panic on invalid elasticity_multiplier --- CHANGELOG.md | 5 +++++ go.mod | 2 +- go.sum | 4 ++-- gomod2nix.toml | 4 ++-- integration_tests/test_upgrade.py | 29 +++++++++++++++++------------ 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7aef39401b..1f4c0e85d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ * (test) [#1380](https://github.com/crypto-org-chain/cronos/pull/1380) Upgrade cosmovisor to 1.5.0 in integration test. * (versiondb) [#1379](https://github.com/crypto-org-chain/cronos/pull/1379) Flush versiondb when graceful shutdown, make rocksdb upgrade smooth. +### Bug Fixes + +* (rpc) [#1397](https://github.com/crypto-org-chain/cronos/pull/1397) Avoid panic on invalid elasticity_multiplier. + + *April 8, 2024* ## v1.2.0-rc1 diff --git a/go.mod b/go.mod index eff8c6253c..4d76629af9 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.20240408020015-27de4edabc79 + github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20240419022701-412115d02b10 // 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 450d0a9c5c..207627b180 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.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/ethermint v0.6.1-0.20240419022701-412115d02b10 h1:6uN0+FzbTTFbGAlqdrKjcJt/geaK6zveGtm2p33tXJg= +github.com/crypto-org-chain/ethermint v0.6.1-0.20240419022701-412115d02b10/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 2491e98d4f..36f7081834 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.20240408020015-27de4edabc79" - hash = "sha256-kzUbVz9+KPFFoauHmSgywEvhPeKtU2EinyxPTVrqsWE=" + version = "v0.6.1-0.20240419022701-412115d02b10" + hash = "sha256-wuXg0oZlIHc+x9tSmxZxGNoBa521p+o/Nk4ynJHKlRU=" replaced = "github.com/crypto-org-chain/ethermint" [mod."github.com/felixge/httpsnoop"] version = "v1.0.2" diff --git a/integration_tests/test_upgrade.py b/integration_tests/test_upgrade.py index e77b80fa0b..cc8a8dded6 100644 --- a/integration_tests/test_upgrade.py +++ b/integration_tests/test_upgrade.py @@ -128,10 +128,6 @@ def exec(c, tmp_path_factory): wait_for_port(ports.evmrpc_port(c.base_port(0))) wait_for_new_blocks(cli, 1) - height = cli.block_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", @@ -156,11 +152,14 @@ def do_upgrade(plan_name, target, mode=None): 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() + height = cli.block_height() + target_height0 = height + 15 + print("upgrade v1.1 height", target_height0) + + do_upgrade("v1.1.0", target_height0, "block") + cli = c.cosmos_cli() # check basic tx works wait_for_port(ports.evmrpc_port(c.base_port(0))) @@ -196,6 +195,7 @@ def do_upgrade(plan_name, target, mode=None): print("old values", old_height, old_balance, old_base_fee) do_upgrade("v1.2", target_height1) + cli = c.cosmos_cli() # check basic tx works wait_for_port(ports.evmrpc_port(c.base_port(0))) @@ -240,10 +240,11 @@ def do_upgrade(plan_name, target, mode=None): 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 + e0 = cli.query_params("evm", height=target_height0 - 1)["params"] + e1 = cli.query_params("evm", height=target_height1 - 1)["params"] + f0 = cli.query_params("feemarket", height=target_height0 - 1)["params"] + f1 = cli.query_params("feemarket", height=target_height1 - 1)["params"] + assert e0["evm_denom"] == e1["evm_denom"] == "basetcro" # update the genesis time = current time + 5 secs newtime = datetime.utcnow() + timedelta(seconds=5) @@ -257,7 +258,11 @@ def do_upgrade(plan_name, target, mode=None): file.write_text(json.dumps(genesis)) c.supervisorctl("start", "cronos_777-1-node0", "cronos_777-1-node1") wait_for_new_blocks(c.cosmos_cli(), 1) - c.supervisorctl("stop", "all") + + assert e0 == cli.query_params("evm", height=target_height0 - 1)["params"] + assert e1 == cli.query_params("evm", height=target_height1 - 1)["params"] + assert f0 == cli.query_params("feemarket", height=target_height0 - 1)["params"] + assert f1 == cli.query_params("feemarket", height=target_height1 - 1)["params"] def test_cosmovisor_upgrade(custom_cronos: Cronos, tmp_path_factory):