Skip to content

Commit

Permalink
fix: various build and configuration errors
Browse files Browse the repository at this point in the history
  • Loading branch information
distractedm1nd authored and sebasti810 committed Jul 8, 2024
1 parent 0b47213 commit e144bdc
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ edition = "2021"
[features]
default = []
key_transparency = []
testing = []
ci = []

[dependencies]
Expand Down Expand Up @@ -49,6 +48,6 @@ ahash = "0.8.7"
celestia-rpc = "0.2.0"
celestia-types = "0.2.0"
mockall = "0.12.1"
keystore = { git = "https://github.com/deltadevsde/keystore", rev = "c817b6797ac6642d93af96949a893f58ba129e5c" }
keystore = { git = "https://github.com/deltadevsde/keystore", rev = "40f21a41afd0654091bb0881665288034ab8533f" }
pyroscope = "0.5.7"
pyroscope_pprofrs = "0.2.7"
20 changes: 7 additions & 13 deletions src/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use config::{builder::DefaultState, ConfigBuilder, File, FileFormat};
use serde::Deserialize;
use std::sync::Arc;

#[cfg(not(test))]
use crate::da::CelestiaConnection;
#[cfg(test)]
use crate::da::LocalDataAvailabilityLayer;
use crate::da::{
CelestiaConnection,
LocalDataAvailabilityLayer
};

use crate::da::DataAvailabilityLayer;

Expand Down Expand Up @@ -67,7 +67,6 @@ pub struct Config {
pub enum DALayerOption {
#[default]
Celestia,
#[cfg(test)]
InMemory,
None,
}
Expand All @@ -88,7 +87,7 @@ impl Default for WebServerConfig {
}

#[derive(Debug, Deserialize, Clone)]
struct CelestiaConfig {
pub struct CelestiaConfig {
connection_string: String,
namespace_id: String,
}
Expand Down Expand Up @@ -164,7 +163,6 @@ pub fn load_config(args: CommandLineArgs) -> Result<Config, config::ConfigError>
})
}

#[cfg(not(test))]
pub async fn initialize_da_layer(config: &Config) -> Arc<dyn DataAvailabilityLayer + 'static> {
match &config.da_layer {
DALayerOption::Celestia => {
Expand All @@ -182,11 +180,7 @@ pub async fn initialize_da_layer(config: &Config) -> Arc<dyn DataAvailabilityLay
}
}
}
DALayerOption::InMemory => Arc::new(LocalDataAvailabilityLayer::new()) as Arc<dyn DataAvailabilityLayer + 'static>,
DALayerOption::None => panic!("No DALayer"),
}
}

#[cfg(test)]
pub async fn initialize_da_layer(_config: &Config) -> Arc<dyn DataAvailabilityLayer + 'static> {
Arc::new(LocalDataAvailabilityLayer::new()) as Arc<dyn DataAvailabilityLayer + 'static>
}
}
16 changes: 4 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,7 @@ use storage::RedisConnections;
#[macro_use]
extern crate log;

/// The main function that initializes and runs the Actix web server.
///
/// # Behavior
/// 1. Loads environment variables using `dotenv` and sets up the server configuration.
/// 2. Spawns a task that runs the `initialize_or_increment_epoch_state` function in a loop for epoch-based behavior of the application
/// 3. Sets up CORS (Cross-Origin Resource Sharing) rules to allow specific origins and headers.
/// 4. Registers routes for various services.
/// 5. Binds the server to the configured IP and port.
/// 6. Runs the server and awaits its completion.
/// The main function that initializes and runs a deimos client.
#[actix_web::main]
async fn main() -> std::io::Result<()> {
let args = CommandLineArgs::parse();
Expand All @@ -44,10 +36,8 @@ async fn main() -> std::io::Result<()> {
let da = initialize_da_layer(&config).await;

let node: Arc<dyn NodeType> = match args.command {
// LightClients need a DA layer, so we can unwrap here
Commands::LightClient {} => Arc::new(LightClient::new(da, config.public_key)),
Commands::Sequencer {} => Arc::new(Sequencer::new(
// TODO: convert error to std::io::Error...is there a better solution?
Arc::new(
RedisConnections::new()
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?,
Expand All @@ -58,5 +48,7 @@ async fn main() -> std::io::Result<()> {
)),
};

node.start().await
node.start()
.await
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))
}
5 changes: 3 additions & 2 deletions src/node_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use async_trait::async_trait;
use crypto_hash::{hex_digest, Algorithm};
use ed25519_dalek::{Signer, SigningKey};
use indexed_merkle_tree::{error::MerkleTreeError, node::Node, tree::IndexedMerkleTree};
use std::{self, io::ErrorKind, sync::Arc, time::Duration};
use std::{self, sync::Arc, time::Duration};
use tokio::{
sync::{
mpsc::{channel, Receiver, Sender},
Expand Down Expand Up @@ -201,7 +201,8 @@ impl Sequencer {
"sequencer_loop: finalized epoch {}",
self.db.get_epoch().unwrap()
);
epoch_buffer.send(epoch);
// should panic here if we cannot send to buffer
epoch_buffer.send(epoch).await.unwrap();
}
Err(e) => error!("sequencer_loop: finalizing epoch: {}", e),
}
Expand Down
2 changes: 1 addition & 1 deletion src/zk_snark/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
error::{DeimosError, GeneralError, ProofError},
error::{DeimosError, GeneralError},
storage::ChainEntry,
utils::create_and_verify_snark,
};
Expand Down

0 comments on commit e144bdc

Please sign in to comment.