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

Fix calibration due to delak change #1004

Merged
merged 2 commits into from
Aug 22, 2023
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::common::HostCostMeasurement;
use ed25519_dalek::{PublicKey, SecretKey};
use ed25519_dalek::SigningKey;
use rand::rngs::StdRng;
use soroban_env_host::{cost_runner::ComputeEd25519PubKeyRun, Host};

Expand All @@ -13,8 +13,7 @@ impl HostCostMeasurement for ComputeEd25519PubKeyMeasure {
type Runner = ComputeEd25519PubKeyRun;

fn new_random_case(_host: &Host, rng: &mut StdRng, _input: u64) -> Vec<u8> {
let secret = SecretKey::generate(rng);
let public: PublicKey = (&secret).into();
public.as_bytes().as_slice().into()
let key = SigningKey::generate(rng);
key.verifying_key().to_bytes().into()
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::common::HostCostMeasurement;
use ed25519_dalek::{Keypair, PublicKey, Signature, Signer};
use ed25519_dalek::{Signature, Signer, SigningKey, VerifyingKey};
use rand::rngs::StdRng;
use soroban_env_host::{
cost_runner::{VerifyEd25519SigRun, VerifyEd25519SigSample},
Expand All @@ -16,10 +16,10 @@ impl HostCostMeasurement for VerifyEd25519SigMeasure {

fn new_random_case(_host: &Host, rng: &mut StdRng, input: u64) -> VerifyEd25519SigSample {
let size = 1 + input * Self::STEP_SIZE;
let keypair: Keypair = Keypair::generate(rng);
let key: PublicKey = keypair.public;
let signingkey: SigningKey = SigningKey::generate(rng);
let key: VerifyingKey = signingkey.verifying_key();
let msg: Vec<u8> = (0..size).map(|x| x as u8).collect();
let sig: Signature = keypair.sign(msg.as_slice());
let sig: Signature = signingkey.sign(msg.as_slice());
VerifyEd25519SigSample { key, msg, sig }
}
}
2 changes: 1 addition & 1 deletion soroban-env-host/benches/common/cost_types/vm_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl HostCostMeasurement for VmInstantiationMeasure {

fn new_random_case(_host: &Host, rng: &mut StdRng, _input: u64) -> VmInstantiationSample {
let id: xdr::Hash = [0; 32].into();
let idx = rng.gen_range(0..10) % util::TEST_WASMS.len();
let idx = rng.gen_range(0..=10) % util::TEST_WASMS.len();
let wasm = util::TEST_WASMS[idx].into();
VmInstantiationSample { id: Some(id), wasm }
}
Expand Down
2 changes: 1 addition & 1 deletion soroban-env-host/benches/common/measure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ pub fn measure_cost_variation<HCM: HostCostMeasurement>(
1 => Some(HCM::new_best_case(host, &mut rng)),
2 => Some(HCM::new_worst_case(host, &mut rng, large_input)),
n if n < count => {
let input = rng.gen_range(1..2 + large_input);
let input = rng.gen_range(1..=2 + large_input);
Some(HCM::new_random_case(host, &mut rng, input))
}
_ => None,
Expand Down