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 integration test #4119

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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,306 changes: 1,121 additions & 185 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,12 @@ fs_extra = "1.2.0"
futures = "0.3"
git2 = { version = "0.18.1", default-features = false }
# branch yuji/derive-arbitrary
ibc = { git = "https://github.com/heliaxdev/cosmos-ibc-rs", rev = "38bd2a32f35117d4d9165a3c68c64ccd87ad56dd", features = ["serde"] }
ibc-derive = { git = "https://github.com/heliaxdev/cosmos-ibc-rs", rev = "38bd2a32f35117d4d9165a3c68c64ccd87ad56dd" }
ibc-testkit = { git = "https://github.com/heliaxdev/cosmos-ibc-rs", rev = "38bd2a32f35117d4d9165a3c68c64ccd87ad56dd", default-features = false }
# ibc = { git = "https://github.com/heliaxdev/cosmos-ibc-rs", rev = "38bd2a32f35117d4d9165a3c68c64ccd87ad56dd", features = ["serde"] }
# ibc-derive = { git = "https://github.com/heliaxdev/cosmos-ibc-rs", rev = "38bd2a32f35117d4d9165a3c68c64ccd87ad56dd" }
# ibc-testkit = { git = "https://github.com/heliaxdev/cosmos-ibc-rs", rev = "38bd2a32f35117d4d9165a3c68c64ccd87ad56dd", default-features = false }
ibc = { path = "../ibc-rs/ibc", features = ["serde"] }
ibc-derive = { path = "../ibc-rs/ibc-derive" }
ibc-testkit = { path = "../ibc-rs/ibc-testkit", default-features = false }
ics23 = "0.12.0"
index-set = { git = "https://github.com/heliaxdev/index-set", tag = "v0.8.1", features = ["serialize-borsh", "serialize-serde"] }
indexmap = { git = "https://github.com/heliaxdev/indexmap", tag = "2.2.4-heliax-1", features = ["borsh-schema", "serde"] }
Expand Down Expand Up @@ -189,6 +192,7 @@ tendermint-config = "0.38.0"
tendermint-light-client = "0.38.0"
tendermint-proto = "0.38.0"
tendermint-rpc = {version = "0.38.0", default-features = false}
tendermint-testgen = "0.38.0"
test-log = {version = "0.2.14", default-features = false, features = ["trace"]}
tiny-bip39 = {git = "https://github.com/anoma/tiny-bip39.git", rev = "bf0f6d8713589b83af7a917366ec31f5275c0e57"}
tiny-hderive = {git = "https://github.com/heliaxdev/tiny-hderive.git", rev = "173ae03abed0cd25d88a5a13efac00af96b75b87"}
Expand All @@ -207,14 +211,15 @@ tracing-appender = "0.2.2"
tracing-log = "0.2.0"
tracing-subscriber = {version = "0.3.7", default-features = false, features = ["env-filter", "fmt"]}
typed-builder = "0.19.1"
wasmparser = "0.107.0"
warp = "0.3.6"
wasm-instrument = {version = "0.4.0", features = ["sign_ext"]}
wasmer = "4.3.5"
wasmer-cache = "4.3.5"
wasmer-compiler = "4.3.5"
wasmer-compiler-singlepass = "4.3.5"
wasmer-types = "4.3.5"
wasmer-vm = "4.3.5"
wasmparser = "0.107.0"
wasmtimer = "0.2.0"
winapi = "0.3.9"
xorf = { version = "0.11.0", features = ["serde"] }
Expand Down
6 changes: 6 additions & 0 deletions crates/core/src/key/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,12 @@ impl<PK: PublicKey> From<&PK> for PublicKeyHash {
}
}

impl From<PublicKeyHash> for [u8; address::HASH_LEN] {
fn from(PublicKeyHash(value): PublicKeyHash) -> Self {
value
}
}

