Skip to content

Commit

Permalink
feat(voyager): remove unused ics20bank and refactor for new proto
Browse files Browse the repository at this point in the history
  • Loading branch information
hussein-aitlahcen committed Oct 9, 2023
1 parent 92b2837 commit 2ef1ba4
Show file tree
Hide file tree
Showing 19 changed files with 16,832 additions and 11,217 deletions.
19 changes: 8 additions & 11 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion evm/contracts/Glue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ contract Glue {
IbcCoreClientV1Height.Data memory,
OptimizedConsensusState memory,
ProcessedMoment memory,
TendermintTypesCanonicalVote.Data memory
TendermintTypesCanonicalVote.Data memory,
IbcLightclientsTendermintV1ClientState.Data memory,
IbcLightclientsTendermintV1ConsensusState.Data memory,
IbcLightclientsTendermintV1Header.Data memory
) public pure {}
}
13,576 changes: 7,335 additions & 6,241 deletions generated/contracts/src/devnet_ownable_ibc_handler.rs

Large diffs are not rendered by default.

14,206 changes: 9,374 additions & 4,832 deletions generated/contracts/src/glue.rs

Large diffs are not rendered by default.

75 changes: 74 additions & 1 deletion generated/contracts/src/ibc_handler.rs

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions generated/contracts/src/lib.rs

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

17 changes: 17 additions & 0 deletions generated/contracts/src/shared_types.rs

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

3 changes: 1 addition & 2 deletions generated/rust/Cargo.toml

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

8 changes: 8 additions & 0 deletions generated/rust/src/union.galois.api.v1.rs

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

14 changes: 4 additions & 10 deletions generated/rust/src/union.ibc.lightclients.cometbls.v1.rs

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

1 change: 1 addition & 0 deletions lib/chain-utils/src/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ impl<C: ChainSpec> EventSource for Evm<C> {
}))
}
IBCHandlerEvents::WriteAcknowledgementFilter(_) => None,
IBCHandlerEvents::TimeoutPacketFilter(_) => None,
};

