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

IBC Relayer Integration Test Suite #1521

Merged
merged 118 commits into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from 112 commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
7ecaf9f
WIP relayer test
soareschen Oct 11, 2021
1220dd4
Bootstrap chain almost working
soareschen Oct 11, 2021
dfe933e
Refactor chain bootstrap code
soareschen Oct 11, 2021
730ccad
Trying to get create client work.
soareschen Oct 12, 2021
489da0d
Test create client is now working
soareschen Oct 12, 2021
c0b6360
Fix formatting
soareschen Oct 12, 2021
92c6d22
WIP IBC packet transfer
soareschen Oct 13, 2021
4b01acb
Got IBC transfer working
soareschen Oct 14, 2021
05b3374
Refactor supervisor and denom tracing
soareschen Oct 15, 2021
4e136d5
More refactoring
soareschen Oct 15, 2021
2e64e63
More refactoring
soareschen Oct 15, 2021
1d5a996
Refactor build_and_send_transfer_messages
soareschen Oct 15, 2021
dd8be25
Round trip IBC token transfer is now working
soareschen Oct 15, 2021
6d63b9a
Refactor channel bootstrap code
soareschen Oct 15, 2021
f86229a
Add tagged chain handle wrapper
soareschen Oct 26, 2021
eb570aa
Rename ChainCommand to ChainDriver
soareschen Oct 26, 2021
1d258a1
Merge remote-tracking branch 'origin/master' into soares/chain-manager
soareschen Oct 27, 2021
c10d371
Make bootstrap pair return impl ChainHandle
soareschen Oct 27, 2021
91d13d2
Add tagged types
soareschen Oct 27, 2021
c6089d4
Refactor bootstrap pair
soareschen Oct 27, 2021
9d6f6a0
Tag ChainDriver
soareschen Oct 27, 2021
15c952c
Add mono tag, refactor single chain bootstrap
soareschen Oct 28, 2021
1f6f521
More refactoring
soareschen Oct 28, 2021
5a84287
More refactoring
soareschen Oct 28, 2021
9c588e5
Fix chain tags
soareschen Oct 28, 2021
cf36f4b
Channel creation ordering is now consistent
soareschen Oct 28, 2021
de17ae4
Test IBC transfer in both directions
soareschen Oct 28, 2021
c56bf49
Fix monitor shutdown error
soareschen Oct 28, 2021
15a2fce
Refactor wait wallet amount
soareschen Oct 28, 2021
e981147
Make init script return test config. Add hang test helper
soareschen Oct 28, 2021
2553c8b
Draft memo testing working
soareschen Oct 29, 2021
36b425e
Add boostrap_chain_and_channel_pair
soareschen Oct 29, 2021
d361e5d
Add memo test as separate test
soareschen Oct 29, 2021
7a69387
Disable health check in tests to suppress version errors from gaiad i…
soareschen Oct 29, 2021
4b1bcd1
Add CI workflow
soareschen Oct 29, 2021
c492e7e
Merge remote-tracking branch 'origin/master' into soares/integration-…
soareschen Oct 29, 2021
27bf828
Use experimental Nix with flakes
soareschen Oct 29, 2021
89926d3
Refactor test cases to use composable traits
soareschen Nov 1, 2021
0631ca5
Use NoTestConfig wrapper type for test defaults
soareschen Nov 1, 2021
6a11bf3
Reorder code definitions
soareschen Nov 1, 2021
071db9a
Try out new way to override test config and implement override defaults
soareschen Nov 2, 2021
5feab4b
Preemptively shutdown supervisor at the end of chain tests
soareschen Nov 2, 2021
801c840
Rearrange type definitions
soareschen Nov 2, 2021
c5e16b3
Rename framework traits
soareschen Nov 2, 2021
ef25d82
Rename and move override traits
soareschen Nov 2, 2021
8fbfaa8
Rename ChainDeployment to ConnectedChains
soareschen Nov 2, 2021
5b5ebfd
Merge remote-tracking branch 'origin/master' into soares/integration-…
soareschen Nov 2, 2021
f7451dc
Refactor chain bootstrap
soareschen Nov 3, 2021
c19a9e8
Add BinaryNodeTest trait
soareschen Nov 3, 2021
89aa22a
Add alpha- and beta- prefix to binary chain nodes
soareschen Nov 3, 2021
3f22bbd
Add HANG_ON_FAIL test hooks
soareschen Nov 3, 2021
bda08a5
Add non-owned BinaryNodeTest
soareschen Nov 3, 2021
8273fcb
Refactor Supervisor to use shared reference to chain registry
soareschen Nov 3, 2021
fe30bf3
Spawn supervisor in OwnedBinaryChainTest
soareschen Nov 3, 2021
d00aa35
New test override approach with separate override argument
soareschen Nov 3, 2021
46ba11b
Clean up overrides design
soareschen Nov 3, 2021
a6c2d67
Fix cargo doc
soareschen Nov 3, 2021
fd85f65
Save relayer config onto file system
soareschen Nov 3, 2021
b21b15d
Simplify test overrides
soareschen Nov 4, 2021
0eed6da
Use absolute path for data directory path
soareschen Nov 4, 2021
fa2d3da
Adding documentation
soareschen Nov 4, 2021
b4e52ad
Add documentation for `framework` module
soareschen Nov 4, 2021
2f49bea
Adding more documentation
soareschen Nov 4, 2021
a6e5321
Reorganize test data directory
soareschen Nov 4, 2021
e2f8b5e
Add documentation for `bootstrap` module
soareschen Nov 4, 2021
6940ca0
Reorganize tagged module
soareschen Nov 5, 2021
d12ec23
Add documentation for MonoTagged
soareschen Nov 5, 2021
b146b65
Refactor tagged methods into traits
soareschen Nov 5, 2021
4c3e33d
Add documentation for DualTagged
soareschen Nov 5, 2021
ac906ae
Finish documenting most constructs
soareschen Nov 5, 2021
695c31e
Merge branch 'master' into soares/integration-test
soareschen Nov 5, 2021
ee05104
Move example documentation
soareschen Nov 5, 2021
70b85e3
Rename hang to suspend
soareschen Nov 5, 2021
d99f5a0
Fix example doctest
soareschen Nov 5, 2021
f3dce71
Add more detailed documentation for DualTagged::contra_map
soareschen Nov 5, 2021
215512d
Remove ChainClientServer and inline the handle and node fields directly
soareschen Nov 8, 2021
c4c33ca
Add documentation for connected chains and channels
soareschen Nov 8, 2021
057fd22
Finish documenting everything
soareschen Nov 8, 2021
f70b4bd
Merge remote-tracking branch 'origin/master' into soares/integration-…
soareschen Nov 8, 2021
75aec4e
Only check for version in health check.
soareschen Nov 8, 2021
af550bf
Stop chain handle when it is dropped
soareschen Nov 8, 2021
0428286
Add simulation manual test
soareschen Nov 9, 2021
eaa1be6
Add documentation for new constructs
soareschen Nov 9, 2021
5bfafa2
Move manual tests into the tests::manual module
soareschen Nov 9, 2021
0d7c0f8
Add test framework for running tests with self-connected chains
soareschen Nov 11, 2021
5ef27f7
Add NodeConfigOverride for overriding full node config
soareschen Nov 11, 2021
b446c85
Draft definition for N-ary connected chains using const generics
soareschen Nov 11, 2021
33a7b68
Implement N-ary bootstrap chains code
soareschen Nov 11, 2021
f8e1329
Done initial bootstrap code for N-ary channels.
soareschen Nov 11, 2021
d48494d
Refactor to allow dynamic sized n-ary chains
soareschen Nov 12, 2021
953ef25
Running binary IBC transfer test as n-ary test successful
soareschen Nov 12, 2021
a131fdf
Add environment exporter to test
soareschen Nov 12, 2021
174dc11
Separate drop handlers from chain and node types
soareschen Nov 15, 2021
c2ba0e3
Remove reference version of test traits
soareschen Nov 15, 2021
19bbd8d
Remove "Owned" and "owned_" prefixes
soareschen Nov 15, 2021
0571875
Put N-ary chain features behind "experimental" feature flag
soareschen Nov 15, 2021
b1b62e3
Clean up cargo configuration, address review feedback
soareschen Nov 15, 2021
453a487
Merge remote-tracking branch 'origin/master' into soares/integration-…
soareschen Nov 15, 2021
e6538b5
Fix build error
soareschen Nov 15, 2021
bce75e3
Fix doctests
soareschen Nov 15, 2021
c07b446
Add custom Default instance for ModeConfig which enables everything b…
soareschen Nov 15, 2021
0cbc0f4
Follow default ModeConfig as specified in #1539
soareschen Nov 15, 2021
8a56ee8
Add test_setup_with_binary_channel command wrapper
soareschen Nov 15, 2021
54954b0
Merge remote-tracking branch 'origin/master' into soares/integration-…
soareschen Nov 15, 2021
0800c9c
Fix clippy
soareschen Nov 15, 2021
d1772f3
Fix unit test CI
soareschen Nov 15, 2021
0f885b4
Randomize created client and connection ids
soareschen Nov 16, 2021
fdfbdfe
Randomize channel IDs when bootstrapping channels
soareschen Nov 16, 2021
17e2e06
Move bootstrap connection code to separate module
soareschen Nov 16, 2021
2f63503
Add back child process as a shared Arc pointer in FullNode
soareschen Nov 16, 2021
20d502d
Move experimental N-ary test chains to separate PR
soareschen Nov 16, 2021
9aae3d8
Merge remote-tracking branch 'origin/master' into soares/integration-…
soareschen Nov 16, 2021
1fa6440
Fill out missing documentation
soareschen Nov 18, 2021
dd0ec98
Move N-ary chain constructs to #1572
soareschen Nov 18, 2021
b5b128b
Minor fix documentation
soareschen Nov 18, 2021
d9d8d0f
Add a bit more documentation to tagged identifiers
soareschen Nov 18, 2021
d45ceae
Merge branch 'master' into soares/integration-test
soareschen Nov 18, 2021
bad9e5c
Slightly clean up bootstrap logs
soareschen Nov 18, 2021
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
70 changes: 70 additions & 0 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Rust
on:
pull_request:
paths:
- .github/workflows/rust.yml
- Cargo.toml
- ci/**
- e2e/**
- proto/**
- modules/**
- relayer/**
- relayer-cli/**
- relayer-rest/**
- telemetry/**
push:
branches: master
paths:
- .github/workflows/rust.yml
- Cargo.toml
- ci/**
- e2e/**
- proto/**
- modules/**
- relayer/**
- relayer-cli/**
- relayer-rest/**
- telemetry/**

env:
CARGO_INCREMENTAL: 0
CARGO_PROFILE_DEV_DEBUG: 1
CARGO_PROFILE_RELEASE_DEBUG: 1
RUST_BACKTRACE: short
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10

jobs:
integration-test:
runs-on: ubuntu-latest
strategy:
matrix:
gaiad:
- gaia4
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v15
with:
install_url: https://nixos-nix-install-tests.cachix.org/serve/vij683ly7sl95nnhb67bdjjfabclr85m/install
install_options: '--tarball-url-prefix https://nixos-nix-install-tests.cachix.org/serve'
extra_nix_config: |
experimental-features = nix-command flakes
- uses: cachix/cachix-action@v10
with:
name: cosmos
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v1
- uses: actions-rs/cargo@v1
with:
command: test
args: -p ibc-integration-test --no-fail-fast --no-run
- env:
RUST_LOG: info
RUST_BACKTRACE: 1
run: |
nix shell github:informalsystems/cosmos.nix#${{ matrix.gaiad }} -c cargo \
test -p ibc-integration-test --no-fail-fast -- \
--nocapture --test-threads=1
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: test
args: --all-features --no-fail-fast -- --nocapture
args: --all-features --no-fail-fast --workspace --exclude ibc-integration-test -- --nocapture

# test-coverage:
# runs-on: ubuntu-latest
Expand Down
29 changes: 29 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ members = [
"relayer-rest",
"telemetry",
"proto",
"tools/integration-test",
]

exclude = [
Expand All @@ -22,4 +23,3 @@ exclude = [
# tendermint-proto = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
# tendermint-light-client = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }
# tendermint-testgen = { git = "https://github.com/informalsystems/tendermint-rs", branch = "master" }

1 change: 0 additions & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ filter = false
# [Default: true]
tx_confirmation = true


# The REST section defines parameters for Hermes' built-in RESTful API.
# https://hermes.informal.systems/rest.html
[rest]
Expand Down
5 changes: 2 additions & 3 deletions modules/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ default = ["flex-error/std", "flex-error/eyre_tracer"]

# This feature grants access to development-time mocking libraries, such as `MockContext` or `MockHeader`.
# Depends on the `testgen` suite for generating Tendermint light blocks.
mocks = ["tendermint-testgen", "sha2"]
mocks = ["tendermint-testgen"]

[dependencies]
# Proto definitions for all IBC-related interfaces, e.g., connections or channels.
Expand All @@ -38,7 +38,7 @@ prost-types = { version = "0.9", default-features = false }
bytes = { version = "1.1.0", default-features = false }
safe-regex = { version = "0.2.4", default-features = false }
subtle-encoding = { version = "0.5", default-features = false }
sha2 = { version = "0.9.8", default-features = false, optional = true }
sha2 = { version = "0.9.8", default-features = false }
flex-error = { version = "0.4.4", default-features = false }

[dependencies.tendermint]
Expand All @@ -62,7 +62,6 @@ test-env-log = { version = "0.2.7", features = ["trace"] }
modelator = "0.2.1"
tendermint-rpc = { version = "=0.23.0", features = ["http-client", "websocket-client"] }
tendermint-testgen = { version = "=0.23.0" } # Needed for generating (synthetic) light blocks.
sha2 = { version = "0.9.8" }

# pin clap to avoid miscompilations with modelator
clap = "=3.0.0-beta.4"
Expand Down
28 changes: 28 additions & 0 deletions modules/src/applications/ics20_fungible_token_transfer/denom.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use sha2::{Digest, Sha256};
use subtle_encoding::hex;

use crate::core::ics24_host::identifier::{ChannelId, PortId};
use crate::prelude::*;

use super::error::Error;

pub fn derive_ibc_denom(
port_id: &PortId,
channel_id: &ChannelId,
denom: &str,
) -> Result<String, Error> {
let transfer_path = format!("{}/{}/{}", port_id, channel_id, denom);
derive_ibc_denom_with_path(&transfer_path)
}

/// Derive the transferred token denomination using
/// <https://github.com/cosmos/ibc-go/blob/main/docs/architecture/adr-001-coin-source-tracing.md>
pub fn derive_ibc_denom_with_path(transfer_path: &str) -> Result<String, Error> {
let mut hasher = Sha256::new();
hasher.update(transfer_path.as_bytes());

let denom_bytes = hasher.finalize();
let denom_hex = String::from_utf8(hex::encode_upper(denom_bytes)).map_err(Error::utf8)?;

Ok(format!("ibc/{}", denom_hex))
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ use crate::core::ics04_channel::error as channel_error;
use crate::core::ics24_host::error::ValidationError;
use crate::core::ics24_host::identifier::{ChannelId, PortId};
use crate::prelude::*;
use flex_error::define_error;

use alloc::string::FromUtf8Error;
use flex_error::{define_error, DisplayOnly};

define_error! {
#[derive(Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -36,5 +38,9 @@ define_error! {
InvalidPacketTimeoutTimestamp
{ timestamp: u64 }
| _ | { "invalid packet timeout timestamp value" },

Utf8
[ DisplayOnly<FromUtf8Error> ]
| _ | { "utf8 decoding error" },
}
}
4 changes: 4 additions & 0 deletions modules/src/applications/ics20_fungible_token_transfer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ pub mod context;
pub mod error;
pub mod msgs;
pub mod relay_application_logic;

mod denom;

pub use denom::*;
5 changes: 2 additions & 3 deletions modules/src/clients/ics07_tendermint/client_state.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::prelude::*;

use core::str::FromStr;
use core::convert::{TryFrom, TryInto};
use core::time::Duration;

use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -196,8 +196,7 @@ impl TryFrom<RawClientState> for ClientState {
.ok_or_else(Error::missing_trusting_period)?;

Ok(Self {
chain_id: ChainId::from_str(raw.chain_id.as_str())
.map_err(Error::invalid_chain_identifier)?,
chain_id: ChainId::from_string(raw.chain_id.as_str()),
trust_level: trust_level
.try_into()
.map_err(|e| Error::invalid_trust_threshold(format!("{}", e)))?,
Expand Down
13 changes: 8 additions & 5 deletions modules/src/core/ics04_channel/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,19 @@ pub struct Packet {
}

impl Packet {
/// Checks whether a packet from a [`SendPacket`] event is
/// timed-out relative to the current state of the destination
/// chain.
/// Checks whether a packet from a
/// [`SendPacket`](crate::core::ics04_channel::events::SendPacket)
/// event is timed-out relative to the current state of the
/// destination chain.
///
/// Checks both for time-out relative to the destination chain's
/// current timestamp `dst_chain_ts` as well as relative to
/// the height `dst_chain_height`.
///
/// Note: a timed-out packet should result in a [`MsgTimeout`],
/// instead of the common-case where it results in [`MsgRecvPacket`].
/// Note: a timed-out packet should result in a
/// [`MsgTimeout`](crate::core::ics04_channel::msgs::timeout::MsgTimeout),
/// instead of the common-case where it results in
/// [`MsgRecvPacket`](crate::core::ics04_channel::msgs::recv_packet::MsgRecvPacket).
pub fn timed_out(&self, dst_chain_ts: &Timestamp, dst_chain_height: Height) -> bool {
(self.timeout_height != Height::zero() && self.timeout_height < dst_chain_height)
|| (self.timeout_timestamp != Timestamp::none()
Expand Down
48 changes: 32 additions & 16 deletions modules/src/core/ics24_host/identifier.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::prelude::*;

use core::convert::{From, Infallible};
use core::fmt::{self, Display, Formatter};
use core::str::FromStr;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -41,6 +42,19 @@ impl ChainId {
}
}

pub fn from_string(id: &str) -> Self {
let version = if Self::is_epoch_format(id) {
Self::chain_version(id)
} else {
0
};

Self {
id: id.to_string(),
version,
}
}

/// Get a reference to the underlying string.
pub fn as_str(&self) -> &str {
&self.id
Expand Down Expand Up @@ -89,19 +103,10 @@ impl ChainId {
}

impl FromStr for ChainId {
type Err = ValidationError;
type Err = Infallible;

fn from_str(id: &str) -> Result<Self, Self::Err> {
let version = if Self::is_epoch_format(id) {
Self::chain_version(id)
} else {
0
};

Ok(Self {
id: id.to_string(),
version,
})
Ok(Self::from_string(id))
}
}

Expand Down Expand Up @@ -129,11 +134,9 @@ impl Default for ChainId {
}
}

impl TryFrom<String> for ChainId {
type Error = ValidationError;

fn try_from(value: String) -> Result<Self, Self::Error> {
Self::from_str(value.as_str())
impl From<String> for ChainId {
fn from(value: String) -> Self {
Self::from_string(&value)
}
}

Expand Down Expand Up @@ -290,6 +293,10 @@ impl PartialEq<str> for ConnectionId {
pub struct PortId(String);

impl PortId {
pub fn unsafe_new(id: &str) -> Self {
Self(id.to_string())
}

/// Get this identifier as a borrowed `&str`
pub fn as_str(&self) -> &str {
&self.0
Expand Down Expand Up @@ -392,6 +399,15 @@ pub struct PortChannelId {
pub port_id: PortId,
}

impl PortChannelId {
pub fn new(channel_id: ChannelId, port_id: PortId) -> Self {
Self {
channel_id,
port_id,
}
}
}

impl Display for PortChannelId {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "{}/{}", self.port_id, self.channel_id)
Expand Down
2 changes: 1 addition & 1 deletion relayer-cli/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl Runnable for StartCmd {
let config = (*app_config()).clone();
let config = Arc::new(RwLock::new(config));

let (supervisor, tx_cmd) = make_supervisor::<ProdChainHandle>(config.clone())
let (mut supervisor, tx_cmd) = make_supervisor::<ProdChainHandle>(config.clone())
.unwrap_or_else(|e| {
Output::error(format!("Hermes failed to start, last error: {}", e)).exit();
unreachable!()
Expand Down
9 changes: 4 additions & 5 deletions relayer-cli/src/commands/tx/transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ impl TxIcs20MsgTransferCmd {
&self,
config: &Config,
) -> Result<TransferOptions, Box<dyn std::error::Error>> {
let src_chain_config = config.find_chain(&self.src_chain_id).ok_or_else(|| {
config.find_chain(&self.src_chain_id).ok_or_else(|| {
format!(
"missing configuration for source chain '{}'",
self.src_chain_id
)
})?;

let dest_chain_config = config.find_chain(&self.dst_chain_id).ok_or_else(|| {
config.find_chain(&self.dst_chain_id).ok_or_else(|| {
format!(
"missing configuration for destination chain '{}'",
self.dst_chain_id
Expand All @@ -120,8 +120,6 @@ impl TxIcs20MsgTransferCmd {
}

let opts = TransferOptions {
packet_src_chain_config: src_chain_config.clone(),
packet_dst_chain_config: dest_chain_config.clone(),
packet_src_port_id: self.src_port_id.clone(),
packet_src_channel_id: self.src_channel_id.clone(),
amount: self.amount,
Expand Down Expand Up @@ -212,7 +210,8 @@ impl Runnable for TxIcs20MsgTransferCmd {

// Checks pass, build and send the tx
let res: Result<Vec<IbcEvent>, Error> =
build_and_send_transfer_messages(chains.src, chains.dst, opts).map_err(Error::packet);
build_and_send_transfer_messages(&chains.src, &chains.dst, &opts)
.map_err(Error::packet);

match res {
Ok(ev) => Output::success(ev).exit(),
Expand Down
Loading