From 30e456a3ae6bb2fa70cb374a4cd320991062434c Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 19 Apr 2024 09:37:55 +0800 Subject: [PATCH 1/2] Problem: panic on invalid elasticity_multiplier --- app/app.go | 4 ++-- go.mod | 2 +- go.sum | 4 ++-- gomod2nix.toml | 4 ++-- integration_tests/test_upgrade.py | 29 ++++++++++++++++++----------- x/cronos/keeper/grpc_query.go | 3 ++- x/cronos/rpc/api.go | 5 ++--- 7 files changed, 29 insertions(+), 22 deletions(-) diff --git a/app/app.go b/app/app.go index ba53284f16..055ae5bd70 100644 --- a/app/app.go +++ b/app/app.go @@ -256,7 +256,7 @@ func StoreKeys() ( keys := storetypes.NewKVStoreKeys(storeKeys...) tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) - okeys := storetypes.NewObjectStoreKeys(banktypes.ObjectStoreKey, evmtypes.ObjectStoreKey, feemarkettypes.ObjectStoreKey) + okeys := storetypes.NewObjectStoreKeys(banktypes.ObjectStoreKey, evmtypes.ObjectStoreKey) return keys, memKeys, tkeys, okeys } @@ -582,7 +582,7 @@ func New( app.FeeMarketKeeper = feemarketkeeper.NewKeeper( appCodec, authtypes.NewModuleAddress(govtypes.ModuleName), - keys[feemarkettypes.StoreKey], okeys[feemarkettypes.ObjectStoreKey], + keys[feemarkettypes.StoreKey], feeMarketS, ) // Set authority to x/gov module account to only expect the module account to update params diff --git a/go.mod b/go.mod index d622b569f7..ecc3544869 100644 --- a/go.mod +++ b/go.mod @@ -274,7 +274,7 @@ replace ( 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 // block-stm branch - github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20240412074628-5a7f857a8e5f + github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20240419013511-775ac80b75c7 // 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 13d5cf1a01..dafe0d1901 100644 --- a/go.sum +++ b/go.sum @@ -427,8 +427,8 @@ github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20240415105151-0108877a3201 github.com/crypto-org-chain/cosmos-sdk/store v0.0.0-20240415105151-0108877a3201/go.mod h1:lfuLI1f4o+0SGtlHQS4x5qsjRcZZfYqG8bp3k8hM0M8= github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20240415105151-0108877a3201 h1:DbCOM19ywdL5K+bOy4h+0MppzcPgI2guHnYCfDNnAcM= github.com/crypto-org-chain/cosmos-sdk/x/tx v0.0.0-20240415105151-0108877a3201/go.mod h1:CBCU6fsRVz23QGFIQBb1DNX2DztJCf3jWyEkHY2nJQ0= -github.com/crypto-org-chain/ethermint v0.6.1-0.20240412074628-5a7f857a8e5f h1:Xnv4n06Xpw4sUkN4Vuf75wtJkBdrL2O4Yy05xIQhmEc= -github.com/crypto-org-chain/ethermint v0.6.1-0.20240412074628-5a7f857a8e5f/go.mod h1:OSFT4cvzHl0g2DizYR9vIy5/xRYAvFJrnRydAmgCqyM= +github.com/crypto-org-chain/ethermint v0.6.1-0.20240419013511-775ac80b75c7 h1:tawNK/e1F1AexRdhxC9o6M70IIrbCuvM6C8F/ujHwTY= +github.com/crypto-org-chain/ethermint v0.6.1-0.20240419013511-775ac80b75c7/go.mod h1:OSFT4cvzHl0g2DizYR9vIy5/xRYAvFJrnRydAmgCqyM= github.com/crypto-org-chain/go-block-stm v0.0.0-20240408011717-9f11af197bde h1:sQIHTJfVt5VTrF7po9eZiFkZiPjlHbFvnXtGCOoBjNM= github.com/crypto-org-chain/go-block-stm v0.0.0-20240408011717-9f11af197bde/go.mod h1:iwQTX9xMX8NV9k3o2BiWXA0SswpsZrDk5q3gA7nWYiE= github.com/crypto-org-chain/go-ethereum v1.10.20-0.20231207063621-43cf32d91c3e h1:vnyepPQ/m25+19xcTuBUdRxmltZ/EjVWNqEjhg7Ummk= diff --git a/gomod2nix.toml b/gomod2nix.toml index 391dd96ab2..97955bd296 100644 --- a/gomod2nix.toml +++ b/gomod2nix.toml @@ -259,8 +259,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.20240412074628-5a7f857a8e5f" - hash = "sha256-PbdZqHZ5r2Yd3wLoJJfI3XAdYqvESH7UqsR9ow/7am4=" + version = "v0.6.1-0.20240419013511-775ac80b75c7" + hash = "sha256-94bgC0Z+VD8w9j8+mwW/7PJSZlpKdtdR87C1E8hg3T4=" replaced = "github.com/crypto-org-chain/ethermint" [mod."github.com/fatih/color"] version = "v1.16.0" diff --git a/integration_tests/test_upgrade.py b/integration_tests/test_upgrade.py index cc1cd54788..f15c0e1faf 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) @@ -263,6 +264,12 @@ def do_upgrade(plan_name, target, mode=None): print("upgrade v1.3 height", target_height2) do_upgrade("v1.3", target_height2) + cli = c.cosmos_cli() + 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): exec(custom_cronos, tmp_path_factory) diff --git a/x/cronos/keeper/grpc_query.go b/x/cronos/keeper/grpc_query.go index be37fbfc34..f8f37aeab1 100644 --- a/x/cronos/keeper/grpc_query.go +++ b/x/cronos/keeper/grpc_query.go @@ -12,6 +12,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/crypto-org-chain/cronos/v2/x/cronos/types" "github.com/ethereum/go-ethereum/common" + ethtypes "github.com/ethereum/go-ethereum/core/types" evmkeeper "github.com/evmos/ethermint/x/evm/keeper" evmtypes "github.com/evmos/ethermint/x/evm/types" ) @@ -80,7 +81,7 @@ func (k Keeper) ReplayBlock(goCtx context.Context, req *types.ReplayBlockRequest } // populate the `From` field - if _, err := msg.GetSenderLegacy(chainID); err != nil { + if _, err := msg.GetSenderLegacy(ethtypes.LatestSignerForChainID(chainID)); err != nil { return nil, err } fees, err := evmkeeper.VerifyFee(txData, evmDenom, baseFee, homestead, istanbul, shanghai, ctx.IsCheckTx()) diff --git a/x/cronos/rpc/api.go b/x/cronos/rpc/api.go index 1ced0978aa..e2b6d68358 100644 --- a/x/cronos/rpc/api.go +++ b/x/cronos/rpc/api.go @@ -174,8 +174,7 @@ func (api *CronosAPI) GetTransactionReceiptsByBlock(blockNrOrHash rpctypes.Block } else { status = hexutil.Uint(ethtypes.ReceiptStatusSuccessful) } - - from, err := ethMsg.GetSenderLegacy(api.chainIDEpoch) + from, err := ethMsg.GetSenderLegacy(ethtypes.LatestSignerForChainID(api.chainIDEpoch)) if err != nil { return nil, err } @@ -313,7 +312,7 @@ func (api *CronosAPI) ReplayBlock(blockNrOrHash rpctypes.BlockNumberOrHash, post status = hexutil.Uint(ethtypes.ReceiptStatusSuccessful) } - from, err := ethMsg.GetSenderLegacy(api.chainIDEpoch) + from, err := ethMsg.GetSenderLegacy(ethtypes.LatestSignerForChainID(api.chainIDEpoch)) if err != nil { return nil, err } From 3a4fb2bbed288e35671d797a16dc13fe70ee8159 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 19 Apr 2024 10:21:46 +0800 Subject: [PATCH 2/2] update doc --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e9a16036e..ebfe614b85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ * (store) [#1378](https://github.com/crypto-org-chain/cronos/pull/1378) Upgrade rocksdb to `v8.11.3`. * (versiondb) [#1387](https://github.com/crypto-org-chain/cronos/pull/1387) Add dedicated config section for versiondb, prepare for sdk 0.50 integration. +### 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