/// Derive Tendermint raw hash from the public key
pub trait PublicKeyTmRawHash {
/// Derive Tendermint raw hash from the public key
Expand Down
5 changes: 3 additions & 2 deletions crates/ibc/src/context/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,10 @@ impl TryFrom<Vec<u8>> for AnyConsensusState {
type Error = ClientError;

fn try_from(bytes: Vec<u8>) -> Result<Self, Self::Error> {
dbg!(&bytes);
Any::decode(&bytes[..])
.map_err(|e| ClientError::Other {
description: e.to_string(),
.map_err(|e: prost::DecodeError| ClientError::Other {
description: format!("decode AnyConsensusState {e}"),
})?
.try_into()
}
Expand Down
8 changes: 4 additions & 4 deletions crates/ibc/src/context/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub trait IbcCommonContext: IbcStorageContext {
match self.storage().read_bytes(&key)? {
Some(value) => Any::decode(&value[..])
.map_err(|e| ClientError::Other {
description: e.to_string(),
description: format!("client_state {e}"),
})?
.try_into()
.map_err(ContextError::from),
Expand Down Expand Up @@ -77,7 +77,7 @@ pub trait IbcCommonContext: IbcStorageContext {
match self.storage().read_bytes(&key)? {
Some(value) => Any::decode(&value[..])
.map_err(|e| ClientError::Other {
description: e.to_string(),
description: format!("consensus_state {e}"),
})?
.try_into()
.map_err(ContextError::from),
Expand Down Expand Up @@ -120,7 +120,7 @@ pub trait IbcCommonContext: IbcStorageContext {
) -> Result<AnyConsensusState> {
Any::decode(&consensus_state[..])
.map_err(|e| ClientError::Other {
description: e.to_string(),
description: format!("decode_consensus_state_value {e}"),
})?
.try_into()
.map_err(ContextError::from)
Expand All @@ -138,7 +138,7 @@ pub trait IbcCommonContext: IbcStorageContext {
let key = Key::parse(key).expect("the key should be parsable");
let height = storage::consensus_height(&key).map_err(|e| {
ClientError::Other {
description: e.to_string(),
description: format!("consensus state heights: {e}"),
}
})?;
heights.push(height);
Expand Down
5 changes: 3 additions & 2 deletions crates/ibc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,14 +737,14 @@ where
// needed in actual txs to addresses whose VPs should be triggered
let verifiers = Rc::new(RefCell::new(BTreeSet::<Address>::new()));

let message = decode_message::<Transfer>(tx_data)?;
let message = decode_message::<Transfer>(tx_data).unwrap();
match message {
IbcMessage::Transfer(msg) => {
let token_transfer_ctx = TokenTransferContext::new(
self.ctx.inner.clone(),
verifiers.clone(),
);
self.insert_verifiers()?;
self.insert_verifiers().unwrap();
send_transfer_validate(
&self.ctx,
&token_transfer_ctx,
Expand All @@ -763,6 +763,7 @@ where
.map_err(Error::NftTransfer)
}
IbcMessage::Envelope(envelope) => {
dbg!(&envelope);
validate(&self.ctx, &self.router, *envelope)
.map_err(|e| Error::Context(Box::new(e)))
}
Expand Down
8 changes: 4 additions & 4 deletions crates/ibc/src/vp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,16 @@ where
.ok_or(VpError::NoTxData)?;

// Pseudo execution and compare them
self.validate_state(&tx_data, keys_changed)?;
self.validate_state(&tx_data, keys_changed).unwrap();

// Validate the state according to the given IBC message
self.validate_with_msg(&tx_data)?;
self.validate_with_msg(&tx_data).unwrap();

// Validate the denom store if a denom key has been changed
self.validate_trace(keys_changed)?;
self.validate_trace(keys_changed).unwrap();

// Check the limits
self.check_limits(keys_changed)?;
self.check_limits(keys_changed).unwrap();

Ok(())
}
Expand Down
5 changes: 4 additions & 1 deletion crates/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ testing = [
"clap",
"lazy_static",
"rand",
"serde",
]
benches = [
"namada_apps_lib/benches",
Expand Down Expand Up @@ -86,6 +87,7 @@ rayon.workspace = true
regex.workspace = true
rlimit.workspace = true
rocksdb.workspace = true
serde = {workspace = true, optional = true}
serde_json = {workspace = true, features = ["raw_value"]}
sha2.workspace = true
smooth-operator.workspace = true
Expand All @@ -99,7 +101,7 @@ tower-abci.workspace = true
tower.workspace = true
tracing-subscriber = { workspace = true, optional = true, features = ["std", "json", "ansi", "tracing-log"]}
tracing.workspace = true
warp = "0.3.2"
warp.workspace = true
zstd.workspace = true

[dev-dependencies]
Expand All @@ -112,6 +114,7 @@ clap.workspace = true
lazy_static.workspace= true
proptest.workspace = true
rand = { workspace = true, features = ["std"] }
serde.workspace = true
test-log.workspace = true
tokio-test.workspace = true

Expand Down
Loading
Loading