Skip to content

Commit

Permalink
chore(voyager): make client-update for state lenses generic (#3461)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeryz authored Jan 9, 2025
2 parents 2be2cda + fdc287c commit 2b32162
Show file tree
Hide file tree
Showing 16 changed files with 169 additions and 508 deletions.
52 changes: 14 additions & 38 deletions Cargo.lock

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

6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ members = [
"voyager/plugins/client-update/ethereum",
"voyager/plugins/client-update/movement",
"voyager/plugins/client-update/tendermint",
"voyager/plugins/client-update/state-lens/evm",
"voyager/plugins/client-update/state-lens/ics23-ics23",
"voyager/plugins/client-update/state-lens",

"voyager/plugins/periodic-client-update",

Expand Down Expand Up @@ -172,6 +171,7 @@ members = [

"lib/ibc-union-spec",
"lib/ibc-classic-spec",
"lib/state-lens-light-client-types",
]

[workspace.package]
Expand Down Expand Up @@ -200,6 +200,8 @@ chain-utils = { path = "lib/chain-utils", default-features = false }
cometbft-rpc = { path = "lib/cometbft-rpc", default-features = false }
cometbft-types = { path = "lib/cometbft-types", default-features = false }

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

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

Expand Down
23 changes: 23 additions & 0 deletions lib/state-lens-light-client-types/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
edition.workspace = true
license-file.workspace = true
name = "state-lens-light-client-types"
repository.workspace = true
version = "0.1.0"

[dependencies]
alloy = { workspace = true, features = ["sol-types"], optional = true }
bincode = { workspace = true, features = ["alloc", "derive"], optional = true }
protos = { workspace = true, optional = true, features = ["proto_full", "serde"] }
serde = { workspace = true, optional = true, features = ["derive"] }
thiserror = { workspace = true }
unionlabs = { workspace = true, features = ["ethabi", "proto"] }

[features]
bincode = ["dep:bincode", "unionlabs/bincode"]
default = []
ethabi = ["unionlabs/ethabi", "dep:alloy", "dep:protos"]
serde = ["dep:serde"]

[lints]
workspace = true
52 changes: 52 additions & 0 deletions lib/state-lens-light-client-types/src/header.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
use unionlabs::{ibc::core::client::height::Height, primitives::Bytes};

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "bincode", derive(bincode::Encode, bincode::Decode))]
pub struct Header {
pub l1_height: Height,
pub l2_height: Height,
/// Proof of the L2 consensus state as stored in the state of the L1.
pub l2_consensus_state_proof: Bytes,
pub l2_consensus_state: Bytes,
}

#[cfg(feature = "ethabi")]
pub mod ethabi {
use alloy::sol_types::SolValue;
use unionlabs::{
encoding::{Encode, EthAbi},
impl_ethabi_via_try_from_into,
union::ics23,
};

use crate::Header;

impl_ethabi_via_try_from_into!(Header => SolHeader);

impl Encode<EthAbi> for Header {
fn encode(self) -> Vec<u8> {
Into::<SolHeader>::into(self).abi_encode_params()
}
}

alloy::sol! {
struct SolHeader {
uint64 l1Height;
uint64 l2Height;
bytes l2InclusionProof;
bytes l2ConsensusState;
}
}

impl From<Header> for SolHeader {
fn from(value: Header) -> Self {
Self {
l1Height: value.l1_height.height(),
l2Height: value.l2_height.height(),
l2InclusionProof: value.l2_consensus_state_proof.into(),
l2ConsensusState: value.l2_consensus_state.into(),
}
}
}
}
3 changes: 3 additions & 0 deletions lib/state-lens-light-client-types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod header;

pub use header::Header;
22 changes: 22 additions & 0 deletions voyager/plugins/client-update/state-lens/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
edition = "2021"
name = "voyager-client-update-plugin-state-lens"
version = "0.1.0"

[dependencies]
alloy = { workspace = true, features = ["rpc", "rpc-types", "transports", "transport-http", "transport-ws", "reqwest", "provider-ws"] }
enumorph = { workspace = true }
ibc-union-spec = { workspace = true }
ics23 = { workspace = true }
jsonrpsee = { workspace = true, features = ["macros", "server", "tracing"] }
macros = { workspace = true }
protos = { workspace = true }
serde = { workspace = true, features = ["derive"] }
serde_json = { workspace = true }
state-lens-light-client-types = { workspace = true, features = ["serde"] }
tokio = { workspace = true }
tracing = { workspace = true }
tracing-subscriber = { workspace = true }
unionlabs = { workspace = true }
voyager-message = { workspace = true }
voyager-vm = { workspace = true }
29 changes: 0 additions & 29 deletions voyager/plugins/client-update/state-lens/evm/Cargo.toml

This file was deleted.

Loading

0 comments on commit 2b32162

Please sign in to comment.