Skip to content

Commit

Permalink
feat: reorganize libraries (#3347)
Browse files Browse the repository at this point in the history
- rename `IbcVersionId` to `IbcSpecId` as this type no longer represents
an IBC *version*, but rather the entire specification
- clean up `ibc-solidity`, removing unused definitions and moving some
that are only used in one place into said place where they're used. this
crate now only defines the IBC stack itself, so the `ibc` module was
also inlined
- split IBC spec definitions out of `voyager-message` into their own
crates
- these crates define the interface of the individual IBC interfaces;
there are still some rough edges but this is a good start
- remove `ics24` module from `unionlabs` and move those store path
definitions into the relevant IBC spec libraries
  - TODO: move `unionlabs::id` as well
- `union-ibc` now depends on `voyager-core`. i'm not super happy about
this, but it's fine for now - i'm still working on the library design
for the IBC specs, but i will likely split them further such that
`union-ibc` can only depend on the parts it needs.
  • Loading branch information
benluelo authored Dec 6, 2024
2 parents c5ac71e + 83db711 commit 4ffee44
Show file tree
Hide file tree
Showing 70 changed files with 3,146 additions and 3,356 deletions.
46 changes: 46 additions & 0 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ members = [
"mpc/shared",
"mpc/client",
"mpc/coordinator",

"lib/ibc-union-spec",
"lib/ibc-classic-spec",
]

[workspace.package]
Expand Down Expand Up @@ -231,6 +234,9 @@ poseidon-rs = { path = "lib/poseidon-rs", default-features =
protos = { path = "generated/rust/protos", default-features = false }
reconnecting-jsonrpc-ws-client = { path = "lib/reconnecting-jsonrpc-ws-client", default-features = false }

ibc-classic-spec = { path = "lib/ibc-classic-spec", default-features = false }
ibc-union-spec = { path = "lib/ibc-union-spec", default-features = false }

movement-light-client-types = { path = "lib/movement-light-client-types", default-features = false }

cosmos-sdk-event = { path = "lib/cosmos-sdk-event", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion cosmwasm/ucs01-relay/src/ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use cosmwasm_std::{
IbcReceiveResponse, IbcTimeout, IbcTimeoutBlock, MessageInfo, Reply, Response, SubMsgResult,
Timestamp,
};
use ibc_solidity::ibc::{Channel, Packet};
use ibc_solidity::{Channel, Packet};
use prost::{Message, Name};
use protos::cosmwasm::wasm::v1::MsgIbcSendResponse;
use token_factory_api::TokenFactoryMsg;
Expand Down
2 changes: 1 addition & 1 deletion cosmwasm/ucs01-relay/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use cosmwasm_std::{
IbcReceiveResponse, IbcTimeout, IbcTimeoutBlock, MessageInfo, StdError, Timestamp, Uint128,
Uint512, WasmMsg,
};
use ibc_solidity::ibc::{Channel, Packet};
use ibc_solidity::{Channel, Packet};
use sha2::{Digest, Sha256};
use token_factory_api::TokenFactoryMsg;
use ucs01_relay_api::{
Expand Down
31 changes: 16 additions & 15 deletions cosmwasm/union-ibc/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ crate-type = ["cdylib", "rlib"]
library = []

[dependencies]
alloy = { workspace = true, features = ["sol-types"] }
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true, features = ["abort"] }
cw-storage-plus = { workspace = true }
ethabi = { workspace = true }
hex = { workspace = true }
ibc-solidity = { workspace = true, features = ["serde"] }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
sha2 = { workspace = true }
sha3 = { workspace = true }
strum = { version = "0.26.3", features = ["derive"] }
thiserror = { workspace = true }
union-ibc-msg = { workspace = true }
unionlabs = { workspace = true, features = ["ethabi"] }
alloy = { workspace = true, features = ["sol-types"] }
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true, features = ["abort"] }
cw-storage-plus = { workspace = true }
ethabi = { workspace = true }
hex = { workspace = true }
ibc-solidity = { workspace = true, features = ["serde"] }
ibc-union-spec.workspace = true
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
sha2 = { workspace = true }
sha3 = { workspace = true }
strum = { version = "0.26.3", features = ["derive"] }
thiserror = { workspace = true }
union-ibc-msg = { workspace = true }
unionlabs = { workspace = true, features = ["ethabi"] }
2 changes: 1 addition & 1 deletion cosmwasm/union-ibc/core/msg/src/module.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ibc_solidity::ibc::Packet;
use ibc_solidity::Packet;
use unionlabs::bytes::Bytes;

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
Expand Down
4 changes: 2 additions & 2 deletions cosmwasm/union-ibc/core/msg/src/msg.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ibc_solidity::ibc::Packet;
use ibc_solidity::Packet;
use unionlabs::bytes::Bytes;

#[derive(serde::Serialize, serde::Deserialize)]
Expand Down Expand Up @@ -107,7 +107,7 @@ pub struct MsgChannelOpenInit {
#[serde(deny_unknown_fields)]
pub struct MsgChannelOpenTry {
pub port_id: String,
pub channel: ibc_solidity::ibc::Channel,
pub channel: ibc_solidity::Channel,
pub counterparty_version: String,
pub proof_init: Bytes,
pub proof_height: u64,
Expand Down
10 changes: 5 additions & 5 deletions cosmwasm/union-ibc/core/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ use cosmwasm_std::{
to_json_binary, wasm_execute, Addr, Binary, Deps, DepsMut, Env, Event, MessageInfo, Response,
};
use cw_storage_plus::Item;
use ibc_solidity::ibc::{Channel, ChannelState, Connection, ConnectionState, Packet};
use ibc_solidity::{Channel, ChannelState, Connection, ConnectionState, Packet};
use ibc_union_spec::{
BatchPacketsPath, BatchReceiptsPath, ChannelPath, ClientStatePath, ConnectionPath,
ConsensusStatePath, COMMITMENT_MAGIC,
};
use serde::{Deserialize, Serialize};
use union_ibc_msg::{
lightclient::{QueryMsg as LightClientQuery, Status, VerifyClientMessageUpdate},
Expand All @@ -25,10 +29,6 @@ use union_ibc_msg::{
use unionlabs::{
ethereum::keccak256,
hash::{hash_v2::HexPrefixed, H256},
ics24::ethabi::{
BatchPacketsPath, BatchReceiptsPath, ChannelPath, ClientStatePath, ConnectionPath,
ConsensusStatePath, COMMITMENT_MAGIC,
},
};

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion cosmwasm/union-ibc/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub mod contract;
pub mod state;

use cosmwasm_std::{Addr, StdError};
use ibc_solidity::ibc::{ChannelState, ConnectionState};
use ibc_solidity::{ChannelState, ConnectionState};
use thiserror::Error;
use unionlabs::bytes::Bytes;

Expand Down
2 changes: 1 addition & 1 deletion cosmwasm/union-ibc/core/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::BTreeSet;

use cosmwasm_std::{Addr, Binary};
use cw_storage_plus::{Item, Map};
use ibc_solidity::ibc::{Channel, Connection};
use ibc_solidity::{Channel, Connection};

pub const CHANNEL_OWNER: Map<u32, Addr> = Map::new("channel_owner");

Expand Down
5 changes: 1 addition & 4 deletions cosmwasm/union-ibc/light-clients/arbitrum/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use ethereum_light_client::client::EthereumLightClient;
use union_ibc_light_client::IbcClientError;
use unionlabs::{hash::H256, ibc::core::client::height::Height, ics24::PathParseError};
use unionlabs::{hash::H256, ibc::core::client::height::Height};

use crate::client::ArbitrumLightClient;

Expand All @@ -22,9 +22,6 @@ pub enum Error {
#[error("expected value ({expected}) and stored value ({stored}) don't match")]
StoredValueMismatch { expected: H256, stored: H256 },

#[error("unable to parse ics24 path")]
PathParse(#[from] PathParseError),

#[error("failed to verify arbitrum header: {0}")]
HeaderVerify(#[from] arbitrum_verifier::Error),

Expand Down
19 changes: 19 additions & 0 deletions lib/ibc-classic-spec/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
edition.workspace = true
license-file.workspace = true
name = "ibc-classic-spec"
repository.workspace = true
version = "0.1.0"

[dependencies]
enumorph.workspace = true
macros.workspace = true
serde = { workspace = true, features = ["derive"] }
subset-of.workspace = true
thiserror.workspace = true
tracing.workspace = true
unionlabs.workspace = true
voyager-core.workspace = true

[lints]
workspace = true
Loading

0 comments on commit 4ffee44

Please sign in to comment.