Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check: fix benches with deps upgrade #245

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions dlc-manager/benches/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use dlc_messages::oracle_msgs::EventDescriptor;
use dlc_messages::oracle_msgs::OracleAnnouncement;
use dlc_messages::oracle_msgs::OracleEvent;
use secp256k1_zkp::{
global::SECP256K1, rand::thread_rng, schnorr::Signature, KeyPair, SecretKey, XOnlyPublicKey,
global::SECP256K1, rand::thread_rng, schnorr::Signature, Keypair, SecretKey, XOnlyPublicKey,
};
use std::str::FromStr;

Expand Down Expand Up @@ -131,15 +131,15 @@ fn create_contract_descriptor() -> ContractDescriptor {
}

fn get_schnorr_pubkey() -> XOnlyPublicKey {
XOnlyPublicKey::from_keypair(&KeyPair::new(SECP256K1, &mut thread_rng())).0
XOnlyPublicKey::from_keypair(&Keypair::new(SECP256K1, &mut thread_rng())).0
}

fn get_pubkey() -> secp256k1_zkp::PublicKey {
secp256k1_zkp::PublicKey::from_secret_key(SECP256K1, &SecretKey::new(&mut thread_rng()))
}

fn get_p2wpkh_script_pubkey() -> ScriptBuf {
ScriptBuf::new_v0_p2wpkh(&WPubkeyHash::hash(&get_pubkey().serialize()))
ScriptBuf::new_p2wpkh(&WPubkeyHash::hash(&get_pubkey().serialize()))
}

fn create_oracle_announcements() -> Vec<OracleAnnouncement> {
Expand Down Expand Up @@ -234,7 +234,7 @@ pub fn sign_bench(c: &mut Criterion) {
TOTAL_COLLATERAL,
&seckey,
&dlc_transactions.funding_script_pubkey,
fund_output_value,
fund_output_value.to_sat(),
&dlc_transactions.cets,
0,
)
Expand All @@ -258,7 +258,7 @@ pub fn verify_bench(c: &mut Criterion) {
TOTAL_COLLATERAL,
&seckey,
&dlc_transactions.funding_script_pubkey,
fund_output_value,
fund_output_value.to_sat(),
&dlc_transactions.cets,
0,
)
Expand All @@ -272,7 +272,7 @@ pub fn verify_bench(c: &mut Criterion) {
SECP256K1,
&pubkey,
&dlc_transactions.funding_script_pubkey,
fund_output_value,
fund_output_value.to_sat(),
&dlc_transactions.cets,
adaptor_signatures,
0,
Expand Down
22 changes: 8 additions & 14 deletions dlc/benches/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mod benches {
use dlc::*;
use rayon::prelude::*;
use secp256k1_zkp::{
global::SECP256K1, rand::thread_rng, rand::RngCore, KeyPair, Message, PublicKey, SecretKey,
global::SECP256K1, rand::thread_rng, rand::RngCore, Keypair, Message, PublicKey, SecretKey,
};

use test::{black_box, Bencher};
Expand All @@ -28,14 +28,14 @@ mod benches {
const ALL_BASE: usize = 2;

fn generate_oracle_info(nb_nonces: usize) -> OracleInfo {
let public_key = KeyPair::new(SECP256K1, &mut thread_rng())
let public_key = Keypair::new(SECP256K1, &mut thread_rng())
.x_only_public_key()
.0;

let mut nonces = Vec::with_capacity(nb_nonces);
for _ in 0..nb_nonces {
nonces.push(
KeyPair::new(SECP256K1, &mut thread_rng())
Keypair::new(SECP256K1, &mut thread_rng())
.x_only_public_key()
.0,
);
Expand All @@ -57,7 +57,7 @@ mod benches {
.map(|_| {
let mut buf = [0u8; 32];
thread_rng().fill_bytes(&mut buf);
Message::from_slice(&buf).unwrap()
Message::from_digest_slice(&buf).unwrap()
})
.collect()
})
Expand All @@ -76,11 +76,7 @@ mod benches {
for _ in 0..nb_oracles {
tmp.push(
cur.iter()
.map(|x| {
Message::from_hashed_data::<secp256k1_zkp::hashes::sha256::Hash>(&[
(*x) as u8,
])
})
.map(|x| Message::from_digest_slice(&[(*x) as u8]).unwrap())
.collect(),
);
}
Expand Down Expand Up @@ -111,9 +107,7 @@ mod benches {
(0..base)
.map(|i| {
(0..nb_nonces)
.map(|_| {
Message::from_hashed_data::<secp256k1_zkp::hashes::sha256::Hash>(&[i as u8])
})
.map(|_| Message::from_digest_slice(&[i as u8]).unwrap())
.collect()
})
.collect()
Expand Down Expand Up @@ -147,7 +141,7 @@ mod benches {
&oracle_infos,
&seckey,
&funding_script_pubkey(),
cet.output[0].value,
cet.output[0].value.to_sat(),
&generate_single_outcome_messages(SINGLE_NB_ORACLES, SINGLE_NB_NONCES),
)
.unwrap(),
Expand All @@ -170,7 +164,7 @@ mod benches {
adaptor_point,
&seckey,
&funding_script_pubkey(),
cet.output[0].value,
cet.output[0].value.to_sat(),
)
.unwrap(),
)
Expand Down
Loading