From ed296db185e7c1906cc7a94d6e773e18dee26511 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 27 Oct 2023 11:08:51 +0800 Subject: [PATCH 1/3] Problem: redundant parse chainID from gensis when start server --- CHANGELOG.md | 1 + go.mod | 2 +- go.sum | 4 +-- gomod2nix.toml | 4 +-- integration_tests/test_client_id.py | 43 +++++++++++++++++++++++++++++ 5 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 integration_tests/test_client_id.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 905bf90c07..e42507db71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - [#1215](https://github.com/crypto-org-chain/cronos/pull/1215) Update ethermint to fix of concurrent write in fee history. - [#1217](https://github.com/crypto-org-chain/cronos/pull/1217) Use the default chain-id behavour in sdk. +- [#1216](https://github.com/crypto-org-chain/cronos/pull/1216) Update ethermint to fix of avoid redundant parse chainID from gensis when start server. *October 17, 2023* diff --git a/go.mod b/go.mod index 094b9dd4e8..49be3460c3 100644 --- a/go.mod +++ b/go.mod @@ -234,7 +234,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/evmos/go-ethereum v1.10.26-evmos-rc1 - github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20231019015135-65c0efeabb62 + github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20231027030935-291bfa0458c4 // 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 c5f83c1858..00183b6562 100644 --- a/go.sum +++ b/go.sum @@ -484,8 +484,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.20231013072415-eec017435467 h1:m0/aHPIJAzi2MSP3TXzzbLTFf+koRFQiaYmerRZUtK4= github.com/crypto-org-chain/cosmos-sdk v0.46.0-beta2.0.20231013072415-eec017435467/go.mod h1:G384omH7cXgm90xXR7xpHvsKG7vdBaDuz4To6GpTHUU= -github.com/crypto-org-chain/ethermint v0.6.1-0.20231019015135-65c0efeabb62 h1:vkDT9v2ozR3Y0AJsrs+r+bTtgs2Kll0sq3Q/ZwXDDoc= -github.com/crypto-org-chain/ethermint v0.6.1-0.20231019015135-65c0efeabb62/go.mod h1:wnJQyK4n0vShhL+YIAUd7XCzUhgZ9fgG6yJ14n7qefo= +github.com/crypto-org-chain/ethermint v0.6.1-0.20231027030935-291bfa0458c4 h1:uLaq7qqIYJ2tJ5fQE5EBvqAgvM5Y4jWbz9V4AURwMGI= +github.com/crypto-org-chain/ethermint v0.6.1-0.20231027030935-291bfa0458c4/go.mod h1:rbAKU2rftDobCIoCiol3SO+bTqw2cERu9TEki7PvfK0= github.com/crypto-org-chain/gravity-bridge/module/v2 v2.0.1-0.20230825054824-75403cd90c6e h1:rSTc35OBjjCBx47rHPWBCIHNGPbMnEj8f7fNcK2TjVI= github.com/crypto-org-chain/gravity-bridge/module/v2 v2.0.1-0.20230825054824-75403cd90c6e/go.mod h1:HBaDqlFjlaXJwVQtA7jHejyaA7xwjXI2o6pU/ccP3tE= github.com/cyphar/filepath-securejoin v0.2.3/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= diff --git a/gomod2nix.toml b/gomod2nix.toml index f043fa26a6..a208b4cfe0 100644 --- a/gomod2nix.toml +++ b/gomod2nix.toml @@ -216,8 +216,8 @@ schema = 3 hash = "sha256-GgcReGsIIuBE2TabDYqDO9sBGogdVr9RSh4arQzdPnE=" replaced = "github.com/evmos/go-ethereum" [mod."github.com/evmos/ethermint"] - version = "v0.6.1-0.20231019015135-65c0efeabb62" - hash = "sha256-0fyozPeRfig2Nalb031GFSpM50jF4qx1qPDDStTubRs=" + version = "v0.6.1-0.20231027030935-291bfa0458c4" + hash = "sha256-T+iQ9tSyGTvJn7wSIFCFWqUeU9KUk3Ml4v1rgC9FENk=" replaced = "github.com/crypto-org-chain/ethermint" [mod."github.com/felixge/httpsnoop"] version = "v1.0.2" diff --git a/integration_tests/test_client_id.py b/integration_tests/test_client_id.py new file mode 100644 index 0000000000..afbe464026 --- /dev/null +++ b/integration_tests/test_client_id.py @@ -0,0 +1,43 @@ +import json +from pathlib import Path + +import pytest +from pystarport import ports + +from .network import setup_custom_cronos +from .utils import wait_for_port + + +@pytest.fixture(scope="module") +def custom_cronos(tmp_path_factory): + path = tmp_path_factory.mktemp("cronos") + yield from setup_custom_cronos( + path, + 26800, + Path(__file__).parent / "configs/default.jsonnet", + ) + + +def test_config_client_id(custom_cronos): + n0 = "cronos_777-1-node0" + p0 = custom_cronos.base_port(0) + w3 = custom_cronos.w3 + custom_cronos.supervisorctl("stop", n0) + cli = custom_cronos.cosmos_cli(0) + dir = cli.data_dir / "config" + + def edit_gensis_cfg(chain_id): + genesis_cfg = dir / "genesis.json" + genesis = json.loads(genesis_cfg.read_text()) + genesis["chain_id"] = chain_id + genesis_cfg.write_text(json.dumps(genesis)) + + # start with empty chain_id from genesis should fail + edit_gensis_cfg("") + with pytest.raises(Exception): + custom_cronos.supervisorctl("start", n0) + + edit_gensis_cfg("cronos_777-1") + custom_cronos.supervisorctl("start", n0) + wait_for_port(ports.evmrpc_port(p0)) + assert w3.eth.chain_id == 777 From bcefb106c3990e432f28bb8cdd1bed11c494c28b Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 27 Oct 2023 14:33:41 +0800 Subject: [PATCH 2/3] Apply suggestions from code review --- integration_tests/test_client_id.py | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/integration_tests/test_client_id.py b/integration_tests/test_client_id.py index afbe464026..deaf3ebb3e 100644 --- a/integration_tests/test_client_id.py +++ b/integration_tests/test_client_id.py @@ -1,29 +1,17 @@ import json -from pathlib import Path import pytest from pystarport import ports -from .network import setup_custom_cronos from .utils import wait_for_port -@pytest.fixture(scope="module") -def custom_cronos(tmp_path_factory): - path = tmp_path_factory.mktemp("cronos") - yield from setup_custom_cronos( - path, - 26800, - Path(__file__).parent / "configs/default.jsonnet", - ) - - -def test_config_client_id(custom_cronos): +def test_config_client_id(cronos): n0 = "cronos_777-1-node0" - p0 = custom_cronos.base_port(0) - w3 = custom_cronos.w3 - custom_cronos.supervisorctl("stop", n0) - cli = custom_cronos.cosmos_cli(0) + p0 = cronos.base_port(0) + w3 = cronos.w3 + cronos.supervisorctl("stop", n0) + cli = cronos.cosmos_cli(0) dir = cli.data_dir / "config" def edit_gensis_cfg(chain_id): @@ -35,9 +23,9 @@ def edit_gensis_cfg(chain_id): # start with empty chain_id from genesis should fail edit_gensis_cfg("") with pytest.raises(Exception): - custom_cronos.supervisorctl("start", n0) + cronos.supervisorctl("start", n0) edit_gensis_cfg("cronos_777-1") - custom_cronos.supervisorctl("start", n0) + cronos.supervisorctl("start", n0) wait_for_port(ports.evmrpc_port(p0)) assert w3.eth.chain_id == 777 From 6b80a9d20db1b0040294b3ce48312800be6155c6 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 27 Oct 2023 14:39:41 +0800 Subject: [PATCH 3/3] Apply suggestions from code review --- integration_tests/test_client_id.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/integration_tests/test_client_id.py b/integration_tests/test_client_id.py index deaf3ebb3e..9930cb50cb 100644 --- a/integration_tests/test_client_id.py +++ b/integration_tests/test_client_id.py @@ -14,18 +14,19 @@ def test_config_client_id(cronos): cli = cronos.cosmos_cli(0) dir = cli.data_dir / "config" - def edit_gensis_cfg(chain_id): + def edit_genesis_cfg(chain_id): genesis_cfg = dir / "genesis.json" genesis = json.loads(genesis_cfg.read_text()) genesis["chain_id"] = chain_id genesis_cfg.write_text(json.dumps(genesis)) # start with empty chain_id from genesis should fail - edit_gensis_cfg("") + edit_genesis_cfg("") with pytest.raises(Exception): cronos.supervisorctl("start", n0) - edit_gensis_cfg("cronos_777-1") + chain_id = 777 + edit_genesis_cfg(f"cronos_{chain_id}-1") cronos.supervisorctl("start", n0) wait_for_port(ports.evmrpc_port(p0)) - assert w3.eth.chain_id == 777 + assert w3.eth.chain_id == chain_id