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

refactor(conductor, relayer): remove astria-celestia-client #1022

Merged
merged 2 commits into from
Apr 30, 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
8 changes: 6 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ base64 = "0.21"
base64-serde = "0.7.0"
bytes = "1"
celestia-tendermint = "0.32.1"
celestia-types = "0.1.1"
celestia-rpc = "0.1.1"
clap = "4"
ed25519-consensus = "2.1.0"
ethers = "2.0.11"
Expand Down
1 change: 0 additions & 1 deletion crates/astria-celestia-mock/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ homepage = "https://astria.org"

[dependencies]
celestia-client = { package = "astria-celestia-client", path = "../astria-celestia-client" }

jsonrpsee = { workspace = true, features = ["macros", "server"] }
14 changes: 12 additions & 2 deletions crates/astria-conductor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ name = "astria-conductor"
[dependencies]
astria-build-info = { path = "../astria-build-info", features = ["runtime"] }
astria-core = { path = "../astria-core", features = [
"celestia",
"client",
"serde",
"brotli",
] }
astria-eyre = { path = "../astria-eyre" }
celestia-client = { package = "astria-celestia-client", path = "../astria-celestia-client" }
config = { package = "astria-config", path = "../astria-config" }
merkle = { package = "astria-merkle", path = "../astria-merkle" }
sequencer-client = { package = "astria-sequencer-client", path = "../astria-sequencer-client", features = [
Expand Down Expand Up @@ -59,6 +59,16 @@ tokio-stream = "0.1.14"
tracing-futures = { version = "0.2.5", features = ["futures-03"] }
moka = { version = "0.12.5", features = ["future"] }

### Celestia specific imports
#
# The crates imported here are all specific to eigerco's celestia APIs
# (including jsonrpsee).
# As none of them are reexported it is important to keep these in sync
# when updating.
celestia-rpc = "0.1.1"
celestia-types = { workspace = true }
jsonrpsee = { version = "0.20", features = ["client-core", "macros"] }

[dev-dependencies]
astria-core = { path = "../astria-core", features = [
"server",
Expand All @@ -70,8 +80,8 @@ config = { package = "astria-config", path = "../astria-config", features = [
"tests",
] }

celestia-tendermint = { workspace = true }
insta = { workspace = true, features = ["json"] }
jsonrpsee = { workspace = true, features = ["server"] }
once_cell = { workspace = true }
wiremock = { workspace = true }

Expand Down
4 changes: 2 additions & 2 deletions crates/astria-conductor/src/celestia/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use astria_eyre::eyre::{
self,
WrapErr as _,
};
use celestia_client::jsonrpsee::http_client::HttpClient as CelestiaClient;
use jsonrpsee::http_client::HttpClient as CelestiaClient;
use sequencer_client::HttpClient as SequencerClient;
use tokio_util::sync::CancellationToken;

Expand Down Expand Up @@ -48,7 +48,7 @@ impl Builder {
}

fn create_celestia_client(endpoint: String, bearer_token: &str) -> eyre::Result<CelestiaClient> {
use celestia_client::jsonrpsee::http_client::{
use jsonrpsee::http_client::{
HeaderMap,
HttpClientBuilder,
};
Expand Down
16 changes: 9 additions & 7 deletions crates/astria-conductor/src/celestia/convert.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use astria_core::brotli::decompress_bytes;
use celestia_client::{
celestia_types::{
nmt::Namespace,
Blob,
use astria_core::{
brotli::decompress_bytes,
sequencerblock::v1alpha1::{
CelestiaRollupBlob,
CelestiaSequencerBlob,
},
CelestiaRollupBlob,
CelestiaSequencerBlob,
};
use celestia_types::{
nmt::Namespace,
Blob,
};
use prost::{
Message as _,
Expand Down
18 changes: 8 additions & 10 deletions crates/astria-conductor/src/celestia/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ use astria_eyre::{
eyre,
eyre::WrapErr as _,
};
use celestia_client::{
celestia_types::{
nmt::Namespace,
Blob,
},
jsonrpsee::{
self,
http_client::HttpClient as CelestiaClient,
},
use celestia_types::{
nmt::Namespace,
Blob,
};
use jsonrpsee::{
self,
http_client::HttpClient as CelestiaClient,
};
use telemetry::display::base64;
use tokio::try_join;
Expand Down Expand Up @@ -84,7 +82,7 @@ async fn fetch_blobs_with_retry(
height: u64,
namespace: Namespace,
) -> eyre::Result<Vec<Blob>> {
use celestia_client::celestia_rpc::BlobClient as _;
use celestia_rpc::BlobClient as _;

let number_attempts = AtomicU32::new(0);
let retry_config = tryhard::RetryFutureConfig::new(u32::MAX)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ use astria_eyre::eyre::{
Result,
WrapErr as _,
};
use celestia_client::{
celestia_rpc::HeaderClient as _,
jsonrpsee::http_client::HttpClient,
};
use celestia_rpc::HeaderClient as _;
use futures::{
Future,
FutureExt as _,
Stream,
StreamExt as _,
};
use jsonrpsee::http_client::HttpClient;
use tokio_stream::wrappers::IntervalStream;

pub(super) fn stream_latest_heights(
Expand Down
10 changes: 4 additions & 6 deletions crates/astria-conductor/src/celestia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ use astria_eyre::eyre::{
bail,
WrapErr as _,
};
use celestia_client::{
celestia_types::nmt::Namespace,
jsonrpsee::http_client::HttpClient as CelestiaClient,
};
use celestia_types::nmt::Namespace;
use futures::{
future::{
BoxFuture,
Expand All @@ -25,6 +22,7 @@ use futures::{
},
FutureExt as _,
};
use jsonrpsee::http_client::HttpClient as CelestiaClient;
use sequencer_client::{
tendermint,
tendermint::block::Height as SequencerHeight,
Expand Down Expand Up @@ -253,9 +251,9 @@ impl RunningReader {

let latest_heights = stream_latest_heights(celestia_client.clone(), celestia_block_time);
let rollup_id = executor.rollup_id();
let rollup_namespace = celestia_client::celestia_namespace_v0_from_rollup_id(rollup_id);
let rollup_namespace = astria_core::celestia::namespace_v0_from_rollup_id(rollup_id);
let sequencer_namespace =
celestia_client::celestia_namespace_v0_from_bytes(sequencer_chain_id.as_bytes());
astria_core::celestia::namespace_v0_from_sha256_of_bytes(sequencer_chain_id.as_bytes());

let celestia_next_height = executor.celestia_base_block_height().value();
let celestia_reference_height = executor.celestia_base_block_height().value();
Expand Down
10 changes: 6 additions & 4 deletions crates/astria-conductor/src/celestia/reconstruct.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use std::collections::HashMap;

use astria_core::primitive::v1::RollupId;
use celestia_client::{
CelestiaRollupBlob,
CelestiaSequencerBlob,
use astria_core::{
primitive::v1::RollupId,
sequencerblock::v1alpha1::{
CelestiaRollupBlob,
CelestiaSequencerBlob,
},
};
use telemetry::display::base64;
use tracing::{
Expand Down
8 changes: 4 additions & 4 deletions crates/astria-conductor/src/celestia/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ use std::{
time::Duration,
};

use astria_core::sequencerblock::v1alpha1::{
CelestiaRollupBlob,
CelestiaSequencerBlob,
};
use astria_eyre::{
eyre,
eyre::{
ensure,
WrapErr as _,
},
};
use celestia_client::{
CelestiaRollupBlob,
CelestiaSequencerBlob,
};
use moka::future::Cache;
use sequencer_client::{
tendermint::block::{
Expand Down
2 changes: 1 addition & 1 deletion crates/astria-conductor/src/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use astria_eyre::eyre::{
WrapErr as _,
};
use bytes::Bytes;
use celestia_client::celestia_types::Height as CelestiaHeight;
use celestia_types::Height as CelestiaHeight;
use sequencer_client::tendermint::{
block::Height as SequencerHeight,
Time as TendermintTime,
Expand Down
2 changes: 1 addition & 1 deletion crates/astria-conductor/src/executor/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use astria_eyre::{
eyre::WrapErr as _,
};
use bytes::Bytes;
use celestia_client::celestia_types::Height as CelestiaHeight;
use celestia_types::Height as CelestiaHeight;
use sequencer_client::tendermint::block::Height as SequencerHeight;
use tokio::sync::watch::{
self,
Expand Down
31 changes: 14 additions & 17 deletions crates/astria-conductor/tests/blackbox/helpers/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,32 @@ macro_rules! block {
#[macro_export]
macro_rules! celestia_network_head {
(height: $height:expr) => {
::celestia_client::celestia_types::ExtendedHeader {
header: ::celestia_client::celestia_tendermint::block::header::Header {
::celestia_types::ExtendedHeader {
header: ::celestia_tendermint::block::header::Header {
height: $height.into(),
version: ::celestia_client::celestia_tendermint::block::header::Version {
version: ::celestia_tendermint::block::header::Version {
block: 0,
app: 0,
},
chain_id: "test_celestia-1000".try_into().unwrap(),
time: ::celestia_client::celestia_tendermint::Time::from_unix_timestamp(1, 1)
.unwrap(),
time: ::celestia_tendermint::Time::from_unix_timestamp(1, 1).unwrap(),
last_block_id: None,
last_commit_hash: ::celestia_client::celestia_tendermint::Hash::Sha256([0; 32]),
data_hash: ::celestia_client::celestia_tendermint::Hash::Sha256([0; 32]),
validators_hash: ::celestia_client::celestia_tendermint::Hash::Sha256([0; 32]),
next_validators_hash: ::celestia_client::celestia_tendermint::Hash::Sha256([0; 32]),
consensus_hash: ::celestia_client::celestia_tendermint::Hash::Sha256([0; 32]),
last_commit_hash: ::celestia_tendermint::Hash::Sha256([0; 32]),
data_hash: ::celestia_tendermint::Hash::Sha256([0; 32]),
validators_hash: ::celestia_tendermint::Hash::Sha256([0; 32]),
next_validators_hash: ::celestia_tendermint::Hash::Sha256([0; 32]),
consensus_hash: ::celestia_tendermint::Hash::Sha256([0; 32]),
app_hash: vec![0; 32].try_into().unwrap(),
last_results_hash: ::celestia_client::celestia_tendermint::Hash::Sha256([0; 32]),
evidence_hash: ::celestia_client::celestia_tendermint::Hash::Sha256([0; 32]),
last_results_hash: ::celestia_tendermint::Hash::Sha256([0; 32]),
evidence_hash: ::celestia_tendermint::Hash::Sha256([0; 32]),
proposer_address: vec![0u8; 20].try_into().unwrap(),
},
commit: ::celestia_client::celestia_tendermint::block::Commit {
commit: ::celestia_tendermint::block::Commit {
height: $height.into(),
..Default::default()
},
validator_set: ::celestia_client::celestia_tendermint::validator::Set::without_proposer(
vec![],
),
dah: ::celestia_client::celestia_types::DataAvailabilityHeader {
validator_set: ::celestia_tendermint::validator::Set::without_proposer(vec![]),
dah: ::celestia_types::DataAvailabilityHeader {
row_roots: vec![],
column_roots: vec![],
},
Expand Down
20 changes: 6 additions & 14 deletions crates/astria-conductor/tests/blackbox/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use astria_core::{
primitive::v1::RollupId,
};
use bytes::Bytes;
use celestia_client::celestia_types::{
use celestia_types::{
nmt::Namespace,
Blob,
};
Expand Down Expand Up @@ -192,7 +192,7 @@ impl TestConductor {

pub async fn mount_celestia_header_network_head(
&self,
extended_header: celestia_client::celestia_types::ExtendedHeader,
extended_header: celestia_types::ExtendedHeader,
) {
use wiremock::{
matchers::{
Expand Down Expand Up @@ -480,21 +480,13 @@ pub fn make_blobs(height: u32) -> Blobs {

let raw_header = ::prost::Message::encode_to_vec(&head.into_raw());
let head_compressed = compress_bytes(&raw_header).unwrap();
let header = ::celestia_client::celestia_types::Blob::new(
::celestia_client::celestia_namespace_v0_from_bytes(crate::SEQUENCER_CHAIN_ID.as_bytes()),
head_compressed,
)
.unwrap();
let header = Blob::new(sequencer_namespace(), head_compressed).unwrap();

let mut rollup = Vec::new();
for elem in tail {
let raw_rollup = ::prost::Message::encode_to_vec(&elem.into_raw());
let rollup_compressed = compress_bytes(&raw_rollup).unwrap();
let blob = ::celestia_client::celestia_types::Blob::new(
::celestia_client::celestia_namespace_v0_from_rollup_id(crate::ROLLUP_ID),
rollup_compressed,
)
.unwrap();
let blob = Blob::new(rollup_namespace(), rollup_compressed).unwrap();
rollup.push(blob);
}
Blobs {
Expand Down Expand Up @@ -606,10 +598,10 @@ pub fn make_validator_set(height: u32) -> tendermint_rpc::endpoint::validators::

#[must_use]
pub fn rollup_namespace() -> Namespace {
celestia_client::celestia_namespace_v0_from_rollup_id(ROLLUP_ID)
astria_core::celestia::namespace_v0_from_rollup_id(ROLLUP_ID)
}

#[must_use]
pub fn sequencer_namespace() -> Namespace {
celestia_client::celestia_namespace_v0_from_bytes(SEQUENCER_CHAIN_ID.as_bytes())
astria_core::celestia::namespace_v0_from_sha256_of_bytes(SEQUENCER_CHAIN_ID.as_bytes())
}
2 changes: 2 additions & 0 deletions crates/astria-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ keywords = ["astria", "grpc", "rpc", "blockchain", "execution", "protobuf"]

[dependencies]
brotli = { version = "5.0.0", optional = true }
celestia-types = { version = "0.1.1", optional = true }
pbjson = { version = "0.6.0", optional = true }

merkle = { package = "astria-merkle", path = "../astria-merkle" }
Expand All @@ -42,6 +43,7 @@ base64-serde = { workspace = true, optional = true }
base64 = { workspace = true }

[features]
celestia = ["dep:celestia-types"]
client = ["dep:tonic"]
serde = ["dep:serde", "dep:pbjson", "dep:base64-serde"]
server = ["dep:tonic"]
Expand Down
Loading
Loading