Skip to content

Commit

Permalink
wip 2
Browse files Browse the repository at this point in the history
  • Loading branch information
tzemanovic committed Dec 23, 2024
1 parent 4010feb commit 35c95ef
Show file tree
Hide file tree
Showing 10 changed files with 1,443 additions and 255 deletions.
1,306 changes: 1,121 additions & 185 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 7 additions & 3 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 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
Loading

0 comments on commit 35c95ef

Please sign in to comment.