Skip to content

Commit

Permalink
rpc: rebranding to CometBFT
Browse files Browse the repository at this point in the history
Change to CometBFT naming in documentation and URLs.
  • Loading branch information
mzabaluev committed Dec 13, 2023
1 parent 24108f0 commit bb035e1
Show file tree
Hide file tree
Showing 29 changed files with 124 additions and 124 deletions.
88 changes: 44 additions & 44 deletions rpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

See the [repo root] for build status, license, rust version, etc.

# tendermint-rpc
# cometbft-rpc

A Rust implementation of the core types returned by a Tendermint node's RPC
A Rust implementation of the core types returned by a CometBFT node's RPC
endpoint. These can be used to deserialize JSON-RPC responses.

All networking related features will be feature guarded to keep the
Expand All @@ -24,30 +24,30 @@ select when using it.
Several client-related features are provided at present:

* `http-client` - Provides `HttpClient`, which is a basic RPC client that
interacts with remote Tendermint nodes via **JSON-RPC over HTTP or
interacts with remote CometBFT nodes via **JSON-RPC over HTTP or
HTTPS**. This client does not provide `Event` subscription
functionality. See the [Tendermint RPC] for more details.
functionality. See the [CometBFT RPC] for more details.
* `websocket-client` - Provides `WebSocketClient`, which provides full
client functionality, including general RPC functionality as well as
`Event`] subscription functionality. Can be used over secure
(`wss://`) and unsecure (`ws://`) connections.

### CLI

A `tendermint-rpc` console application is provided for testing/experimentation
A `cometbft-rpc` console application is provided for testing/experimentation
purposes. To build this application:

```bash
# From the tendermint-rpc crate's directory
# From the cometbft-rpc crate's directory
cd rpc
cargo build --bin tendermint-rpc --features cli
cargo build --bin cometbft-rpc --features cli

# To run directly and show usage information
cargo run --bin tendermint-rpc --features cli -- --help
cargo run --bin cometbft-rpc --features cli -- --help

# To install the binary to your Cargo binaries path
# (should be globally accessible)
cargo install --bin tendermint-rpc --features cli --path .
cargo install --bin cometbft-rpc --features cli --path .
```

The application sends its logs to **stderr** and its output to **stdout**, so
Expand All @@ -57,35 +57,35 @@ it's relatively easy to capture RPC output.

```bash
# Check which RPC commands/endpoints are supported.
tendermint-rpc --help
cometbft-rpc --help

# Query the status of the Tendermint node bound to tcp://127.0.0.1:26657
tendermint-rpc status
# Query the status of the CometBFT node bound to tcp://127.0.0.1:26657
cometbft-rpc status

# Submit a transaction to the key/value store ABCI app via a Tendermint node
# Submit a transaction to the key/value store ABCI app via a CometBFT node
# bound to tcp://127.0.0.1:26657
tendermint-rpc broadcast-tx-async somekey=somevalue
cometbft-rpc broadcast-tx-async somekey=somevalue

# Query the value associated with key "somekey" (still assuming a key/value
# store ABCI app)
tendermint-rpc abci-query somekey
cometbft-rpc abci-query somekey

# To use an HTTP/S proxy to access your RPC endpoint
tendermint-rpc --proxy-url http://yourproxy:8080 abci-query somekey
cometbft-rpc --proxy-url http://yourproxy:8080 abci-query somekey

# To set your HTTP/S proxy for multiple subsequent queries
export HTTP_PROXY=http://yourproxy:8080
tendermint-rpc abci-query somekey
cometbft-rpc abci-query somekey

# Subscribe to receive new blocks (must use the WebSocket endpoint)
# Prints out all incoming events
tendermint-rpc -u ws://127.0.0.1:26657/websocket subscribe "tm.event='NewBlock'"
cometbft-rpc -u ws://127.0.0.1:26657/websocket subscribe "tm.event='NewBlock'"

# If you want to execute a number of queries against a specific endpoint and
# don't feel like re-typing the URL over and over again, just set the
# TENDERMINT_RPC_URL environment variable
export TENDERMINT_RPC_URL=ws://127.0.0.1:26657/websocket
tendermint-rpc subscribe "tm.event='Tx'"
# COMETBFT_RPC_URL environment variable
export COMETBFT_RPC_URL=ws://127.0.0.1:26657/websocket
cometbft-rpc subscribe "tm.event='Tx'"
```

