From 1d5532223079d4abe078c243bca5848398f1a6c4 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 19 Apr 2024 11:12:01 +0800 Subject: [PATCH 1/2] Problem: panic on invalid elasticity_multiplier (#1397) * Problem: panic on invalid elasticity_multiplier * update doc --- CHANGELOG.md | 4 ++++ 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 ++--- 8 files changed, 33 insertions(+), 22 deletions(-) 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 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 62835e89b23e5d039aa79de46659649c30ce13d3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 19 Apr 2024 22:43:06 +0800 Subject: [PATCH 2/2] Bump golang.org/x/net from 0.18.0 to 0.23.0 in /memiavl (#1399) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.18.0 to 0.23.0. - [Commits](https://github.com/golang/net/compare/v0.18.0...v0.23.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- memiavl/go.mod | 6 +++--- memiavl/go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/memiavl/go.mod b/memiavl/go.mod index 013259fc6f..552ac2e5ae 100644 --- a/memiavl/go.mod +++ b/memiavl/go.mod @@ -57,9 +57,9 @@ require ( github.com/tidwall/match v1.1.1 // indirect github.com/tidwall/pretty v1.2.0 // indirect github.com/tidwall/tinylru v1.1.0 // indirect - golang.org/x/crypto v0.17.0 // indirect - golang.org/x/net v0.18.0 // indirect - golang.org/x/sys v0.15.0 // indirect + golang.org/x/crypto v0.21.0 // indirect + golang.org/x/net v0.23.0 // indirect + golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/memiavl/go.sum b/memiavl/go.sum index 6be902069c..6ee2429b17 100644 --- a/memiavl/go.sum +++ b/memiavl/go.sum @@ -324,8 +324,8 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -393,8 +393,8 @@ golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= -golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -463,8 +463,8 @@ golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= -golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=