Skip to content

Commit

Permalink
chore(features): remove stardust feature (#1022)
Browse files Browse the repository at this point in the history
* Remove `stardust` feature

* Fix CI commands
  • Loading branch information
Alexandcoats authored Jan 10, 2023
1 parent 761a4f2 commit 08c9fb4
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 47 deletions.
8 changes: 4 additions & 4 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[alias]
ci-check-all = "check --all-targets --all-features"
ci-check-inx = "check --all-targets --no-default-features --features inx,stardust"
ci-check-api = "check --all-targets --no-default-features --features api,stardust"
ci-check-inx = "check --all-targets --no-default-features --features inx"
ci-check-api = "check --all-targets --no-default-features --features api"
ci-check-features = "hack check --each-feature --no-dev-deps"

ci-clippy-all = "clippy --all-targets --all-features -- -D warnings"
ci-clippy-inx = "clippy --all-targets --no-default-features --features inx,stardust -- -D warnings"
ci-clippy-api = "clippy --all-targets --no-default-features --features api,stardust -- -D warnings"
ci-clippy-inx = "clippy --all-targets --no-default-features --features inx -- -D warnings"
ci-clippy-api = "clippy --all-targets --no-default-features --features api -- -D warnings"

ci-doctest = "test --doc --all-features"
ci-doc = "doc --all-features --no-deps --document-private-items"
Expand Down
17 changes: 3 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ eyre = { version = "0.6", default-features = false, features = [ "track-caller",
futures = { version = "0.3", default-features = false }
humantime = { version = "2.1.0", default-features = false }
humantime-serde = { version = "1.1", default-features = false }
iota-types = { version = "1.0.0-rc", default-features = false, features = [ "api", "block", "std" ] }
mongodb = { version = "2.3", default-features = false, features = [ "tokio-runtime" ] }
packable = { version = "0.7", default-features = false }
pin-project = { version = "1.0", default-features = false }
prefix-hex = { version = "0.5.0", default-features = false, features = [ "primitive-types" ] }
primitive-types = { version = "0.12", default-features = false }
Expand Down Expand Up @@ -61,7 +63,6 @@ ed25519 = { version = "1.5", default-features = false, features = [ "alloc", "pk
ed25519-dalek = { version = "1.0", default-features = false, features = [ "u64_backend" ], optional = true }
hex = { version = "0.4", default-features = false, optional = true }
hyper = { version = "0.14", default-features = false, features = [ "server", "tcp", "stream" ], optional = true }
packable = { version = "0.7", default-features = false, optional = true }
rand = { version = "0.8", default-features = false, features = [ "std" ], optional = true }
regex = { version = "1.7", default-features = false, features = [ "std" ], optional = true }
rust-argon2 = { version = "1.0.0", default-features = false, optional = true }
Expand All @@ -80,9 +81,6 @@ tracing-loki = { version = "0.2", default-features = false, features = [ "compat
# PoI
iota-crypto = { version = "0.15", default-features = false, features = [ "blake2b" ], optional = true }

# Stardust types
iota-types = { version = "1.0.0-rc", default-features = false, features = [ "api", "block", "std" ], optional = true }

[dev-dependencies]
iota-types = { version = "1.0.0-rc", default-features = false, features = [ "api", "block", "std", "rand" ] }
rand = { version = "0.8", default-features = false, features = [ "std" ] }
Expand All @@ -95,7 +93,6 @@ default = [
"loki",
"metrics",
"poi",
"stardust",
]
analytics = [
"dep:influxdb",
Expand All @@ -108,21 +105,17 @@ api = [
"dep:hex",
"derive_more/from",
"dep:hyper",
"dep:packable",
"dep:rand",
"dep:regex",
"dep:rust-argon2",
"dep:serde_urlencoded",
"dep:tower",
"dep:tower-http",
"dep:zeroize",
"stardust",
]
inx = [
"dep:inx",
"dep:packable",
"dep:tonic",
"stardust",
]
loki = [
"dep:tracing-loki",
Expand All @@ -136,11 +129,7 @@ poi = [
"dep:iota-crypto",
]
rand = [
"iota-types?/rand",
]
stardust = [
"dep:iota-types",
"dep:packable",
"iota-types/rand",
]

[profile.production]
Expand Down
2 changes: 1 addition & 1 deletion src/bin/inx-chronicle/api/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pub enum RequestError {
BadPagingState,
#[error("invalid time range")]
BadTimeRange,
#[cfg(feature = "stardust")]

#[error("invalid IOTA Stardust data: {0}")]
IotaStardust(#[from] iota_types::block::Error),
#[error("invalid bool value provided: {0}")]
Expand Down
2 changes: 0 additions & 2 deletions src/bin/inx-chronicle/api/extractors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ pub struct TimeRangeQuery {
end_timestamp: Option<u32>,
}

#[cfg(feature = "stardust")]
mod stardust {
use chronicle::types::stardust::milestone::MilestoneTimestamp;

Expand Down Expand Up @@ -105,7 +104,6 @@ mod stardust {
}
}

#[cfg(feature = "stardust")]
pub use stardust::*;

#[cfg(test)]
Expand Down
1 change: 0 additions & 1 deletion src/bin/inx-chronicle/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
mod extractors;

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

mod error;
Expand Down
2 changes: 0 additions & 2 deletions src/bin/inx-chronicle/api/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ pub fn routes() -> Router {
#[allow(unused_mut)]
let mut router = Router::new();

#[cfg(feature = "stardust")]
{
router = router.merge(super::stardust::routes())
}
Expand Down Expand Up @@ -135,7 +134,6 @@ async fn list_routes(
}

pub async fn is_healthy(database: &MongoDb) -> ApiResult<bool> {
#[cfg(feature = "stardust")]
{
let newest = match database
.collection::<MilestoneCollection>()
Expand Down
19 changes: 9 additions & 10 deletions src/bin/inx-chronicle/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ impl From<&InfluxDbArgs> for chronicle::db::influxdb::InfluxDbConfig {
}
}

#[cfg(all(feature = "stardust", feature = "inx"))]
#[cfg(feature = "inx")]
use crate::stardust_inx::config as inx;

#[cfg(all(feature = "stardust", feature = "inx"))]
#[cfg(feature = "inx")]
#[derive(Args, Debug)]
pub struct InxArgs {
/// The address of the node INX interface Chronicle tries to connect to - if enabled.
Expand All @@ -147,7 +147,7 @@ pub struct InxArgs {
pub disable_inx: bool,
}

#[cfg(all(feature = "stardust", feature = "inx"))]
#[cfg(feature = "inx")]
impl From<&InxArgs> for inx::InxConfig {
fn from(value: &InxArgs) -> Self {
Self {
Expand Down Expand Up @@ -241,7 +241,7 @@ impl From<&LokiArgs> for crate::config::loki::LokiConfig {
}
}

#[cfg(any(all(feature = "stardust", feature = "inx"), feature = "api"))]
#[cfg(any(feature = "inx", feature = "api"))]
fn parse_duration(arg: &str) -> Result<std::time::Duration, humantime::DurationError> {
arg.parse::<humantime::Duration>().map(Into::into)
}
Expand All @@ -253,7 +253,7 @@ impl ClArgs {
mongodb: (&self.mongodb).into(),
#[cfg(any(feature = "analytics", feature = "metrics"))]
influxdb: (&self.influxdb).into(),
#[cfg(all(feature = "stardust", feature = "inx"))]
#[cfg(feature = "inx")]
inx: (&self.inx).into(),
#[cfg(feature = "api")]
api: (&self.api).into(),
Expand Down Expand Up @@ -291,7 +291,7 @@ impl ClArgs {
);
return Ok(PostCommand::Exit);
}
#[cfg(all(feature = "analytics", feature = "stardust", feature = "inx"))]
#[cfg(all(feature = "analytics", feature = "inx"))]
Subcommands::FillAnalytics {
start_milestone,
end_milestone,
Expand Down Expand Up @@ -393,7 +393,7 @@ impl ClArgs {
return Ok(PostCommand::Exit);
}
}
#[cfg(feature = "stardust")]

Subcommands::BuildIndexes => {
tracing::info!("Connecting to database using hosts: `{}`.", config.mongodb.hosts_str()?);
let db = chronicle::db::MongoDb::connect(&config.mongodb).await?;
Expand Down Expand Up @@ -423,7 +423,7 @@ pub enum AnalyticsChoice {
UnlockConditions,
}

#[cfg(all(feature = "analytics", feature = "stardust"))]
#[cfg(feature = "analytics")]
impl From<AnalyticsChoice> for Box<dyn chronicle::db::collections::analytics::Analytic> {
fn from(value: AnalyticsChoice) -> Self {
use chronicle::db::collections::analytics::{
Expand Down Expand Up @@ -453,7 +453,7 @@ pub enum Subcommands {
/// Generate a JWT token using the available config.
#[cfg(feature = "api")]
GenerateJWT,
#[cfg(all(feature = "analytics", feature = "stardust"))]
#[cfg(feature = "analytics")]
FillAnalytics {
/// The inclusive starting milestone index.
#[arg(short, long)]
Expand All @@ -476,7 +476,6 @@ pub enum Subcommands {
run: bool,
},
/// Manually build indexes.
#[cfg(feature = "stardust")]
BuildIndexes,
}

Expand Down
2 changes: 1 addition & 1 deletion src/bin/inx-chronicle/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct ChronicleConfig {
pub influxdb: chronicle::db::influxdb::InfluxDbConfig,
#[cfg(feature = "api")]
pub api: crate::api::ApiConfig,
#[cfg(all(feature = "stardust", feature = "inx"))]
#[cfg(feature = "inx")]
pub inx: super::stardust_inx::InxConfig,
#[cfg(feature = "loki")]
pub loki: loki::LokiConfig,
Expand Down
6 changes: 2 additions & 4 deletions src/bin/inx-chronicle/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod api;
mod cli;
mod config;
mod process;
#[cfg(all(feature = "stardust", feature = "inx"))]
#[cfg(feature = "inx")]
mod stardust_inx;

use bytesize::ByteSize;
Expand Down Expand Up @@ -44,14 +44,13 @@ async fn main() -> eyre::Result<()> {
ByteSize::b(db.size().await?)
);

#[cfg(feature = "stardust")]
build_indexes(&db).await?;

let mut tasks: JoinSet<eyre::Result<()>> = JoinSet::new();

let (shutdown_signal, _) = tokio::sync::broadcast::channel::<()>(1);

#[cfg(all(feature = "inx", feature = "stardust"))]
#[cfg(feature = "inx")]
if config.inx.enabled {
#[cfg(any(feature = "analytics", feature = "metrics"))]
#[allow(unused_mut)]
Expand Down Expand Up @@ -162,7 +161,6 @@ fn set_up_logging(#[allow(unused)] config: &ChronicleConfig) -> eyre::Result<()>
Ok(())
}

#[cfg(feature = "stardust")]
async fn build_indexes(db: &MongoDb) -> eyre::Result<()> {
use chronicle::db::collections;
let start_indexes = db.get_index_names().await?;
Expand Down
1 change: 0 additions & 1 deletion src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
//! Module that contains the database and associated models.
/// Module containing the collections in the database.
#[cfg(feature = "stardust")]
pub mod collections;

/// Module containing InfluxDb types and traits.
Expand Down
2 changes: 0 additions & 2 deletions src/types/ledger/inclusion_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ impl From<LedgerInclusionState> for Bson {
}
}

#[cfg(feature = "stardust")]
impl From<iota::LedgerInclusionStateDto> for LedgerInclusionState {
fn from(value: iota::LedgerInclusionStateDto) -> Self {
match value {
Expand All @@ -35,7 +34,6 @@ impl From<iota::LedgerInclusionStateDto> for LedgerInclusionState {
}
}

#[cfg(feature = "stardust")]
impl From<LedgerInclusionState> for iota::LedgerInclusionStateDto {
fn from(value: LedgerInclusionState) -> Self {
match value {
Expand Down
9 changes: 4 additions & 5 deletions src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@

//! Module that contains the types.
#[cfg(feature = "stardust")]
pub mod context;
#[cfg(feature = "stardust")]

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

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

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

pub mod tangle;
pub mod util;

0 comments on commit 08c9fb4

Please sign in to comment.