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

Migrate from tendermint-rs to cometbft-rs #3865

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft
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
660 changes: 349 additions & 311 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,4 @@ exclude = [
overflow-checks = true

[patch.crates-io]
# tendermint = { git = "https://github.com/informalsystems/tendermint-rs.git", branch = "main" }
# tendermint-rpc = { git = "https://github.com/informalsystems/tendermint-rs.git", branch = "main" }
# tendermint-proto = { git = "https://github.com/informalsystems/tendermint-rs.git", branch = "main" }
# tendermint-light-client = { git = "https://github.com/informalsystems/tendermint-rs.git", branch = "main" }
# tendermint-light-client-verifier = { git = "https://github.com/informalsystems/tendermint-rs.git", branch = "main" }
# tendermint-light-client-detector = { git = "https://github.com/informalsystems/tendermint-rs.git", branch = "main" }
# tendermint-testgen = { git = "https://github.com/informalsystems/tendermint-rs.git", branch = "main" }
ibc-proto = { git = "https://github.com/cosmos/ibc-proto-rs.git", branch = "migrate-cometbft" }
2 changes: 1 addition & 1 deletion crates/chain-registry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ description = """
[dependencies]
ibc-relayer-types = { version = "0.27.0", path = "../relayer-types" }
ibc-proto = { version = "0.42.0", features = ["serde"] }
tendermint-rpc = { version = "0.34.0", features = ["http-client", "websocket-client"] }
cometbft-rpc = { version = "0.1.0-alpha.2", features = ["http-client", "websocket-client"] }

async-trait = "0.1.72"
flex-error = { version = "0.4.4", default-features = false }
Expand Down
6 changes: 3 additions & 3 deletions crates/chain-registry/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub struct Codebase {
pub compatible_versions: Vec<String>,
pub binaries: Binaries,
pub cosmos_sdk_version: String,
pub tendermint_version: String,
pub cometbft_version: String,
pub cosmwasm_version: String,
pub cosmwasm_enabled: bool,
}
Expand Down Expand Up @@ -233,7 +233,7 @@ mod tests {
"windows/amd64": "test"
},
"cosmos_sdk_version": "0.45",
"tendermint_version": "0.34",
"cometbft_version": "0.34",
"cosmwasm_version": "0.24",
"cosmwasm_enabled": true
},
Expand Down Expand Up @@ -301,7 +301,7 @@ mod tests {
assert_eq!(chain_data.codebase.binaries.darwin_amd64, "test");
assert_eq!(chain_data.codebase.binaries.windows_amd64, "test");
assert_eq!(chain_data.codebase.cosmos_sdk_version, "0.45");
assert_eq!(chain_data.codebase.tendermint_version, "0.34");
assert_eq!(chain_data.codebase.cometbft_version, "0.34");
assert_eq!(chain_data.codebase.cosmwasm_version, "0.24");
assert_eq!(chain_data.codebase.cosmwasm_enabled, true);
assert_eq!(chain_data.peers.seeds[0].id, "test");
Expand Down
20 changes: 10 additions & 10 deletions crates/chain-registry/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use cometbft_rpc;
use flex_error::{define_error, TraceError};
use http;
use itertools::Itertools;
use reqwest;
use serde_json;
use std::path::PathBuf;
use tendermint_rpc;
use tokio::task::JoinError;
use tokio::time::error::Elapsed;

Expand Down Expand Up @@ -49,17 +49,17 @@ define_error! {

RpcConnectError
{ rpc: String }
[ TraceError<tendermint_rpc::Error> ]
[ TraceError<cometbft_rpc::Error> ]
|e| { format_args!("Error when connecting to RPC: {}", e.rpc) },

RpcConsensusParamsError
{ rpc: String }
[ TraceError<tendermint_rpc::Error> ]
[ TraceError<cometbft_rpc::Error> ]
|e| { format_args!("Unable to fetch consensus params for RPC: {}", e.rpc) },

RpcStatusError
{ rpc: String }
[ TraceError<tendermint_rpc::Error> ]
[ TraceError<cometbft_rpc::Error> ]
|e| { format_args!("Unable to fetch status for RPC: {}", e.rpc) },

RpcUrlWithoutAuthority
Expand Down Expand Up @@ -90,14 +90,14 @@ define_error! {
[ TraceError<http::Error> ]
|e| { format_args!("Error when parsing URL: {}", e.url) },

TendermintUrlParseError
CometbftUrlParseError
{ url: String }
[ TraceError<tendermint_rpc::Error> ]
[ TraceError<cometbft_rpc::Error> ]
|e| { format_args!("Error when parsing URL: {}", e.url) },

WebsocketUrlParseError
{ url: String }
[ TraceError<tendermint_rpc::Error> ]
[ TraceError<cometbft_rpc::Error> ]
|e| { format_args!("Error when parsing URL: {}", e.url) },

StatusError
Expand All @@ -114,12 +114,12 @@ define_error! {

WebsocketConnectError
{ url: String }
[ TraceError<tendermint_rpc::Error> ]
[ TraceError<cometbft_rpc::Error> ]
|e| { format_args!("Unable to connect to WebSocket: {}", e.url) },

WebsocketConnCloseError
{ url: String }
[ TraceError<tendermint_rpc::Error> ]
[ TraceError<cometbft_rpc::Error> ]
|e| { format_args!("Unable to close WebSocket connection: {}", e.url) },

WebsocketTimeOutError
Expand All @@ -129,7 +129,7 @@ define_error! {

WebsocketDriverError
{ url: String }
[ TraceError<tendermint_rpc::Error> ]
[ TraceError<cometbft_rpc::Error> ]
|e| { format_args!("Unable to close WebSocket driver: {}", e.url) },
}
}
8 changes: 4 additions & 4 deletions crates/chain-registry/src/formatter.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! Contains traits to format the URL of API endpoints from a `&str` to any type.
//! Contains struct to build a `tendermint_rpc::Url` representing a
//! Contains struct to build a `cometbft_rpc::Url` representing a
//! WebSocket URL from a RPC URL and to parse or build a valid `http::Uri`
//! from an (in)complete GRPC URL.
use crate::error::RegistryError;
use http::uri::Scheme;
use http::Uri;
use std::str::FromStr;

use tendermint_rpc::Url;
use cometbft_rpc::Url;

/// `UriFormatter` contains the basic expectations to parse a valid URL from a `&str`.
pub trait UriFormatter {
Expand All @@ -33,7 +33,7 @@ pub struct SimpleGrpcFormatter;
impl UriFormatter for SimpleWebSocketFormatter {
type OutputFormat = Url;

/// Format a WebSocket URL from an RPC URL and return a `tendermint_rpc::Url`.
/// Format a WebSocket URL from an RPC URL and return a `cometbft_rpc::Url`.
fn parse_or_build_address(rpc_address: &str) -> Result<Self::OutputFormat, RegistryError> {
let uri = rpc_address
.parse::<Uri>()
Expand All @@ -58,7 +58,7 @@ impl UriFormatter for SimpleWebSocketFormatter {

match uri_websocket {
Ok(uri_websocket) => Ok(Url::from_str(uri_websocket.to_string().as_str()).map_err(
|e| RegistryError::tendermint_url_parse_error(rpc_address.to_string(), e),
|e| RegistryError::cometbft_url_parse_error(rpc_address.to_string(), e),
)?),
Err(e) => Err(RegistryError::unable_to_build_websocket_endpoint(
rpc_address.to_string(),
Expand Down
12 changes: 6 additions & 6 deletions crates/chain-registry/src/querier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use tokio::time::timeout;
use tokio::time::Duration;
use tracing::{debug, info};

use cometbft_rpc::{Client, SubscriptionClient, Url, WebSocketClient};
use ibc_proto::cosmos::bank::v1beta1::query_client::QueryClient;
use tendermint_rpc::{Client, SubscriptionClient, Url, WebSocketClient};

use crate::error::RegistryError;
use crate::formatter::{SimpleWebSocketFormatter, UriFormatter};
Expand Down Expand Up @@ -138,7 +138,7 @@ impl QueryContext for SimpleHermesRpcQuerier {

Ok(HermesConfigData {
rpc_address: Url::from_str(&rpc)
.map_err(|e| RegistryError::tendermint_url_parse_error(rpc, e))?,
.map_err(|e| RegistryError::cometbft_url_parse_error(rpc, e))?,
max_block_size: latest_consensus_params,
websocket: websocket_addr,
})
Expand Down Expand Up @@ -167,17 +167,17 @@ impl QueryContext for GrpcHealthCheckQuerier {

/// Query the endpoint and return the GRPC url
async fn query(uri: Self::QueryInput) -> Result<Self::QueryOutput, Self::QueryError> {
let tendermint_url = uri
let cometbft_url = uri
.to_string()
.parse()
.map_err(|e| RegistryError::tendermint_url_parse_error(uri.to_string(), e))?;
.map_err(|e| RegistryError::cometbft_url_parse_error(uri.to_string(), e))?;

info!("Querying gRPC server at {tendermint_url}");
info!("Querying gRPC server at {cometbft_url}");

QueryClient::connect(uri)
.await
.map_err(|_| RegistryError::unable_to_connect_with_grpc())?;

Ok(tendermint_url)
Ok(cometbft_url)
}
}
12 changes: 6 additions & 6 deletions crates/relayer-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ tokio = { version = "1.0", features = ["full"] }
tracing = "0.1.36"
tracing-subscriber = { version = "0.3.14", features = ["fmt", "env-filter", "json"]}
time = "0.3"
[dependencies.tendermint]
version = "0.34.0"
[dependencies.cometbft]
version = "0.1.0-alpha.2"
features = ["secp256k1"]

[dependencies.tendermint-rpc]
version = "0.34.0"
[dependencies.cometbft-rpc]
version = "0.1.0-alpha.2"
features = ["http-client", "websocket-client"]

[dependencies.tendermint-light-client-verifier]
version = "0.34.0"
[dependencies.cometbft-light-client-verifier]
version = "0.1.0-alpha.2"

[dependencies.abscissa_core]
version = "=0.6.0"
Expand Down
2 changes: 1 addition & 1 deletion crates/relayer-cli/src/chain_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use ibc_relayer::config::types::{MaxMsgNum, MaxTxSize, Memo, TrustThreshold};
use ibc_relayer::config::{default, AddressType, ChainConfig, EventSourceMode, GasPrice};
use ibc_relayer::keyring::Store;

use tendermint_rpc::Url;
use cometbft_rpc::Url;

const MAX_HEALTHY_QUERY_RETRIES: u8 = 5;

Expand Down
12 changes: 6 additions & 6 deletions crates/relayer-cli/src/commands/evidence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use abscissa_core::{Command, Runnable};
use ibc_relayer::config::{ChainConfig, Config};
use tokio::runtime::Runtime as TokioRuntime;

use tendermint::block::Height as TendermintHeight;
use tendermint::evidence::{DuplicateVoteEvidence, LightClientAttackEvidence};
use tendermint::validator;
use tendermint_rpc::{Client, Paging};
use cometbft::block::Height as TendermintHeight;
use cometbft::evidence::{DuplicateVoteEvidence, Evidence, LightClientAttackEvidence};
use cometbft::validator;
use cometbft_rpc::{Client, Paging};

use ibc_relayer::chain::cosmos::CosmosSdkChain;
use ibc_relayer::chain::endpoint::ChainEndpoint;
Expand Down Expand Up @@ -206,13 +206,13 @@ fn check_misbehaviour_at(

for evidence in block.evidence.into_vec() {
match evidence {
tendermint::evidence::Evidence::DuplicateVote(dv) => {
Evidence::DuplicateVote(dv) => {
warn!("found duplicate vote evidence");
trace!("{dv:#?}");

handle_duplicate_vote(rt.clone(), config, chain, key_name, *dv)?;
}
tendermint::evidence::Evidence::LightClientAttack(lc) => {
Evidence::LightClientAttack(lc) => {
warn!("found light client attack evidence");
trace!("{lc:#?}");

Expand Down
2 changes: 1 addition & 1 deletion crates/relayer-cli/src/commands/listen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use std::thread;

use abscissa_core::clap::Parser;
use abscissa_core::{application::fatal_error, Runnable};
use cometbft_rpc::{client::CompatMode, Client, HttpClient};
use eyre::eyre;
use itertools::Itertools;
use tendermint_rpc::{client::CompatMode, Client, HttpClient};
use tokio::runtime::Runtime as TokioRuntime;
use tracing::{error, info, instrument};

Expand Down
2 changes: 1 addition & 1 deletion crates/relayer-cli/src/commands/logs/log_level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct SetLogLevelCmd {
long = "log-filter",
help_heading = "FLAGS",
value_name = "LOG_FILTER",
help = "The target of the log level to update, if left empty all the targets will be updated. Example `ibc` or `tendermint_rpc`"
help = "The target of the log level to update, if left empty all the targets will be updated. Example `ibc` or `cometbft_rpc`"
)]
log_filter: Option<String>,
}
Expand Down
2 changes: 1 addition & 1 deletion crates/relayer-cli/src/commands/query/tx/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::str::FromStr;
use abscissa_core::clap::Parser;
use abscissa_core::{Command, Runnable};

use tendermint::Hash;
use cometbft::Hash;

use ibc_relayer_types::core::ics24_host::identifier::ChainId;

Expand Down
8 changes: 4 additions & 4 deletions crates/relayer-cli/src/commands/tx/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ use std::thread;
use abscissa_core::clap::Parser;
use abscissa_core::{Command, Runnable};

use cometbft::block::Height as BlockHeight;
use cometbft_light_client_verifier::types::TrustThreshold;
use cometbft_rpc::Url;
use ibc_relayer::config::Config;
use ibc_relayer::event::IbcEventWithHeight;
use ibc_relayer::foreign_client::{CreateOptions, ForeignClient};
Expand All @@ -20,9 +23,6 @@ use ibc_relayer::{
use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ClientId};
use ibc_relayer_types::events::IbcEvent;
use ibc_relayer_types::Height;
use tendermint::block::Height as BlockHeight;
use tendermint_light_client_verifier::types::TrustThreshold;
use tendermint_rpc::Url;
use tracing::debug;

use crate::application::app_config;
Expand Down Expand Up @@ -616,9 +616,9 @@ mod tests {
use std::str::FromStr;

use abscissa_core::clap::Parser;
use cometbft_light_client_verifier::types::TrustThreshold;
use humantime::Duration;
use ibc_relayer_types::core::ics24_host::identifier::{ChainId, ClientId};
use tendermint_light_client_verifier::types::TrustThreshold;

#[test]
fn test_parse_trust_threshold() {
Expand Down
4 changes: 2 additions & 2 deletions crates/relayer-cli/src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ fn build_tracing_filter(
std::env::var(HERMES_LOG_VAR).unwrap_or_else(|_| default_directive(default_level));

if debug_sections.contains(&DebugSection::Rpc) {
// Enable debug tracing for the `tendermint_rpc` crate as well
directive.push_str(",tendermint_rpc=debug");
// Enable debug tracing for the `cometbft_rpc` crate as well
directive.push_str(",cometbft_rpc=debug");
}

// Build the filter directive
Expand Down
2 changes: 1 addition & 1 deletion crates/relayer-cli/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use flex_error::{define_error, DisplayError};
use std::io::Error as IoError;

use tendermint::Error as TendermintError;
use cometbft::Error as TendermintError;

use ibc_relayer_types::applications::ics29_fee::error::Error as FeeError;
use ibc_relayer_types::core::ics04_channel::channel::IdentifiedChannelEnd;
Expand Down
Loading
Loading