Skip to content

Commit

Permalink
cleaned logs (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
antiyro authored Jun 7, 2024
1 parent b9799ff commit 4fcd311
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 185 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Next release

- fix(logs): fixed some logs and others
- fix(rpc): fixed block storage column
- chore: update dependencies
- fix(hashers): cleaned hashers using types core hashers and Felt
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

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

6 changes: 1 addition & 5 deletions crates/client/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ name = "mc-db"
version.workspace = true
edition.workspace = true
description = "Starknet database backend"
authors = [
"Kasar <https://github.com/kasarlabs>",
"KSS <https://github.com/keep-starknet-strange>",
"Substrate DevHub <https://github.com/substrate-developer-hub>",
]
authors = ["Kasar <https://github.com/kasarlabs>"]
homepage = "https://github.com/kasarlabs/deoxys"
license = "MIT"
publish = false
Expand Down
2 changes: 1 addition & 1 deletion crates/client/db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ impl Drop for DBDropHook {
fn drop(&mut self) {
let backend = BACKEND_SINGLETON.get().unwrap() as *const _ as *mut Arc<DeoxysBackend>;
let db = DB_SINGLETON.get().unwrap() as *const _ as *mut Arc<DB>;
log::info!("⏳ Closing database...");
log::info!("⏳ Closing database properly...");
// TODO(HACK): again, i can't emphasize enough how bad of a hack this is
unsafe {
std::ptr::drop_in_place(backend);
Expand Down
6 changes: 1 addition & 5 deletions crates/client/rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
[package]
authors = [
"Kasar <https://github.com/kasarlabs>",
"KSS <https://github.com/keep-starknet-strange>",
"Substrate DevHub <https://github.com/substrate-developer-hub>",
]
authors = ["Kasar <https://github.com/kasarlabs>"]
description = "Starknet RPC compatibility layer for Substrate"
edition.workspace = true
homepage = "https://github.com/kasarlabs/deoxys"
Expand Down
2 changes: 1 addition & 1 deletion crates/client/rpc/src/methods/read/get_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub async fn get_events(starknet: &Starknet, filter: EventFilterWithPage) -> Rpc
return Err(StarknetRpcApiError::PageSizeTooBig.into());
}

// Get the substrate block numbers for the requested range
// Get the block numbers for the requested range
let (from_block, to_block, latest_block) =
block_range(starknet, filter.event_filter.from_block, filter.event_filter.to_block)?;

Expand Down
155 changes: 0 additions & 155 deletions crates/client/sync/src/commitments/lib.rs

This file was deleted.

8 changes: 4 additions & 4 deletions crates/client/sync/src/l1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use ethers::types::{Address, BlockNumber as EthBlockNumber, Filter, TransactionR
use ethers::utils::hex::decode;
use futures::stream::StreamExt;
use mc_db::{DeoxysBackend, WriteBatchWithTransaction};
use mp_felt::Felt252Wrapper;
use mp_felt::{trim_hash, Felt252Wrapper};
use primitive_types::H256;
use prometheus_endpoint::prometheus::core::Number;
use reqwest::Url;
Expand Down Expand Up @@ -172,10 +172,10 @@ impl EthereumClient {
/// Update the L1 state with the latest data
pub fn update_l1(state_update: L1StateUpdate, block_metrics: Option<BlockMetrics>) -> anyhow::Result<()> {
log::info!(
"🔄 Updated L1 head: Number: #{}, Hash: {}, Root: {}",
"🔄 Updated L1 head #{} ({}) with state root ({})",
state_update.block_number,
state_update.block_hash,
state_update.global_root
trim_hash(&Felt252Wrapper::from(state_update.block_hash)),
trim_hash(&Felt252Wrapper::from(state_update.global_root))
);

if let Some(block_metrics) = block_metrics {
Expand Down
7 changes: 6 additions & 1 deletion crates/client/sync/src/l2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ async fn l2_verify_and_apply_task(
verify: bool,
backup_every_n_blocks: Option<u64>,
block_metrics: Option<BlockMetrics>,
starting_block: u64,
sync_timer: Arc<Mutex<Option<Instant>>>,
telemetry: TelemetryHandle,
) -> anyhow::Result<()> {
Expand Down Expand Up @@ -149,6 +150,7 @@ async fn l2_verify_and_apply_task(
update_sync_metrics(
// &mut command_sink,
block_n,
starting_block,
block_metrics.as_ref(),
sync_timer.clone(),
)
Expand Down Expand Up @@ -301,6 +303,7 @@ pub async fn sync(
provider: SequencerGatewayProvider,
config: L2SyncConfig,
block_metrics: Option<BlockMetrics>,
starting_block: u64,
chain_id: StarkFelt,
telemetry: TelemetryHandle,
) -> anyhow::Result<()> {
Expand Down Expand Up @@ -335,6 +338,7 @@ pub async fn sync(
config.verify,
config.backup_every_n_blocks,
block_metrics,
starting_block,
Arc::clone(&sync_timer),
telemetry,
));
Expand All @@ -349,6 +353,7 @@ pub async fn sync(

async fn update_sync_metrics(
block_number: u64,
starting_block: u64,
block_metrics: Option<&BlockMetrics>,
sync_timer: Arc<Mutex<Option<Instant>>>,
) -> anyhow::Result<()> {
Expand All @@ -370,7 +375,7 @@ async fn update_sync_metrics(
let sync_time = block_metrics.l2_sync_time.get() + elapsed_time;
block_metrics.l2_sync_time.set(sync_time);
block_metrics.l2_latest_sync_time.set(elapsed_time);
block_metrics.l2_avg_sync_time.set(block_metrics.l2_sync_time.get() / block_number as f64);
block_metrics.l2_avg_sync_time.set(block_metrics.l2_sync_time.get() / (block_number - starting_block) as f64);
}

Ok(())
Expand Down
3 changes: 2 additions & 1 deletion crates/client/sync/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub mod starknet_sync_worker {
.unwrap_or_default() as _
};

log::info!(" Starting L2 sync from block {}", starting_block);
log::info!("⛓️ Starting L2 sync from block {}", starting_block);

let provider = SequencerGatewayProvider::new(
fetch_config.gateway.clone(),
Expand All @@ -74,6 +74,7 @@ pub mod starknet_sync_worker {
backup_every_n_blocks,
},
block_metrics,
starting_block,
chain_id,
telemetry,
),
Expand Down
3 changes: 2 additions & 1 deletion crates/client/sync/src/utils/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::sync::Arc;
use blockifier::block::GasPrices;
use mp_block::{DeoxysBlock, DeoxysBlockInfo, DeoxysBlockInner};
use mp_felt::Felt252Wrapper;
use mp_hashers::pedersen::PedersenHasher;
use starknet_api::block::BlockHash;
use starknet_api::hash::StarkFelt;
use starknet_api::transaction::{
Expand Down Expand Up @@ -70,7 +71,7 @@ pub fn convert_block(block: p::Block, chain_id: StarkFelt) -> Result<DeoxysBlock
extra_data,
};

let computed_block_hash: FieldElement = header.hash::<mp_hashers::pedersen::PedersenHasher>().into();
let computed_block_hash: FieldElement = header.hash::<PedersenHasher>().into();
// mismatched block hash is allowed for blocks 1466..=2242
if computed_block_hash != block_hash && !(1466..=2242).contains(&block_number) {
return Err(L2SyncError::MismatchedBlockHash(block_number));
Expand Down
7 changes: 2 additions & 5 deletions crates/node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
[package]
authors = [
"Kasar <https://github.com/kasarlabs>",
"KSS <https://github.com/keep-starknet-strange>",
"Substrate DevHub <https://github.com/substrate-developer-hub>",
]
authors = ["Kasar <https://github.com/kasarlabs>"]
description = "Deoxys node"
edition.workspace = true
homepage = "https://github.com/kasarlabs/deoxys"
Expand Down Expand Up @@ -51,6 +47,7 @@ reqwest = { workspace = true }
url = { workspace = true }

anyhow.workspace = true
chrono = "0.4.38"
env_logger = "0.11.3"
forwarded-header-value = "0.1.1"
governor.workspace = true
Expand Down
18 changes: 12 additions & 6 deletions crates/node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![warn(missing_docs)]

use anyhow::Context;
use chrono::Local;
use clap::Parser;

mod cli;
Expand All @@ -11,16 +12,21 @@ mod util;
use cli::RunCmd;
use mc_telemetry::{SysInfo, TelemetryService};
use service::{DatabaseService, RpcService, SyncService};
use std::io::Write;
use tokio::task::JoinSet;

const GREET_IMPL_NAME: &str = "Deoxys";
const GREET_SUPPORT_URL: &str = "https://kasar.io";
const GREET_AUTHORS: &[&str] =
&["Kasar <https://github.com/kasarlabs>", "KSS <https://github.com/keep-starknet-strange>"];
const GREET_AUTHORS: &[&str] = &["Kasar <https://github.com/kasarlabs>"];

#[tokio::main]
async fn main() -> anyhow::Result<()> {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info"))
.format(|buf, record| {
let ts = Local::now().format("%Y-%m-%d %H:%M:%S");
writeln!(buf, "[{} {}] {}", ts, record.level(), record.args())
})
.init();

crate::util::setup_rayon_threadpool()?;
let mut run_cmd: RunCmd = RunCmd::parse();
Expand All @@ -30,11 +36,11 @@ async fn main() -> anyhow::Result<()> {
log::info!("👽 {} Node", GREET_IMPL_NAME);
log::info!("✌️ Version {}", node_version);
for author in GREET_AUTHORS {
log::info!("❤️ by {}", author);
log::info!("❤️ By {}", author);
}
log::info!("💁 Support URL: {}", GREET_SUPPORT_URL);
log::info!("👤 Role: full node");
log::info!("🏷 Node name: {}", node_name);
log::info!("🏷 Node Name: {}", node_name);
log::info!("👤 Role: Full Node");

let sys_info = SysInfo::probe();
sys_info.show();
Expand Down

0 comments on commit 4fcd311

Please sign in to comment.