### Mock Clients
Expand All @@ -100,13 +100,13 @@ traits.
- RPC [core types] in golang

- RPC endpoints REST interface documentation:
<https://docs.tendermint.com/v0.34/rpc/>
<https://docs.cometbft.com/v1/rpc/>

## Testing

The RPC types are directly tested through the [integration
tests](./tests/integration.rs). These tests use fixtures taken from running
Tendermint nodes to ensure compatibility without needing access to a running
CometBFT nodes to ensure compatibility without needing access to a running
node during testing. All of these fixtures were generated manually, and
automatic regeneration of the fixtures is [on our roadmap][autogen-fixtures].

Expand All @@ -117,40 +117,40 @@ To run these tests locally:
cargo test --all-features
```

The RPC client is also indirectly tested through the [Tendermint integration
tests](../tendermint/tests/integration.rs), which happens during
The RPC client is also indirectly tested through the [CometBFT integration
tests](../cometbft/tests/integration.rs), which happens during
[CI](../.github/workflows/test.yml). All of these tests require a running
Tendermint node, and are therefore ignored by default. To run these tests
CometBFT node, and are therefore ignored by default. To run these tests
locally:

```bash
# In one terminal, spin up a Tendermint node
docker pull tendermint/tendermint:latest
docker run -it --rm -v "/tmp/tendermint:/tendermint" \
tendermint/tendermint init
docker run -it --rm -v "/tmp/tendermint:/tendermint" \
# In one terminal, spin up a CometBFT node
docker pull cometbft/cometbft:latest
docker run -it --rm -v "/tmp/cometbft:/cometbft" \
cometbft/cometbft init
docker run -it --rm -v "/tmp/cometbft:/cometbft" \
-p 26657:26657 \
tendermint/tendermint node --proxy_app=kvstore
cometbft/cometbft node --proxy_app=kvstore

