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

Use single heavy input in the transaction_throughput.rs benchmarks #2205

Merged
44 changes: 23 additions & 21 deletions benches/benches/transaction_throughput.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ where

fn signed_transfers(c: &mut Criterion) {
let generator = |rng: &mut StdRng| {
TransactionBuilder::script(vec![], vec![])
let predicate = op::ret(RegId::ONE).to_bytes().to_vec();
let owner = Input::predicate_owner(&predicate);
let mut tx = TransactionBuilder::script(vec![], vec![])
.script_gas_limit(10000)
.add_unsigned_coin_input(
SecretKey::random(rng),
Expand All @@ -179,16 +181,22 @@ fn signed_transfers(c: &mut Criterion) {
Default::default(),
Default::default(),
)
.add_unsigned_coin_input(
SecretKey::random(rng),
.add_input(Input::coin_predicate(
rng.gen(),
owner,
1000,
Default::default(),
Default::default(),
)
Default::default(),
predicate.clone(),
vec![],
))
.add_output(Output::coin(rng.gen(), 50, AssetId::default()))
.add_output(Output::change(rng.gen(), 0, AssetId::default()))
.finalize()
.finalize();
tx.estimate_predicates(&checked_parameters(), MemoryInstance::new())
.expect("Predicate check failed");
netrome marked this conversation as resolved.
Show resolved Hide resolved
tx
};
bench_txs("signed transfers", c, generator);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we rename this to "predicate transfer" now when we use a predicate instead of a signed coin input?

}
Expand All @@ -209,16 +217,6 @@ fn predicate_transfers(c: &mut Criterion) {
predicate.clone(),
vec![],
))
.add_input(Input::coin_predicate(
rng.gen(),
owner,
1000,
Default::default(),
Default::default(),
Default::default(),
predicate,
vec![],
))
.add_output(Output::coin(rng.gen(), 50, AssetId::default()))
.add_output(Output::change(rng.gen(), 0, AssetId::default()))
.finalize();
Expand Down Expand Up @@ -262,6 +260,8 @@ fn predicate_transfers_eck1(c: &mut Criterion) {
.chain(message.as_ref().iter().copied())
.chain(public.as_ref().iter().copied())
.collect();
let predicate_2 = op::ret(RegId::ONE).to_bytes().to_vec();
let owner_2 = Input::predicate_owner(&predicate_2);

let mut tx = TransactionBuilder::script(vec![], vec![])
.script_gas_limit(10000)
Expand All @@ -277,13 +277,13 @@ fn predicate_transfers_eck1(c: &mut Criterion) {
))
.add_input(Input::coin_predicate(
rng.gen(),
owner,
owner_2,
1000,
Default::default(),
Default::default(),
Default::default(),
predicate,
predicate_data,
predicate_2,
vec![],
))
.add_output(Output::coin(rng.gen(), 50, AssetId::default()))
.add_output(Output::change(rng.gen(), 0, AssetId::default()))
Expand Down Expand Up @@ -330,6 +330,8 @@ fn predicate_transfers_ed19(c: &mut Criterion) {
.chain(message.as_ref().iter().copied()),
)
.collect();
let predicate_2 = op::ret(RegId::ONE).to_bytes().to_vec();
let owner_2 = Input::predicate_owner(&predicate_2);

let mut tx = TransactionBuilder::script(vec![], vec![])
.script_gas_limit(10000)
Expand All @@ -345,13 +347,13 @@ fn predicate_transfers_ed19(c: &mut Criterion) {
))
.add_input(Input::coin_predicate(
rng.gen(),
owner,
owner_2,
1000,
Default::default(),
Default::default(),
Default::default(),
predicate,
predicate_data,
predicate_2,
vec![],
))
.add_output(Output::coin(rng.gen(), 50, AssetId::default()))
.add_output(Output::change(rng.gen(), 0, AssetId::default()))
Expand Down
2 changes: 2 additions & 0 deletions tests/test-helpers/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use fuel_core::{
},
service::{
Config,
DbType,
FuelService,
},
};
Expand Down Expand Up @@ -229,6 +230,7 @@ impl TestSetupBuilder {
starting_gas_price: self.starting_gas_price,
..Config::local_node_with_configs(chain_conf, state)
};
assert_eq!(config.combined_db_config.database_type, DbType::RocksDb);

let srv = FuelService::new_node(config).await.unwrap();
let client = FuelClient::from(srv.bound_address);
Expand Down
Loading