Skip to content

Commit

Permalink
fix: apply lint and fmt fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajil1213 committed Jul 22, 2024
1 parent 1cc01dc commit 4978fcf
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 27 deletions.
3 changes: 1 addition & 2 deletions crates/btcio/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![allow(dead_code)] // TODO: remove this once `get_height_blkid` and `deepest_block` are used.
//! Input-output with Bitcoin, implementing L1 chain trait.
pub mod status;
pub mod reader;
pub mod rpc;

pub mod status;
10 changes: 4 additions & 6 deletions crates/btcio/src/reader/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use tracing::*;
use super::config::ReaderConfig;
use super::messages::{BlockData, L1Event};
use crate::rpc::traits::L1Client;
use crate::rpc::types::RpcBlockchainInfo;
use crate::status::{apply_status_updates, StatusUpdate};

fn filter_interesting_txs(block: &Block) -> Vec<u32> {
Expand Down Expand Up @@ -173,10 +172,9 @@ async fn do_reader_task(
let cur_height = state.cur_height;
let poll_span = debug_span!("l1poll", %cur_height);

if let Err(err) =
poll_for_new_blocks(client, &event_tx, &config, &mut state, status_updates)
.instrument(poll_span)
.await
if let Err(err) = poll_for_new_blocks(client, event_tx, &config, &mut state, status_updates)

Check warning on line 175 in crates/btcio/src/reader/query.rs

View check run for this annotation

Codecov / codecov/patch

crates/btcio/src/reader/query.rs#L175

Added line #L175 was not covered by tests
.instrument(poll_span)
.await
{
warn!(%cur_height, err = %err, "failed to poll Bitcoin client");
status_updates.push(StatusUpdate::RpcError(err.to_string()));

Check warning on line 180 in crates/btcio/src/reader/query.rs

View check run for this annotation

Codecov / codecov/patch

crates/btcio/src/reader/query.rs#L179-L180

Added lines #L179 - L180 were not covered by tests
Expand All @@ -199,7 +197,7 @@ async fn do_reader_task(
current_time.elapsed().as_millis() as u64
));

Check warning on line 198 in crates/btcio/src/reader/query.rs

View check run for this annotation

Codecov / codecov/patch

crates/btcio/src/reader/query.rs#L196-L198

Added lines #L196 - L198 were not covered by tests

apply_status_updates(&status_updates, l1_status.clone()).await;
apply_status_updates(status_updates, l1_status.clone()).await;

Check warning on line 200 in crates/btcio/src/reader/query.rs

View check run for this annotation

Codecov / codecov/patch

crates/btcio/src/reader/query.rs#L200

Added line #L200 was not covered by tests
}
}

Expand Down
2 changes: 0 additions & 2 deletions crates/btcio/src/rpc/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ use std::{fmt::Display, str::FromStr};
use async_trait::async_trait;
use bitcoin::Txid;

use anyhow::anyhow;
use base64::engine::general_purpose;
use base64::Engine;
use bitcoin::hashes::sha256d::Hash;
use bitcoin::hashes::Hash as _;
// use async_recursion::async_recursion;
use bitcoin::{
Expand Down
5 changes: 3 additions & 2 deletions crates/btcio/src/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ pub async fn apply_status_updates(
StatusUpdate::RpcConnected(connected) => {
l1_status_writer.bitcoin_rpc_connected = *connected
}
StatusUpdate::RpcError(err_string) => l1_status_writer.last_rpc_error = Some(err_string.clone()),
StatusUpdate::RpcError(err_string) => {
l1_status_writer.last_rpc_error = Some(err_string.clone())

Check warning on line 29 in crates/btcio/src/status.rs

View check run for this annotation

Codecov / codecov/patch

crates/btcio/src/status.rs#L28-L29

Added lines #L28 - L29 were not covered by tests
}
StatusUpdate::CurTip(tip) => l1_status_writer.cur_tip_blkid = tip.clone(),
}

}
}
6 changes: 3 additions & 3 deletions crates/consensus-logic/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ fn poll_horizon_l1_block<D: Database>(
}
retries += 1;
}
return Err(anyhow::anyhow!(
Err(anyhow::anyhow!(
"Max retries exceeded for polling horizon l1 block"
));
))

