Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cleanup and remove unused code #3350

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 60 additions & 60 deletions hubble/src/indexer/tendermint/create_client_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,17 @@ pub fn schedule_create_client_checker(
let client_type = parse_wasm_client_type(wasm_blob).unwrap();

let counterparty_chain_id = match client_type.unwrap() {
WasmClientType::Ethereum => {
let cs = match ethereum_light_client_types::ClientState::decode_as::<Bincode>(&cs.data) {
Ok(cs) => cs,
// We changed the format of berachain client states, but union-testnet-8 still contains an old configuration which we need to ignore.
Err(err) => {
warn!("error while decoding client {client_id}: {:?}. Most likely due to a client state upgrade. This can then be safely ignored", err);
continue;
}
};
cs.chain_id.to_string()
}
// WasmClientType::Ethereum => {
// let cs = match ethereum_light_client_types::ClientState::decode_as::<Bincode>(&cs.data) {
// Ok(cs) => cs,
// // We changed the format of berachain client states, but union-testnet-8 still contains an old configuration which we need to ignore.
// Err(err) => {
// warn!("error while decoding client {client_id}: {:?}. Most likely due to a client state upgrade. This can then be safely ignored", err);
// continue;
// }
// };
// cs.chain_id.to_string()
// }
WasmClientType::Cometbls => {
let cs = match cometbls_light_client_types::ClientState::decode_as::<Bincode>(&cs.data) {
Ok(cs) => cs,
Expand All @@ -109,55 +109,55 @@ pub fn schedule_create_client_checker(

cs.chain_id
}
WasmClientType::Scroll => {
let cs = match scroll_light_client_types::ClientState::decode_as::<Bincode>(&cs.data) {
Ok(cs) => cs,
Err(err) => {
warn!("error while decoding client {client_id}: {:?}. Most likely due to a client state upgrade. This can then be safely ignored", err);
continue
}
};

cs.chain_id.to_string()
}
WasmClientType::Arbitrum => {
let cs = match arbitrum_light_client_types::ClientState::decode_as::<Bincode>(&cs.data) {
Ok(cs) => cs,
Err(err) => {
warn!("error while decoding client {client_id}: {:?}. Most likely due to a client state upgrade. This can then be safely ignored", err);
continue
}
};

cs.chain_id.to_string()
}
WasmClientType::Linea => todo!("We still need to add linea"),
WasmClientType::Berachain => {
let cs = match berachain_light_client_types::ClientState::decode_as::<Bincode>(&cs.data) {
Ok(cs) => cs,
// We changed the format of berachain client states, but union-testnet-8 still contains an old configuration which we need to ignore.
Err(err) => {
warn!("error while decoding client {client_id}: {:?}. Most likely due to a client state upgrade. This can then be safely ignored", err);
continue;
}
};

cs.execution_chain_id.to_string()
}
WasmClientType::EvmInCosmos => {
todo!("We still need to add evm-in-cosmos")
}
WasmClientType::Movement => {
let cs = match movement_light_client_types::ClientState::decode_as::<Bincode>(&cs.data) {
Ok(cs) => cs,
Err(err) => {
warn!("error while decoding client {client_id}: {:?}. Most likely due to a client state upgrade. This can then be safely ignored", err);
continue;
}
};

cs.chain_id.to_string()
}
// WasmClientType::Scroll => {
// let cs = match scroll_light_client_types::ClientState::decode_as::<Bincode>(&cs.data) {
// Ok(cs) => cs,
// Err(err) => {
// warn!("error while decoding client {client_id}: {:?}. Most likely due to a client state upgrade. This can then be safely ignored", err);
// continue
// }
// };

// cs.chain_id.to_string()
// }
// WasmClientType::Arbitrum => {
// let cs = match arbitrum_light_client_types::ClientState::decode_as::<Bincode>(&cs.data) {
// Ok(cs) => cs,
// Err(err) => {
// warn!("error while decoding client {client_id}: {:?}. Most likely due to a client state upgrade. This can then be safely ignored", err);
// continue
// }
// };

// cs.chain_id.to_string()
// }
// WasmClientType::Linea => todo!("We still need to add linea"),
// WasmClientType::Berachain => {
// let cs = match berachain_light_client_types::ClientState::decode_as::<Bincode>(&cs.data) {
// Ok(cs) => cs,
// // We changed the format of berachain client states, but union-testnet-8 still contains an old configuration which we need to ignore.
// Err(err) => {
// warn!("error while decoding client {client_id}: {:?}. Most likely due to a client state upgrade. This can then be safely ignored", err);
// continue;
// }
// };

// cs.execution_chain_id.to_string()
// }
// WasmClientType::EvmInCosmos => {
// todo!("We still need to add evm-in-cosmos")
// }
// WasmClientType::Movement => {
// let cs = match movement_light_client_types::ClientState::decode_as::<Bincode>(&cs.data) {
// Ok(cs) => cs,
// Err(err) => {
// warn!("error while decoding client {client_id}: {:?}. Most likely due to a client state upgrade. This can then be safely ignored", err);
// continue;
// }
// };

// cs.chain_id.to_string()
// }
};

info!("{}: add mapping {} => {} (ibc.lightclients.wasm.v1.ClientState)", internal_chain_id, client_id, counterparty_chain_id);
Expand Down
20 changes: 1 addition & 19 deletions lib/chain-utils/src/cosmos_sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use unionlabs::{
id::{ClientId, ConnectionId},
parse_wasm_client_type,
signer::CosmosSigner,
ErrorReporter, MaybeRecoverableError, WasmClientType,
ErrorReporter, WasmClientType,
};

use crate::{
Expand Down Expand Up @@ -531,24 +531,6 @@ pub enum BroadcastTxCommitError {
OutOfGas,
}

impl MaybeRecoverableError for BroadcastTxCommitError {
fn is_recoverable(&self) -> bool {
match self {
// tx wasn't included, retry unconditionally
Self::Inclusion(_) => true,
Self::Tx(code) => matches!(
code,
CosmosSdkError::SdkError(SdkError::ErrTxInMempoolCache)
| CosmosSdkError::SdkError(SdkError::ErrMempoolIsFull)
| CosmosSdkError::SdkError(SdkError::ErrTxTimeoutHeight)
| CosmosSdkError::SdkError(SdkError::ErrWrongSequence)
),
Self::SimulateTx(_) => false,
_ => false,
}
}
}

#[allow(non_upper_case_globals)] // TODO: Report this upstream to num_enum
pub mod cosmos_sdk_error {
macro_rules! cosmos_sdk_errors {
Expand Down
1 change: 0 additions & 1 deletion lib/unionlabs/src/cometbls/types.rs

This file was deleted.

1 change: 0 additions & 1 deletion lib/unionlabs/src/cometbls/types/canonical_vote.rs

This file was deleted.

1 change: 0 additions & 1 deletion lib/unionlabs/src/cosmwasm/mod.rs

This file was deleted.

1 change: 0 additions & 1 deletion lib/unionlabs/src/cosmwasm/wasm/mod.rs

This file was deleted.

29 changes: 0 additions & 29 deletions lib/unionlabs/src/cosmwasm/wasm/msg_execute_contract.rs

This file was deleted.

35 changes: 1 addition & 34 deletions lib/unionlabs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,12 @@ pub const DELAY_PERIOD: u64 = 0;
/// Wrapper types around protos defined in <https://github.com/cosmos/gogoproto/tree/main/protobuf/google/protobuf>, matching the proto module structure.
pub mod google;

pub mod cosmwasm;

#[cfg(feature = "near")]
pub mod near;

/// Defines types that wrap the IBC specification, matching the proto module structure. This also includes `union` extensions to ibc (i.e. types defined in `union.ibc`).
pub mod ibc;

/// Defines types that are extended from tendermint in cometbls
pub mod cometbls;

/// Defines types that wrap the cosmos specification, matching the proto module structure.
pub mod cosmos;

Expand Down Expand Up @@ -73,6 +68,7 @@ pub mod bounded;

pub mod constants;

// TODO: Remove (only used in ucs01-relay-api currently)
pub mod validated;

pub mod bytes;
Expand Down Expand Up @@ -170,16 +166,8 @@ macro_rules! export_wasm_client_type {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum WasmClientType {
Ethereum,
Cometbls,
Tendermint,
Scroll,
Arbitrum,
Linea,
// TODO: Rename to beacon-kit
Berachain,
EvmInCosmos,
Movement,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -208,15 +196,8 @@ impl FromStr for WasmClientType {

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"Ethereum" => Ok(WasmClientType::Ethereum),
"Cometbls" => Ok(WasmClientType::Cometbls),
"Tendermint" => Ok(WasmClientType::Tendermint),
"Scroll" => Ok(WasmClientType::Scroll),
"Arbitrum" => Ok(WasmClientType::Arbitrum),
"Linea" => Ok(WasmClientType::Linea),
"Berachain" => Ok(WasmClientType::Berachain),
"EvmInCosmos" => Ok(WasmClientType::EvmInCosmos),
"Movement" => Ok(WasmClientType::Movement),
_ => Err(WasmClientTypeParseError::UnknownType(s.to_string())),
}
}
Expand All @@ -225,15 +206,8 @@ impl FromStr for WasmClientType {
impl Display for WasmClientType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Ethereum => write!(f, "Ethereum"),
Self::Cometbls => write!(f, "Cometbls"),
Self::Tendermint => write!(f, "Tendermint"),
Self::Scroll => write!(f, "Scroll"),
Self::Arbitrum => write!(f, "Arbitrum"),
Self::Linea => write!(f, "Linea"),
Self::Berachain => write!(f, "Berachain"),
Self::EvmInCosmos => write!(f, "EvmInCosmos"),
Self::Movement => write!(f, "Movement"),
}
}
}
Expand Down Expand Up @@ -267,13 +241,6 @@ pub fn parse_wasm_client_type(
.transpose()
}

// TODO: remove this as it is unused
pub trait MaybeRecoverableError: core::error::Error {
fn is_recoverable(&self) -> bool;
}

fn _is_object_safe(_: &dyn MaybeRecoverableError) {}

pub fn ensure<E>(expr: bool, err: E) -> Result<(), E> {
expr.then_some(()).ok_or(err)
}
Expand Down
Loading
Loading