Skip to content

Commit

Permalink
fix deps
Browse files Browse the repository at this point in the history
  • Loading branch information
mina86 committed Apr 22, 2024
1 parent fe0ec30 commit b17fb89
Show file tree
Hide file tree
Showing 12 changed files with 269 additions and 378 deletions.
481 changes: 192 additions & 289 deletions Cargo.lock

Large diffs are not rendered by default.

38 changes: 18 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,18 @@ curve25519-dalek-new = { git = "https://github.com/dalek-cryptography/curve25519
curve25519-dalek = { git = "https://github.com/solana-labs/curve25519-dalek.git", rev = "b500cdc2a920cd5bff9e2dd974d7b97349d61464" }
anchor-client = { git = "https://github.com/dhruvja/anchor" }
anchor-lang = { git = "https://github.com/dhruvja/anchor" }
ibc = { git = "https://github.com/mina86/ibc-rs", rev = "6015aea441d4660f7f7ecd89b5e770a993448089" }
ibc-core-channel-types = { git = "https://github.com/mina86/ibc-rs", rev = "6015aea441d4660f7f7ecd89b5e770a993448089" }
ibc-core-client-context = { git = "https://github.com/mina86/ibc-rs", rev = "6015aea441d4660f7f7ecd89b5e770a993448089" }
ibc-core-client-types = { git = "https://github.com/mina86/ibc-rs", rev = "6015aea441d4660f7f7ecd89b5e770a993448089" }
ibc-core-commitment-types = { git = "https://github.com/mina86/ibc-rs", rev = "6015aea441d4660f7f7ecd89b5e770a993448089" }
ibc-core-connection-types = { git = "https://github.com/mina86/ibc-rs", rev = "6015aea441d4660f7f7ecd89b5e770a993448089" }
ibc-core-host = { git = "https://github.com/mina86/ibc-rs", rev = "6015aea441d4660f7f7ecd89b5e770a993448089" }
ibc-core-host-types = { git = "https://github.com/mina86/ibc-rs", rev = "6015aea441d4660f7f7ecd89b5e770a993448089" }
ibc-primitives = { git = "https://github.com/mina86/ibc-rs", rev = "6015aea441d4660f7f7ecd89b5e770a993448089" }

ibc = { git = "https://github.com/mina86/ibc-rs", rev = "2b50319f3460d03e8781e5a834c4b56bdcfdc5bc", default-features = false, features = ["borsh", "serde"] }
ibc-client-tendermint-types = { git = "https://github.com/mina86/ibc-rs", rev = "2b50319f3460d03e8781e5a834c4b56bdcfdc5bc", default-features = false }
ibc-core-channel-types = { git = "https://github.com/mina86/ibc-rs", rev = "2b50319f3460d03e8781e5a834c4b56bdcfdc5bc", default-features = false }
ibc-core-client-context = { git = "https://github.com/mina86/ibc-rs", rev = "2b50319f3460d03e8781e5a834c4b56bdcfdc5bc", default-features = false }
ibc-core-client-types = { git = "https://github.com/mina86/ibc-rs", rev = "2b50319f3460d03e8781e5a834c4b56bdcfdc5bc", default-features = false }
ibc-core-commitment-types = { git = "https://github.com/mina86/ibc-rs", rev = "2b50319f3460d03e8781e5a834c4b56bdcfdc5bc", default-features = false }
ibc-core-connection-types = { git = "https://github.com/mina86/ibc-rs", rev = "2b50319f3460d03e8781e5a834c4b56bdcfdc5bc", default-features = false }
ibc-core-host = { git = "https://github.com/mina86/ibc-rs", rev = "2b50319f3460d03e8781e5a834c4b56bdcfdc5bc", default-features = false }
ibc-core-host-types = { git = "https://github.com/mina86/ibc-rs", rev = "2b50319f3460d03e8781e5a834c4b56bdcfdc5bc", default-features = false }
ibc-primitives = { git = "https://github.com/mina86/ibc-rs", rev = "2b50319f3460d03e8781e5a834c4b56bdcfdc5bc", default-features = false }
ibc-testkit = { git = "https://github.com/mina86/ibc-rs", rev = "2b50319f3460d03e8781e5a834c4b56bdcfdc5bc", default-features = false }
# ibc-testkit = { git = "https://github.com/mina86/ibc-rs", rev = "6015aea441d4660f7f7ecd89b5e770a993448089" }
#ibc = { path = "../ibc-rs-mina/ibc" }
#ibc-app-nft-transfer = { path = "../ibc-rs-mina/ibc-apps/ics721-nft-transfer" }
Expand Down Expand Up @@ -106,18 +109,13 @@ ibc-primitives = { git = "https://github.com/mina86/ibc-rs", rev = "6
#ibc-primitives = { path = "../ibc-rs-mina/ibc-primitives" }
#ibc-query = { path = "../ibc-rs-mina" }
#ibc-testkit = { path = "../ibc-rs-mina/ibc-testkit" }
bip39 = { git="https://github.com/dhruvja/rust-bip39.git" }
tendermint = { git = "https://github.com/informalsystems/tendermint-rs", rev = "37822e540e272d2ca9e763769ad20c581203ff9a" }
tendermint-light-client = { git = "https://github.com/informalsystems/tendermint-rs", rev = "37822e540e272d2ca9e763769ad20c581203ff9a" }
tendermint-light-client-verifier = { git = "https://github.com/informalsystems/tendermint-rs", rev = "37822e540e272d2ca9e763769ad20c581203ff9a" }
tendermint-proto = { git = "https://github.com/informalsystems/tendermint-rs", rev = "37822e540e272d2ca9e763769ad20c581203ff9a" }
tendermint-testgen = { git = "https://github.com/informalsystems/tendermint-rs", rev = "37822e540e272d2ca9e763769ad20c581203ff9a" }

# tendermint = { path = "../tendermint-rs/tendermint" }
# tendermint-light-client = { path = "../tendermint-rs/light-client" }
# tendermint-light-client-verifier = { path = "../tendermint-rs/light-client-verifier" }
# tendermint-proto = { path = "../tendermint-rs/proto" }
# tendermint-testgen = { path = "../tendermint-rs/testgen" }
tendermint = { git = "https://github.com/mina86/tendermint-rs", rev = "45fbd500d731effb95a98257630feb46f6c41d06" }
tendermint-light-client = { git = "https://github.com/mina86/tendermint-rs", rev = "45fbd500d731effb95a98257630feb46f6c41d06" }
tendermint-light-client-verifier = { git = "https://github.com/mina86/tendermint-rs", rev = "45fbd500d731effb95a98257630feb46f6c41d06" }
tendermint-proto = { git = "https://github.com/mina86/tendermint-rs", rev = "45fbd500d731effb95a98257630feb46f6c41d06" }
tendermint-testgen = { git = "https://github.com/mina86/tendermint-rs", rev = "45fbd500d731effb95a98257630feb46f6c41d06" }

# cfg-expr = { git = "https://github.com/EmbarkStudios/cfg-expr", tag="0.15.0" }


Expand Down
13 changes: 4 additions & 9 deletions contracts/pallet-ibc/src/light_clients.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,7 @@ impl AnyClientState {
AnyClientState::Beefy(client_state) => client_state.latest_height(),
AnyClientState::Tendermint(client_state) => client_state.latest_height(),
AnyClientState::Wasm(client_state) => client_state.latest_height(),
AnyClientState::Guest(client_state) =>
ibc::Height::new(1, u64::from(client_state.latest_height)),
AnyClientState::Guest(client_state) => client_state.latest_height(),
#[cfg(any(test, feature = "testing"))]
AnyClientState::Mock(client_state) => client_state.latest_height(),
}
Expand Down Expand Up @@ -503,11 +502,7 @@ impl AnyClientMessage {
h.inner.maybe_header_height(),
ics08_wasm::client_message::ClientMessage::Misbehaviour(_) => None,
},
Self::Guest(inner) => match inner {
cf_guest::ClientMessage::Header(h) =>
Some(Height::new(1, u64::from(h.block_header.block_height))),
cf_guest::ClientMessage::Misbehaviour(_) => None,
},
Self::Guest(inner) => inner.maybe_header_height(),
#[cfg(any(test, feature = "testing"))]
Self::Mock(inner) => match inner {
ibc::mock::header::MockClientMessage::Header(h) => Some(h.height()),
Expand Down Expand Up @@ -605,11 +600,11 @@ impl TryFrom<Any> for AnyClientMessage {
cf_guest::ClientMessage::decode_vec(&value.value)
.map_err(ics02_client::error::Error::decode_raw_header)?,
)),
GUEST_HEADER_TYPE_URL => Ok(Self::Guest(cf_guest::ClientMessage::Header(
GUEST_HEADER_TYPE_URL => Ok(Self::Guest(cf_guest::ClientMessage::from(
cf_guest::Header::decode_vec(&value.value)
.map_err(ics02_client::error::Error::decode_raw_header)?,
))),
GUEST_MISBEHAVIOUR_TYPE_URL => Ok(Self::Guest(cf_guest::ClientMessage::Misbehaviour(
GUEST_MISBEHAVIOUR_TYPE_URL => Ok(Self::Guest(cf_guest::ClientMessage::from(
cf_guest::Misbehaviour::decode_vec(&value.value)
.map_err(ics02_client::error::Error::decode_raw_header)?,
))),
Expand Down
7 changes: 1 addition & 6 deletions light-clients/cf-guest-cw/src/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,7 @@ impl<'a> ChannelReader for Context<'a> {

/// A hashing function for packet commitments
fn hash(&self, value: Vec<u8>) -> Vec<u8> {
// let mut hasher = Sha256::default();
// hasher.update(value);
// hasher.finalize().to_vec()

//TODO(blas)
vec![]
cf_guest::digest(&value).as_slice().into()
}

fn client_update_time(
Expand Down
29 changes: 11 additions & 18 deletions light-clients/cf-guest-cw/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fn process_message(
//log!(ctx, "process_message: {:?}", msg);
let result = match msg {
ExecuteMsg::VerifyMembership(msg) => {
let client_state = ctx.client_state(&client_id)?;
let _ = ctx.client_state(&client_id)?;
let msg = VerifyMembershipMsg::try_from(msg)?;
crate::helpers::verify_delay_passed(
ctx,
Expand All @@ -95,7 +95,6 @@ fn process_message(
msg.delay_block_period,
)?;
let consensus_state = ctx.consensus_state(&client_id, msg.height)?;
// TODO(blas)
verify(
&CommitmentPrefix::default(),
&msg.proof,
Expand All @@ -106,7 +105,7 @@ fn process_message(
Ok(()).map(|_| to_binary(&ContractResult::success()))
},
ExecuteMsg::VerifyNonMembership(msg) => {
let client_state = ctx.client_state(&client_id)?;
let _ = ctx.client_state(&client_id)?;
let msg = VerifyNonMembershipMsg::try_from(msg)?;
crate::helpers::verify_delay_passed(
ctx,
Expand Down Expand Up @@ -184,19 +183,16 @@ fn process_message(
},
ExecuteMsg::CheckSubstituteAndUpdateState(
crate::msg::CheckSubstituteAndUpdateStateMsg {},
) => helpers::check_substitute_and_update_state(ctx)
.map_err(|e| ContractError::Tendermint(e.to_string()))
.and_then(|(cs, cu)| {
) => helpers::check_substitute_and_update_state(ctx).map_err(Into::into).and_then(
|(cs, cu)| {
let height = cs.latest_height();
ctx.store_consensus_state_prefixed(height, cu, SUBJECT_PREFIX);
ctx.store_client_state_prefixed(cs, SUBJECT_PREFIX)
.map_err(|e| ContractError::Tendermint(e.to_string()))?;
ctx.store_client_state_prefixed(cs, SUBJECT_PREFIX)?;
Ok(to_binary(&ContractResult::success()))
}),
},
),
ExecuteMsg::VerifyUpgradeAndUpdateState(msg) => {
let old_client_state = ctx
.client_state(&client_id)
.map_err(|e| ContractError::Tendermint(e.to_string()))?;
let old_client_state = ctx.client_state(&client_id)?;
let msg: VerifyUpgradeAndUpdateStateMsg =
VerifyUpgradeAndUpdateStateMsg::try_from(msg)?;
helpers::verify_upgrade_and_update_state(
Expand All @@ -208,17 +204,14 @@ fn process_message(
msg.proof_upgrade_client,
msg.proof_upgrade_consensus_state,
)
.map_err(|e| ContractError::Tendermint(e.to_string()))
.map_err(Into::into)
.and_then(|(cs, cu)| {
let height = cs.latest_height();
ctx.store_consensus_state(client_id.clone(), height, cu)
.map_err(|e| ContractError::Tendermint(e.to_string()))?;
ctx.store_client_state(client_id, cs)
.map_err(|e| ContractError::Tendermint(e.to_string()))?;
ctx.store_consensus_state(client_id.clone(), height, cu)?;
ctx.store_client_state(client_id, cs)?;
Ok(to_binary(&ContractResult::success()))
})
},
_ => unimplemented!("none of the other messages are implemented at the moment"),
};
Ok(result??)
}
Expand Down
16 changes: 5 additions & 11 deletions light-clients/cf-guest-cw/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

use std::time::Duration;

use guestchain::PubKey;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

Expand All @@ -28,21 +25,18 @@ use cosmwasm_std::{to_binary, Addr, CosmosMsg, StdResult, WasmMsg};
use ibc::{
core::{
ics02_client::{
client_consensus::ConsensusState as _, client_state::ClientState as _,
context::ClientReader, error::Error as Ics02Error, height::Height,
client_state::ClientState as _, context::ClientReader, error::Error as Ics02Error,
height::Height,
},
ics23_commitment::{commitment::CommitmentProofBytes, merkle::MerkleProof},
ics23_commitment::commitment::CommitmentProofBytes,
ics24_host::identifier::ClientId,
},
protobuf::Protobuf,
};
use ibc_proto::{
google::protobuf::Any,
ibc::core::commitment::v1::{MerklePath, MerkleProof as RawMerkleProof},
};
use ibc_proto::google::protobuf::Any;
use prost::Message;

use cf_guest::{error::Error, ClientState, ConsensusState};
use cf_guest::{ClientState, ConsensusState};

use ics08_wasm::{
client_state::ClientState as WasmClientState,
Expand Down
3 changes: 1 addition & 2 deletions light-clients/cf-guest-cw/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
// limitations under the License.

use crate::{ics23::FakeInner, Bytes, ContractError};
use core::{str::FromStr, time::Duration};
use core::str::FromStr;
use cosmwasm_schema::cw_serde;
use ibc::{
core::{
ics02_client::trust_threshold::TrustThreshold,
ics23_commitment::commitment::{CommitmentPrefix, CommitmentProofBytes},
ics24_host::Path,
},
Expand Down
15 changes: 4 additions & 11 deletions light-clients/cf-guest/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
use alloc::{
string::{String, ToString},
vec::Vec,
};
use core::time::Duration;
use alloc::string::{String, ToString};

use ibc::{
core::{
ics02_client::height::Height, ics23_commitment::specs::ProofSpecs,
ics24_host::identifier::ClientId,
},
core::{ics02_client::height::Height, ics24_host::identifier::ClientId},
timestamp::Timestamp,
};
use lib::hash::CryptoHash;
Expand Down Expand Up @@ -122,7 +115,7 @@ where
fn upgrade(
mut self,
upgrade_height: ibc::Height,
upgrade_options: Self::UpgradeOptions,
_upgrade_options: Self::UpgradeOptions,
_chain_id: ibc::core::ics24_host::identifier::ChainId,
) -> Self {
self.0.latest_height = upgrade_height.revision_height.into();
Expand All @@ -133,7 +126,7 @@ where
elapsed.as_nanos() as u64 > self.0.trusting_period_ns
}

fn encode_to_vec(&self) -> Result<ibc::prelude::Vec<u8>, tendermint_proto::Error> {
fn encode_to_vec(&self) -> Result<ibc::prelude::Vec<u8>, ibc::protobuf::Error> {
Ok(self.0.encode())
}
}
18 changes: 10 additions & 8 deletions light-clients/cf-guest/src/client_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ use guestchain::Signature;
use crate::alloc::string::ToString;
use alloc::vec::Vec;
use guestchain::{PubKey, Verifier};
use ibc::core::{
ics02_client::{
client_consensus::ConsensusState,
client_def::{ClientDef, ConsensusUpdateResult},
client_state::ClientState as OtherClientState,
error::Error as Ics02ClientError,
use ibc::{
core::{
ics02_client::{
client_consensus::ConsensusState,
client_def::{ClientDef, ConsensusUpdateResult},
client_state::ClientState as OtherClientState,
error::Error as Ics02ClientError,
},
ics26_routing::context::ReaderContext,
},
ics26_routing::context::ReaderContext,
protobuf::Protobuf,
};
use prost::Message;
use tendermint_proto::Protobuf;

use crate::{error::Error, ClientMessage, ClientState, ConsensusState as ClientConsensusState};

Expand Down
2 changes: 1 addition & 1 deletion light-clients/cf-guest/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl ibc::core::ics02_client::client_consensus::ConsensusState for ConsensusStat
ibc::timestamp::Timestamp::from_nanoseconds(self.0.timestamp_ns.get()).unwrap()
}

fn encode_to_vec(&self) -> Result<ibc::prelude::Vec<u8>, tendermint_proto::Error> {
fn encode_to_vec(&self) -> Result<ibc::prelude::Vec<u8>, ibc::protobuf::Error> {
Ok(proto::ConsensusState::from(self).encode_to_vec())
}
}
Expand Down
12 changes: 10 additions & 2 deletions light-clients/cf-guest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ impl From<BadMessage> for ClientError {
}
}

/// Returns digest of the value.
///
/// This is used, among other places, as packet commitment.
#[inline]
pub fn digest(value: &[u8]) -> lib::hash::CryptoHash {
lib::hash::CryptoHash::digest(value)
}

/// Returns digest of the value with client id mixed in.
///
/// We don’t store full client id in the trie key for paths which include
Expand Down Expand Up @@ -99,7 +107,7 @@ macro_rules! wrap {
}
}

impl tendermint_proto::Protobuf<ibc_proto::google::protobuf::Any> for $Outer {}
impl ibc::protobuf::Protobuf<ibc_proto::google::protobuf::Any> for $Outer {}
};

($($Inner:ident)::*<PK> as $Outer:ident) => {
Expand Down Expand Up @@ -143,7 +151,7 @@ macro_rules! wrap {
}
}

impl<PK: guestchain::PubKey> tendermint_proto::Protobuf<ibc_proto::google::protobuf::Any> for $Outer<PK> {}
impl<PK: guestchain::PubKey> ibc::protobuf::Protobuf<ibc_proto::google::protobuf::Any> for $Outer<PK> {}
};

(impl Default for $Outer:ident) => {
Expand Down
13 changes: 12 additions & 1 deletion light-clients/cf-guest/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,23 @@ use crate::proto;
super::wrap!(cf_guest_upstream::ClientMessage<PK> as ClientMessage);
super::wrap!(impl<PK> proto for ClientMessage);

impl<PK: PubKey> ClientMessage<PK> {
pub fn maybe_header_height(&self) -> Option<ibc::Height> {
if let cf_guest_upstream::ClientMessage::Header(hdr) = &self.0 {
let height = hdr.block_header.block_height;
Some(ibc::Height::new(1, height.into()))
} else {
None
}
}
}

impl<PK> ibc::core::ics02_client::client_message::ClientMessage for ClientMessage<PK>
where
PK: PubKey + Send + Sync,
PK::Signature: Send + Sync,
{
fn encode_to_vec(&self) -> Result<ibc::prelude::Vec<u8>, tendermint_proto::Error> {
fn encode_to_vec(&self) -> Result<ibc::prelude::Vec<u8>, ibc::protobuf::Error> {
Ok(proto::ClientMessage::from(self).encode_to_vec())
}
}
Expand Down

0 comments on commit b17fb89

Please sign in to comment.