# In another terminal, run the ignored Tendermint tests to connect to the node
# In another terminal, run the ignored CometBFT tests to connect to the node
# running at tcp://127.0.0.1:26657
cd ../tendermint
cd ../cometbft
cargo test --all-features -- --ignored
```

[//]: # (badges)

[crate-image]: https://img.shields.io/crates/v/tendermint-rpc.svg
[crate-link]: https://crates.io/crates/tendermint-rpc
[docs-image]: https://docs.rs/tendermint-rpc/badge.svg
[docs-link]: https://docs.rs/tendermint-rpc/
[crate-image]: https://img.shields.io/crates/v/cometbft-rpc.svg
[crate-link]: https://crates.io/crates/cometbft-rpc
[docs-image]: https://docs.rs/cometbft-rpc/badge.svg
[docs-link]: https://docs.rs/cometbft-rpc/

[//]: # (general links)

[repo root]: https://github.com/informalsystems/tendermint-rs
[tendermint]: https://github.com/tendermint/tendermint
[core types]: https://github.com/tendermint/tendermint/blob/8b4a30fada85fccd8f0cb15009344f1cbd8de616/rpc/core/types/responses.go#L1
[tendermint.rs]: https://crates.io/crates/tendermint
[Tendermint RPC]: https://docs.tendermint.com/v0.34/rpc/
[`/subscribe` endpoint]: https://docs.tendermint.com/v0.34/rpc/#/Websocket/subscribe
[repo root]: https://github.com/cometbft/cometbft-rs
[cometbft]: https://github.com/cometbft/cometbft
[core types]: https://github.com/cometbft/cometbft/blob/8b4a30fada85fccd8f0cb15009344f1cbd8de616/rpc/core/types/responses.go#L1
[cometbft.rs]: https://crates.io/crates/cometbft
[CometBFT RPC]: https://docs.cometbft.com/v1/rpc/
[`/subscribe` endpoint]: https://docs.cometbft.com/v1/rpc/#/Websocket/subscribe
[autogen-fixtures]: https://github.com/informalsystems/tendermint-rs/issues/612
6 changes: 3 additions & 3 deletions rpc/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Tendermint RPC client.
//! CometBFT RPC client.
mod compat;
pub use compat::CompatMode;
Expand Down Expand Up @@ -38,7 +38,7 @@ use crate::{
Error, Order, SimpleRequest,
};

/// Provides lightweight access to the Tendermint RPC. It gives access to all
/// Provides lightweight access to the CometBFT RPC. It gives access to all
/// endpoints with the exception of the event subscription-related ones.
///
/// To access event subscription capabilities, use a client that implements the
Expand Down Expand Up @@ -272,7 +272,7 @@ pub trait Client {
self.perform(net_info::Request).await
}

/// `/status`: get Tendermint status including node info, pubkey, latest
/// `/status`: get CometBFT status including node info, pubkey, latest
/// block hash, app hash, block height and time.
async fn status(&self) -> Result<status::Response, Error> {
self.perform(status::Request).await
Expand Down
12 changes: 6 additions & 6 deletions rpc/src/client/bin/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! CLI for performing simple interactions against a Tendermint node's RPC.
//! CLI for performing simple interactions against a CometBFT node's RPC.
use core::str::FromStr;

Expand All @@ -15,22 +15,22 @@ use structopt::StructOpt;
use tokio::{task::JoinHandle, time::Duration};
use tracing::{debug, error, info, level_filters::LevelFilter, warn};

/// CLI for performing simple interactions against a Tendermint node's RPC.
/// CLI for performing simple interactions against a CometBFT node's RPC.
///
/// Supports HTTP, HTTPS, WebSocket and secure WebSocket (wss://) URLs.
#[derive(Debug, StructOpt)]
struct Opt {
/// The URL of the Tendermint node's RPC endpoint.
/// The URL of the CometBFT node's RPC endpoint.
#[structopt(
short,
long,
default_value = "http://127.0.0.1:26657",
env = "TENDERMINT_RPC_URL"
env = "COMETBFT_RPC_URL"
)]
url: Url,

/// An optional HTTP/S proxy through which to submit requests to the
/// Tendermint node's RPC endpoint. Only available for HTTP/HTTPS endpoints
/// CometBFT node's RPC endpoint. Only available for HTTP/HTTPS endpoints
/// (i.e. WebSocket proxies are not supported).
#[structopt(long)]
proxy_url: Option<Url>,
Expand Down Expand Up @@ -148,7 +148,7 @@ enum ClientRequest {
LatestCommit,
/// Obtain information about the P2P stack and other network connections.
NetInfo,
/// Get Tendermint status (node info, public key, latest block hash, etc.).
/// Get CometBFT status (node info, public key, latest block hash, etc.).
Status,
/// Fetch a transaction by way of its hash.
Tx {
Expand Down
12 changes: 6 additions & 6 deletions rpc/src/client/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use cometbft::Version;
use crate::prelude::*;
use crate::Error;

/// Protocol compatibility mode for a Tendermint RPC client.
/// Protocol compatibility mode for a CometBFT RPC client.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum CompatMode {
/// Use version 0.34 of the protocol.
Expand All @@ -28,7 +28,7 @@ impl CompatMode {
Self::V0_37
}

/// Parse the Tendermint version string to determine
/// Parse the CometBFT version string to determine
/// the compatibility mode.
///
/// The version can be obtained by querying the `/status` endpoint.
Expand All @@ -41,16 +41,16 @@ impl CompatMode {
/// be handled by the same server. In the future, the RPC protocol should
/// follow versioning practices designed to avoid ambiguities with
/// message formats.
pub fn from_version(tendermint_version: Version) -> Result<CompatMode, Error> {
let raw_version: String = tendermint_version.into();
pub fn from_version(cometbft_version: Version) -> Result<CompatMode, Error> {
let raw_version: String = cometbft_version.into();
let version = semver::Version::parse(raw_version.trim_start_matches('v'))
.map_err(|_| Error::invalid_tendermint_version(raw_version))?;
.map_err(|_| Error::invalid_cometbft_version(raw_version))?;

match (version.major, version.minor) {
(0, 34) => Ok(CompatMode::V0_34),
(0, 37) => Ok(CompatMode::V0_37),
(0, 38) => Ok(CompatMode::V0_37),
_ => Err(Error::unsupported_tendermint_version(version.to_string())),
_ => Err(Error::unsupported_cometbft_version(version.to_string())),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/client/sync.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Synchronization primitives specific to the Tendermint RPC client.
//! Synchronization primitives specific to the CometBFT RPC client.
//!
//! At present, this wraps Tokio's synchronization primitives and provides some
//! convenience methods. We also only implement unbounded channels at present.
Expand Down
2 changes: 1 addition & 1 deletion rpc/src/client/transport.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Tendermint RPC client implementations for different transports.
//! CometBFT RPC client implementations for different transports.
mod auth;
pub mod mock;
Expand Down
16 changes: 8 additions & 8 deletions rpc/src/client/transport/http.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! HTTP-based transport for Tendermint RPC Client.
//! HTTP-based transport for CometBFT RPC Client.
use core::{
convert::{TryFrom, TryInto},
Expand All @@ -23,11 +23,11 @@ use crate::{
Error, Order, Scheme, SimpleRequest, Url,
};

const USER_AGENT: &str = concat!("tendermint.rs/", env!("CARGO_PKG_VERSION"));
const USER_AGENT: &str = concat!("cometbft.rs/", env!("CARGO_PKG_VERSION"));

/// A JSON-RPC/HTTP Tendermint RPC client (implements [`crate::Client`]).
/// A JSON-RPC/HTTP CometBFT RPC client (implements [`crate::Client`]).
///
/// Supports both HTTP and HTTPS connections to Tendermint RPC endpoints, and
/// Supports both HTTP and HTTPS connections to CometBFT RPC endpoints, and
/// allows for the use of HTTP proxies (see [`HttpClient::new_with_proxy`] for
/// details).
///
Expand Down Expand Up @@ -66,7 +66,7 @@ pub struct Builder {
}

impl Builder {
/// Use the specified compatibility mode for the Tendermint RPC protocol.
/// Use the specified compatibility mode for the CometBFT RPC protocol.
///
/// The default is the latest protocol version supported by this crate.
pub fn compat_mode(mut self, mode: CompatMode) -> Self {
Expand Down Expand Up @@ -108,7 +108,7 @@ impl Builder {
}

impl HttpClient {
/// Construct a new Tendermint RPC HTTP/S client connecting to the given
/// Construct a new CometBFT RPC HTTP/S client connecting to the given
/// URL.
pub fn new<U>(url: U) -> Result<Self, Error>
where
Expand All @@ -118,7 +118,7 @@ impl HttpClient {
Self::builder(url).build()
}

/// Construct a new Tendermint RPC HTTP/S client connecting to the given
/// Construct a new CometBFT RPC HTTP/S client connecting to the given
/// URL, but via the specified proxy's URL.
///
/// If the RPC endpoint is secured (HTTPS), the proxy will automatically
Expand All @@ -134,7 +134,7 @@ impl HttpClient {
Self::builder(url).proxy_url(proxy_url.try_into()?).build()
}

/// Initiate a builder for a Tendermint RPC HTTP/S client connecting
/// Initiate a builder for a CometBFT RPC HTTP/S client connecting
/// to the given URL, so that more configuration options can be specified
/// with the builder.
pub fn builder(url: HttpClientUrl) -> Builder {
Expand Down
Loading

0 comments on commit bb035e1

Please sign in to comment.