diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8c04205fee..017b829b74 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,7 +50,7 @@ jobs: needs: ["release"] strategy: matrix: - runner: [macos-latest, macos-14] + runner: [macos-13, macos-14] runs-on: ${{ matrix.runner }} environment: release steps: diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cb47ea598..0246d83164 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +*May 3, 2024* + +## v1.2.2 + +### Bug Fixes + +* (rpc) [#1416](https://github.com/crypto-org-chain/cronos/pull/1416) Fix parsed logs from old events. + *April 22, 2024* ## v1.2.1 diff --git a/default.nix b/default.nix index 4516138d6a..3505f2c08e 100644 --- a/default.nix +++ b/default.nix @@ -11,7 +11,7 @@ , nativeByteOrder ? true # nativeByteOrder mode will panic on big endian machines }: let - version = "v1.2.1"; + version = "v1.2.2"; pname = "cronosd"; tags = [ "ledger" "netgo" network "rocksdb" "grocksdb_no_link" ] ++ lib.optionals nativeByteOrder [ "nativebyteorder" ]; ldflags = lib.concatStringsSep "\n" ([ diff --git a/go.mod b/go.mod index 4d76629af9..7632737742 100644 --- a/go.mod +++ b/go.mod @@ -239,7 +239,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/crypto-org-chain/go-ethereum v1.10.20-0.20231207063621-43cf32d91c3e - github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20240419022701-412115d02b10 + github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20240430071430-1588ad231d11 // 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 207627b180..2d5009cd79 100644 --- a/go.sum +++ b/go.sum @@ -488,8 +488,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.20240228013111-9bd1e035ed1d h1:ihUBUAEwQYHZEqf7lXrJithNCUJTjB8q3oSQA6Nevco= github.com/crypto-org-chain/cosmos-sdk v0.46.0-beta2.0.20240228013111-9bd1e035ed1d/go.mod h1:cmAawe8FV/52oPKbgeHLt4UpNkrNu8R5KD+kw0kxJFc= -github.com/crypto-org-chain/ethermint v0.6.1-0.20240419022701-412115d02b10 h1:6uN0+FzbTTFbGAlqdrKjcJt/geaK6zveGtm2p33tXJg= -github.com/crypto-org-chain/ethermint v0.6.1-0.20240419022701-412115d02b10/go.mod h1:zJYmx1D+tDggzvXmdJ0/I62TeIykdCMfJBjBxOcniAU= +github.com/crypto-org-chain/ethermint v0.6.1-0.20240430071430-1588ad231d11 h1:f+Qr9QgF1UXmAsEaoKon/w7hbMDIJR8Mi5kAtEeAIvw= +github.com/crypto-org-chain/ethermint v0.6.1-0.20240430071430-1588ad231d11/go.mod h1:zJYmx1D+tDggzvXmdJ0/I62TeIykdCMfJBjBxOcniAU= github.com/crypto-org-chain/go-ethereum v1.10.20-0.20231207063621-43cf32d91c3e h1:vnyepPQ/m25+19xcTuBUdRxmltZ/EjVWNqEjhg7Ummk= github.com/crypto-org-chain/go-ethereum v1.10.20-0.20231207063621-43cf32d91c3e/go.mod h1:+a8pUj1tOyJ2RinsNQD4326YS+leSoKGiG/uVVb0x6Y= github.com/crypto-org-chain/gravity-bridge/module/v2 v2.0.1-0.20230825054824-75403cd90c6e h1:rSTc35OBjjCBx47rHPWBCIHNGPbMnEj8f7fNcK2TjVI= diff --git a/gomod2nix.toml b/gomod2nix.toml index 36f7081834..072cd04cd4 100644 --- a/gomod2nix.toml +++ b/gomod2nix.toml @@ -216,8 +216,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.20240419022701-412115d02b10" - hash = "sha256-wuXg0oZlIHc+x9tSmxZxGNoBa521p+o/Nk4ynJHKlRU=" + version = "v0.6.1-0.20240430071430-1588ad231d11" + hash = "sha256-/o/PSThx/29+kx5Xtpdp6MI8v/dOgrc53/RqGiCOrWc=" replaced = "github.com/crypto-org-chain/ethermint" [mod."github.com/felixge/httpsnoop"] version = "v1.0.2" diff --git a/integration_tests/configs/cosmovisor.jsonnet b/integration_tests/configs/cosmovisor.jsonnet index 51c9c7c3bd..6aad17b950 100644 --- a/integration_tests/configs/cosmovisor.jsonnet +++ b/integration_tests/configs/cosmovisor.jsonnet @@ -5,8 +5,13 @@ 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'], + }] + super.validators[1:], genesis+: { app_state+: { bank+: { @@ -23,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 2d06b77080..e960419f8a 100644 --- a/integration_tests/configs/upgrade-test-package.nix +++ b/integration_tests/configs/upgrade-test-package.nix @@ -1,14 +1,5 @@ let pkgs = import ../../nix { }; - fetchFlake0 = repo: rev: (pkgs.flake-compat { - src = { - outPath = builtins.fetchTarball "https://github.com/${repo}/archive/${rev}.tar.gz"; - inherit rev; - shortRev = builtins.substring 0 7 rev; - }; - }).defaultNix; - # v1.0.15 - released0 = (fetchFlake0 "crypto-org-chain/cronos" "1f5e2618362303d91f621b47cbc1115cf4fa0195").default; fetchFlake = repo: rev: (pkgs.flake-compat { src = { outPath = builtins.fetchTarball "https://github.com/${repo}/archive/${rev}.tar.gz"; @@ -16,12 +7,17 @@ let shortRev = builtins.substring 0 7 rev; }; }).defaultNix; + # v0.8.x + releasedGenesis = (fetchFlake "crypto-org-chain/cronos" "2f2cc88b501b47149690fdef05afbbbe5bc116c9").default; + # v1.0.15 + released1_1 = (fetchFlake "crypto-org-chain/cronos" "1f5e2618362303d91f621b47cbc1115cf4fa0195").default; # v1.1.1 - released = (fetchFlake "crypto-org-chain/cronos" "10b8eeb9052e3c52aa59dec15f5d3aca781d1271").default; + released1_2 = (fetchFlake "crypto-org-chain/cronos" "10b8eeb9052e3c52aa59dec15f5d3aca781d1271").default; current = pkgs.callPackage ../../. { }; in pkgs.linkFarm "upgrade-test-package" [ - { name = "genesis"; path = released0; } - { name = "v1.1.0"; path = released; } + { name = "genesis"; path = releasedGenesis; } + { name = "v1.0.0"; path = released1_1; } + { name = "v1.1.0"; path = released1_2; } { name = "v1.2"; path = current; } ] diff --git a/integration_tests/cosmoscli.py b/integration_tests/cosmoscli.py index 920fe15a87..e477752c9f 100644 --- a/integration_tests/cosmoscli.py +++ b/integration_tests/cosmoscli.py @@ -670,7 +670,15 @@ def edit_validator( ) ) - def gov_propose_legacy(self, proposer, kind, proposal, mode="block", **kwargs): + def gov_propose_legacy( + self, + proposer, + kind, + proposal, + mode="block", + method="submit-legacy-proposal", + **kwargs, + ): kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE) kwargs.setdefault("gas", DEFAULT_GAS) if mode: @@ -680,11 +688,11 @@ def gov_propose_legacy(self, proposer, kind, proposal, mode="block", **kwargs): self.raw( "tx", "gov", - "submit-legacy-proposal", + method, kind, proposal["name"], "-y", - "--no-validate", + "--no-validate" if method == "submit-legacy-proposal" else None, from_=proposer, # content title=proposal.get("title"), @@ -746,19 +754,21 @@ def gov_propose_legacy(self, proposer, kind, proposal, mode="block", **kwargs): def gov_vote(self, voter, proposal_id, option, event_query_tx=True, **kwargs): kwargs.setdefault("gas_prices", DEFAULT_GAS_PRICE) - rsp = json.loads( - self.raw( - "tx", - "gov", - "vote", - proposal_id, - option, - "-y", - from_=voter, - home=self.data_dir, - **kwargs, - ) + raw = self.raw( + "tx", + "gov", + "vote", + proposal_id, + option, + "-y", + from_=voter, + home=self.data_dir, + **kwargs, ) + # skip success log info that breaks json.loads + brace_index = raw.index(b"{") + json_part = raw[brace_index:] + rsp = json.loads(json_part) if rsp["code"] == 0 and event_query_tx: rsp = self.event_query_tx_for(rsp["txhash"]) return rsp diff --git a/integration_tests/test_upgrade.py b/integration_tests/test_upgrade.py index cc8a8dded6..c890dcdd83 100644 --- a/integration_tests/test_upgrade.py +++ b/integration_tests/test_upgrade.py @@ -14,12 +14,14 @@ 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, @@ -109,13 +111,27 @@ def exec(c, tmp_path_factory): """ cli = c.cosmos_cli() port = ports.api_port(c.base_port(0)) + w3 = c.w3 + erc20 = deploy_contract( + w3, + CONTRACTS["TestERC20A"], + key=KEYS["validator"], + ) + tx = erc20.functions.transfer(ADDRS["community"], 10).build_transaction( + {"from": ADDRS["validator"]} + ) + 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}) + send_enable = [ {"denom": "basetcro", "enabled": False}, {"denom": "stake", "enabled": True}, ] p = get_send_enable(port) assert sorted(p, key=lambda x: x["denom"]) == send_enable - # export genesis from old version c.supervisorctl("stop", "all") migrate = tmp_path_factory.mktemp("migrate") @@ -128,7 +144,7 @@ def exec(c, tmp_path_factory): 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"): rsp = cli.gov_propose_legacy( "community", "software-upgrade", @@ -140,6 +156,7 @@ def do_upgrade(plan_name, target, mode=None): "deposit": "10000basetcro", }, mode=mode, + method=method, ) assert rsp["code"] == 0, rsp["raw_log"] approve_proposal(c, rsp) @@ -152,6 +169,24 @@ 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))) + target_height00 = cli.block_height() + 15 + print("upgrade v1.0 height", target_height00) + do_upgrade("v1.0.0", target_height00, "block", method="submit-proposal") + 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() @@ -264,6 +299,9 @@ def do_upgrade(plan_name, target, mode=None): 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 + def test_cosmovisor_upgrade(custom_cronos: Cronos, tmp_path_factory): exec(custom_cronos, tmp_path_factory) diff --git a/integration_tests/utils.py b/integration_tests/utils.py index 323207d83e..2afe6dc1c2 100644 --- a/integration_tests/utils.py +++ b/integration_tests/utils.py @@ -147,9 +147,9 @@ def cb(attrs): rsp = n.cosmos_cli(i).gov_vote("validator", proposal_id, "yes", event_query_tx) assert rsp["code"] == 0, rsp["raw_log"] wait_for_new_blocks(cli, 1) - assert ( - int(cli.query_tally(proposal_id)["yes_count"]) == cli.staking_pool() - ), "all validators should have voted yes" + res = cli.query_tally(proposal_id) + count = res.get("yes") or res.get("yes_count") + assert int(count) == cli.staking_pool(), "all validators should have voted yes" print("wait for proposal to be activated") proposal = cli.query_proposal(proposal_id) wait_for_block_time(cli, isoparse(proposal["voting_end_time"])) diff --git a/x/cronos/rpc/api.go b/x/cronos/rpc/api.go index bf4fa9fb76..521996196c 100644 --- a/x/cronos/rpc/api.go +++ b/x/cronos/rpc/api.go @@ -180,7 +180,7 @@ func (api *CronosAPI) GetTransactionReceiptsByBlock(blockNrOrHash rpctypes.Block return nil, err } - logs, err := evmtypes.DecodeMsgLogsFromEvents(txResult.Data, parsedTx.MsgIndex, uint64(blockRes.Height)) + logs, err := evmtypes.DecodeMsgLogsFromEvents(txResult.Data, txResult.Events, parsedTx.MsgIndex, uint64(blockRes.Height)) if err != nil { api.logger.Debug("failed to parse logs", "block", resBlock.Block.Height, "txIndex", txIndex, "msgIndex", msgIndex, "error", err.Error()) }