diff --git a/integration_tests/configs/ibc.jsonnet b/integration_tests/configs/ibc.jsonnet index a10cf0de73..05e72760b3 100644 --- a/integration_tests/configs/ibc.jsonnet +++ b/integration_tests/configs/ibc.jsonnet @@ -5,6 +5,9 @@ config { 'account-prefix': 'crc', 'coin-type': 60, key_name: 'signer1', + 'app-config'+: { + 'index-events': super['index-events'] + ['message.action'], + }, genesis+: { app_state+: { feemarket+: { @@ -128,9 +131,13 @@ config { }, }, gas_price: { - price: 10000000000000, + price: 10000000000000000, denom: 'basetcro', }, + extension_options: [{ + type: 'ethermint_dynamic_fee', + value: '1000000', + }], }, { id: 'chainmain-1', diff --git a/integration_tests/cosmoscli.py b/integration_tests/cosmoscli.py index 0024021380..14c2fa2d7f 100644 --- a/integration_tests/cosmoscli.py +++ b/integration_tests/cosmoscli.py @@ -189,6 +189,12 @@ def query_all_txs(self, addr): ) return json.loads(txs) + def tx_search(self, events: str): + "/tx_search" + return json.loads( + self.raw("query", "txs", events=events, output="json", node=self.node_rpc) + ) + def distribution_commission(self, addr): coin = json.loads( self.raw( diff --git a/integration_tests/shell.nix b/integration_tests/shell.nix index f686410965..27a510bc59 100644 --- a/integration_tests/shell.nix +++ b/integration_tests/shell.nix @@ -19,6 +19,6 @@ pkgs.mkShell { pkgs.rocksdb (import ../nix/testenv.nix { inherit pkgs; }) (import ../nix/chainmain.nix { inherit pkgs; }) - (import ../nix/hermes.nix { inherit pkgs; }) + pkgs.hermes ]; } diff --git a/integration_tests/test_ibc.py b/integration_tests/test_ibc.py index 2d16f00292..73a078c9c9 100644 --- a/integration_tests/test_ibc.py +++ b/integration_tests/test_ibc.py @@ -9,6 +9,7 @@ CONTRACTS, deploy_contract, eth_to_bech32, + parse_events_rpc, send_transaction, wait_for_fn, wait_for_new_blocks, @@ -45,6 +46,17 @@ def check_balance_change(): wait_for_fn("balance change", check_balance_change) assert old_dst_balance + dst_amount == new_dst_balance + # assert that the relayer transactions do enables the dynamic fee extension option. + cli = ibc.cronos.cosmos_cli() + criteria = "message.action=/ibc.core.channel.v1.MsgChannelOpenInit" + tx = cli.tx_search(criteria)["txs"][0] + events = parse_events_rpc(tx["events"]) + fee = int(events["tx"]["fee"].removesuffix("basetcro")) + gas = int(tx["gas_wanted"]) + # the effective fee is decided by the max_priority_fee (base fee is zero) + # rather than the normal gas price + assert fee == gas * 1000000 + def test_cronos_transfer_tokens(ibc): """ diff --git a/integration_tests/utils.py b/integration_tests/utils.py index c46b7233dc..79b2bbbff5 100644 --- a/integration_tests/utils.py +++ b/integration_tests/utils.py @@ -1,3 +1,4 @@ +import base64 import configparser import json import os @@ -6,6 +7,7 @@ import subprocess import sys import time +from collections import defaultdict from concurrent.futures import ThreadPoolExecutor, as_completed from pathlib import Path @@ -176,6 +178,21 @@ def parse_events(logs): } +def parse_events_rpc(events): + result = defaultdict(dict) + for ev in events: + for attr in ev["attributes"]: + if attr["key"] is None: + continue + key = base64.b64decode(attr["key"].encode()).decode() + if attr["value"] is not None: + value = base64.b64decode(attr["value"].encode()).decode() + else: + value = None + result[ev["type"]][key] = value + return result + + _next_unique = 0 diff --git a/nix/default.nix b/nix/default.nix index cd3a2c62fe..944a842cdd 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -47,6 +47,7 @@ import sources.nixpkgs { paths = with pkgs.openssl; [ out dev ]; }; }; + hermes = pkgs.callPackage ./hermes.nix { src = sources.ibc-rs; }; }) (_: pkgs: { test-env = import ./testenv.nix { inherit pkgs; }; }) (_: pkgs: { diff --git a/nix/hermes.nix b/nix/hermes.nix index f6f1053eb1..163171a831 100644 --- a/nix/hermes.nix +++ b/nix/hermes.nix @@ -1,31 +1,25 @@ -{ pkgs ? import ./default.nix { } }: -let - version = "v1.0.0-rc.2"; - srcUrl = { - x86_64-linux = { - url = - "https://github.com/informalsystems/ibc-rs/releases/download/${version}/hermes-${version}-x86_64-unknown-linux-gnu.tar.gz"; - sha256 = "sha256-ms+3Ka8Ijbx63OXQzzNZ1kLrwVJDIVnvyc1TG69bun0="; - }; - x86_64-darwin = { - url = - "https://github.com/informalsystems/ibc-rs/releases/download/${version}/hermes-${version}-x86_64-apple-darwin.tar.gz"; - sha256 = "sha256-ygp49IPTXKqK12gE8OiyXjXhkJvfUZNuXVnS14SVScQ="; - }; - }.${pkgs.stdenv.system} or (throw - "Unsupported system: ${pkgs.stdenv.system}"); -in -pkgs.stdenv.mkDerivation { +{ src +, lib +, stdenv +, darwin +, rustPlatform +, symlinkJoin +, openssl +}: +rustPlatform.buildRustPackage rec { name = "hermes"; - inherit version; - src = pkgs.fetchurl srcUrl; - sourceRoot = "."; - installPhase = '' - echo "hermes" - echo $out - install -m755 -D hermes $out/bin/hermes - ''; - - meta = with pkgs.lib; { platforms = with platforms; linux ++ darwin; }; - + inherit src; + cargoSha256 = "sha256-42yTWf7fFEko0n/Y7AA2vA2s/gMypcZDvbbd9DAcuRw="; + cargoBuildFlags = "-p ibc-relayer-cli"; + buildInputs = lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.Security + darwin.libiconv + ]; + doCheck = false; + RUSTFLAGS = "--cfg ossl111 --cfg ossl110 --cfg ossl101"; + OPENSSL_NO_VENDOR = "1"; + OPENSSL_DIR = symlinkJoin { + name = "openssl"; + paths = with openssl; [ out dev ]; + }; } diff --git a/nix/sources.json b/nix/sources.json index df2c20ea03..763353aa29 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -72,6 +72,18 @@ "url": "https://github.com/crypto-org-chain/gravity-bridge/archive/3d5bdc8af5227588d04064132335932ee88f57c3.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, + "ibc-rs": { + "branch": "feemarket", + "description": "IBC Relayer (Hermes) and Modules in Rust", + "homepage": "", + "owner": "yihuang", + "repo": "ibc-rs", + "rev": "e33cceaa247d5eda7650c24bd3968dea6a05248a", + "sha256": "1kq73qvhdz35pxcx07rqqygvb3n8z8wsgw8knddj2b1x3yj66444", + "type": "tarball", + "url": "https://github.com/yihuang/ibc-rs/archive/e33cceaa247d5eda7650c24bd3968dea6a05248a.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + }, "niv": { "branch": "master", "description": "Easy dependency management for Nix projects",