Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into rocksdb8
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Jul 18, 2023
2 parents 3bf2baf + 7ee50bf commit 831bc1b
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ jobs:
make test
# run versiondb tests
nix profile install -f ./nix rocksdb
nix registry add nixpkgs github:NixOS/nixpkgs/23.05
nix profile install nixpkgs#rocksdb
export PKG_CONFIG_PATH=$HOME/.nix-profile/lib/pkgconfig
export CGO_CFLAGS="$(pkg-config --cflags rocksdb)" CGO_LDFLAGS="$(pkg-config --libs rocksdb)"
export LD_LIBRARY_PATH=$HOME/.nix-profile/lib
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ jobs:
*.sum
- name: run golangci-lint
run: |
nix profile install -f ./nix rocksdb golangci-lint
nix registry add nixpkgs github:NixOS/nixpkgs/23.05
nix profile install nixpkgs#rocksdb nixpkgs#golangci-lint
export PKG_CONFIG_PATH=$HOME/.nix-profile/lib/pkgconfig
export CGO_CFLAGS="$(pkg-config --cflags rocksdb)" CGO_LDFLAGS="$(pkg-config --libs rocksdb)"
golangci-lint version
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- [#1073](https://github.com/crypto-org-chain/cronos/pull/1073) memiavl automatically truncate corrupted wal tail.
- [#1087](https://github.com/crypto-org-chain/cronos/pull/1087) memiavl fix LastCommitID when memiavl db not loaded.
- [#1088](https://github.com/crypto-org-chain/cronos/pull/1088) memiavl fix empty value in write-ahead-log replaying.
- [#1102](https://github.com/crypto-org-chain/cronos/pull/1102) avoid duplicate cache events emitted from ibc and gravity hook.

### Features

Expand Down
13 changes: 13 additions & 0 deletions integration_tests/test_gravity.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import json

import pytest
import requests
from eth_account.account import Account
from eth_utils import abi
from hexbytes import HexBytes
from pystarport import ports
from web3.exceptions import BadFunctionCallOutput

from .gravity_utils import prepare_gravity, setup_cosmos_erc20_contract
Expand Down Expand Up @@ -295,6 +297,17 @@ def check():

wait_for_fn("check balance on cronos", check)

# check duplicate end_block_events
height = cli.block_height()
port = ports.rpc_port(gravity.cronos.base_port(0))
url = f"http://127.0.0.1:{port}/block_results?height={height}"
res = requests.get(url).json().get("result")
if res:
events = res["end_block_events"]
target = "ethereum_send_to_cosmos_handled"
count = sum(1 for evt in events if evt["type"] == target)
assert count <= 2, f"duplicate {target}"


def test_direct_token_mapping(gravity):
"""
Expand Down
23 changes: 23 additions & 0 deletions integration_tests/test_ibc.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ def get_balances(chain, addr):
return chain.cosmos_cli().balances(addr)


def find_duplicate(attributes):
res = set()
key = attributes[0]["key"]
for attribute in attributes:
if attribute["key"] == key:
value0 = attribute["value"]
elif attribute["key"] == "amount":
amount = attribute["value"]
value_pair = f"{value0}:{amount}"
if value_pair in res:
return value_pair
res.add(value_pair)
return None


def test_ibc_transfer_with_hermes(ibc):
"""
test ibc transfer tokens with hermes cli
Expand Down Expand Up @@ -68,6 +83,14 @@ def check_balance_change():
# rather than the normal gas price
assert fee == gas * 1000000

# check duplicate OnRecvPacket events
criteria = "message.action=/ibc.core.channel.v1.MsgRecvPacket"
tx = cli.tx_search(criteria)["txs"][0]
events = tx["logs"][1]["events"]
for event in events:
dup = find_duplicate(event["attributes"])
assert not dup, f"duplicate {dup} in {event['type']}"


def test_ibc_incentivized_transfer(ibc):
if not ibc.incentivized:
Expand Down
1 change: 0 additions & 1 deletion x/cronos/keeper/gravity_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func (k Keeper) AfterSendToCosmosEvent(ctx sdk.Context, event gravitytypes.SendT
err := k.doAfterSendToCosmosEvent(cacheCtx, event)
if err == nil {
commit()
ctx.EventManager().EmitEvents(cacheCtx.EventManager().Events())
} else {
k.Logger(ctx).Error("AfterSendToCosmosEvent hook failed", "error", err)
}
Expand Down
1 change: 0 additions & 1 deletion x/cronos/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ func (k Keeper) OnRecvVouchers(
err := k.ConvertVouchersToEvmCoins(cacheCtx, receiver, tokens)
if err == nil {
commit()
ctx.EventManager().EmitEvents(cacheCtx.EventManager().Events())
} else {
k.Logger(ctx).Error(
fmt.Sprintf("Failed to convert vouchers to evm tokens for receiver %s, coins %s. Receive error %s",
Expand Down

0 comments on commit 831bc1b

Please sign in to comment.