Skip to content

Commit

Permalink
chore: Delete lib.rs and move it's contents to utils and main.
Browse files Browse the repository at this point in the history
  • Loading branch information
ceyhunsen committed Mar 4, 2025
1 parent 61c515e commit d38bfb4
Show file tree
Hide file tree
Showing 24 changed files with 113 additions and 117 deletions.
2 changes: 1 addition & 1 deletion core/src/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{
},
},
tx_sender::TxSender,
EVMAddress,
utils::EVMAddress,
};
use bitcoin::hashes::Hash;
use bitcoin::{
Expand Down
5 changes: 3 additions & 2 deletions core/src/builder/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use super::script::{CheckSig, DepositScript, SpendableScript, TimelockScript};
use crate::bitvm_client::SECP;
use crate::errors::BridgeError;
use crate::{bitvm_client, EVMAddress};
use crate::{bitvm_client, utils::EVMAddress};
use bitcoin::address::NetworkUnchecked;
use bitcoin::Amount;
use bitcoin::{
Expand Down Expand Up @@ -165,6 +165,7 @@ mod tests {
bitvm_client::{self, SECP},
builder,
musig2::AggregateFromPublicKeys,
utils::EVMAddress,
};
use bitcoin::{
key::{Keypair, TapTweak},
Expand Down Expand Up @@ -275,7 +276,7 @@ mod tests {
let deposit_address = builder::address::generate_deposit_address(
nofn_xonly_pk,
recovery_taproot_address.as_unchecked(),
crate::EVMAddress(evm_address),
EVMAddress(evm_address),
Amount::from_sat(100_000_000),
bitcoin::Network::Regtest,
200,
Expand Down
2 changes: 1 addition & 1 deletion core/src/builder/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Currently generate_witness functions are not yet used.
#![allow(dead_code)]

use crate::EVMAddress;
use crate::utils::EVMAddress;
use bitcoin::hashes::{hash160, Hash};
use bitcoin::opcodes::OP_TRUE;
use bitcoin::script::PushBytesBuf;
Expand Down
1 change: 1 addition & 0 deletions core/src/builder/sighash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ pub fn create_nofn_sighash_stream(
/// and Disprove TX for each sequential_collateral_tx and kickoff_utxo. It yields the sighashes for these tx's for the input that has operators burn connector.
/// Possible future optimization: Each verifier already generates some of these TX's in create_operator_sighash_stream()
/// It is possible to for verifiers somehow return the required sighashes for operator signatures there too. But operators only needs to use sighashes included in this function.
#[allow(clippy::too_many_arguments)]
pub fn create_operator_sighash_stream(
db: Database,
operator_idx: usize,
Expand Down
8 changes: 3 additions & 5 deletions core/src/builder/transaction/creator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,15 +552,13 @@ pub fn create_round_txhandlers(

#[cfg(test)]
mod tests {

use crate::bitvm_client::ClementineBitVMPublicKeys;
use crate::builder::transaction::TransactionType;
use crate::rpc::clementine::{self};
use crate::{rpc::clementine::DepositParams, test::common::*, EVMAddress};
use crate::rpc::clementine::{AssertRequest, KickoffId, TransactionRequest};
use crate::{rpc::clementine::DepositParams, test::common::*, utils::EVMAddress};
use bitcoin::Txid;
use futures::future::try_join_all;

use crate::builder::transaction::TransactionType;
use crate::rpc::clementine::{AssertRequest, KickoffId, TransactionRequest};
use std::str::FromStr;

#[tokio::test(flavor = "multi_thread")]
Expand Down
2 changes: 1 addition & 1 deletion core/src/builder/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::rpc::clementine::GrpcTransactionId;
use crate::rpc::clementine::{
NormalSignatureKind, NormalTransactionId, NumberedTransactionId, NumberedTransactionType,
};
use crate::EVMAddress;
use crate::utils::EVMAddress;
use bitcoin::address::NetworkUnchecked;
use bitcoin::opcodes::all::{OP_PUSHNUM_1, OP_RETURN};
use bitcoin::script::Builder;
Expand Down
3 changes: 2 additions & 1 deletion core/src/builder/transaction/operator_reimburse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::constants::MIN_TAPROOT_AMOUNT;
use crate::errors::BridgeError;
use crate::rpc::clementine::KickoffId;
use crate::rpc::clementine::NormalSignatureKind;
use crate::{builder, UTXO};
use crate::{builder, utils::UTXO};
use bitcoin::hashes::Hash;
use bitcoin::script::PushBytesBuf;
use bitcoin::secp256k1::schnorr::Signature;
Expand All @@ -31,6 +31,7 @@ pub enum AssertScripts<'a> {
}

/// Creates a [`TxHandler`] for the `kickoff_tx`. This transaction will be sent by the operator
#[allow(clippy::too_many_arguments)]
pub fn create_kickoff_txhandler(
kickoff_id: KickoffId,
deposit_outpoint: OutPoint,
Expand Down
4 changes: 2 additions & 2 deletions core/src/database/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{
execute_query_with_tx,
operator::PublicHash,
rpc::clementine::{DepositSignatures, TaggedSignature},
UTXO,
utils::UTXO,
};
use bitcoin::{OutPoint, Txid, XOnlyPublicKey};
use bitvm::signatures::winternitz;
Expand Down Expand Up @@ -732,7 +732,7 @@ mod tests {
use crate::rpc::clementine::{
DepositSignatures, NormalSignatureKind, NumberedSignatureKind, TaggedSignature,
};
use crate::UTXO;
use crate::utils::UTXO;
use crate::{database::Database, test::common::*};
use std::str::FromStr;

Expand Down
4 changes: 2 additions & 2 deletions core/src/database/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//!
//! This module includes wrappers for easy parsing of the foreign types.
use crate::{errors::BridgeError, EVMAddress};
use crate::{errors::BridgeError, utils::EVMAddress};
use bitcoin::{
address::NetworkUnchecked,
block,
Expand Down Expand Up @@ -269,7 +269,7 @@ mod tests {
database::Database,
rpc::clementine::TaggedSignature,
test::common::*,
EVMAddress,
utils::EVMAddress,
};
use bitcoin::{
block::{self, Version},
Expand Down
3 changes: 2 additions & 1 deletion core/src/extended_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::sync::Arc;

use crate::builder;
use crate::errors::BridgeError;
use crate::EVMAddress;
use crate::utils::EVMAddress;
use bitcoin::address::NetworkUnchecked;
use bitcoin::Address;
use bitcoin::Amount;
Expand Down Expand Up @@ -132,6 +132,7 @@ impl ExtendedRpc {
}

#[tracing::instrument(skip(self), err(level = tracing::Level::ERROR), ret(level = tracing::Level::TRACE))]
#[allow(clippy::too_many_arguments)]
pub async fn check_deposit_utxo(
&self,
nofn_xonly_pk: XOnlyPublicKey,
Expand Down
87 changes: 0 additions & 87 deletions core/src/lib.rs

This file was deleted.

31 changes: 28 additions & 3 deletions core/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
use clementine_core::database::Database;
use clementine_core::servers::{
use database::Database;
use servers::{
create_aggregator_grpc_server, create_operator_grpc_server, create_verifier_grpc_server,
create_watchtower_grpc_server,
};
use clementine_core::utils::get_configuration_for_binaries;
use std::process::exit;
use utils::get_configuration_for_binaries;

pub mod actor;
pub mod aggregator;
pub mod bitcoin_syncer;
pub mod bitvm_client;
pub mod builder;
pub mod citrea;
pub mod cli;
pub mod config;
pub mod constants;
pub mod database;
pub mod errors;
pub mod extended_rpc;
pub mod header_chain_prover;
pub mod musig2;
pub mod operator;
pub mod rpc;
pub mod servers;
pub mod tx_sender;
pub mod utils;
pub mod verifier;
pub mod watchtower;

#[cfg(test)]
pub mod test;

#[tokio::main]
async fn main() {
Expand Down
2 changes: 1 addition & 1 deletion core/src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::rpc::clementine::KickoffId;
use crate::tx_sender::{
ActivatedWithOutpoint, ActivatedWithTxid, FeePayingType, TxDataForLogging, TxSender,
};
use crate::{builder, UTXO};
use crate::{builder, utils::UTXO};
use alloy::transports::http::reqwest::Url;
use bitcoin::consensus::deserialize;
use bitcoin::hashes::Hash;
Expand Down
2 changes: 1 addition & 1 deletion core/src/rpc/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ mod tests {
use crate::actor::Actor;
use crate::musig2::AggregateFromPublicKeys;
use crate::rpc::clementine::{self};
use crate::{builder, EVMAddress};
use crate::{builder, utils::EVMAddress};
use crate::{rpc::clementine::DepositParams, test::common::*};
use bitcoin::Txid;
use bitcoincore_rpc::RpcApi;
Expand Down
2 changes: 1 addition & 1 deletion core/src/rpc/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use super::error;
use crate::builder::transaction::sign::{AssertRequestData, TransactionRequestData};
use crate::builder::transaction::{DepositData, TransactionType};
use crate::errors::BridgeError;
use crate::EVMAddress;
use crate::utils::EVMAddress;
use bitcoin::hashes::{sha256d, FromSliceError, Hash};
use bitcoin::secp256k1::schnorr::Signature;
use bitcoin::{OutPoint, Txid};
Expand Down
2 changes: 1 addition & 1 deletion core/src/rpc/parser/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{
},
error::{self, invalid_argument},
},
EVMAddress,
utils::EVMAddress,
};
use bitcoin::secp256k1::schnorr::Signature;
use bitcoin::secp256k1::PublicKey;
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/common/citrea/requests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::citrea::LIGHT_CLIENT_ADDRESS;
use crate::errors::BridgeError;
use crate::test::common::citrea::parameters::get_transaction_params;
use crate::EVMAddress;
use crate::utils::EVMAddress;
use alloy::sol_types::SolValue;
use bitcoin::{Block, Transaction};
use jsonrpsee::core::client::ClientT;
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::rpc::clementine::clementine_operator_client::ClementineOperatorClient
use crate::rpc::clementine::clementine_verifier_client::ClementineVerifierClient;
use crate::rpc::clementine::clementine_watchtower_client::ClementineWatchtowerClient;
use crate::rpc::clementine::{DepositParams, Empty};
use crate::EVMAddress;
use crate::utils::EVMAddress;
use bitcoin::{OutPoint, Txid};
use bitcoincore_rpc::RpcApi;
pub use test_utils::*;
Expand Down
3 changes: 1 addition & 2 deletions core/src/test/common/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ use crate::servers::{
create_aggregator_unix_server, create_operator_unix_server, create_verifier_unix_server,
create_watchtower_unix_server,
};
use crate::utils::initialize_logger;
use crate::utils::{initialize_logger, EVMAddress, UTXO};
use crate::{
actor::Actor, builder, config::BridgeConfig, database::Database, errors::BridgeError,
extended_rpc::ExtendedRpc, musig2::AggregateFromPublicKeys,
};
use crate::{EVMAddress, UTXO};
use bitcoin::secp256k1::schnorr;
use std::net::TcpListener;
use tokio::sync::oneshot;
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
citrea::{self},
create_test_config_with_thread_name, run_single_deposit,
},
EVMAddress,
utils::EVMAddress,
};
use async_trait::async_trait;
use bitcoincore_rpc::RpcApi;
Expand Down
2 changes: 1 addition & 1 deletion core/src/test/full_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::rpc::clementine::{
};
use crate::test::common::*;
use crate::tx_sender::{FeePayingType, TxSender};
use crate::EVMAddress;
use crate::utils::EVMAddress;
use bitcoin::consensus::{self};
use bitcoin::hashes::Hash;
use bitcoin::Transaction;
Expand Down
1 change: 1 addition & 0 deletions core/src/tx_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ impl TxSender {
/// It will automatically save inputs as cancelled outpoints.
/// It will automatically save inputs as activated outpoints.
#[tracing::instrument(err(level = tracing::Level::ERROR), ret(level = tracing::Level::TRACE))]
#[allow(clippy::too_many_arguments)]
pub async fn try_to_send(
&self,
dbtx: DatabaseTransaction<'_, '_>,
Expand Down
Loading

0 comments on commit d38bfb4

Please sign in to comment.