-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
Bench for Move based transfer with Gas #190
Changes from 9 commits
9244d05
7a75de3
a895e65
ef56ea9
311452b
a0b12bc
e796f2e
66da9f3
ca192db
8beb52b
108c64b
dbbc26e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,12 @@ | |
use bytes::Bytes; | ||
use fastpay::{network, transport}; | ||
use fastpay_core::authority::*; | ||
use fastx_types::FASTX_FRAMEWORK_ADDRESS; | ||
use fastx_types::{base_types::*, committee::*, messages::*, object::Object, serialize::*}; | ||
use futures::stream::StreamExt; | ||
use log::*; | ||
use move_core_types::ident_str; | ||
use rand::Rng; | ||
use std::time::{Duration, Instant}; | ||
use structopt::StructOpt; | ||
use tokio::runtime::Runtime; | ||
|
@@ -67,6 +70,9 @@ struct ClientServerBenchmark { | |
/// Number of database cpus | ||
#[structopt(long, default_value = "1")] | ||
db_cpus: usize, | ||
/// Use Move orders | ||
#[structopt(long)] | ||
use_move: bool, | ||
} | ||
#[derive(Debug, Clone, PartialEq, EnumString)] | ||
enum BenchmarkType { | ||
|
@@ -160,20 +166,30 @@ impl ClientServerBenchmark { | |
let keypair = get_key_pair(); | ||
let object_id: ObjectID = ObjectID::random(); | ||
|
||
let object = Object::with_id_owner_for_testing(object_id, keypair.0); | ||
let object = if self.use_move { | ||
Object::with_id_owner_gas_coin_object_for_testing( | ||
ObjectID::random(), | ||
SequenceNumber::new(), | ||
keypair.0, | ||
rand::thread_rng().gen_range(0..0xFFFFFF), | ||
) | ||
} else { | ||
Object::with_id_owner_for_testing(object_id, keypair.0) | ||
}; | ||
|
||
assert!(object.version() == SequenceNumber::from(0)); | ||
let object_ref = object.to_object_reference(); | ||
state.init_order_lock(object_ref).await; | ||
account_objects.push((keypair.0, object.clone(), keypair.1)); | ||
state.insert_object(object).await; | ||
account_objects.push((keypair.0, object_ref, keypair.1)); | ||
|
||
let gas_object_id = ObjectID::random(); | ||
let gas_object = Object::with_id_owner_for_testing(gas_object_id, keypair.0); | ||
assert!(gas_object.version() == SequenceNumber::from(0)); | ||
let gas_object_ref = gas_object.to_object_reference(); | ||
state.init_order_lock(gas_object_ref).await; | ||
gas_objects.push(gas_object.clone()); | ||
state.insert_object(gas_object).await; | ||
gas_objects.push(gas_object_ref); | ||
} | ||
state | ||
}); | ||
|
@@ -182,15 +198,47 @@ impl ClientServerBenchmark { | |
// Make one transaction per account (transfer order + confirmation). | ||
let mut orders: Vec<Bytes> = Vec::new(); | ||
let mut next_recipient = get_key_pair().0; | ||
for ((pubx, object_ref, secx), gas_payment) in account_objects.iter().zip(gas_objects) { | ||
let transfer = Transfer { | ||
object_ref: *object_ref, | ||
sender: *pubx, | ||
recipient: Address::FastPay(next_recipient), | ||
gas_payment, | ||
for ((account_addr, object, secret), gas_obj) in account_objects.iter().zip(gas_objects) { | ||
let object_ref = object.to_object_reference(); | ||
let gas_object_ref = gas_obj.to_object_reference(); | ||
|
||
let order = if self.use_move { | ||
// TODO: authority should not require seq# or digets for package in Move calls. Use dummy values | ||
let framework_obj_ref = ( | ||
FASTX_FRAMEWORK_ADDRESS, | ||
SequenceNumber::new(), | ||
ObjectDigest::new([0; 32]), | ||
); | ||
|
||
Order::new_move_call( | ||
*account_addr, | ||
framework_obj_ref, | ||
ident_str!("GAS").to_owned(), | ||
ident_str!("transfer").to_owned(), | ||
Vec::new(), | ||
// Do I really need this TypeArg? Does not make a diff | ||
|
||
//vec![move_core_types::language_storage::TypeTag::Struct( | ||
//GasCoin::type_(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sblackshear specifying type_args did not make a difference here so I committed them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We will need them eventually, but punting on them until we use |
||
//)], | ||
gas_object_ref, | ||
vec![object_ref], | ||
vec![bcs::to_bytes(&next_recipient.to_vec()).unwrap()], | ||
1000, | ||
secret, | ||
) | ||
} else { | ||
let transfer = Transfer { | ||
sender: *account_addr, | ||
recipient: Address::FastPay(next_recipient), | ||
object_ref, | ||
gas_payment: gas_object_ref, | ||
}; | ||
Order::new_transfer(transfer, secret) | ||
}; | ||
next_recipient = *pubx; | ||
let order = Order::new_transfer(transfer, secx); | ||
|
||
// Set the next recipient to current | ||
next_recipient = *account_addr; | ||
|
||
// Serialize order | ||
let serialized_order = serialize_order(&order); | ||
|
@@ -210,10 +258,10 @@ impl ClientServerBenchmark { | |
let serialized_certificate = serialize_cert(&certificate); | ||
assert!(!serialized_certificate.is_empty()); | ||
|
||
if self.benchmark_type != BenchmarkType::OrdersOnly { | ||
if self.benchmark_type != BenchmarkType::CertsOnly { | ||
orders.push(serialized_order.into()); | ||
} | ||
if self.benchmark_type != BenchmarkType::CertsOnly { | ||
if self.benchmark_type != BenchmarkType::OrdersOnly { | ||
orders.push(serialized_certificate.into()); | ||
} | ||
} | ||
|
@@ -261,6 +309,30 @@ impl ClientServerBenchmark { | |
|
||
let responses = mass_client.run(orders, connections).concat().await; | ||
info!("Received {} responses.", responses.len(),); | ||
// Check the responses for errors | ||
for resp in responses { | ||
let reply_message = deserialize_message(&resp[..]); | ||
match reply_message { | ||
Ok(SerializedMessage::OrderResp(resp)) => | ||
oxade marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
#[allow(clippy::collapsible_if)] | ||
if resp.signed_effects.is_some() { | ||
if resp.signed_effects.as_ref().unwrap().effects.status | ||
!= ExecutionStatus::Success | ||
{ | ||
info!( | ||
"Execution Error {:?}", | ||
resp.signed_effects.unwrap().effects.status | ||
); | ||
} | ||
} | ||
} | ||
Err(err) => { | ||
info!("Received Error {:?}", err); | ||
} | ||
_ => {} | ||
}; | ||
} | ||
} else { | ||
// Use actual client core | ||
let client = network::Client::new( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use a seeded RNG here? Want to make sure we get the same values across different runs.