diff --git a/Cargo.lock b/Cargo.lock index 140e9f7..0668773 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -452,7 +452,7 @@ dependencies = [ [[package]] name = "ethereum-consensus" version = "0.1.0" -source = "git+https://github.com/datachainlab/ethereum-light-client-rs?rev=186c5b1d9935f15428ca8b209ad99ed20eaf81c6#186c5b1d9935f15428ca8b209ad99ed20eaf81c6" +source = "git+https://github.com/datachainlab/ethereum-light-client-rs?rev=v0.1.3#edc099170b44afee83508ffa1c951b32361e4d4f" dependencies = [ "displaydoc", "hex", @@ -480,7 +480,7 @@ dependencies = [ [[package]] name = "ethereum-ibc" version = "0.1.0" -source = "git+https://github.com/datachainlab/ethereum-ibc-rs?rev=v0.0.12#50790b532a0abb8d2310c03ff24c217ba27e103d" +source = "git+https://github.com/datachainlab/ethereum-ibc-rs?rev=v0.0.14#27719dd36f9971bc4a7d09c1059b454e3ce2a073" dependencies = [ "bytes", "displaydoc", @@ -500,7 +500,7 @@ dependencies = [ [[package]] name = "ethereum-ibc-proto" version = "0.1.0" -source = "git+https://github.com/datachainlab/ethereum-ibc-rs?rev=v0.0.12#50790b532a0abb8d2310c03ff24c217ba27e103d" +source = "git+https://github.com/datachainlab/ethereum-ibc-rs?rev=v0.0.14#27719dd36f9971bc4a7d09c1059b454e3ce2a073" dependencies = [ "prost", "serde", @@ -509,11 +509,10 @@ dependencies = [ [[package]] name = "ethereum-light-client-verifier" version = "0.1.0" -source = "git+https://github.com/datachainlab/ethereum-light-client-rs?rev=186c5b1d9935f15428ca8b209ad99ed20eaf81c6#186c5b1d9935f15428ca8b209ad99ed20eaf81c6" +source = "git+https://github.com/datachainlab/ethereum-light-client-rs?rev=v0.1.3#edc099170b44afee83508ffa1c951b32361e4d4f" dependencies = [ "displaydoc", "ethereum-consensus", - "log", "patricia-merkle-trie", "primitive-types", "rlp", diff --git a/Cargo.toml b/Cargo.toml index bdb9762..0e5a14a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,4 +10,4 @@ displaydoc = { version = "0.2", default-features = false } tiny-keccak = { version = "1.4" } light-client = { git = "https://github.com/datachainlab/lcp", rev = "v0.2.11", default-features = false, features = ["ibc"] } -ethereum-ibc = { git = "https://github.com/datachainlab/ethereum-ibc-rs", rev = "v0.0.12", default-features = false } +ethereum-ibc = { git = "https://github.com/datachainlab/ethereum-ibc-rs", rev = "v0.0.14", default-features = false } diff --git a/src/client.rs b/src/client.rs index f9c4736..d4ee1c0 100644 --- a/src/client.rs +++ b/src/client.rs @@ -30,14 +30,9 @@ use light_client::{ }; use tiny_keccak::Keccak; -pub struct EthereumLightClient< - const SYNC_COMMITTEE_SIZE: usize, - const EXECUTION_PAYLOAD_TREE_DEPTH: usize, ->; - -impl LightClient - for EthereumLightClient -{ +pub struct EthereumLightClient; + +impl LightClient for EthereumLightClient { fn client_type(&self) -> String { eth_client_type().as_str().into() } @@ -47,7 +42,7 @@ impl Result { - let client_state: ClientState = + let client_state: ClientState = ctx.client_state(client_id)?.try_into()?; Ok(client_state.latest_height().into()) } @@ -58,10 +53,7 @@ impl Result { - let client_state = - ClientState::::try_from( - any_client_state.clone(), - )?; + let client_state = ClientState::::try_from(any_client_state.clone())?; let consensus_state = ConsensusState::try_from(any_consensus_state)?; let _ = client_state .initialise(consensus_state.0.clone().into()) @@ -181,9 +173,7 @@ impl - EthereumLightClient -{ +impl EthereumLightClient { fn validate_args( ctx: &dyn HostClientReader, client_id: ClientId, @@ -193,7 +183,7 @@ impl, ) -> Result< ( - ClientState, + ClientState, ConsensusState, CommitmentPrefix, Path, @@ -201,7 +191,7 @@ impl { - let client_state: ClientState = + let client_state: ClientState = ctx.client_state(&client_id)?.try_into()?; if client_state.is_frozen() { @@ -227,7 +217,7 @@ impl, ) -> Result { - let client_state: ClientState = + let client_state: ClientState = ctx.client_state(&client_id)?.try_into()?; if client_state.is_frozen() { @@ -260,7 +250,7 @@ impl, + EthereumClientState, EthereumConsensusState, >::new(ctx), client_id.into(), @@ -273,9 +263,9 @@ impl, - >(new_client_state.as_ref()) + downcast_client_state::>( + new_client_state.as_ref(), + ) .unwrap() .clone(), ); @@ -316,7 +306,7 @@ impl, ) -> Result { - let client_state: ClientState = + let client_state: ClientState = ctx.client_state(&client_id)?.try_into()?; if client_state.is_frozen() { @@ -337,10 +327,10 @@ impl, - EthereumConsensusState, - >::new(ctx); + let ibc_ctx = + IBCContext::, EthereumConsensusState>::new( + ctx, + ); let new_client_state = client_state .check_misbehaviour_and_update_state( @@ -354,9 +344,9 @@ impl, - >(new_client_state.as_ref()) + downcast_client_state::>( + new_client_state.as_ref(), + ) .unwrap() .clone(), ); @@ -412,7 +402,7 @@ impl, + client_state: &ClientState, heights: Vec, ) -> Result, light_client::Error> { let mut prev_states = Vec::new(); diff --git a/src/lib.rs b/src/lib.rs index 363ff8c..f0a5a10 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,6 @@ use client::EthereumLightClient; use ethereum_ibc::client_state::ETHEREUM_CLIENT_STATE_TYPE_URL; -use ethereum_ibc::consensus::{bellatrix, deneb}; use light_client::LightClientRegistry; extern crate alloc; @@ -24,34 +23,13 @@ mod internal_prelude { } use internal_prelude::*; -pub fn register_implementations< - const SYNC_COMMITTEE_SIZE: usize, - const EXECUTION_PAYLOAD_TREE_DEPTH: usize, ->( +pub fn register_implementations( registry: &mut dyn LightClientRegistry, ) { registry .put_light_client( ETHEREUM_CLIENT_STATE_TYPE_URL.to_string(), - Box::new(EthereumLightClient::), + Box::new(EthereumLightClient::), ) .unwrap() } - -/// Register the light client implementations for the bellatrix and capella testnets -pub fn register_bellatrix_implementations( - registry: &mut dyn LightClientRegistry, -) { - register_implementations::( - registry, - ); -} - -/// Register the light client implementations for the deneb testnet -pub fn register_deneb_implementations( - registry: &mut dyn LightClientRegistry, -) { - register_implementations::( - registry, - ); -} diff --git a/src/state.rs b/src/state.rs index bf08c85..facf90e 100644 --- a/src/state.rs +++ b/src/state.rs @@ -11,23 +11,19 @@ use light_client::types::proto::google::protobuf::Any as IBCAny; use light_client::types::Any; #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)] -pub struct ClientState( - pub(crate) EthereumClientState, +pub struct ClientState( + pub(crate) EthereumClientState, ); -impl Deref - for ClientState -{ - type Target = EthereumClientState; +impl Deref for ClientState { + type Target = EthereumClientState; fn deref(&self) -> &Self::Target { &self.0 } } -impl TryFrom - for ClientState -{ +impl TryFrom for ClientState { type Error = Error; fn try_from(value: Any) -> Result { @@ -42,10 +38,8 @@ impl - From> for Any -{ - fn from(value: ClientState) -> Self { +impl From> for Any { + fn from(value: ClientState) -> Self { IBCAny::from(value.0).into() } } @@ -84,12 +78,9 @@ impl From for Any { // canonicalize_client_state canonicalizes some fields of specified client state // target fields: latest_slot, latest_execution_block_number, frozen_height -pub fn canonicalize_client_state< - const SYNC_COMMITTEE_SIZE: usize, - const EXECUTION_PAYLOAD_TREE_DEPTH: usize, ->( - client_state: ClientState, -) -> ClientState { +pub fn canonicalize_client_state( + client_state: ClientState, +) -> ClientState { let mut client_state = client_state.0; client_state.latest_slot = 0u64.into(); client_state.latest_execution_block_number = 0u64.into(); @@ -105,8 +96,8 @@ pub fn canonicalize_consensus_state(consensus_state: ConsensusState) -> Consensu ConsensusState(consensus_state) } -pub fn gen_state_id( - client_state: ClientState, +pub fn gen_state_id( + client_state: ClientState, consensus_state: ConsensusState, ) -> Result { Ok(gen_state_id_from_any(