From 53a940334c8f5c03377ca56fcc9cf43deea6efc3 Mon Sep 17 00:00:00 2001 From: benluelo Date: Sat, 21 Sep 2024 18:34:36 +0100 Subject: [PATCH] feat(voyager): split out voyager-core --- Cargo.lock | 16 ++ Cargo.toml | 3 + generated/rust/aptos-move-ibc/Cargo.toml | 10 +- lib/ics-008-wasm-client/Cargo.toml | 2 +- lib/unionlabs/Cargo.toml | 2 +- lib/voyager-core/Cargo.toml | 26 ++ lib/voyager-core/src/lib.rs | 272 ++++++++++++++++++ lib/voyager-message/Cargo.toml | 1 + lib/voyager-message/src/call.rs | 9 +- lib/voyager-message/src/callback.rs | 6 +- lib/voyager-message/src/context.rs | 13 +- lib/voyager-message/src/data.rs | 66 +---- lib/voyager-message/src/lib.rs | 249 ++-------------- lib/voyager-message/src/module.rs | 36 +-- lib/voyager-message/src/rpc.rs | 5 +- lib/voyager-message/src/rpc/server.rs | 21 +- tools/move-bindgen/Cargo.toml | 30 +- voyager/modules/chain/cosmos-sdk/src/main.rs | 9 +- voyager/modules/chain/ethereum/src/main.rs | 6 +- voyager/modules/chain/movement/Cargo.toml | 60 ++-- voyager/modules/chain/movement/src/main.rs | 6 +- voyager/modules/client/cometbls/src/main.rs | 10 +- voyager/modules/client/ethereum/src/main.rs | 13 +- voyager/modules/client/movement/Cargo.toml | 36 +-- voyager/modules/client/movement/src/main.rs | 13 +- .../consensus/cometbls/src/callback.rs | 3 +- .../modules/consensus/cometbls/src/main.rs | 4 +- .../modules/consensus/ethereum/src/main.rs | 4 +- voyager/modules/consensus/movement/Cargo.toml | 8 +- .../modules/consensus/movement/src/main.rs | 16 +- voyager/modules/transaction/aptos/Cargo.toml | 42 +-- voyager/modules/transaction/aptos/src/main.rs | 3 +- .../transaction/cosmos-sdk/src/main.rs | 3 +- .../modules/transaction/ethereum/src/main.rs | 3 +- .../plugins/transaction-batch/src/callback.rs | 4 +- voyager/plugins/transaction-batch/src/main.rs | 5 +- voyager/src/cli.rs | 2 +- voyager/src/cli/handshake.rs | 2 +- voyager/src/main.rs | 3 +- 39 files changed, 540 insertions(+), 482 deletions(-) create mode 100644 lib/voyager-core/Cargo.toml create mode 100644 lib/voyager-core/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 719bb766de..47da42c4c3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13728,6 +13728,21 @@ dependencies = [ "voyager-message", ] +[[package]] +name = "voyager-core" +version = "0.1.0" +dependencies = [ + "enumorph", + "hex", + "hex-literal", + "macros", + "serde", + "serde_json", + "thiserror", + "tracing", + "unionlabs", +] + [[package]] name = "voyager-message" version = "0.1.0" @@ -13772,6 +13787,7 @@ dependencies = [ "tracing-subscriber 0.3.18", "typenum", "unionlabs", + "voyager-core", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index f192ae6687..473810c9b8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,6 +43,7 @@ members = [ "lib/unionlabs", "lib/zktrie-rs", "lib/voyager-message", + "lib/voyager-core", "lib/near/near-ibc", "lib/near/near-light-client", @@ -99,6 +100,7 @@ members = [ "lib/aptos-verifier", "lib/reconnecting-jsonrpc-ws-client", + "lib/voyager-core", ] [workspace.package] @@ -156,6 +158,7 @@ tendermint-verifier = { path = "lib/tendermint-verifier", default-fea token-factory-api = { path = "cosmwasm/token-factory-api", default-features = false } ucs01-relay-api = { path = "cosmwasm/ucs01-relay-api", default-features = false } unionlabs = { path = "lib/unionlabs", default-features = false } +voyager-core = { path = "lib/voyager-core", default-features = false } voyager-message = { path = "lib/voyager-message", default-features = false } zktrie = { path = "lib/zktrie-rs", default-features = false } diff --git a/generated/rust/aptos-move-ibc/Cargo.toml b/generated/rust/aptos-move-ibc/Cargo.toml index 91b9c6a183..fe89ae7697 100644 --- a/generated/rust/aptos-move-ibc/Cargo.toml +++ b/generated/rust/aptos-move-ibc/Cargo.toml @@ -1,9 +1,9 @@ [package] -edition.workspace = true -license-file.workspace = true -name = "aptos-move-ibc" -repository.workspace = true -version = "0.1.0" +edition = { workspace = true } +license-file = { workspace = true } +name = "aptos-move-ibc" +repository = { workspace = true } +version = "0.1.0" [dependencies] move-bindgen = { workspace = true } diff --git a/lib/ics-008-wasm-client/Cargo.toml b/lib/ics-008-wasm-client/Cargo.toml index a0ccf018fc..477823eff8 100644 --- a/lib/ics-008-wasm-client/Cargo.toml +++ b/lib/ics-008-wasm-client/Cargo.toml @@ -13,7 +13,7 @@ workspace = true cosmwasm-std = { workspace = true } dlmalloc = { workspace = true, features = ["global"] } frame-support-procedural = { workspace = true } -macros.workspace = true +macros = { workspace = true } prost = { workspace = true } protos = { workspace = true, features = ["proto_full", "std"] } serde = { workspace = true, features = ["derive"] } diff --git a/lib/unionlabs/Cargo.toml b/lib/unionlabs/Cargo.toml index 4028b2e104..db306c105c 100644 --- a/lib/unionlabs/Cargo.toml +++ b/lib/unionlabs/Cargo.toml @@ -52,7 +52,7 @@ typenum = { workspace = true, features = ["const-generics", "no uint = "*" wasmparser = { version = "0.113" } -base64.workspace = true +base64 = { workspace = true } bcs = { workspace = true } borsh = { workspace = true, features = ["borsh-derive"], optional = true } bs58 = "0.4" diff --git a/lib/voyager-core/Cargo.toml b/lib/voyager-core/Cargo.toml new file mode 100644 index 0000000000..6262951867 --- /dev/null +++ b/lib/voyager-core/Cargo.toml @@ -0,0 +1,26 @@ +[package] +edition = { workspace = true } +license-file = { workspace = true } +name = "voyager-core" +repository = { workspace = true } +resolver = "2" +version = "0.1.0" + +[lints] +workspace = true + +[dependencies] +enumorph = { workspace = true } +hex = { workspace = true } +macros = { workspace = true } +serde = { workspace = true, features = ["derive"] } +serde_json = { workspace = true } +thiserror = { workspace = true } +tracing = { workspace = true } +unionlabs = { workspace = true } + +[dev-dependencies] +hex-literal = { workspace = true } + +[features] +default = [] diff --git a/lib/voyager-core/src/lib.rs b/lib/voyager-core/src/lib.rs new file mode 100644 index 0000000000..2fb709dee2 --- /dev/null +++ b/lib/voyager-core/src/lib.rs @@ -0,0 +1,272 @@ +#![warn(clippy::pedantic)] + +use macros::{apply, model}; +use serde_json::Value; +use unionlabs::{hash::H256, ibc::core::client::height::Height}; + +/// Represents the IBC interface of a chain. +/// +/// Since multiple chains with different consensus mechanisms can have the same +/// execution environment, this value is used to describe how the IBC state is +/// stored on-chain and how the IBC stack is to be interacted with. +#[apply(str_newtype)] +pub struct IbcInterface; + +/// Well-known IBC interfaces, defined as constants for reusability and to allow +/// for pattern matching. +impl IbcInterface<'static> { + /// Native light clients in ibc-go, through the client v1 router. This + /// entrypoint uses protobuf [`Any`] wrapping to route to the correct + /// module, such as "/ibc.lightclients.tendermint.v1.ClientState" for native + /// 07-tendermint clients. + /// + /// [`Any`]: https://protobuf.dev/programming-guides/proto3/#any + pub const IBC_GO_V8_NATIVE: &'static str = "ibc-go-v8/native"; + + /// 08-wasm light clients in ibc-go, through the client v1 router. Similar + /// to the ibc-go-v8/native entrypoint, this module also uses [`Any`] + /// wrapping for client routing, however, there is another level of + /// indirection, since the `Any` routing only routes to the wasm module. All + /// state for wasm clients is [wrapped](wasm-protos), with the internal + /// state being opaque bytes to be interpreted by the light client. + /// + /// [`Any`]: https://protobuf.dev/programming-guides/proto3/#any + /// [wasm-protos]: https://github.com/cosmos/ibc-go/blob/release/v8.4.x/proto/ibc/lightclients/wasm/v1/wasm.proto + pub const IBC_GO_V8_08_WASM: &'static str = "ibc-go-v8/08-wasm"; + + /// Solidity light clients, run via Union's IBC solidity stack. This stack + /// is fully virtualized in the EVM, and as such can be run on any chain + /// running the EVM as part of their execution layer (ethereum, ethereum + /// L2s, berachain, etc). + pub const IBC_SOLIDITY: &'static str = "ibc-solidity"; + + pub const IBC_MOVE_APTOS: &'static str = "ibc-move/aptos"; + + // lots more to come - near, fuel - stay tuned +} + +/// Newtype for client types. Clients of the same type have the same client +/// state, consensus state, and header (client update) types. +#[apply(str_newtype)] +pub struct ClientType; + +/// Well-known client types, defined as constants for reusability and to allow +/// for pattern matching. +impl ClientType<'static> { + /// A client tracking [CometBLS] consensus. + /// + /// [CometBLS]: https://github.com/unionlabs/cometbls + pub const COMETBLS: &'static str = "cometbls"; + + /// A client tracking vanilla [CometBFT] (Tendermint) consensus. + /// + /// [CometBFT]: https://github.com/cometbft/cometbft + pub const TENDERMINT: &'static str = "tendermint"; + + /// A client tracking the Ethereum beacon chain consensus, with the mainnet + /// configuration. + pub const ETHEREUM_MAINNET: &'static str = "ethereum-mainnet"; + + /// A client tracking the Ethereum beacon chain consensus, with the minimal + /// configuration. + pub const ETHEREUM_MINIMAL: &'static str = "ethereum-minimal"; + + /// A client tracking the state of the [Scroll] zkevm L2, settling on + /// Ethereum. + /// + /// [Scroll]: https://github.com/scroll-tech/scroll + pub const SCROLL: &'static str = "scroll"; + + /// A client tracking the state of the [Arbitrum] optimistic L2, settling on + /// Ethereum. + /// + /// [Arbitrum]: https://github.com/OffchainLabs/nitro-contracts + pub const ARBITRUM: &'static str = "arbitrum"; + + /// A client tracking the state of a [BeaconKit] chain. + /// + /// [BeaconKit]: https://github.com/berachain/beacon-kit + pub const BEACON_KIT: &'static str = "beacon-kit"; + + /// A client tracking the state of a [Movement] chain. + /// + /// [Movement]: https://github.com/movementlabsxyz/movement + pub const MOVEMENT: &'static str = "movement"; + + // lots more to come - near, linea, polygon - stay tuned +} + +/// Identifier used to uniquely identify a chain, as provided by the chain +/// itself. +/// +/// # Examples +/// +/// | chain id | chain | +/// | --------------- | ------------------------ | +/// | 1 | ethereum mainnet | +/// | 11155111 | ethereum sepolia testnet | +/// | union-testnet-8 | union testnet | +/// | stargaze-1 | stargaze mainnet | +#[apply(str_newtype)] +pub struct ChainId; + +/// The type of a light client on a chain, along with the IBC interface it's on +/// (and any associated metadata). +/// +/// # Examples +/// +/// - 08-wasm client on union, tracking ethereum mainnet: `(ibc-go-v8/08-wasm, +/// ethereum_mainnet, {"checksum": "0x..."})` +/// - 07-tendermint client on stargaze, tracking osmosis: `(ibc-go-v8/native, +/// tendermint)` +/// - 08-wasm client on babylon, tracking union: `(ibc-go-v8/08-wasm, cometbls, +/// {"checksum": "0x..."}))` +/// - cometbls client on scroll, tracking union: `(ibc-solidity, cometbls)` +#[model] +pub struct ClientInfo { + pub client_type: ClientType<'static>, + pub ibc_interface: IbcInterface<'static>, + /// Additional metadata about this client. + /// + /// This is currently only used for threading the checksum for ibc-go + /// 08-wasm clients, and can likely be removed when support for that IBC + /// interface is dropped. + #[serde(default)] + pub metadata: Value, +} + +#[model] +pub struct ClientStateMeta { + /// The counterparty height this client has been updated to. A consensus + /// state will exist at this height. + pub height: Height, + + /// The chain id of the counterparty chain this client tracks. + pub chain_id: ChainId<'static>, +} + +#[model] +pub struct ConsensusStateMeta { + /// The timestamp of the counterparty at the height represented by this + /// consensus state. + pub timestamp_nanos: u64, +} + +#[model] +pub struct IbcGo08WasmClientMetadata { + pub checksum: H256, +} + +#[macro_export] +macro_rules! str_newtype { + ( + $(#[doc = $doc:literal])+ + $vis:vis struct $Struct:ident; + ) => { + $(#[doc = $doc])+ + #[derive(macros::Debug, Clone, PartialEq, Eq, Hash, ::serde::Serialize, ::serde::Deserialize)] + // I tested this and apparently it's not required (newtype is automatically transparent?) but + // keeping it here for clarity + #[serde(transparent)] + #[debug("{}({:?})", stringify!($Struct), self.0)] + $vis struct $Struct<'a>(#[doc(hidden)] ::std::borrow::Cow<'a, str>); + + impl<'a> ::core::fmt::Display for $Struct<'a> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + ::core::fmt::Display::fmt(&self.0, f) + } + } + + #[allow(unused)] + impl<'a> $Struct<'a> { + /// Construct a new [` + #[doc = stringify!($Struct)] + /// `]. + /// + /// This will capture the lifetime of the passed in value: + /// ``` + #[doc = concat!( + "let _: ", + stringify!($Struct), + "<'static> = ", + stringify!($Struct), + "::new(\"static string\");" + )] + /// let owned_string: String = "owned string".into(); + /// + /// // not static + #[doc = concat!( + "let _: ", + stringify!($Struct), + "<'_> = ", + stringify!($Struct), + "::new(&owned_string);" + )] + #[doc = concat!( + "let _: ", + stringify!($Struct), + "<'static> = ", + stringify!($Struct), + "::new(owned_string);" + )] + pub fn new(s: impl Into<::std::borrow::Cow<'a, str>>) -> Self { + Self(s.into()) + } + + /// Convert this [` + #[doc = concat!(stringify!($Struct))] + /// `] into an owned version of itself. + /// + /// This will allocate if the contained value is not already on the heap even if `'a == 'static`. + #[must_use = concat!("converting to an owned version of ", stringify!($Struct), " has no effect other than possibly allocating, if the returned value is not needed then the call to this method can be removed altogether and the value dropped directly")] + pub fn into_owned(self) -> $Struct<'static> { + use std::borrow::Cow; + + $Struct(match self.0 { + Cow::Borrowed(x) => Cow::Owned(x.to_owned()), + Cow::Owned(x) => Cow::Owned(x), + }) + } + + /// Extracts a string slice containing the entire contained value. + #[must_use = "getting a reference to the contained string slice has no effect"] + pub fn as_str(&self) -> &str { + self.0.as_ref() + } + + + /// Borrow this [` + #[doc = stringify!($Struct)] + /// `], returning a new owned value pointing to the same data. + /// + /// ``` + #[doc = concat!("let t = ", stringify!($Struct), "::new_static(\"static\");")] + /// + /// takes_ownership(t.borrow()); + /// takes_ownership(t); + /// + #[doc = concat!("fn takes_ownership<'a>(c: ", stringify!($Struct), "<'a>) {}")] + /// ``` + #[must_use = "borrowing the inner value has no effect"] + pub fn borrow<'b>(&'a self) -> $Struct<'b> + where + 'a: 'b, + { + use std::borrow::Cow; + + match self.0 { + Cow::Borrowed(s) => Self(Cow::Borrowed(s)), + Cow::Owned(ref s) => Self(Cow::Borrowed(s.as_str())), + } + } + } + + impl $Struct<'static> { + /// `const`-friendly version of [`Self::new`]. + #[must_use = concat!("constructing a ", stringify!($Struct), " has no effect")] + pub const fn new_static(ibc_interface: &'static str) -> Self { + Self(::std::borrow::Cow::Borrowed(ibc_interface)) + } + } + }; +} diff --git a/lib/voyager-message/Cargo.toml b/lib/voyager-message/Cargo.toml index e39da5b554..fe3990006b 100644 --- a/lib/voyager-message/Cargo.toml +++ b/lib/voyager-message/Cargo.toml @@ -49,6 +49,7 @@ tracing = { workspace = true } tracing-subscriber = { workspace = true, features = ["json"] } typenum = { workspace = true } unionlabs = { workspace = true, features = ["ethabi"] } +voyager-core = { workspace = true } [dev-dependencies] hex-literal = { workspace = true } diff --git a/lib/voyager-message/src/call.rs b/lib/voyager-message/src/call.rs index 3ea6f79511..d27af3e615 100644 --- a/lib/voyager-message/src/call.rs +++ b/lib/voyager-message/src/call.rs @@ -31,17 +31,17 @@ use unionlabs::{ }; #[cfg(doc)] -use crate::data::ClientInfo; +use crate::core::ClientInfo; use crate::{ callback::AggregateFetchBlockRange, + core::{ChainId, IbcInterface}, data::{IbcMessage, LatestHeight, MsgCreateClientData, WithChainId}, error_object_to_queue_error, json_rpc_error_to_queue_error, module::{ ChainModuleClient, ClientModuleClient, ConsensusModuleClient, QueueInteractionsClient, }, rpc::json_rpc_error_to_rpc_error, - top_level_identifiable_enum, ChainId, Context, IbcInterface, PluginMessage, VoyagerMessage, - FATAL_JSONRPC_ERROR_CODE, + top_level_identifiable_enum, Context, PluginMessage, VoyagerMessage, FATAL_JSONRPC_ERROR_CODE, }; #[apply(top_level_identifiable_enum)] @@ -238,7 +238,8 @@ pub struct WaitForTimestamp { pub timestamp: i64, } -/// Wait for the client `.client_id` on `.chain_id` to trust a height >= `.height`. +/// Wait for the client `.client_id` on `.chain_id` to trust a height >= +/// `.height`. #[model] pub struct WaitForTrustedHeight { pub chain_id: ChainId<'static>, diff --git a/lib/voyager-message/src/callback.rs b/lib/voyager-message/src/callback.rs index 15753ac9ba..5d4106b23b 100644 --- a/lib/voyager-message/src/callback.rs +++ b/lib/voyager-message/src/callback.rs @@ -14,13 +14,15 @@ use unionlabs::{ id::ClientId, traits::Member, }; +use voyager_core::ClientInfo; use crate::{ call::FetchBlockRange, - data::{ClientInfo, Data, LatestHeight, OrderedHeaders, OrderedMsgUpdateClients}, + core::ChainId, + data::{Data, LatestHeight, OrderedHeaders, OrderedMsgUpdateClients}, error_object_to_queue_error, json_rpc_error_to_queue_error, module::{ClientModuleClient, QueueInteractionsClient}, - top_level_identifiable_enum, ChainId, Context, PluginMessage, VoyagerMessage, + top_level_identifiable_enum, Context, PluginMessage, VoyagerMessage, }; #[apply(top_level_identifiable_enum)] diff --git a/lib/voyager-message/src/context.rs b/lib/voyager-message/src/context.rs index eec73f8e5d..b63abeea3c 100644 --- a/lib/voyager-message/src/context.rs +++ b/lib/voyager-message/src/context.rs @@ -14,13 +14,14 @@ use tracing::{debug, debug_span, error, info, instrument, warn, Instrument}; use unionlabs::{ethereum::keccak256, traits::Member, ErrorReporter}; use crate::{ + core::{ChainId, ClientType, IbcInterface}, module::{ ChainModuleClient, ChainModuleInfo, ClientModuleClient, ClientModuleInfo, ConsensusModuleClient, ConsensusModuleInfo, ModuleInfo, ModuleKindInfo, PluginModuleInfo, QueueInteractionsClient, }, rpc::{server::Server, VoyagerRpcServer}, - ChainId, ClientType, IbcInterface, FATAL_JSONRPC_ERROR_CODE, + FATAL_JSONRPC_ERROR_CODE, }; pub const INVALID_CONFIG_EXIT_CODE: u8 = 13; @@ -69,8 +70,8 @@ impl ModuleRpcClient { let socket = Self::make_socket_path(name); let client = reconnecting_jsonrpc_ws_client::Client::new({ - // NOTE: This needs to be leaked because the return type of the .build() method below - // captures the lifetime of the `name` parameter(?) + // NOTE: This needs to be leaked because the return type of the .build() method + // below captures the lifetime of the `name` parameter(?) let socket: &'static str = Box::leak(socket.clone().into_boxed_str()); let name = name.to_owned(); move || { @@ -576,12 +577,12 @@ impl From for ErrorObjectOwned { #[derive(Debug, Clone, PartialEq, thiserror::Error)] pub enum ClientModuleNotFound { - #[error("no module loaded for client type `{}`", client_type.0)] + #[error("no module loaded for client type `{}`", client_type)] ClientTypeNotFound { client_type: ClientType<'static> }, #[error( "no module loaded supporting IBC interface `{}` and client type `{}`", - client_type.0, - ibc_interface.0, + client_type, + ibc_interface )] IbcInterfaceNotFound { client_type: ClientType<'static>, diff --git a/lib/voyager-message/src/data.rs b/lib/voyager-message/src/data.rs index b346758e8a..a77778a7be 100644 --- a/lib/voyager-message/src/data.rs +++ b/lib/voyager-message/src/data.rs @@ -32,8 +32,8 @@ use unionlabs::{ }; use crate::{ - module::{ClientStateMeta, ConsensusStateMeta}, - top_level_identifiable_enum, ChainId, ClientType, IbcInterface, PluginMessage, + core::{ChainId, ClientInfo, ClientStateMeta, ClientType, ConsensusStateMeta}, + top_level_identifiable_enum, PluginMessage, }; #[apply(top_level_identifiable_enum)] @@ -46,8 +46,7 @@ pub enum Data { // TODO: Remove this LatestHeight(LatestHeight), - ClientInfo(ClientInfo), - + // ClientInfo(ClientInfo), OrderedHeaders(OrderedHeaders), OrderedMsgUpdateClients(OrderedMsgUpdateClients), @@ -67,9 +66,9 @@ pub struct ChainEvent { /// The chain on the other end of this IBC event. pub counterparty_chain_id: ChainId<'static>, pub tx_hash: H256, - /// The "provable height" of the event. This is the minimum height at which the effect of the - /// IBC action that caused this event is provable in the state root of the chain identified by - /// [`Self::chain_id`]. + /// The "provable height" of the event. This is the minimum height at which + /// the effect of the IBC action that caused this event is provable in + /// the state root of the chain identified by [`Self::chain_id`]. pub provable_height: Height, pub event: FullIbcEvent, } @@ -105,8 +104,9 @@ impl ChainEvent { } } - /// Returns the counterparty client id of this ibc event, if there is a counterparty. - /// This will return `None` for `UpdateClient` and `CreateClient`. + /// Returns the counterparty client id of this ibc event, if there is a + /// counterparty. This will return `None` for `UpdateClient` and + /// `CreateClient`. pub fn counterparty_client_id(&self) -> Option<&ClientId> { match self.event { FullIbcEvent::ConnectionOpenInit(ref event) => Some(&event.counterparty_client_id), @@ -167,8 +167,8 @@ pub enum IbcMessage { } impl IbcMessage { - /// Returns the proof height of the IBC message, if it has one. (ConnectionOpenInit does not - /// contain a proof, for example) + /// Returns the proof height of the IBC message, if it has one. + /// (ConnectionOpenInit does not contain a proof, for example) pub fn proof_height(&self) -> Option { match self { IbcMessage::CreateClient(_) => None, @@ -355,8 +355,8 @@ pub struct ConnectionMetadata { pub connection_id: ConnectionId, } -/// Similar to [`IbcEvent`], but contains more information (counterparty clients, channel version, -/// etc) +/// Similar to [`IbcEvent`], but contains more information (counterparty +/// clients, channel version, etc) #[model] #[derive(Enumorph, SubsetOf)] pub enum FullIbcEvent { @@ -387,43 +387,6 @@ pub struct LatestHeight { pub height: Height, } -/// The type of a light client on a chain, along with the IBC interface it's on -/// (and any associated metadata). -/// -/// # Examples -/// -/// - 08-wasm client on union, tracking ethereum mainnet: `(ibc-go-v8/08-wasm, ethereum_mainnet, -/// {"checksum": "0x..."})` -/// - 07-tendermint client on stargaze, tracking osmosis: `(ibc-go-v8/native, tendermint)` -/// - 08-wasm client on babylon, tracking union: `(ibc-go-v8/08-wasm, cometbls, {"checksum": -/// "0x..."}))` -/// - cometbls client on scroll, tracking union: `(ibc-solidity, cometbls)` -#[model] -pub struct ClientInfo { - pub client_type: ClientType<'static>, - pub ibc_interface: IbcInterface<'static>, - /// Additional metadata about this client. - /// - /// This is currently only used for threading the checksum for ibc-go 08-wasm clients, and can - /// likely be removed when support for that IBC interface is dropped. - #[serde(default)] - pub metadata: Value, -} - -#[model] -pub struct SelfClientState { - #[serde(with = "::serde_utils::hex_string")] - #[debug(wrap = ::serde_utils::fmt::DebugAsHex)] - pub self_client_state: Vec, -} - -#[model] -pub struct SelfConsensusState { - #[serde(with = "::serde_utils::hex_string")] - #[debug(wrap = ::serde_utils::fmt::DebugAsHex)] - pub self_consensus_state: Vec, -} - #[model] pub struct UnfinalizedTrustedClientState { pub height: Height, @@ -454,7 +417,8 @@ pub struct IbcProof { pub struct RawIbcProof { pub path: Path, pub height: Height, - /// The raw proof, encoded as JSON, which will be encoded by the relevant client module. + /// The raw proof, encoded as JSON, which will be encoded by the relevant + /// client module. pub proof: Value, } diff --git a/lib/voyager-message/src/lib.rs b/lib/voyager-message/src/lib.rs index 5ae20ed234..9f24490218 100644 --- a/lib/voyager-message/src/lib.rs +++ b/lib/voyager-message/src/lib.rs @@ -7,10 +7,10 @@ use jsonrpsee::types::{ error::{INVALID_PARAMS_CODE, METHOD_NOT_FOUND_CODE}, ErrorObject, }; -use macros::{apply, model}; +use macros::model; use queue_msg::{aggregation::SubsetOf, QueueError, QueueMessage}; use reth_ipc::client::IpcClientBuilder; -use serde::{de::DeserializeOwned, Deserialize, Serialize}; +use serde::de::DeserializeOwned; use serde_json::Value; use tracing::{debug, debug_span, error, info, trace, Instrument}; use unionlabs::{never::Never, traits::Member, ErrorReporter}; @@ -35,6 +35,7 @@ pub mod rpc; pub use reconnecting_jsonrpc_ws_client; pub use reth_ipc; +pub use voyager_core as core; pub struct VoyagerMessage { #[allow(clippy::type_complexity)] // it's a phantom data bro fight me @@ -50,15 +51,17 @@ impl QueueMessage for VoyagerMessage type Context = Context; } -/// Error code for fatal errors. If a plugin or module responds with this error code, it will be -/// treated as failed and not retried. +/// Error code for fatal errors. If a plugin or module responds with this error +/// code, it will be treated as failed and not retried. pub const FATAL_JSONRPC_ERROR_CODE: i32 = -0xBADBEEF; -/// Convert a [`jsonrpsee::core::client::Error`] to a `queue-msg` [`QueueError`]. +/// Convert a [`jsonrpsee::core::client::Error`] to a `queue-msg` +/// [`QueueError`]. /// -/// All errors are treated as retryable, unless `error` is a `Call` variant and the contained -/// [`ErrorObject`] is deemed to be fatal. See [`error_object_to_queue_error`] for more information -/// on the conversion from [`ErrorObject`] to [`QueueError`]. +/// All errors are treated as retryable, unless `error` is a `Call` variant and +/// the contained [`ErrorObject`] is deemed to be fatal. See +/// [`error_object_to_queue_error`] for more information on the conversion from +/// [`ErrorObject`] to [`QueueError`]. pub fn json_rpc_error_to_queue_error(error: jsonrpsee::core::client::Error) -> QueueError { match error { jsonrpsee::core::client::Error::Call(error) => error_object_to_queue_error(error), @@ -70,13 +73,16 @@ pub fn json_rpc_error_to_queue_error(error: jsonrpsee::core::client::Error) -> Q /// /// Certain error codes are treated as fatal (i.e. not retryable): /// -/// - [`FATAL_JSONRPC_ERROR_CODE`]: Custom error code that can be returned by plugin and modules to -/// denote that a fatal error has occurred, and this message is not retryable. -/// - [`METHOD_NOT_FOUND_CODE`]: The plugin or module does not expose the method that was attempted -/// to be called. This indicates a bug in the plugin or module. -/// - [`INVALID_PARAMS_CODE`]: The custom message sent to the plugin or module could not be -/// deserialized. This could either be due a bug in the plugin or module (JSON serialization not -/// roundtripping correctly) or a message that was manually inserted into the queue via `/msg`. +/// - [`FATAL_JSONRPC_ERROR_CODE`]: Custom error code that can be returned by +/// plugin and modules to denote that a fatal error has occurred, and this +/// message is not retryable. +/// - [`METHOD_NOT_FOUND_CODE`]: The plugin or module does not expose the method +/// that was attempted to be called. This indicates a bug in the plugin or +/// module. +/// - [`INVALID_PARAMS_CODE`]: The custom message sent to the plugin or module +/// could not be deserialized. This could either be due a bug in the plugin or +/// module (JSON serialization not roundtripping correctly) or a message that +/// was manually inserted into the queue via `/msg`. pub fn error_object_to_queue_error(error: ErrorObject<'_>) -> QueueError { if error.code() == FATAL_JSONRPC_ERROR_CODE || error.code() == METHOD_NOT_FOUND_CODE @@ -88,219 +94,10 @@ pub fn error_object_to_queue_error(error: ErrorObject<'_>) -> QueueError { } } -macro_rules! str_newtype { - ( - $(#[doc = $doc:literal])+ - $vis:vis struct $Struct:ident; - ) => { - $(#[doc = $doc])+ - #[derive(macros::Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] - // I tested this and apparently it's not required (newtype is automatically transparent?) but - // keeping it here for clarity - #[serde(transparent)] - #[debug("{}({:?})", stringify!($Struct), self.0)] - $vis struct $Struct<'a>(#[doc(hidden)] ::std::borrow::Cow<'a, str>); - - impl<'a> ::core::fmt::Display for $Struct<'a> { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - ::core::fmt::Display::fmt(&self.0, f) - } - } - - #[allow(unused)] - impl<'a> $Struct<'a> { - /// Construct a new [` - #[doc = stringify!($Struct)] - /// `]. - /// - /// This will capture the lifetime of the passed in value: - /// ``` - #[doc = concat!( - "let _: ", - stringify!($Struct), - "<'static> = ", - stringify!($Struct), - "::new(\"static string\");" - )] - /// let owned_string: String = "owned string".into(); - /// - /// // not static - #[doc = concat!( - "let _: ", - stringify!($Struct), - "<'_> = ", - stringify!($Struct), - "::new(&owned_string);" - )] - #[doc = concat!( - "let _: ", - stringify!($Struct), - "<'static> = ", - stringify!($Struct), - "::new(owned_string);" - )] - pub fn new(s: impl Into<::std::borrow::Cow<'a, str>>) -> Self { - Self(s.into()) - } - - /// Convert this [` - #[doc = concat!(stringify!($Struct))] - /// `] into an owned version of itself. - /// - /// This will allocate if the contained value is not already on the heap even if `'a == 'static`. - pub fn into_owned(self) -> $Struct<'static> { - use std::borrow::Cow; - - $Struct(match self.0 { - Cow::Borrowed(x) => Cow::Owned(x.to_owned()), - Cow::Owned(x) => Cow::Owned(x), - }) - } - - /// Extracts a string slice containing the entire contained value. - pub fn as_str(&self) -> &str { - self.0.as_ref() - } - - - /// Borrow this [` - #[doc = stringify!($Struct)] - /// `], returning a new owned value pointing to the same data. - /// - /// ``` - #[doc = concat!("let t = ", stringify!($Struct), "::new_static(\"static\");")] - /// - /// takes_ownership(t.borrow()); - /// takes_ownership(t); - /// - #[doc = concat!("fn takes_ownership<'a>(c: ", stringify!($Struct), "<'a>) {}")] - /// ``` - pub fn borrow<'b>(&'a self) -> $Struct<'b> - where - 'a: 'b, - { - use std::borrow::Cow; - - match self.0 { - Cow::Borrowed(s) => Self(Cow::Borrowed(s)), - Cow::Owned(ref s) => Self(Cow::Borrowed(s.as_str())), - } - } - } - - /// `const`-friendly version of [`Self::new`]. - #[allow(unused)] - impl $Struct<'static> { - pub const fn new_static(ibc_interface: &'static str) -> Self { - Self(::std::borrow::Cow::Borrowed(ibc_interface)) - } - } - }; -} - -/// Represents the IBC interface of a chain. Since multiple chains with -/// different consensus mechanisms can have the same execution environment, this -/// value is used to describe how the IBC state is stored on-chain and how the -/// IBC stack is to be interacted with. -#[apply(str_newtype)] -pub struct IbcInterface; - -/// Well-known IBC interfaces, defined as constants for reusability and to allow -/// for pattern matching. -impl IbcInterface<'static> { - /// Native light clients in ibc-go, through the client v1 router. This - /// entrypoint uses protobuf [`Any`] wrapping to route to the correct - /// module, such as "/ibc.lightclients.tendermint.v1.ClientState" for native - /// 07-tendermint clients. - /// - /// [`Any`]: https://protobuf.dev/programming-guides/proto3/#any - pub const IBC_GO_V8_NATIVE: &'static str = "ibc-go-v8/native"; - - /// 08-wasm light clients in ibc-go, through the client v1 router. Similar - /// to the ibc-go-v8/native entrypoint, this module also uses [`Any`] - /// wrapping for client routing, however, there is another level of - /// indirection, since the `Any` routing only routes to the wasm module. All - /// state for wasm clients is [wrapped](wasm-protos), with the internal - /// state being opaque bytes to be interpreted by the light client. - /// - /// [`Any`]: https://protobuf.dev/programming-guides/proto3/#any - /// [wasm-protos]: https://github.com/cosmos/ibc-go/blob/release/v8.4.x/proto/ibc/lightclients/wasm/v1/wasm.proto - pub const IBC_GO_V8_08_WASM: &'static str = "ibc-go-v8/08-wasm"; - - /// Solidity light clients, run via Union's IBC solidity stack. This stack - /// is fully virtualized in the EVM, and as such can be run on any chain - /// running the EVM as part of their execution layer (ethereum, ethereum - /// L2s, berachain, etc). - pub const IBC_SOLIDITY: &'static str = "ibc-solidity"; - - pub const IBC_MOVE_APTOS: &'static str = "ibc-move/aptos"; - - // lots more to come - near, fuel - stay tuned -} - -/// Newtype for client types. Clients of the same type have the same client -/// state, consensus state, and header (client update) types. -#[apply(str_newtype)] -pub struct ClientType; - -/// Well-known client types, defined as constants for reusability and to allow -/// for pattern matching. -impl ClientType<'static> { - /// A client tracking CometBLS consensus. - pub const COMETBLS: &'static str = "cometbls"; - - /// A client tracking vanilla Tendermint (CometBFT). - pub const TENDERMINT: &'static str = "tendermint"; - - /// A client tracking the Ethereum beacon chain consensus, with the mainnet - /// configuration. - pub const ETHEREUM_MAINNET: &'static str = "ethereum-mainnet"; - - /// A client tracking the Ethereum beacon chain consensus, with the minimal - /// configuration. - pub const ETHEREUM_MINIMAL: &'static str = "ethereum-minimal"; - - /// A client tracking the state of the [Scroll] zkevm L2, settling on - /// Ethereum. - /// - /// [Scroll]: https://github.com/scroll-tech/scroll - pub const SCROLL: &'static str = "scroll"; - - /// A client tracking the state of the Arbitrum optimistic L2, settling on - /// Ethereum. - /// - /// [Arbitrum]: https://github.com/OffchainLabs/nitro-contracts - pub const ARBITRUM: &'static str = "arbitrum"; - - /// A client tracking the state of a [BeaconKit] chain. - /// - /// [BeaconKit]: https://github.com/berachain/beacon-kit - pub const BEACON_KIT: &'static str = "beacon-kit"; - - /// A client tracking the state of a [Movement] chain. - /// - /// [Movement]: https://github.com/movementlabsxyz/movement - pub const MOVEMENT: &'static str = "movement"; - - // lots more to come - near, linea, polygon - stay tuned -} - -/// Identifier used to uniquely identify a chain, as provided by the chain itself. -/// -/// # Examples -/// -/// | chain id | chain | -/// | --------------- | ------------------------ | -/// | 1 | ethereum mainnet | -/// | 11155111 | ethereum sepolia testnet | -/// | union-testnet-8 | union testnet | -/// | stargaze-1 | stargaze mainnet | -#[apply(str_newtype)] -pub struct ChainId; - /// A message specific to a plugin. /// -/// This is used in [`Call`], [`Callback`], and [`Data`] to route messages to plugins. +/// This is used in [`Call`], [`Callback`], and [`Data`] to route messages to +/// plugins. #[model] pub struct PluginMessage { pub plugin: String, diff --git a/lib/voyager-message/src/module.rs b/lib/voyager-message/src/module.rs index 510a04c175..4df224367a 100644 --- a/lib/voyager-message/src/module.rs +++ b/lib/voyager-message/src/module.rs @@ -8,7 +8,6 @@ use serde_json::{json, Value}; use serde_utils::Hex; use tracing::debug; use unionlabs::{ - hash::H256, ibc::core::client::height::Height, ics24::{IbcPath, Path}, id::ClientId, @@ -16,16 +15,15 @@ use unionlabs::{ ErrorReporter, }; #[cfg(doc)] -// #[cfg_attr(not(doc), allow(unused_imports))] use { crate::{callback::AggregateMsgUpdateClientsFromOrderedHeaders, data::OrderedHeaders}, unionlabs::ibc::core::client::msg_update_client::MsgUpdateClient, }; use crate::{ - data::{ClientInfo, Data}, - ChainId, ClientType, IbcInterface, ModuleContext, ModuleServer, VoyagerMessage, - FATAL_JSONRPC_ERROR_CODE, + core::{ChainId, ClientInfo, ClientStateMeta, ClientType, ConsensusStateMeta, IbcInterface}, + data::Data, + ModuleContext, ModuleServer, VoyagerMessage, FATAL_JSONRPC_ERROR_CODE, }; #[model] @@ -74,9 +72,9 @@ impl IModuleKindInfo for ClientModuleInfo {} #[model] pub struct PluginModuleInfo { /// A jaq filter to run on every message before pushing them to the queue. - /// This ***MUST*** return a bool. If this returns `true`, the message will be - /// pushed to the optimization queue with this plugin's name as the tag, - /// else it will be passed on to the next plugin to be filtered. + /// This ***MUST*** return a bool. If this returns `true`, the message will + /// be pushed to the optimization queue with this plugin's name as the + /// tag, else it will be passed on to the next plugin to be filtered. pub interest_filter: String, } @@ -417,25 +415,3 @@ pub trait ConsensusModule { counterparty_chain_id: ChainId<'static>, ) -> RpcResult>>; } - -#[model] -pub struct ClientStateMeta { - /// The counterparty height this client has been updated to. A consensus - /// state will exist at this height. - pub height: Height, - - /// The chain id of the counterparty chain this client tracks. - pub chain_id: ChainId<'static>, -} - -#[model] -pub struct ConsensusStateMeta { - /// The timestamp of the counterparty at the height represented by this - /// consensus state. - pub timestamp_nanos: u64, -} - -#[model] -pub struct IbcGo08WasmClientMetadata { - pub checksum: H256, -} diff --git a/lib/voyager-message/src/rpc.rs b/lib/voyager-message/src/rpc.rs index 89fbeef57f..a9a46931f7 100644 --- a/lib/voyager-message/src/rpc.rs +++ b/lib/voyager-message/src/rpc.rs @@ -16,7 +16,7 @@ use unionlabs::{ }; use crate::{ - data::ClientInfo, module::ClientStateMeta, ChainId, ClientType, IbcInterface, + core::{ChainId, ClientInfo, ClientStateMeta, ClientType, IbcInterface}, FATAL_JSONRPC_ERROR_CODE, }; @@ -202,7 +202,8 @@ pub fn json_rpc_error_to_rpc_error(value: jsonrpsee::core::client::Error) -> Err } } -/// Some required state was missing (connection/channel end, packet commitment, ..) +/// Some required state was missing (connection/channel end, packet commitment, +/// ..) pub fn missing_state( message: impl Into, data: Option, diff --git a/lib/voyager-message/src/rpc/server.rs b/lib/voyager-message/src/rpc/server.rs index 748cb1cb03..1a8d57685b 100644 --- a/lib/voyager-message/src/rpc/server.rs +++ b/lib/voyager-message/src/rpc/server.rs @@ -17,16 +17,13 @@ use unionlabs::{ use crate::{ context::Modules, - data::ClientInfo, - module::{ - ChainModuleClient, ChainModuleClientExt, ClientModuleClient, ClientStateMeta, - ConsensusModuleClient, - }, + core::{ChainId, ClientInfo, ClientStateMeta, ClientType, IbcInterface}, + module::{ChainModuleClient, ChainModuleClientExt, ClientModuleClient, ConsensusModuleClient}, rpc::{ json_rpc_error_to_rpc_error, IbcProof, IbcState, Info, SelfClientState, SelfConsensusState, VoyagerRpcServer, }, - ChainId, ClientType, IbcInterface, FATAL_JSONRPC_ERROR_CODE, + FATAL_JSONRPC_ERROR_CODE, }; #[derive(Debug, Clone)] @@ -50,8 +47,8 @@ pub struct ServerInner { // } // impl<'a> IbcStateCacheKey<'a> { -// pub fn new(chain_id: ChainId<'a>, path: &'a Path, height: Height) -> Self { -// Self { +// pub fn new(chain_id: ChainId<'a>, path: &'a Path, height: Height) -> Self +// { Self { // chain_id, // path: Cow::Borrowed(path), // height, @@ -60,8 +57,8 @@ pub struct ServerInner { // } // impl IbcStateCacheKey<'static> { -// pub fn new_owned(chain_id: ChainId<'static>, path: Path, height: Height) -> Self { -// Self { +// pub fn new_owned(chain_id: ChainId<'static>, path: Path, height: Height) +// -> Self { Self { // chain_id, // path: Cow::Owned(path), // height, @@ -185,8 +182,8 @@ impl ServerInner { // serde_json::from_value::(state.clone()).map_err(|e| { // ErrorObject::owned( // FATAL_JSONRPC_ERROR_CODE, - // format!("unable to deserialize state: {}", ErrorReporter(e)), - // Some(json!({ + // format!("unable to deserialize state: {}", + // ErrorReporter(e)), Some(json!({ // "path": path, // "state": state // })), diff --git a/tools/move-bindgen/Cargo.toml b/tools/move-bindgen/Cargo.toml index 0b9cdbdf68..ef7176bae0 100644 --- a/tools/move-bindgen/Cargo.toml +++ b/tools/move-bindgen/Cargo.toml @@ -7,21 +7,21 @@ repository = { workspace = true } version = "0.0.0" [dependencies] -aptos-crypto = { workspace = true } -aptos-rest-client = { workspace = true } -aptos-types = { workspace = true } -bcs = { workspace = true } -futures.workspace = true -move-bindgen-derive = { workspace = true } -move-core-types.workspace = true -prettyplease = "0.2.22" -proc-macro2 = "*" -quote = "1.0.35" -serde = { workspace = true, features = ["derive"] } -serde_json = { workspace = true } -syn = { version = "2.0.52", default-features = false, features = ["clone-impls", "parsing", "printing", "proc-macro", "derive", "extra-traits"] } -tokio = { workspace = true, features = ["full"] } -tracing = { workspace = true } +aptos-crypto = { workspace = true } +aptos-rest-client = { workspace = true } +aptos-types = { workspace = true } +bcs = { workspace = true } +futures = { workspace = true } +move-bindgen-derive = { workspace = true } +move-core-types = { workspace = true } +prettyplease = "0.2.22" +proc-macro2 = "*" +quote = "1.0.35" +serde = { workspace = true, features = ["derive"] } +serde_json = { workspace = true } +syn = { version = "2.0.52", default-features = false, features = ["clone-impls", "parsing", "printing", "proc-macro", "derive", "extra-traits"] } +tokio = { workspace = true, features = ["full"] } +tracing = { workspace = true } [lints] workspace = true diff --git a/voyager/modules/chain/cosmos-sdk/src/main.rs b/voyager/modules/chain/cosmos-sdk/src/main.rs index 75c52be2a4..b17266cadf 100644 --- a/voyager/modules/chain/cosmos-sdk/src/main.rs +++ b/voyager/modules/chain/cosmos-sdk/src/main.rs @@ -43,15 +43,14 @@ use unionlabs::{ }; use voyager_message::{ call::Call, - data::{ChainEvent, ChannelMetadata, ClientInfo, ConnectionMetadata, Data, PacketMetadata}, + core::{ChainId, ClientInfo, ClientType, IbcGo08WasmClientMetadata, IbcInterface}, + data::{ChainEvent, ChannelMetadata, ConnectionMetadata, Data, PacketMetadata}, module::{ - ChainModuleInfo, ChainModuleServer, IbcGo08WasmClientMetadata, ModuleInfo, - QueueInteractionsServer, RawClientState, + ChainModuleInfo, ChainModuleServer, ModuleInfo, QueueInteractionsServer, RawClientState, }, reconnecting_jsonrpc_ws_client, rpc::{json_rpc_error_to_rpc_error, missing_state, VoyagerRpcClient, VoyagerRpcClientExt}, - run_module_server, ChainId, ClientType, IbcInterface, ModuleContext, ModuleServer, - VoyagerMessage, FATAL_JSONRPC_ERROR_CODE, + run_module_server, ModuleContext, ModuleServer, VoyagerMessage, FATAL_JSONRPC_ERROR_CODE, }; use crate::{ diff --git a/voyager/modules/chain/ethereum/src/main.rs b/voyager/modules/chain/ethereum/src/main.rs index 9461d22225..e08436cf3c 100644 --- a/voyager/modules/chain/ethereum/src/main.rs +++ b/voyager/modules/chain/ethereum/src/main.rs @@ -36,9 +36,10 @@ use unionlabs::{ }; use voyager_message::{ call::Call, + core::{ChainId, ClientInfo, ClientType, IbcInterface}, data::{ ChainEvent, ChannelMetadata, ChannelOpenAck, ChannelOpenConfirm, ChannelOpenInit, - ChannelOpenTry, ClientInfo, ConnectionMetadata, ConnectionOpenAck, ConnectionOpenConfirm, + ChannelOpenTry, ConnectionMetadata, ConnectionOpenAck, ConnectionOpenConfirm, ConnectionOpenInit, ConnectionOpenTry, CreateClient, Data, PacketMetadata, UpdateClient, }, module::{ @@ -46,8 +47,7 @@ use voyager_message::{ }, reconnecting_jsonrpc_ws_client, rpc::{json_rpc_error_to_rpc_error, missing_state, VoyagerRpcClient, VoyagerRpcClientExt}, - run_module_server, ChainId, ClientType, DefaultCmd, IbcInterface, ModuleContext, ModuleServer, - VoyagerMessage, + run_module_server, DefaultCmd, ModuleContext, ModuleServer, VoyagerMessage, }; use crate::{ diff --git a/voyager/modules/chain/movement/Cargo.toml b/voyager/modules/chain/movement/Cargo.toml index 90c252fd3d..57777dd060 100644 --- a/voyager/modules/chain/movement/Cargo.toml +++ b/voyager/modules/chain/movement/Cargo.toml @@ -4,33 +4,33 @@ name = "voyager-chain-module-movement" version = "0.1.0" [dependencies] -aptos-crypto = { workspace = true } -aptos-move-ibc.workspace = true -aptos-rest-client = { workspace = true } -aptos-types = { workspace = true } -bcs = { workspace = true } -clap = { workspace = true, features = ["derive"] } -enumorph.workspace = true -frunk.workspace = true -futures.workspace = true -hex-literal = { workspace = true } -hex.workspace = true -jsonrpsee = { workspace = true, features = ["macros", "server", "tracing"] } -macros.workspace = true -move-bindgen = { workspace = true } -move-core-types.workspace = true -prost.workspace = true -protos.workspace = true -queue-msg = { workspace = true } -reqwest = { workspace = true, features = ["json"] } -serde = { workspace = true, features = ["derive"] } -serde-utils = { workspace = true } -serde_json = { workspace = true } -sha2.workspace = true -sha3.workspace = true -thiserror = { workspace = true } -tokio = { workspace = true } -tracing = { workspace = true } -tracing-subscriber = { workspace = true } -unionlabs = { workspace = true } -voyager-message = { workspace = true } +aptos-crypto = { workspace = true } +aptos-move-ibc = { workspace = true } +aptos-rest-client = { workspace = true } +aptos-types = { workspace = true } +bcs = { workspace = true } +clap = { workspace = true, features = ["derive"] } +enumorph = { workspace = true } +frunk = { workspace = true } +futures = { workspace = true } +hex = { workspace = true } +hex-literal = { workspace = true } +jsonrpsee = { workspace = true, features = ["macros", "server", "tracing"] } +macros = { workspace = true } +move-bindgen = { workspace = true } +move-core-types = { workspace = true } +prost = { workspace = true } +protos = { workspace = true } +queue-msg = { workspace = true } +reqwest = { workspace = true, features = ["json"] } +serde = { workspace = true, features = ["derive"] } +serde-utils = { workspace = true } +serde_json = { workspace = true } +sha2 = { workspace = true } +sha3 = { workspace = true } +thiserror = { workspace = true } +tokio = { workspace = true } +tracing = { workspace = true } +tracing-subscriber = { workspace = true } +unionlabs = { workspace = true } +voyager-message = { workspace = true } diff --git a/voyager/modules/chain/movement/src/main.rs b/voyager/modules/chain/movement/src/main.rs index 0534e45ea5..bf4f9b84e1 100644 --- a/voyager/modules/chain/movement/src/main.rs +++ b/voyager/modules/chain/movement/src/main.rs @@ -36,9 +36,10 @@ use unionlabs::{ }; use voyager_message::{ call::Call, + core::{ChainId, ClientInfo, ClientType, IbcInterface}, data::{ AcknowledgePacket, ChainEvent, ChannelMetadata, ChannelOpenAck, ChannelOpenConfirm, - ChannelOpenInit, ChannelOpenTry, ClientInfo, ConnectionMetadata, ConnectionOpenAck, + ChannelOpenInit, ChannelOpenTry, ConnectionMetadata, ConnectionOpenAck, ConnectionOpenConfirm, ConnectionOpenInit, ConnectionOpenTry, CreateClient, Data, FullIbcEvent, PacketMetadata, RecvPacket, SendPacket, UpdateClient, WriteAcknowledgement, }, @@ -47,8 +48,7 @@ use voyager_message::{ }, reconnecting_jsonrpc_ws_client, rpc::{json_rpc_error_to_rpc_error, missing_state, VoyagerRpcClient, VoyagerRpcClientExt as _}, - run_module_server, ChainId, ClientType, DefaultCmd, IbcInterface, ModuleContext, ModuleServer, - VoyagerMessage, + run_module_server, DefaultCmd, ModuleContext, ModuleServer, VoyagerMessage, }; use crate::{ diff --git a/voyager/modules/client/cometbls/src/main.rs b/voyager/modules/client/cometbls/src/main.rs index ed342d168a..fdccd196c0 100644 --- a/voyager/modules/client/cometbls/src/main.rs +++ b/voyager/modules/client/cometbls/src/main.rs @@ -21,13 +21,11 @@ use unionlabs::{ ErrorReporter, }; use voyager_message::{ + core::{ChainId, ClientStateMeta, ClientType, ConsensusStateMeta, IbcInterface}, data::Data, - module::{ - ClientModuleInfo, ClientModuleServer, ClientStateMeta, ConsensusStateMeta, ModuleInfo, - QueueInteractionsServer, - }, - run_module_server, ChainId, ClientType, DefaultCmd, IbcInterface, ModuleContext, ModuleServer, - VoyagerMessage, FATAL_JSONRPC_ERROR_CODE, + module::{ClientModuleInfo, ClientModuleServer, ModuleInfo, QueueInteractionsServer}, + run_module_server, DefaultCmd, ModuleContext, ModuleServer, VoyagerMessage, + FATAL_JSONRPC_ERROR_CODE, }; use crate::{call::ModuleCall, callback::ModuleCallback, data::ModuleData}; diff --git a/voyager/modules/client/ethereum/src/main.rs b/voyager/modules/client/ethereum/src/main.rs index c83386db58..05194062eb 100644 --- a/voyager/modules/client/ethereum/src/main.rs +++ b/voyager/modules/client/ethereum/src/main.rs @@ -26,13 +26,14 @@ use unionlabs::{ ErrorReporter, }; use voyager_message::{ - data::Data, - module::{ - ClientModuleInfo, ClientModuleServer, ClientStateMeta, ConsensusStateMeta, - IbcGo08WasmClientMetadata, ModuleInfo, QueueInteractionsServer, + core::{ + ChainId, ClientStateMeta, ClientType, ConsensusStateMeta, IbcGo08WasmClientMetadata, + IbcInterface, }, - run_module_server, ChainId, ClientType, DefaultCmd, IbcInterface, ModuleContext, ModuleServer, - VoyagerMessage, FATAL_JSONRPC_ERROR_CODE, + data::Data, + module::{ClientModuleInfo, ClientModuleServer, ModuleInfo, QueueInteractionsServer}, + run_module_server, DefaultCmd, ModuleContext, ModuleServer, VoyagerMessage, + FATAL_JSONRPC_ERROR_CODE, }; use crate::{call::ModuleCall, callback::ModuleCallback, data::ModuleData}; diff --git a/voyager/modules/client/movement/Cargo.toml b/voyager/modules/client/movement/Cargo.toml index cc94b35a49..60d2d5e0ed 100644 --- a/voyager/modules/client/movement/Cargo.toml +++ b/voyager/modules/client/movement/Cargo.toml @@ -4,21 +4,21 @@ name = "voyager-client-module-movement" version = "0.1.0" [dependencies] -chain-utils = { workspace = true } -enumorph.workspace = true -frunk.workspace = true -futures.workspace = true -jsonrpsee = { workspace = true, features = ["macros", "server", "tracing"] } -macros.workspace = true -prost.workspace = true -protos.workspace = true -queue-msg = { workspace = true } -serde = { workspace = true, features = ["derive"] } -serde-utils.workspace = true -serde_json = { workspace = true } -thiserror = { workspace = true } -tokio = { workspace = true } -tracing = { workspace = true } -tracing-subscriber = { workspace = true } -unionlabs = { workspace = true } -voyager-message = { workspace = true } +chain-utils = { workspace = true } +enumorph = { workspace = true } +frunk = { workspace = true } +futures = { workspace = true } +jsonrpsee = { workspace = true, features = ["macros", "server", "tracing"] } +macros = { workspace = true } +prost = { workspace = true } +protos = { workspace = true } +queue-msg = { workspace = true } +serde = { workspace = true, features = ["derive"] } +serde-utils = { workspace = true } +serde_json = { workspace = true } +thiserror = { workspace = true } +tokio = { workspace = true } +tracing = { workspace = true } +tracing-subscriber = { workspace = true } +unionlabs = { workspace = true } +voyager-message = { workspace = true } diff --git a/voyager/modules/client/movement/src/main.rs b/voyager/modules/client/movement/src/main.rs index a9aef8bb28..40f90af1fe 100644 --- a/voyager/modules/client/movement/src/main.rs +++ b/voyager/modules/client/movement/src/main.rs @@ -26,13 +26,14 @@ use unionlabs::{ ErrorReporter, }; use voyager_message::{ - data::Data, - module::{ - ClientModuleInfo, ClientModuleServer, ClientStateMeta, ConsensusStateMeta, - IbcGo08WasmClientMetadata, ModuleInfo, QueueInteractionsServer, + core::{ + ChainId, ClientStateMeta, ClientType, ConsensusStateMeta, IbcGo08WasmClientMetadata, + IbcInterface, }, - run_module_server, ChainId, ClientType, DefaultCmd, IbcInterface, ModuleContext, ModuleServer, - VoyagerMessage, FATAL_JSONRPC_ERROR_CODE, + data::Data, + module::{ClientModuleInfo, ClientModuleServer, ModuleInfo, QueueInteractionsServer}, + run_module_server, DefaultCmd, ModuleContext, ModuleServer, VoyagerMessage, + FATAL_JSONRPC_ERROR_CODE, }; use crate::{call::ModuleCall, callback::ModuleCallback, data::ModuleData}; diff --git a/voyager/modules/consensus/cometbls/src/callback.rs b/voyager/modules/consensus/cometbls/src/callback.rs index af6f01168d..6cf31598cc 100644 --- a/voyager/modules/consensus/cometbls/src/callback.rs +++ b/voyager/modules/consensus/cometbls/src/callback.rs @@ -25,8 +25,9 @@ use unionlabs::{ use voyager_message::{ call::Call, callback::Callback, + core::ChainId, data::{DecodedHeaderMeta, OrderedHeaders}, - ChainId, PluginMessage, VoyagerMessage, + PluginMessage, VoyagerMessage, }; use crate::{ diff --git a/voyager/modules/consensus/cometbls/src/main.rs b/voyager/modules/consensus/cometbls/src/main.rs index 0947a02339..d6b5301895 100644 --- a/voyager/modules/consensus/cometbls/src/main.rs +++ b/voyager/modules/consensus/cometbls/src/main.rs @@ -24,10 +24,10 @@ use unionlabs::{ use voyager_message::{ call::{Call, WaitForHeight}, callback::Callback, + core::{ChainId, ClientType}, data::Data, module::{ConsensusModuleInfo, ConsensusModuleServer, ModuleInfo, QueueInteractionsServer}, - run_module_server, ChainId, ClientType, DefaultCmd, ModuleContext, ModuleServer, - VoyagerMessage, + run_module_server, DefaultCmd, ModuleContext, ModuleServer, VoyagerMessage, }; use crate::{ diff --git a/voyager/modules/consensus/ethereum/src/main.rs b/voyager/modules/consensus/ethereum/src/main.rs index 44765c2628..7dc291d319 100644 --- a/voyager/modules/consensus/ethereum/src/main.rs +++ b/voyager/modules/consensus/ethereum/src/main.rs @@ -32,10 +32,10 @@ use unionlabs::{ }; use voyager_message::{ call::{Call, FetchUpdateHeaders, WaitForTimestamp}, + core::{ChainId, ClientType}, data::{Data, DecodedHeaderMeta, OrderedHeaders}, module::{ConsensusModuleInfo, ConsensusModuleServer, ModuleInfo, QueueInteractionsServer}, - run_module_server, ChainId, ClientType, DefaultCmd, ModuleContext, ModuleServer, - VoyagerMessage, + run_module_server, DefaultCmd, ModuleContext, ModuleServer, VoyagerMessage, }; use crate::{ diff --git a/voyager/modules/consensus/movement/Cargo.toml b/voyager/modules/consensus/movement/Cargo.toml index 0c288ea8ce..b6150f1f30 100644 --- a/voyager/modules/consensus/movement/Cargo.toml +++ b/voyager/modules/consensus/movement/Cargo.toml @@ -8,12 +8,12 @@ aptos-rest-client = { workspace = true } aptos-types = { workspace = true } move-core-types = { workspace = true } -bitvec.workspace = true +bitvec = { workspace = true } chain-utils = { workspace = true } -enumorph.workspace = true +enumorph = { workspace = true } ethers = { workspace = true, features = ["rustls", "ws"] } -frunk.workspace = true -futures.workspace = true +frunk = { workspace = true } +futures = { workspace = true } jsonrpsee = { workspace = true, features = ["macros", "server", "tracing"] } macros = { workspace = true } num-bigint = { workspace = true } diff --git a/voyager/modules/consensus/movement/src/main.rs b/voyager/modules/consensus/movement/src/main.rs index 297f98adc2..b831c3535e 100644 --- a/voyager/modules/consensus/movement/src/main.rs +++ b/voyager/modules/consensus/movement/src/main.rs @@ -2,12 +2,11 @@ use std::collections::VecDeque; use aptos_rest_client::error::RestError; use call::FetchUpdate; -use ethers::providers::{Middleware, Provider, ProviderError, Ws, WsClientError}; use jsonrpsee::core::{async_trait, RpcResult}; -use queue_msg::{aggregation::do_callback, call, data, defer, now, promise, seq, Op}; +use queue_msg::{call, data, Op}; use serde::{Deserialize, Serialize}; use serde_json::Value; -use tracing::{instrument, warn}; +use tracing::instrument; use unionlabs::{ aptos::{ account::AccountAddress, state_proof::StateProof, @@ -26,13 +25,10 @@ use unionlabs::{ }; use voyager_message::{ call::Call, + core::{ChainId, ClientType}, data::{Data, DecodedHeaderMeta, OrderedHeaders}, - module::{ - ConsensusModuleInfo, ConsensusModuleServer, ModuleInfo, PluginModuleServer, - QueueInteractionsServer, - }, - run_module_server, ChainId, ClientType, DefaultCmd, ModuleContext, ModuleServer, - VoyagerMessage, + module::{ConsensusModuleInfo, ConsensusModuleServer, ModuleInfo, QueueInteractionsServer}, + run_module_server, DefaultCmd, ModuleContext, ModuleServer, VoyagerMessage, }; use crate::{call::ModuleCall, callback::ModuleCallback, data::ModuleData}; @@ -155,7 +151,7 @@ impl QueueInteractionsServer for ModuleS match msg { ModuleCall::FetchUpdate(FetchUpdate { from, to }) => { let state_proof: StateProofResponse = client - .get(&format!( + .get(format!( "{}/movement/v1/state-proof/{}", self.ctx.movement_rest_url, from )) diff --git a/voyager/modules/transaction/aptos/Cargo.toml b/voyager/modules/transaction/aptos/Cargo.toml index 98444e38c5..a3d3fc476b 100644 --- a/voyager/modules/transaction/aptos/Cargo.toml +++ b/voyager/modules/transaction/aptos/Cargo.toml @@ -9,24 +9,24 @@ aptos-rest-client = { workspace = true } aptos-types = { workspace = true } move-core-types = { workspace = true } -aptos-move-ibc.workspace = true -bcs = { workspace = true } -bip32 = { workspace = true } -chain-utils = { workspace = true } -enumorph = { workspace = true } -frunk = { workspace = true } -futures = { workspace = true } -jsonrpsee = { workspace = true, features = ["macros", "server", "tracing"] } -macros = { workspace = true } -move-bindgen = { workspace = true } -queue-msg = { workspace = true } -serde = { workspace = true, features = ["derive"] } -serde-utils = { workspace = true } -serde_json = { workspace = true } -sha3 = { workspace = true } -thiserror = { workspace = true } -tokio = { workspace = true } -tracing = { workspace = true } -tracing-subscriber = { workspace = true } -unionlabs = { workspace = true } -voyager-message = { workspace = true } +aptos-move-ibc = { workspace = true } +bcs = { workspace = true } +bip32 = { workspace = true } +chain-utils = { workspace = true } +enumorph = { workspace = true } +frunk = { workspace = true } +futures = { workspace = true } +jsonrpsee = { workspace = true, features = ["macros", "server", "tracing"] } +macros = { workspace = true } +move-bindgen = { workspace = true } +queue-msg = { workspace = true } +serde = { workspace = true, features = ["derive"] } +serde-utils = { workspace = true } +serde_json = { workspace = true } +sha3 = { workspace = true } +thiserror = { workspace = true } +tokio = { workspace = true } +tracing = { workspace = true } +tracing-subscriber = { workspace = true } +unionlabs = { workspace = true } +voyager-message = { workspace = true } diff --git a/voyager/modules/transaction/aptos/src/main.rs b/voyager/modules/transaction/aptos/src/main.rs index f10e94fcbc..6bebef4abf 100644 --- a/voyager/modules/transaction/aptos/src/main.rs +++ b/voyager/modules/transaction/aptos/src/main.rs @@ -18,9 +18,10 @@ use tracing::instrument; use unionlabs::hash::H256; use voyager_message::{ call::Call, + core::ChainId, data::{log_msg, Data, IbcMessage, WithChainId}, module::{ModuleInfo, PluginModuleInfo, PluginModuleServer, QueueInteractionsServer}, - run_module_server, ChainId, DefaultCmd, ModuleContext, ModuleServer, VoyagerMessage, + run_module_server, DefaultCmd, ModuleContext, ModuleServer, VoyagerMessage, }; use crate::{call::ModuleCall, callback::ModuleCallback, data::ModuleData}; diff --git a/voyager/modules/transaction/cosmos-sdk/src/main.rs b/voyager/modules/transaction/cosmos-sdk/src/main.rs index 622dd28de6..8fb18c7721 100644 --- a/voyager/modules/transaction/cosmos-sdk/src/main.rs +++ b/voyager/modules/transaction/cosmos-sdk/src/main.rs @@ -37,9 +37,10 @@ use unionlabs::{ }; use voyager_message::{ call::Call, + core::ChainId, data::{Data, IbcMessage, WithChainId}, module::{ModuleInfo, PluginModuleInfo, PluginModuleServer, QueueInteractionsServer}, - run_module_server, ChainId, DefaultCmd, ModuleContext, ModuleServer, VoyagerMessage, + run_module_server, DefaultCmd, ModuleContext, ModuleServer, VoyagerMessage, FATAL_JSONRPC_ERROR_CODE, }; diff --git a/voyager/modules/transaction/ethereum/src/main.rs b/voyager/modules/transaction/ethereum/src/main.rs index 5fbe20f943..ec14e8dff9 100644 --- a/voyager/modules/transaction/ethereum/src/main.rs +++ b/voyager/modules/transaction/ethereum/src/main.rs @@ -41,9 +41,10 @@ use unionlabs::{ }; use voyager_message::{ call::Call, + core::ChainId, data::{log_msg, Data, IbcMessage, MsgCreateClientData, WithChainId}, module::{ModuleInfo, PluginModuleInfo, PluginModuleServer, QueueInteractionsServer}, - run_module_server, ChainId, DefaultCmd, ModuleContext, ModuleServer, VoyagerMessage, + run_module_server, DefaultCmd, ModuleContext, ModuleServer, VoyagerMessage, }; use crate::{call::ModuleCall, callback::ModuleCallback, data::ModuleData}; diff --git a/voyager/plugins/transaction-batch/src/callback.rs b/voyager/plugins/transaction-batch/src/callback.rs index 96a6272d30..19d00e1c68 100644 --- a/voyager/plugins/transaction-batch/src/callback.rs +++ b/voyager/plugins/transaction-batch/src/callback.rs @@ -16,10 +16,10 @@ use voyager_message::{ MakeMsgConnectionOpenTry, MakeMsgRecvPacket, WaitForTrustedHeight, }, callback::Callback, + core::{ChainId, ClientStateMeta}, data::{Data, IbcMessage, OrderedMsgUpdateClients, WithChainId}, - module::ClientStateMeta, rpc::{json_rpc_error_to_rpc_error, VoyagerRpcClient}, - ChainId, ModuleServer, VoyagerMessage, + ModuleServer, VoyagerMessage, }; use crate::{ diff --git a/voyager/plugins/transaction-batch/src/main.rs b/voyager/plugins/transaction-batch/src/main.rs index d37463eee6..2d0768d3c0 100644 --- a/voyager/plugins/transaction-batch/src/main.rs +++ b/voyager/plugins/transaction-batch/src/main.rs @@ -22,11 +22,12 @@ use unionlabs::{id::ClientId, QueryHeight}; use voyager_message::{ call::{Call, FetchUpdateHeaders, WaitForHeight}, callback::{AggregateMsgUpdateClientsFromOrderedHeaders, Callback}, + core::ChainId, data::{ChainEvent, Data, FullIbcEvent}, module::{ModuleInfo, PluginModuleInfo, PluginModuleServer, QueueInteractionsServer}, rpc::{json_rpc_error_to_rpc_error, VoyagerRpcClient}, - run_module_server, ChainId, DefaultCmd, ModuleContext, ModuleServer, PluginMessage, - VoyagerMessage, FATAL_JSONRPC_ERROR_CODE, + run_module_server, DefaultCmd, ModuleContext, ModuleServer, PluginMessage, VoyagerMessage, + FATAL_JSONRPC_ERROR_CODE, }; use crate::{ diff --git a/voyager/src/cli.rs b/voyager/src/cli.rs index 887ccbad94..c37a825a8e 100644 --- a/voyager/src/cli.rs +++ b/voyager/src/cli.rs @@ -10,7 +10,7 @@ use unionlabs::{ uint::U256, QueryHeight, }; -use voyager_message::ChainId; +use voyager_message::core::ChainId; use crate::cli::handshake::HandshakeCmd; diff --git a/voyager/src/cli/handshake.rs b/voyager/src/cli/handshake.rs index 107b1623bf..f103cc3293 100644 --- a/voyager/src/cli/handshake.rs +++ b/voyager/src/cli/handshake.rs @@ -8,7 +8,7 @@ use unionlabs::{ ibc::core::channel, id::{ClientId, ConnectionId, PortId}, }; -use voyager_message::ChainId; +use voyager_message::core::ChainId; #[derive(Debug)] pub struct HandshakeCmd { diff --git a/voyager/src/main.rs b/voyager/src/main.rs index d0d31ebcc0..29e0699b5a 100644 --- a/voyager/src/main.rs +++ b/voyager/src/main.rs @@ -25,7 +25,8 @@ use tikv_jemallocator::Jemalloc; use tracing_subscriber::EnvFilter; use unionlabs::{ethereum::ibc_commitment_key, ics24}; use voyager_message::{ - call::FetchBlock, context::get_module_info, module::ChainModuleClient, ChainId, VoyagerMessage, + call::FetchBlock, context::get_module_info, core::ChainId, module::ChainModuleClient, + VoyagerMessage, }; #[global_allocator]