Ok(event.map(|event| {
Expand Down
7 changes: 1 addition & 6 deletions lib/chain-utils/src/union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use unionlabs::{
ibc::{
core::{client::height::Height, commitment::merkle_root::MerkleRoot},
google::protobuf::{any::Any, duration::Duration},
lightclients::{cometbls, tendermint::fraction::Fraction, wasm},
lightclients::{cometbls, wasm},
},
id::Id,
id_type,
Expand Down Expand Up @@ -148,11 +148,6 @@ impl Chain for Union {
Any(wasm::client_state::ClientState {
data: cometbls::client_state::ClientState {
chain_id: self.chain_id.clone(),
// https://github.com/cometbft/cometbft/blob/da0e55604b075bac9e1d5866cb2e62eaae386dd9/light/verifier.go#L16
trust_level: Fraction {
numerator: 1,
denominator: 3,
},
// https://github.com/cosmos/relayer/blob/23d1e5c864b35d133cad6a0ef06970a2b1e1b03f/relayer/chains/cosmos/provider.go#L177
trusting_period: Duration::new(
(unbonding_period * 85 / 100).as_secs() as i64,
Expand Down
10 changes: 1 addition & 9 deletions lib/unionlabs/src/ibc/lightclients/cometbls/client_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@ use serde::{Deserialize, Serialize};

use crate::{
errors::{required, MissingField},
ibc::{
core::client::height::Height, google::protobuf::duration::Duration,
lightclients::tendermint::fraction::Fraction,
},
ibc::{core::client::height::Height, google::protobuf::duration::Duration},
Proto, TryFromProtoErrorOf, TypeUrl,
};

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ClientState {
pub chain_id: String,
pub trust_level: Fraction,
pub trusting_period: Duration,
pub unbonding_period: Duration,
pub max_clock_drift: Duration,
Expand All @@ -23,7 +19,6 @@ impl From<ClientState> for protos::union::ibc::lightclients::cometbls::v1::Clien
fn from(value: ClientState) -> Self {
Self {
chain_id: value.chain_id,
trust_level: Some(value.trust_level.into()),
trusting_period: Some(value.trusting_period.into()),
unbonding_period: Some(value.unbonding_period.into()),
max_clock_drift: Some(value.max_clock_drift.into()),
Expand Down Expand Up @@ -56,7 +51,6 @@ impl TryFrom<protos::union::ibc::lightclients::cometbls::v1::ClientState> for Cl
) -> Result<Self, Self::Error> {
Ok(Self {
chain_id: value.chain_id,
trust_level: required!(value.trust_level)?.into(),
trusting_period: required!(value.trusting_period)?
.try_into()
.map_err(TryFromClientStateError::TrustingPeriod)?,
Expand All @@ -76,7 +70,6 @@ impl From<ClientState> for contracts::glue::UnionIbcLightclientsCometblsV1Client
fn from(value: ClientState) -> Self {
Self {
chain_id: value.chain_id,
trust_level: value.trust_level.into(),
trusting_period: value.trusting_period.into(),
unbonding_period: value.unbonding_period.into(),
max_clock_drift: value.max_clock_drift.into(),
Expand All @@ -94,7 +87,6 @@ impl TryFrom<contracts::glue::UnionIbcLightclientsCometblsV1ClientStateData> for
) -> Result<Self, Self::Error> {
Ok(Self {
chain_id: value.chain_id,
trust_level: value.trust_level.into(),
trusting_period: value
.trusting_period
.try_into()
Expand Down
11 changes: 0 additions & 11 deletions lib/unionlabs/src/ibc/lightclients/cometbls/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use serde::{Deserialize, Serialize};

use crate::{
errors::{InvalidLength, MissingField},
ethereum::H256,
ibc::core::client::height::Height,
tendermint::types::signed_header::SignedHeader,
Proto, TryFromProtoErrorOf, TypeUrl,
Expand All @@ -22,10 +21,6 @@ impl Debug for Header {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Header")
.field("signed_header", &self.signed_header)
.field(
"untrusted_validator_set_root",
&self.untrusted_validator_set_root,
)
.field("trusted_height", &self.trusted_height)
.field(
"zero_knowledge_proof",
Expand Down Expand Up @@ -57,7 +52,6 @@ impl From<Header> for protos::union::ibc::lightclients::cometbls::v1::Header {
fn from(value: Header) -> Self {
Self {
signed_header: Some(value.signed_header.into()),
untrusted_validator_set_root: value.untrusted_validator_set_root.into(),
trusted_height: Some(value.trusted_height.into()),
zero_knowledge_proof: value.zero_knowledge_proof,
}
Expand All @@ -69,7 +63,6 @@ impl From<Header> for contracts::glue::UnionIbcLightclientsCometblsV1HeaderData
fn from(value: Header) -> Self {
Self {
signed_header: value.signed_header.into(),
untrusted_validator_set_root: value.untrusted_validator_set_root.into(),
trusted_height: value.trusted_height.into(),
zero_knowledge_proof: value.zero_knowledge_proof.into(),
}
Expand Down Expand Up @@ -102,10 +95,6 @@ impl TryFrom<protos::union::ibc::lightclients::cometbls::v1::Header> for Header
)))?
.try_into()
.map_err(TryFromHeaderError::SignedHeader)?,
untrusted_validator_set_root: value
.untrusted_validator_set_root
.try_into()
.map_err(TryFromHeaderError::UntrustedValidatorSetRoot)?,
trusted_height: value
.trusted_height
.ok_or(TryFromHeaderError::MissingField(MissingField(
Expand Down
4 changes: 2 additions & 2 deletions light-clients/cometbls-light-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl IbcClient for CometblsLightClient {
let untrusted_validators_hash = if untrusted_height_number == trusted_height_number + 1 {
trusted_validators_hash.clone()
} else {
header.signed_header.header.validators_hash
header.signed_header.header.validators_hash.clone()
};

let expected_block_hash = header
Expand Down Expand Up @@ -183,7 +183,7 @@ impl IbcClient for CometblsLightClient {
let untrusted_validators_hash = if untrusted_height_number == trusted_height_number + 1 {
consensus_state.data.next_validators_hash.clone()
} else {
header.untrusted_validator_set_root
header.signed_header.header.validators_hash
};

consensus_state.data.next_validators_hash = untrusted_validators_hash;
Expand Down
2 changes: 1 addition & 1 deletion tools/rust-proto.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
prost = { version = "0.11.0"; default-features = false; features = ["prost-derive"]; };
ethers = { version = "2.0.4"; optional = true; features = ["rustls"]; };
serde = { version = "1.0"; default-features = false; features = ["derive"]; optional = true; };
tonic = { version = "0.8"; features = [ "gzip" ]; optional = true; };
tonic = { version = "0.9"; features = [ "gzip" ]; optional = true; };
schemars = { version = "0.8.3"; default-features = false; optional = true; };
serde-utils = { workspace = true; };
};
Expand Down
2 changes: 1 addition & 1 deletion voyager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tendermint = { git = "https://github.com/unionlabs/tendermint-rs", branch = "bn2
tendermint-proto = { git = "https://github.com/unionlabs/tendermint-rs", branch = "bn254" }
tendermint-rpc = { git = "https://github.com/unionlabs/tendermint-rs", branch = "bn254", features = ["http-client", "websocket-client"] }
tokio = { version = "1.27.0", features = ["macros"] }
tonic = { version = "0.8", features = ["transport","tls","tls-roots","tls-webpki-roots"] }
tonic = { version = "0.9", features = ["transport","tls","tls-roots","tls-webpki-roots"] }
tower = { version = "*", features = ["log"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
clap = { version = "4.3.0", features = ["derive", "env", "error-context"] }
Expand Down
Loading

0 comments on commit 2ef1ba4

Please sign in to comment.