Skip to content

Commit

Permalink
CCCP-167, refactor: rename project (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnjscksdn98 authored Jul 3, 2023
1 parent 01c3acf commit 03879a9
Show file tree
Hide file tree
Showing 35 changed files with 120 additions and 132 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ panic = "unwind"

[workspace.package]
authors = ["bifrost-platform"]
homepage = "https://thebifrost.io"
homepage = "https://www.bifrostnetwork.com"
edition = "2021"
license = "Apache-2.0"
repository = "https://github.com/bifrost-platform/cccp-relayer"
repository = "https://github.com/bifrost-platform/bifrost-relayer.rs"

[workspace.dependencies]
# General
Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ COPY . /relayer

RUN cargo build --release

# 2nd stage: where we run cccp-relayer binary
# 2nd stage: where we run bifrost-relayer binary
FROM debian:stable-slim

COPY --from=builder /relayer/target/release/cccp-relayer /usr/local/bin
COPY --from=builder /relayer/target/release/bifrost-relayer /usr/local/bin
COPY --from=builder /relayer/configs /configs

RUN /usr/local/bin/cccp-relayer --version
RUN /usr/local/bin/bifrost-relayer --version

# 8000 for Prometheus exporter
EXPOSE 8000

VOLUME ["/data"]

ENTRYPOINT ["/usr/local/bin/cccp-relayer"]
ENTRYPOINT ["/usr/local/bin/bifrost-relayer"]
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# ![BIFROST Network](media/bifrost_header.jpeg)
# ![Bifrost Network](media/bifrost_header.jpeg)

# CCCP Relayer
The CCCP Relayer is the core implementation that facilitates the Cross-Chain Communication Protocol (CCCP) for the BIFROST Network. It processes corss-chain transactions and propagates data transfer (e.g. feeding price information) from one blockchain to another.
# Bifrost Relayer
The Bifrost Relayer is the core implementation that facilitates the Cross-Chain Communication Protocol (CCCP) for the Bifrost Network. It processes cross-chain transactions and propagates data transfer (e.g. feeding price information) from one blockchain to another.

## Getting Started

Learn to use the BIFROST network with our [technical docs](https://docs.bifrostnetwork.com/bifrost-network).
Learn to use the Bifrost network with our [technical docs](https://docs.bifrostnetwork.com/bifrost-network).

### BIFROST Network Testnet (ChainID: 49088)
### Bifrost Network Testnet (ChainID: 49088)
|Public Endpoints (rpc/ws)|
|------|
|https://public-01.testnet.bifrostnetwork.com/rpc|
|https://public-02.testnet.bifrostnetwork.com/rpc|
|wss://public-01.testnet.bifrostnetwork.com/wss|
|wss://public-02.testnet.bifrostnetwork.com/wss|

### BIFROST Network Mainnet (ChainID: 3068)
### Bifrost Network Mainnet (ChainID: 3068)
|Public Endpoints (rpc/ws)|
|------|
|https://public-01.mainnet.bifrostnetwork.com/rpc|
Expand All @@ -24,55 +24,55 @@ Learn to use the BIFROST network with our [technical docs](https://docs.bifrostn
|wss://public-02.mainnet.bifrostnetwork.com/wss|

### Install Requirements
To initiate the CCCP Relayer, certain dependencies must be manually installed. Both the executable binary file and the configuration YAML file are essential for all environments and operators.
To initiate the Bifrost Relayer, certain dependencies must be manually installed. Both the executable binary file and the configuration YAML file are essential for all environments and operators.

First, install the latest CCCP Relayer released binary.
First, install the latest Bifrost Relayer released binary.
```sh
wget "https://github.com/bifrost-platform/cccp-relayer/releases/latest/download/cccp-relayer"
wget "https://github.com/bifrost-platform/bifrost-relayer.rs/releases/latest/download/bifrost-relayer"
```

In order to execute the binary, the permission of the file has to be updated.
```sh
chmod +x cccp-relayer
chmod +x bifrost-relayer
```

Then, install the configuration YAML file. This file serves as an example for a quick start. Given the minor differences between Testnet and Mainnet environments, it's crucial to use the appropriate file for the corresponding network.
```sh
# For testnet only
wget "https://github.com/bifrost-platform/cccp-relayer/releases/latest/download/config.testnet.yaml"
wget "https://github.com/bifrost-platform/bifrost-relayer.rs/releases/latest/download/config.testnet.yaml"

# For mainnet only
wget "https://github.com/bifrost-platform/cccp-relayer/releases/latest/download/config.mainnet.yaml"
wget "https://github.com/bifrost-platform/bifrost-relayer.rs/releases/latest/download/config.mainnet.yaml"
```

### Configuration Setup
Next, the configuration YAML file contains certain parameters that the operator has to set. For instance, variables such as the relayer private key and each EVM provider's RPC endpoints depend on the operator, thus these values should be manuall input.

You should prepare RPC endpoints for the following blockchain networks. There are two options for this: 1) operating your own nodes for the blockchains, or 2) utilizing services that offer RPC endpoints, such as Infura or NodeReal. It’s crucial that each node must be archive-mode enabled.

- BIFROST (**Must be priorly self-operating and fully synced**)
- Bifrost (**Must be priorly self-operating and fully synced**)
- Ethereum
- Binance Smart Chain
- Polygon

You should also prepare an EVM account that will act as your relayer account. This account should have enough balance for transaction fees used in operations.

### Run the Relayer
Use the following command to execute the CCCP Relayer. The `<PATH_TO_CONFIG_FILE>` should be set to the absolute path of the installed configuration YAML file.
Use the following command to execute the Bifrost Relayer. The `<PATH_TO_CONFIG_FILE>` should be set to the absolute path of the installed configuration YAML file.
```sh
cccp-relayer --chain <PATH_TO_CONFIG_FILE>
bifrost-relayer --chain <PATH_TO_CONFIG_FILE>
```

## Development
To build and develop CCCP Relayer, you will need a proper development environment. If you've never worked with a Rust-based project before, your should probably try to first install `rustup`.
To build and develop Bifrost Relayer, you will need a proper development environment. If you've never worked with a Rust-based project before, your should probably try to first install `rustup`.
```sh
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

Then, fetch the project's code by using git.
```sh
git clone https://github.com/bifrost-platform/cccp-relayer
cd cccp-relayer
git clone https://github.com/bifrost-platform/bifrost-relayer.rs
cd bifrost-relayer.rs
```

And now build the project to generate the executable binary file. (The first build will take some time to end)
Expand All @@ -83,8 +83,8 @@ cargo build --release
You can now run your relayer after if you have finished configuration setup. The configuration YAML files exists in the `configs/` directory. Execute the relayer using the following command.
```sh
# For testnet only
./target/release/cccp-relayer --chain testnet
./target/release/bifrost-relayer --chain testnet

# For mainnet only
./target/release/cccp-relayer --chain mainnet
./target/release/bifrost-relayer --chain mainnet
```
10 changes: 5 additions & 5 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "cccp-client"
name = "br-client"
version = "0.1.0"
description = "The client implementation for BIFROST relayer"
description = "The client implementation for Bifrost relayer"
authors = { workspace = true }
homepage = { workspace = true }
edition = { workspace = true }
Expand All @@ -23,9 +23,9 @@ tokio = { workspace = true, features = ["signal", "rt-multi-thread", "parking_lo
k256 = { workspace = true, features = ["ecdsa"] }
sha3 = { workspace = true }

# CCCP
cccp-primitives = { path = "../primitives", default-features = false }
cccp-metrics = { path = "../metrics", default-features = false }
# Bifrost Relayer
br-primitives = { path = "../primitives", default-features = false }
br-metrics = { path = "../metrics", default-features = false }

[dev-dependencies]
serde_json = { workspace = true }
12 changes: 6 additions & 6 deletions client/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "cc-cli"
name = "br-cli"
version = "0.1.0"
description = "The client CLI module for BIFROST relayer"
description = "The client CLI module for Bifrost relayer"
authors = { workspace = true }
homepage = { workspace = true }
edition = { workspace = true }
Expand All @@ -19,10 +19,10 @@ serde_yaml = { workspace = true }
serde = { workspace = true, features = ["derive"] }
tokio = { workspace = true, features = ["signal", "rt-multi-thread", "parking_lot"] }

# CCCP
cccp-client = { path = "../../client", default-features = false }
cccp-primitives = { path = "../../primitives", default-features = false }
cccp-metrics = { path = "../../metrics", default-features = false }
# Bifrost Relayer
br-client = { path = "../../client", default-features = false }
br-primitives = { path = "../../primitives", default-features = false }
br-metrics = { path = "../../metrics", default-features = false }

# Substrate
sc-service = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion client/cli/src/configs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cccp_primitives::{
use br_primitives::{
cli::{Configuration, RelayerConfig, Result as CliResult},
errors::{INVALID_CONFIG_FILE_PATH, INVALID_CONFIG_FILE_STRUCTURE},
};
Expand Down
6 changes: 3 additions & 3 deletions client/cli/src/runner.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cccp_primitives::cli::{Configuration, Result as CliResult};
use br_primitives::cli::{Configuration, Result as CliResult};

use sc_service::{Error as ServiceError, TaskManager};
use sc_utils::metrics::{TOKIO_THREADS_ALIVE, TOKIO_THREADS_TOTAL};
Expand Down Expand Up @@ -47,7 +47,7 @@ pub fn build_runtime() -> Result<tokio::runtime::Runtime, std::io::Error> {
.build()
}

/// A CCCP-Relayer CLI runtime that can be used to run a relayer
/// A Bifrost-Relayer CLI runtime that can be used to run a relayer
pub struct Runner {
config: Configuration,
tokio_runtime: tokio::runtime::Runtime,
Expand All @@ -59,7 +59,7 @@ impl Runner {
Ok(Runner {
config: config.clone(),
tokio_runtime,
sentry_client: cccp_metrics::build_sentry_client(
sentry_client: br_metrics::build_sentry_client(
config.relayer_config.system.id,
config.relayer_config.sentry_config,
),
Expand Down
4 changes: 2 additions & 2 deletions client/src/eth/blocks.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cccp_primitives::{
use br_primitives::{
eth::{BootstrapState, ChainID},
sub_display_format,
};
Expand Down Expand Up @@ -162,7 +162,7 @@ impl<T: JsonRpcClient> BlockManager<T> {
/// Increment the waiting block.
fn increment_waiting_block(&mut self) {
self.waiting_block = self.waiting_block.saturating_add(U64::from(1u64));
cccp_metrics::set_block_height(&self.client.get_chain_name(), self.waiting_block.as_u64());
br_metrics::set_block_height(&self.client.get_chain_name(), self.waiting_block.as_u64());
}

/// Verifies if the transaction has interacted with the target contracts.
Expand Down
2 changes: 1 addition & 1 deletion client/src/eth/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use ethers::types::{
};
use tokio::sync::mpsc::{error::SendError, UnboundedSender};

use cccp_primitives::{
use br_primitives::{
eth::{ChainID, GasCoefficient, SocketEventStatus},
PriceResponse,
};
Expand Down
6 changes: 3 additions & 3 deletions client/src/eth/handlers/bridge_relay_handler.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{collections::BTreeMap, str::FromStr, sync::Arc, time::Duration};

use cccp_primitives::{
use br_primitives::{
authority::RoundMetaData,
cli::BootstrapConfig,
eth::{
Expand Down Expand Up @@ -690,7 +690,7 @@ impl<T: JsonRpcClient> BootstrapHandler for BridgeRelayHandler<T> {
}

log::info!(
target: "cccp-relayer",
target: "bifrost-relayer",
"-[{}] ⚙️ [Bootstrap mode] Bootstrap process successfully ended.",
sub_display_format(SUB_LOG_TARGET),
);
Expand Down Expand Up @@ -766,7 +766,7 @@ impl<T: JsonRpcClient> BootstrapHandler for BridgeRelayHandler<T> {
#[cfg(test)]
mod tests {
use super::*;
use cccp_primitives::socket::SocketContract;
use br_primitives::socket::SocketContract;
use ethers::{
providers::{Http, Provider},
types::H160,
Expand Down
2 changes: 1 addition & 1 deletion client/src/eth/handlers/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
mod bridge_relay_handler;
mod roundup_relay_handler;

use br_primitives::eth::BootstrapState;
pub use bridge_relay_handler::*;
use cccp_primitives::eth::BootstrapState;
pub use roundup_relay_handler::*;

use ethers::types::{Log, TransactionReceipt, H256};
Expand Down
2 changes: 1 addition & 1 deletion client/src/eth/handlers/roundup_relay_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::eth::{
VSPPhase2Metadata,
};
use async_trait::async_trait;
use cccp_primitives::{
use br_primitives::{
authority::RoundMetaData,
cli::BootstrapConfig,
eth::{
Expand Down
10 changes: 5 additions & 5 deletions client/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use serde::{de::DeserializeOwned, Serialize};
use tokio::time::{sleep, Duration};

pub use blocks::*;
pub use cccp_primitives::contracts::*;
use cccp_primitives::{
pub use br_primitives::contracts::*;
use br_primitives::{
authority::{AuthorityContract, RoundMetaData},
chainlink_aggregator::ChainlinkContract,
eth::{BridgeDirection, ChainID, BOOTSTRAP_BLOCK_OFFSET, NATIVE_BLOCK_TIME},
Expand Down Expand Up @@ -163,7 +163,7 @@ impl<T: JsonRpcClient> EthClient<T> {
let mut error_msg = String::default();

while retries_remaining > 0 {
cccp_metrics::increase_rpc_calls(&self.get_chain_name());
br_metrics::increase_rpc_calls(&self.get_chain_name());
match self.provider.request(method, params.clone()).await {
Ok(result) => return result,
Err(error) => {
Expand Down Expand Up @@ -195,7 +195,7 @@ impl<T: JsonRpcClient> EthClient<T> {
let mut error_msg = String::default();

while retries_remaining > 0 {
cccp_metrics::increase_rpc_calls(&self.get_chain_name());
br_metrics::increase_rpc_calls(&self.get_chain_name());
match raw_call.call().await {
Ok(result) => return result,
Err(error) => {
Expand Down Expand Up @@ -293,7 +293,7 @@ impl<T: JsonRpcClient> EthClient<T> {

/// Send prometheus metric of the current balance.
pub async fn sync_balance(&self) {
cccp_metrics::set_native_balance(
br_metrics::set_native_balance(
&self.get_chain_name(),
format_units(self.get_balance(self.address()).await, "ether")
.unwrap()
Expand Down
Loading

0 comments on commit 03879a9

Please sign in to comment.