From cadd4a0026c87a9f54ccb6215a5669eb1a3a66f2 Mon Sep 17 00:00:00 2001 From: huangyi Date: Fri, 26 Jul 2024 12:32:06 +0800 Subject: [PATCH 1/6] Problem: v1.3.1 not released --- CHANGELOG.md | 4 +++- default.nix | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ca3b89e5b..3eabcd067d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog -## UNRELEASED +*Jul 26, 2024* + +## v1.3.1 * (store) [#1510](https://github.com/crypto-org-chain/cronos/pull/1510) Upgrade rocksdb to `v9.1.1`. * (store) [#1511](https://github.com/crypto-org-chain/cronos/pull/1511) Upgrade rocksdb to `v9.2.1`. diff --git a/default.nix b/default.nix index 4501d75db8..6b01d71c1d 100644 --- a/default.nix +++ b/default.nix @@ -11,7 +11,7 @@ , nativeByteOrder ? true # nativeByteOrder mode will panic on big endian machines }: let - version = "v1.3.0"; + version = "v1.3.1"; pname = "cronosd"; tags = [ "ledger" "netgo" network "rocksdb" "grocksdb_no_link" ] ++ lib.optionals nativeByteOrder [ "nativebyteorder" ]; ldflags = lib.concatStringsSep "\n" ([ From 97affcd5261e8634734a8e8895486f43f935dfcc Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 26 Jul 2024 13:58:37 +0800 Subject: [PATCH 2/6] no space left on upgrade --- integration_tests/configs/cosmovisor.jsonnet | 20 +-- .../configs/upgrade-test-package.nix | 19 +-- integration_tests/test_basic.py | 2 +- integration_tests/test_gov_update_params.py | 4 +- integration_tests/test_gravity.py | 2 +- integration_tests/test_ibc_update_client.py | 2 +- integration_tests/test_upgrade.py | 148 +++++------------- integration_tests/utils.py | 17 +- 8 files changed, 67 insertions(+), 147 deletions(-) diff --git a/integration_tests/configs/cosmovisor.jsonnet b/integration_tests/configs/cosmovisor.jsonnet index 6aad17b950..8e6fd2a28a 100644 --- a/integration_tests/configs/cosmovisor.jsonnet +++ b/integration_tests/configs/cosmovisor.jsonnet @@ -5,12 +5,14 @@ config { 'app-config'+: { 'app-db-backend': 'rocksdb', 'minimum-gas-prices': '100000000000basetcro', - store:: super.store, - streamers:: super.streamers, 'iavl-lazy-loading':: super['iavl-lazy-loading'], }, validators: [super.validators[0] { - 'app-config':: super['app-config'], + 'app-config'+: { + store: { + streamers: ['versiondb'], + }, + }, }] + super.validators[1:], genesis+: { app_state+: { @@ -28,22 +30,10 @@ config { ], }, }, - evm+: { - params+: { - // emulate the environment on production network - extra_eips: [ - '2929', - '2200', - '1884', - '1344', - ], - }, - }, feemarket+: { params+: { no_base_fee: false, base_fee:: super.base_fee, - initial_base_fee: super.base_fee, }, }, gov: { diff --git a/integration_tests/configs/upgrade-test-package.nix b/integration_tests/configs/upgrade-test-package.nix index e60cebd3c0..27b2127f5a 100644 --- a/integration_tests/configs/upgrade-test-package.nix +++ b/integration_tests/configs/upgrade-test-package.nix @@ -7,20 +7,17 @@ let shortRev = builtins.substring 0 7 rev; }; }).defaultNix; - # v0.7.0 - released_0 = (fetchFlake "crypto-org-chain/cronos" "799ac47e293403bd57580d2ff96bb8d9851c3cde").default; - # v0.8.0 - released_1 = (fetchFlake "crypto-org-chain/cronos" "2f2cc88b501b47149690fdef05afbbbe5bc116c9").default; # v1.0.15 - released_2 = (fetchFlake "crypto-org-chain/cronos" "1f5e2618362303d91f621b47cbc1115cf4fa0195").default; - # v1.1.1 - released_3 = (fetchFlake "crypto-org-chain/cronos" "10b8eeb9052e3c52aa59dec15f5d3aca781d1271").default; + releasedGenesis = (fetchFlake "crypto-org-chain/cronos" "1f5e2618362303d91f621b47cbc1115cf4fa0195").default; + # release/v1.1.x + released1_1 = (fetchFlake "crypto-org-chain/cronos" "69a80154b6b24fca15f3562e2c4b312ee1092220").default; + # release/v1.2.x + released1_2 = (fetchFlake "crypto-org-chain/cronos" "1aea999eef67a0a01b22422bad94b36e45b9759a").default; current = pkgs.callPackage ../../. { }; in pkgs.linkFarm "upgrade-test-package" [ - { name = "genesis"; path = released_0; } - { name = "v0.7.0-hotfix"; path = released_1; } - { name = "v1.0.0"; path = released_2; } - { name = "v1.1.0"; path = released_3; } + { name = "genesis"; path = releasedGenesis; } + { name = "v1.1.0"; path = released1_1; } + { name = "v1.2"; path = released1_2; } { name = "v1.3"; path = current; } ] diff --git a/integration_tests/test_basic.py b/integration_tests/test_basic.py index 0e6c3c71ac..711a00beaf 100644 --- a/integration_tests/test_basic.py +++ b/integration_tests/test_basic.py @@ -974,7 +974,7 @@ def test_submit_send_enabled(cronos, tmp_path): proposal.write_text(json.dumps(proposal_src)) rsp = cli.submit_gov_proposal(proposal, from_="community") assert rsp["code"] == 0, rsp["raw_log"] - approve_proposal(cronos, rsp) + approve_proposal(cronos, rsp["events"]) print("check params have been updated now") p = cli.query_bank_send() assert sorted(p, key=lambda x: x["denom"]) == send_enable diff --git a/integration_tests/test_gov_update_params.py b/integration_tests/test_gov_update_params.py index cc9d6651cc..c78fc83747 100644 --- a/integration_tests/test_gov_update_params.py +++ b/integration_tests/test_gov_update_params.py @@ -38,7 +38,7 @@ def test_evm_update_param(cronos, tmp_path): proposal.write_text(json.dumps(proposal_src)) rsp = cli.submit_gov_proposal(proposal, from_="community") assert rsp["code"] == 0, rsp["raw_log"] - approve_proposal(cronos, rsp) + approve_proposal(cronos, rsp["events"]) print("check params have been updated now") p = cli.query_params("evm")["params"] assert not p["chain_config"]["merge_netsplit_block"] @@ -81,7 +81,7 @@ def test_gov_update_params(cronos, tmp_path): proposal.write_text(json.dumps(proposal_src)) rsp = cli.submit_gov_proposal(proposal, from_="community") assert rsp["code"] == 0, rsp["raw_log"] - approve_proposal(cronos, rsp) + approve_proposal(cronos, rsp["events"]) print("check params have been updated now") rsp = cli.query_params() print("params", rsp) diff --git a/integration_tests/test_gravity.py b/integration_tests/test_gravity.py index 4eb321d8e0..98772bc83a 100644 --- a/integration_tests/test_gravity.py +++ b/integration_tests/test_gravity.py @@ -281,7 +281,7 @@ def test_gov_token_mapping(gravity, tmp_path, is_legacy): rsp = submit_proposal(cli, tmp_path, is_legacy, denom, crc21.address) assert rsp["code"] == 0, rsp["raw_log"] - approve_proposal(gravity.cronos, rsp) + approve_proposal(gravity.cronos, rsp["events"]) print("check the contract mapping exists now") rsp = cli.query_contract_by_denom(denom) diff --git a/integration_tests/test_ibc_update_client.py b/integration_tests/test_ibc_update_client.py index 8a8d3aeb12..86eaa02e7a 100644 --- a/integration_tests/test_ibc_update_client.py +++ b/integration_tests/test_ibc_update_client.py @@ -128,6 +128,6 @@ def check_status(): }, ) assert rsp["code"] == 0, rsp["raw_log"] - approve_proposal(ibc.cronos, rsp) + approve_proposal(ibc.cronos, rsp["events"]) default_trust_period = "1209600s" assert_trust_period(default_trust_period) diff --git a/integration_tests/test_upgrade.py b/integration_tests/test_upgrade.py index 723dd88fd9..f32cb18a1c 100644 --- a/integration_tests/test_upgrade.py +++ b/integration_tests/test_upgrade.py @@ -7,22 +7,20 @@ from pathlib import Path import pytest +import requests from pystarport import ports from pystarport.cluster import SUPERVISOR_CONFIG_FILE -from .cosmoscli import DEFAULT_GAS_PRICE from .network import Cronos, setup_custom_cronos from .utils import ( ADDRS, CONTRACTS, - KEYS, approve_proposal, deploy_contract, edit_ini_sections, get_consensus_params, get_send_enable, send_transaction, - sign_transaction, wait_for_block, wait_for_new_blocks, wait_for_port, @@ -36,6 +34,15 @@ def custom_cronos(tmp_path_factory): yield from setup_cronos_test(tmp_path_factory) +def get_txs(base_port, end): + port = ports.rpc_port(base_port) + res = [] + for h in range(1, end): + url = f"http://127.0.0.1:{port}/block_results?height={h}" + res.append(requests.get(url).json().get("result")["txs_results"]) + return res + + def init_cosmovisor(home): """ build and setup cosmovisor directory structure in each node's home directory @@ -111,39 +118,8 @@ def exec(c, tmp_path_factory): - it should work transparently """ cli = c.cosmos_cli() - port = ports.api_port(c.base_port(0)) - w3 = c.w3 - gas_price = w3.eth.gas_price - erc20 = deploy_contract( - w3, - CONTRACTS["TestERC20A"], - key=KEYS["validator"], - gas_price=gas_price, - ) - tx = erc20.functions.transfer(ADDRS["community"], 10).build_transaction( - { - "from": ADDRS["validator"], - "gasPrice": gas_price, - } - ) - signed = sign_transaction(w3, tx, KEYS["validator"]) - txhash0 = w3.eth.send_raw_transaction(signed.rawTransaction) - receipt0 = w3.eth.wait_for_transaction_receipt(txhash0) - block0 = hex(receipt0["blockNumber"]) - logs0 = w3.eth.get_logs({"fromBlock": block0, "toBlock": block0}) - - def assert_eth_call(): - rsp = w3.eth.call( - { - "from": ADDRS["validator"], - "to": erc20.address, - "data": tx["data"], - }, - block0, - ) - assert (1,) == w3.codec.decode(("uint256",), rsp) - - assert_eth_call() + base_port = c.base_port(0) + port = ports.api_port(base_port) send_enable = [ {"denom": "basetcro", "enabled": False}, {"denom": "stake", "enabled": True}, @@ -160,16 +136,10 @@ def assert_eth_call(): fp.flush() c.supervisorctl("start", "cronos_777-1-node0", "cronos_777-1-node1") - wait_for_port(ports.evmrpc_port(c.base_port(0))) + wait_for_port(ports.evmrpc_port(base_port)) wait_for_new_blocks(cli, 1) - def do_upgrade( - plan_name, - target, - mode=None, - method="submit-legacy-proposal", - gas_prices=DEFAULT_GAS_PRICE, - ): + def do_upgrade(plan_name, target, mode=None): rsp = cli.gov_propose_legacy( "community", "software-upgrade", @@ -178,14 +148,12 @@ def do_upgrade( "title": "upgrade test", "description": "ditto", "upgrade-height": target, - "deposit": "1basetcro", + "deposit": "10000basetcro", }, mode=mode, - method=method, - gas_prices=gas_prices, ) assert rsp["code"] == 0, rsp["raw_log"] - approve_proposal(c, rsp, gas_prices=gas_prices) + approve_proposal(c, rsp["logs"][0]["events"]) # update cli chain binary c.chain_binary = ( @@ -193,54 +161,19 @@ def do_upgrade( ) # block should pass the target height wait_for_block(c.cosmos_cli(), target + 2, timeout=480) - wait_for_port(ports.rpc_port(c.base_port(0))) - - target1 = cli.block_height() + 15 - print("upgrade v0.8.0 height", target1) - gas_prices = "5000000000000basetcro" - do_upgrade( - "v0.7.0-hotfix", - target1, - "block", - method="submit-proposal", - gas_prices=gas_prices, - ) - cli = c.cosmos_cli() - - target2 = cli.block_height() + 15 - print("upgrade v1.0 height", target2) - do_upgrade( - "v1.0.0", - target2, - "block", - method="submit-proposal", - gas_prices=gas_prices, - ) - cli = c.cosmos_cli() - - wait_for_port(ports.evmrpc_port(c.base_port(0))) - - receipt = send_transaction( - c.w3, - { - "to": ADDRS["community"], - "value": 1000, - "maxFeePerGas": 10000000000000, - "maxPriorityFeePerGas": 10000, - }, - ) - assert receipt.status == 1 + wait_for_port(ports.rpc_port(base_port)) # test migrate keystore cli.migrate_keystore() - target3 = cli.block_height() + 15 - print("upgrade v1.1 height", target3) + height = cli.block_height() + target_height0 = height + 15 + print("upgrade v1.1 height", target_height0) - do_upgrade("v1.1.0", target3, "block", gas_prices=gas_prices) + 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))) + wait_for_port(ports.evmrpc_port(base_port)) receipt = send_transaction( c.w3, { @@ -251,6 +184,9 @@ def do_upgrade( }, ) assert receipt.status == 1 + height = cli.block_height() + target_height1 = height + 15 + print("upgrade v1.2 height", target_height1) w3 = c.w3 random_contract = deploy_contract( @@ -269,13 +205,11 @@ def do_upgrade( ) print("old values", old_height, old_balance, old_base_fee) - target4 = cli.block_height() + 15 - print("upgrade v1.3 height", target4) - do_upgrade("v1.3", target4, gas_prices=gas_prices) + do_upgrade("v1.2", target_height1) cli = c.cosmos_cli() # check basic tx works - wait_for_port(ports.evmrpc_port(c.base_port(0))) + wait_for_port(ports.evmrpc_port(base_port)) receipt = send_transaction( c.w3, { @@ -304,7 +238,7 @@ def do_upgrade( ADDRS["validator"] ) # check consensus params - port = ports.rpc_port(c.base_port(0)) + port = ports.rpc_port(base_port) res = get_consensus_params(port, w3.eth.get_block_number()) assert res["block"]["max_gas"] == "60000000" @@ -317,10 +251,10 @@ def do_upgrade( max_callback_gas = cli.query_params()["max_callback_gas"] assert max_callback_gas == "50000", max_callback_gas - e0 = cli.query_params("evm", height=target3 - 1)["params"] - e1 = cli.query_params("evm", height=target4 - 1)["params"] - f0 = cli.query_params("feemarket", height=target3 - 1)["params"] - f1 = cli.query_params("feemarket", height=target4 - 1)["params"] + 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 @@ -336,14 +270,18 @@ def do_upgrade( c.supervisorctl("start", "cronos_777-1-node0", "cronos_777-1-node1") wait_for_new_blocks(c.cosmos_cli(), 1) - assert e0 == cli.query_params("evm", height=target3 - 1)["params"] - assert e1 == cli.query_params("evm", height=target4 - 1)["params"] - assert f0 == cli.query_params("feemarket", height=target3 - 1)["params"] - assert f1 == cli.query_params("feemarket", height=target4 - 1)["params"] + height = cli.block_height() + target_height2 = height + 15 + print("upgrade v1.3 height", target_height2) + txs = get_txs(base_port, height) + do_upgrade("v1.3", target_height2) + assert txs == get_txs(base_port, height) - assert w3.eth.wait_for_transaction_receipt(txhash0)["logs"] == receipt0["logs"] - assert w3.eth.get_logs({"fromBlock": block0, "toBlock": block0}) == logs0 - assert_eth_call() + 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): diff --git a/integration_tests/utils.py b/integration_tests/utils.py index 8febe73595..1c97517428 100644 --- a/integration_tests/utils.py +++ b/integration_tests/utils.py @@ -30,8 +30,6 @@ from web3._utils.transactions import fill_nonce, fill_transaction_defaults from web3.datastructures import AttributeDict -from .cosmoscli import DEFAULT_GAS_PRICE - load_dotenv(Path(__file__).parent.parent / "scripts/.env") Account.enable_unaudited_hdwallet_features() ACCOUNTS = { @@ -138,17 +136,15 @@ def wait_for_block_time(cli, t): def approve_proposal( n, - rsp, + events, event_query_tx=False, - gas_prices=DEFAULT_GAS_PRICE, ): cli = n.cosmos_cli() - def cb(attrs): - return "proposal_id" in attrs - - ev = find_log_event_attrs(rsp["logs"], "submit_proposal", cb) # get proposal_id + ev = find_log_event_attrs( + events, "submit_proposal", lambda attrs: "proposal_id" in attrs + ) proposal_id = ev["proposal_id"] for i in range(len(n.config["validators"])): rsp = n.cosmos_cli(i).gov_vote( @@ -156,7 +152,6 @@ def cb(attrs): proposal_id, "yes", event_query_tx, - gas_prices=gas_prices, ) assert rsp["code"] == 0, rsp["raw_log"] wait_for_new_blocks(cli, 1) @@ -233,8 +228,8 @@ def parse_events(logs): } -def find_log_event_attrs(logs, ev_type, cond=None): - for ev in logs[0]["events"]: +def find_log_event_attrs(events, ev_type, cond=None): + for ev in events: if ev["type"] == ev_type: attrs = {attr["key"]: attr["value"] for attr in ev["attributes"]} if cond is None or cond(attrs): From b0c346e820ccafeaac34bee6bfbd5d18cfe03362 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 26 Jul 2024 15:06:05 +0800 Subject: [PATCH 3/6] fix approve --- integration_tests/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_tests/utils.py b/integration_tests/utils.py index 1c97517428..317b3014a0 100644 --- a/integration_tests/utils.py +++ b/integration_tests/utils.py @@ -700,7 +700,7 @@ def submit_any_proposal(cronos, tmp_path): proposal_file.write_text(json.dumps(proposal_json)) rsp = cli.submit_gov_proposal(proposal_file, from_="community") assert rsp["code"] == 0, rsp["raw_log"] - approve_proposal(cronos, rsp) + approve_proposal(cronos, rsp["events"]) grant_detail = cli.query_grant(granter_addr, grantee_addr) assert grant_detail["granter"] == granter_addr assert grant_detail["grantee"] == grantee_addr From facc66b5a4b643d8fcb476e99d6172ade4786c26 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 26 Jul 2024 15:17:14 +0800 Subject: [PATCH 4/6] Revert "fix approve" This reverts commit b0c346e820ccafeaac34bee6bfbd5d18cfe03362. --- integration_tests/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_tests/utils.py b/integration_tests/utils.py index 317b3014a0..1c97517428 100644 --- a/integration_tests/utils.py +++ b/integration_tests/utils.py @@ -700,7 +700,7 @@ def submit_any_proposal(cronos, tmp_path): proposal_file.write_text(json.dumps(proposal_json)) rsp = cli.submit_gov_proposal(proposal_file, from_="community") assert rsp["code"] == 0, rsp["raw_log"] - approve_proposal(cronos, rsp["events"]) + approve_proposal(cronos, rsp) grant_detail = cli.query_grant(granter_addr, grantee_addr) assert grant_detail["granter"] == granter_addr assert grant_detail["grantee"] == grantee_addr From 34127476cd8606514c08be6d6b8c5821d37f3234 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Fri, 26 Jul 2024 15:17:20 +0800 Subject: [PATCH 5/6] Revert "no space left on upgrade" This reverts commit 97affcd5261e8634734a8e8895486f43f935dfcc. --- integration_tests/configs/cosmovisor.jsonnet | 20 ++- .../configs/upgrade-test-package.nix | 19 ++- integration_tests/test_basic.py | 2 +- integration_tests/test_gov_update_params.py | 4 +- integration_tests/test_gravity.py | 2 +- integration_tests/test_ibc_update_client.py | 2 +- integration_tests/test_upgrade.py | 148 +++++++++++++----- integration_tests/utils.py | 17 +- 8 files changed, 147 insertions(+), 67 deletions(-) diff --git a/integration_tests/configs/cosmovisor.jsonnet b/integration_tests/configs/cosmovisor.jsonnet index 8e6fd2a28a..6aad17b950 100644 --- a/integration_tests/configs/cosmovisor.jsonnet +++ b/integration_tests/configs/cosmovisor.jsonnet @@ -5,14 +5,12 @@ config { 'app-config'+: { 'app-db-backend': 'rocksdb', 'minimum-gas-prices': '100000000000basetcro', + store:: super.store, + streamers:: super.streamers, 'iavl-lazy-loading':: super['iavl-lazy-loading'], }, validators: [super.validators[0] { - 'app-config'+: { - store: { - streamers: ['versiondb'], - }, - }, + 'app-config':: super['app-config'], }] + super.validators[1:], genesis+: { app_state+: { @@ -30,10 +28,22 @@ config { ], }, }, + evm+: { + params+: { + // emulate the environment on production network + extra_eips: [ + '2929', + '2200', + '1884', + '1344', + ], + }, + }, feemarket+: { params+: { no_base_fee: false, base_fee:: super.base_fee, + initial_base_fee: super.base_fee, }, }, gov: { diff --git a/integration_tests/configs/upgrade-test-package.nix b/integration_tests/configs/upgrade-test-package.nix index 27b2127f5a..e60cebd3c0 100644 --- a/integration_tests/configs/upgrade-test-package.nix +++ b/integration_tests/configs/upgrade-test-package.nix @@ -7,17 +7,20 @@ let shortRev = builtins.substring 0 7 rev; }; }).defaultNix; + # v0.7.0 + released_0 = (fetchFlake "crypto-org-chain/cronos" "799ac47e293403bd57580d2ff96bb8d9851c3cde").default; + # v0.8.0 + released_1 = (fetchFlake "crypto-org-chain/cronos" "2f2cc88b501b47149690fdef05afbbbe5bc116c9").default; # v1.0.15 - releasedGenesis = (fetchFlake "crypto-org-chain/cronos" "1f5e2618362303d91f621b47cbc1115cf4fa0195").default; - # release/v1.1.x - released1_1 = (fetchFlake "crypto-org-chain/cronos" "69a80154b6b24fca15f3562e2c4b312ee1092220").default; - # release/v1.2.x - released1_2 = (fetchFlake "crypto-org-chain/cronos" "1aea999eef67a0a01b22422bad94b36e45b9759a").default; + released_2 = (fetchFlake "crypto-org-chain/cronos" "1f5e2618362303d91f621b47cbc1115cf4fa0195").default; + # v1.1.1 + released_3 = (fetchFlake "crypto-org-chain/cronos" "10b8eeb9052e3c52aa59dec15f5d3aca781d1271").default; current = pkgs.callPackage ../../. { }; in pkgs.linkFarm "upgrade-test-package" [ - { name = "genesis"; path = releasedGenesis; } - { name = "v1.1.0"; path = released1_1; } - { name = "v1.2"; path = released1_2; } + { name = "genesis"; path = released_0; } + { name = "v0.7.0-hotfix"; path = released_1; } + { name = "v1.0.0"; path = released_2; } + { name = "v1.1.0"; path = released_3; } { name = "v1.3"; path = current; } ] diff --git a/integration_tests/test_basic.py b/integration_tests/test_basic.py index 711a00beaf..0e6c3c71ac 100644 --- a/integration_tests/test_basic.py +++ b/integration_tests/test_basic.py @@ -974,7 +974,7 @@ def test_submit_send_enabled(cronos, tmp_path): proposal.write_text(json.dumps(proposal_src)) rsp = cli.submit_gov_proposal(proposal, from_="community") assert rsp["code"] == 0, rsp["raw_log"] - approve_proposal(cronos, rsp["events"]) + approve_proposal(cronos, rsp) print("check params have been updated now") p = cli.query_bank_send() assert sorted(p, key=lambda x: x["denom"]) == send_enable diff --git a/integration_tests/test_gov_update_params.py b/integration_tests/test_gov_update_params.py index c78fc83747..cc9d6651cc 100644 --- a/integration_tests/test_gov_update_params.py +++ b/integration_tests/test_gov_update_params.py @@ -38,7 +38,7 @@ def test_evm_update_param(cronos, tmp_path): proposal.write_text(json.dumps(proposal_src)) rsp = cli.submit_gov_proposal(proposal, from_="community") assert rsp["code"] == 0, rsp["raw_log"] - approve_proposal(cronos, rsp["events"]) + approve_proposal(cronos, rsp) print("check params have been updated now") p = cli.query_params("evm")["params"] assert not p["chain_config"]["merge_netsplit_block"] @@ -81,7 +81,7 @@ def test_gov_update_params(cronos, tmp_path): proposal.write_text(json.dumps(proposal_src)) rsp = cli.submit_gov_proposal(proposal, from_="community") assert rsp["code"] == 0, rsp["raw_log"] - approve_proposal(cronos, rsp["events"]) + approve_proposal(cronos, rsp) print("check params have been updated now") rsp = cli.query_params() print("params", rsp) diff --git a/integration_tests/test_gravity.py b/integration_tests/test_gravity.py index 98772bc83a..4eb321d8e0 100644 --- a/integration_tests/test_gravity.py +++ b/integration_tests/test_gravity.py @@ -281,7 +281,7 @@ def test_gov_token_mapping(gravity, tmp_path, is_legacy): rsp = submit_proposal(cli, tmp_path, is_legacy, denom, crc21.address) assert rsp["code"] == 0, rsp["raw_log"] - approve_proposal(gravity.cronos, rsp["events"]) + approve_proposal(gravity.cronos, rsp) print("check the contract mapping exists now") rsp = cli.query_contract_by_denom(denom) diff --git a/integration_tests/test_ibc_update_client.py b/integration_tests/test_ibc_update_client.py index 86eaa02e7a..8a8d3aeb12 100644 --- a/integration_tests/test_ibc_update_client.py +++ b/integration_tests/test_ibc_update_client.py @@ -128,6 +128,6 @@ def check_status(): }, ) assert rsp["code"] == 0, rsp["raw_log"] - approve_proposal(ibc.cronos, rsp["events"]) + approve_proposal(ibc.cronos, rsp) default_trust_period = "1209600s" assert_trust_period(default_trust_period) diff --git a/integration_tests/test_upgrade.py b/integration_tests/test_upgrade.py index f32cb18a1c..723dd88fd9 100644 --- a/integration_tests/test_upgrade.py +++ b/integration_tests/test_upgrade.py @@ -7,20 +7,22 @@ from pathlib import Path import pytest -import requests from pystarport import ports from pystarport.cluster import SUPERVISOR_CONFIG_FILE +from .cosmoscli import DEFAULT_GAS_PRICE from .network import Cronos, setup_custom_cronos from .utils import ( ADDRS, CONTRACTS, + KEYS, approve_proposal, deploy_contract, edit_ini_sections, get_consensus_params, get_send_enable, send_transaction, + sign_transaction, wait_for_block, wait_for_new_blocks, wait_for_port, @@ -34,15 +36,6 @@ def custom_cronos(tmp_path_factory): yield from setup_cronos_test(tmp_path_factory) -def get_txs(base_port, end): - port = ports.rpc_port(base_port) - res = [] - for h in range(1, end): - url = f"http://127.0.0.1:{port}/block_results?height={h}" - res.append(requests.get(url).json().get("result")["txs_results"]) - return res - - def init_cosmovisor(home): """ build and setup cosmovisor directory structure in each node's home directory @@ -118,8 +111,39 @@ def exec(c, tmp_path_factory): - it should work transparently """ cli = c.cosmos_cli() - base_port = c.base_port(0) - port = ports.api_port(base_port) + port = ports.api_port(c.base_port(0)) + w3 = c.w3 + gas_price = w3.eth.gas_price + erc20 = deploy_contract( + w3, + CONTRACTS["TestERC20A"], + key=KEYS["validator"], + gas_price=gas_price, + ) + tx = erc20.functions.transfer(ADDRS["community"], 10).build_transaction( + { + "from": ADDRS["validator"], + "gasPrice": gas_price, + } + ) + signed = sign_transaction(w3, tx, KEYS["validator"]) + txhash0 = w3.eth.send_raw_transaction(signed.rawTransaction) + receipt0 = w3.eth.wait_for_transaction_receipt(txhash0) + block0 = hex(receipt0["blockNumber"]) + logs0 = w3.eth.get_logs({"fromBlock": block0, "toBlock": block0}) + + def assert_eth_call(): + rsp = w3.eth.call( + { + "from": ADDRS["validator"], + "to": erc20.address, + "data": tx["data"], + }, + block0, + ) + assert (1,) == w3.codec.decode(("uint256",), rsp) + + assert_eth_call() send_enable = [ {"denom": "basetcro", "enabled": False}, {"denom": "stake", "enabled": True}, @@ -136,10 +160,16 @@ def exec(c, tmp_path_factory): fp.flush() c.supervisorctl("start", "cronos_777-1-node0", "cronos_777-1-node1") - wait_for_port(ports.evmrpc_port(base_port)) + wait_for_port(ports.evmrpc_port(c.base_port(0))) wait_for_new_blocks(cli, 1) - def do_upgrade(plan_name, target, mode=None): + def do_upgrade( + plan_name, + target, + mode=None, + method="submit-legacy-proposal", + gas_prices=DEFAULT_GAS_PRICE, + ): rsp = cli.gov_propose_legacy( "community", "software-upgrade", @@ -148,12 +178,14 @@ def do_upgrade(plan_name, target, mode=None): "title": "upgrade test", "description": "ditto", "upgrade-height": target, - "deposit": "10000basetcro", + "deposit": "1basetcro", }, mode=mode, + method=method, + gas_prices=gas_prices, ) assert rsp["code"] == 0, rsp["raw_log"] - approve_proposal(c, rsp["logs"][0]["events"]) + approve_proposal(c, rsp, gas_prices=gas_prices) # update cli chain binary c.chain_binary = ( @@ -161,19 +193,54 @@ def do_upgrade(plan_name, target, mode=None): ) # block should pass the target height wait_for_block(c.cosmos_cli(), target + 2, timeout=480) - wait_for_port(ports.rpc_port(base_port)) + wait_for_port(ports.rpc_port(c.base_port(0))) + + target1 = cli.block_height() + 15 + print("upgrade v0.8.0 height", target1) + gas_prices = "5000000000000basetcro" + do_upgrade( + "v0.7.0-hotfix", + target1, + "block", + method="submit-proposal", + gas_prices=gas_prices, + ) + cli = c.cosmos_cli() + + target2 = cli.block_height() + 15 + print("upgrade v1.0 height", target2) + do_upgrade( + "v1.0.0", + target2, + "block", + method="submit-proposal", + gas_prices=gas_prices, + ) + cli = c.cosmos_cli() + + wait_for_port(ports.evmrpc_port(c.base_port(0))) + + receipt = send_transaction( + c.w3, + { + "to": ADDRS["community"], + "value": 1000, + "maxFeePerGas": 10000000000000, + "maxPriorityFeePerGas": 10000, + }, + ) + assert receipt.status == 1 # test migrate keystore cli.migrate_keystore() - height = cli.block_height() - target_height0 = height + 15 - print("upgrade v1.1 height", target_height0) + target3 = cli.block_height() + 15 + print("upgrade v1.1 height", target3) - do_upgrade("v1.1.0", target_height0, "block") + do_upgrade("v1.1.0", target3, "block", gas_prices=gas_prices) cli = c.cosmos_cli() # check basic tx works - wait_for_port(ports.evmrpc_port(base_port)) + wait_for_port(ports.evmrpc_port(c.base_port(0))) receipt = send_transaction( c.w3, { @@ -184,9 +251,6 @@ def do_upgrade(plan_name, target, mode=None): }, ) assert receipt.status == 1 - height = cli.block_height() - target_height1 = height + 15 - print("upgrade v1.2 height", target_height1) w3 = c.w3 random_contract = deploy_contract( @@ -205,11 +269,13 @@ def do_upgrade(plan_name, target, mode=None): ) print("old values", old_height, old_balance, old_base_fee) - do_upgrade("v1.2", target_height1) + target4 = cli.block_height() + 15 + print("upgrade v1.3 height", target4) + do_upgrade("v1.3", target4, gas_prices=gas_prices) cli = c.cosmos_cli() # check basic tx works - wait_for_port(ports.evmrpc_port(base_port)) + wait_for_port(ports.evmrpc_port(c.base_port(0))) receipt = send_transaction( c.w3, { @@ -238,7 +304,7 @@ def do_upgrade(plan_name, target, mode=None): ADDRS["validator"] ) # check consensus params - port = ports.rpc_port(base_port) + port = ports.rpc_port(c.base_port(0)) res = get_consensus_params(port, w3.eth.get_block_number()) assert res["block"]["max_gas"] == "60000000" @@ -251,10 +317,10 @@ 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 - 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"] + e0 = cli.query_params("evm", height=target3 - 1)["params"] + e1 = cli.query_params("evm", height=target4 - 1)["params"] + f0 = cli.query_params("feemarket", height=target3 - 1)["params"] + f1 = cli.query_params("feemarket", height=target4 - 1)["params"] assert e0["evm_denom"] == e1["evm_denom"] == "basetcro" # update the genesis time = current time + 5 secs @@ -270,18 +336,14 @@ def do_upgrade(plan_name, target, mode=None): c.supervisorctl("start", "cronos_777-1-node0", "cronos_777-1-node1") wait_for_new_blocks(c.cosmos_cli(), 1) - height = cli.block_height() - target_height2 = height + 15 - print("upgrade v1.3 height", target_height2) - txs = get_txs(base_port, height) - do_upgrade("v1.3", target_height2) - assert txs == get_txs(base_port, height) + assert e0 == cli.query_params("evm", height=target3 - 1)["params"] + assert e1 == cli.query_params("evm", height=target4 - 1)["params"] + assert f0 == cli.query_params("feemarket", height=target3 - 1)["params"] + assert f1 == cli.query_params("feemarket", height=target4 - 1)["params"] - 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"] + assert w3.eth.wait_for_transaction_receipt(txhash0)["logs"] == receipt0["logs"] + assert w3.eth.get_logs({"fromBlock": block0, "toBlock": block0}) == logs0 + assert_eth_call() def test_cosmovisor_upgrade(custom_cronos: Cronos, tmp_path_factory): diff --git a/integration_tests/utils.py b/integration_tests/utils.py index 1c97517428..8febe73595 100644 --- a/integration_tests/utils.py +++ b/integration_tests/utils.py @@ -30,6 +30,8 @@ from web3._utils.transactions import fill_nonce, fill_transaction_defaults from web3.datastructures import AttributeDict +from .cosmoscli import DEFAULT_GAS_PRICE + load_dotenv(Path(__file__).parent.parent / "scripts/.env") Account.enable_unaudited_hdwallet_features() ACCOUNTS = { @@ -136,15 +138,17 @@ def wait_for_block_time(cli, t): def approve_proposal( n, - events, + rsp, event_query_tx=False, + gas_prices=DEFAULT_GAS_PRICE, ): cli = n.cosmos_cli() + def cb(attrs): + return "proposal_id" in attrs + + ev = find_log_event_attrs(rsp["logs"], "submit_proposal", cb) # get proposal_id - ev = find_log_event_attrs( - events, "submit_proposal", lambda attrs: "proposal_id" in attrs - ) proposal_id = ev["proposal_id"] for i in range(len(n.config["validators"])): rsp = n.cosmos_cli(i).gov_vote( @@ -152,6 +156,7 @@ def approve_proposal( proposal_id, "yes", event_query_tx, + gas_prices=gas_prices, ) assert rsp["code"] == 0, rsp["raw_log"] wait_for_new_blocks(cli, 1) @@ -228,8 +233,8 @@ def parse_events(logs): } -def find_log_event_attrs(events, ev_type, cond=None): - for ev in events: +def find_log_event_attrs(logs, ev_type, cond=None): + for ev in logs[0]["events"]: if ev["type"] == ev_type: attrs = {attr["key"]: attr["value"] for attr in ev["attributes"]} if cond is None or cond(attrs): From bc3461548ff3ece0382eba924f22a8339a8b8f69 Mon Sep 17 00:00:00 2001 From: huangyi Date: Fri, 26 Jul 2024 17:02:12 +0800 Subject: [PATCH 6/6] Problem: block cache size not count in index/filters Solution: - increase block cache size --- cmd/cronosd/opendb/opendb_rocksdb.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/cronosd/opendb/opendb_rocksdb.go b/cmd/cronosd/opendb/opendb_rocksdb.go index 95cb4e7dfa..c2d4599c8d 100644 --- a/cmd/cronosd/opendb/opendb_rocksdb.go +++ b/cmd/cronosd/opendb/opendb_rocksdb.go @@ -13,7 +13,8 @@ import ( "github.com/linxGnu/grocksdb" ) -const BlockCacheSize = 1 << 30 +// 3G block cache +const BlockCacheSize = 3 << 30 func OpenDB(_ types.AppOptions, home string, backendType dbm.BackendType) (dbm.DB, error) { dataDir := filepath.Join(home, "data") @@ -98,7 +99,6 @@ func NewRocksdbOptions(opts *grocksdb.Options, sstFileWriter bool) *grocksdb.Opt // block based table options bbto := grocksdb.NewDefaultBlockBasedTableOptions() - // 1G block cache bbto.SetBlockCache(grocksdb.NewLRUCache(BlockCacheSize)) // http://rocksdb.org/blog/2021/12/29/ribbon-filter.html