Skip to content

Commit

Permalink
Problem: v1.2.x changes not sync to v1.3.x (#1425)
Browse files Browse the repository at this point in the history
* Problem: no parsed log from old event (#1416)

* Problem: no parsed log from old event

* update deps

* update doc

* cleanup

* Problem: v1.2.2 not releasd (#1422)

* Problem: release workflow don't build x86 mac (backport #1423) (#1424)

Because macos-latest becomes M1 mac now.

Solution:
- update runner

---------

Co-authored-by: mmsqe <[email protected]>
  • Loading branch information
yihuang and mmsqe authored May 3, 2024
1 parent 4584c0a commit bf11a2f
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" ([
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
4 changes: 2 additions & 2 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
17 changes: 17 additions & 0 deletions integration_tests/configs/cosmovisor.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -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+: {
Expand All @@ -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: {
Expand Down
20 changes: 8 additions & 12 deletions integration_tests/configs/upgrade-test-package.nix
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
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";
inherit rev;
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; }
]
40 changes: 25 additions & 15 deletions integration_tests/cosmoscli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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"),
Expand Down Expand Up @@ -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
Expand Down
42 changes: 40 additions & 2 deletions integration_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")
Expand All @@ -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",
Expand All @@ -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)
Expand All @@ -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()
Expand Down Expand Up @@ -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)
6 changes: 3 additions & 3 deletions integration_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]))
Expand Down
2 changes: 1 addition & 1 deletion x/cronos/rpc/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down

0 comments on commit bf11a2f

Please sign in to comment.