Skip to content

Commit

Permalink
Problem: panic on invalid elasticity_multiplier (#1397)
Browse files Browse the repository at this point in the history
* Problem: panic on invalid elasticity_multiplier

* update doc
  • Loading branch information
mmsqe authored Apr 19, 2024
1 parent 39a0261 commit 1d55322
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
4 changes: 2 additions & 2 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
29 changes: 18 additions & 11 deletions integration_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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)))
Expand Down Expand Up @@ -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)))
Expand Down Expand Up @@ -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)
Expand All @@ -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)
3 changes: 2 additions & 1 deletion x/cronos/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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())
Expand Down
5 changes: 2 additions & 3 deletions x/cronos/rpc/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 1d55322

Please sign in to comment.