Check warning on line 50 in crates/consensus-logic/src/genesis.rs

View check run for this annotation

Codecov / codecov/patch

crates/consensus-logic/src/genesis.rs#L48-L50

Added lines #L48 - L50 were not covered by tests
}

/// Inserts approprate records into the database to prepare it for syncing the
/// Inserts appropriate records into the database to prepare it for syncing the
/// rollup. Requires that the horizon block header is present in the database.
pub fn init_genesis_states<D: Database>(params: &Params, database: &D) -> anyhow::Result<()> {
debug!("preparing database genesis state!");
Expand Down
7 changes: 1 addition & 6 deletions crates/consensus-logic/src/l1_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ where
Ok(())
}

fn handle_event<L1D>(
event: L1Event,
l1db: &L1D,
csm_ctl: &CsmController,
) -> anyhow::Result<()>
fn handle_event<L1D>(event: L1Event, l1db: &L1D, csm_ctl: &CsmController) -> anyhow::Result<()>

Check warning on line 36 in crates/consensus-logic/src/l1_handler.rs

View check run for this annotation

Codecov / codecov/patch

crates/consensus-logic/src/l1_handler.rs#L36

Added line #L36 was not covered by tests
where
L1D: L1DataStore + Sync + Send + 'static,
{
Expand Down Expand Up @@ -76,7 +72,6 @@ where
let ev = SyncEvent::L1Block(blockdata.block_num(), blkid.into());
csm_ctl.submit_event(ev)?;


Ok(())
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ borsh = { workspace = true }
digest = { workspace = true }
hex = { workspace = true }
reth-primitives = { workspace = true }
sha2 = { workspace = true }
serde = { workspace = true }
sha2 = { workspace = true }

[dev-dependencies]
hex = { workspace = true }
1 change: 0 additions & 1 deletion crates/primitives/src/l1.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::fmt;
use std::time::Duration;

use arbitrary::Arbitrary;
use bitcoin::hashes::Hash;
Expand Down
2 changes: 1 addition & 1 deletion sequencer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ async-trait = { workspace = true }
bitcoin = { workspace = true }
jsonrpsee = { workspace = true, features = ["server", "macros"] }
parking_lot = { workspace = true }
reqwest = { workspace = true }
reth-ipc = { workspace = true }
reth-primitives = { workspace = true }
reth-rpc-api = { workspace = true }
Expand All @@ -35,4 +36,3 @@ thiserror = { workspace = true }
threadpool = { workspace = true }
tokio = { workspace = true }
tracing = { workspace = true }
reqwest = { workspace = true }
4 changes: 2 additions & 2 deletions sequencer/src/l1_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::Arc;
use std::thread;

use alpen_vertex_primitives::l1::L1Status;
use tokio::sync::{mpsc,RwLock};
use tokio::sync::{mpsc, RwLock};

use alpen_vertex_btcio::reader::{
config::ReaderConfig, messages::L1Event, query::bitcoin_data_reader_task,
Expand Down Expand Up @@ -41,7 +41,7 @@ where
ev_tx,
current_block_height,
config.clone(),
l1_status.clone()
l1_status.clone(),

Check warning on line 44 in sequencer/src/l1_reader.rs

View check run for this annotation

Codecov / codecov/patch

sequencer/src/l1_reader.rs#L44

Added line #L44 was not covered by tests
));

let l1db = db.l1_store().clone();
Expand Down
2 changes: 1 addition & 1 deletion test/fn_btcio_read_reorg.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def main(self, ctx: flexitest.RunContext):
btcrpc: BitcoindClient = btc.create_rpc()
seqrpc = seq.create_rpc()

# Add two blocks since each block is generated every 0.5 seconds and we need atleast 4 or more blocks to invalidate 3 blocks at the end
# Add two blocks since each block is generated every 0.5 seconds and we need at least 4 or more blocks to invalidate 3 blocks at the end
time.sleep(3)
l1stat = seqrpc.alp_l1status()
# relative height is chosen such that we can have arbitrary number of blocks which is affected by the time.sleep above
Expand Down

0 comments on commit 4978fcf

Please sign in to comment.