Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: fix duplicate cache events emitted from evm hooks and wrong priority tx are not included #1308

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- [#1294](https://github.com/crypto-org-chain/cronos/pull/1294) Update ethermint to fix and improve of debug_traceCall and eth_feeHistory.
- [#1302](https://github.com/crypto-org-chain/cronos/pull/1302) Fix concurrent map access in rootmulti store.
- [#1304](https://github.com/crypto-org-chain/cronos/pull/1304) Write versiondb with fsync, and relax the version requirement on startup.
- [#1308](https://github.com/crypto-org-chain/cronos/pull/1308) Avoid duplicate cache events emitted from evm hooks.

### Improvements

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,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.20240122030949-2f3643bff8f9
github.com/evmos/ethermint => github.com/crypto-org-chain/ethermint v0.6.1-0.20240201075032-6cc15a04e622
// 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 @@ -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.20240103063449-c887e863fae2 h1:z3LXxlOuRHfRuS6LpA3t9eSaekHmzsdrrDkaXP8UEeU=
github.com/crypto-org-chain/cosmos-sdk v0.46.0-beta2.0.20240103063449-c887e863fae2/go.mod h1:hljXsedSCJYge78hyaMYy+yzDQVGZtKAZBjZn5QMddk=
github.com/crypto-org-chain/ethermint v0.6.1-0.20240122030949-2f3643bff8f9 h1:oIxuY5GLkamJ70/1sf0EUrUnWM1Qhqum9u9NWg8VhbE=
github.com/crypto-org-chain/ethermint v0.6.1-0.20240122030949-2f3643bff8f9/go.mod h1:T3Tkhw8XMu8rYObcXpeTqGUaKogS+DKsGPD3ulHN/mg=
github.com/crypto-org-chain/ethermint v0.6.1-0.20240201075032-6cc15a04e622 h1:tISzkHGwBQMkr/Ty+NcnWIDHI/L4EQOW54Yl5IPHOQg=
github.com/crypto-org-chain/ethermint v0.6.1-0.20240201075032-6cc15a04e622/go.mod h1:T3Tkhw8XMu8rYObcXpeTqGUaKogS+DKsGPD3ulHN/mg=
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.20240122030949-2f3643bff8f9"
hash = "sha256-QIsc4PFyuyE7/UEf+vC1MlSsx9eFtAGMEEy68IfpvfM="
version = "v0.6.1-0.20240201075032-6cc15a04e622"
hash = "sha256-F8POJ9d7xQH5Mt8cdI3xmQsRwrj/WdIrQaIvS9ntjEE="
replaced = "github.com/crypto-org-chain/ethermint"
[mod."github.com/felixge/httpsnoop"]
version = "v1.0.2"
Expand Down
15 changes: 15 additions & 0 deletions integration_tests/ibc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from pathlib import Path
from typing import NamedTuple

import requests
mmsqe marked this conversation as resolved.
Show resolved Hide resolved
from pystarport import cluster, ports

from .network import Chainmain, Cronos, Hermes, setup_custom_cronos
Expand Down Expand Up @@ -255,6 +256,20 @@ def rly_transfer(ibc):
subprocess.run(cmd, check=True, shell=True)


def assert_duplicate(base_port, height):
port = ports.rpc_port(base_port)
url = f"http://127.0.0.1:{port}/block_results?height={height}"
res = requests.get(url).json().get("result")
events = res["txs_results"][0]["events"]
values = set()
for event in events:
if event["type"] == "message":
continue
str = json.dumps(event)
assert str not in values, f"dup event find: {str}"
values.add(str)

mmsqe marked this conversation as resolved.
Show resolved Hide resolved

def find_duplicate(attributes):
res = set()
key = attributes[0]["key"]
Expand Down
8 changes: 8 additions & 0 deletions integration_tests/test_ibc_rly.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from .ibc_utils import (
RATIO,
assert_duplicate,
cronos_transfer_source_tokens,
cronos_transfer_source_tokens_with_proxy,
get_balance,
Expand Down Expand Up @@ -189,6 +190,9 @@ def check_balance_change():
*send_from_module_to_acc(cronos_addr, cronos_signer2, dst_amount, dst_denom),
write_ack(relayer0, cronos_signer2, src_amount, src_denom),
]
assert len(logs) == len(expected)
height = logs[0]["blockNumber"]
assert_duplicate(ibc.cronos.base_port(0), height)
mmsqe marked this conversation as resolved.
Show resolved Hide resolved
for i, log in enumerate(logs):
method_name, args = get_topic_data(w3, method_map, contract_info, log)
assert args == AttributeDict(expected[i]), [i, method_name]
Expand Down Expand Up @@ -264,6 +268,8 @@ def test_cronos_transfer_source_tokens(ibc):
dst_adr = ibc.chainmain.cosmos_cli().address("signer2")
expected = get_transfer_source_tokens_topics(dst_adr, amount, contract, escrow)
assert len(logs) == len(expected)
height = logs[0]["blockNumber"]
assert_duplicate(ibc.cronos.base_port(0), height)
mmsqe marked this conversation as resolved.
Show resolved Hide resolved
for i, log in enumerate(logs):
method_name, args = get_topic_data(w3, method_map, contract_info, log)
assert args == AttributeDict(expected[i]), [i, method_name]
Expand All @@ -280,6 +286,8 @@ def test_cronos_transfer_source_tokens_with_proxy(ibc):
dst_adr = ibc.chainmain.cosmos_cli().address("signer2")
expected = get_transfer_source_tokens_topics(dst_adr, amount, contract, escrow)
assert len(logs) == len(expected)
height = logs[0]["blockNumber"]
assert_duplicate(ibc.cronos.base_port(0), height)
mmsqe marked this conversation as resolved.
Show resolved Hide resolved
for i, log in enumerate(logs):
method_name, args = get_topic_data(w3, method_map, contract_info, log)
assert args == AttributeDict(expected[i]), [i, method_name]
Loading