Skip to content

Commit 37ede70

Browse files
chore: bench format
1 parent 6571d3b commit 37ede70

File tree

4 files changed

+20
-38
lines changed

4 files changed

+20
-38
lines changed

target_chains/ethereum/sdk/stylus/benches/src/extend_pyth.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ pub async fn bench() -> eyre::Result<ContractReport> {
4747
Ok(report)
4848
}
4949

50-
pub async fn run_with(
51-
cache_opt: CacheOpt,
52-
) -> eyre::Result<Vec<FunctionReport>> {
50+
pub async fn run_with(cache_opt: CacheOpt) -> eyre::Result<Vec<FunctionReport>> {
5351
let alice = Account::new().await?;
5452
let alice_wallet = ProviderBuilder::new()
5553
.network::<AnyNetwork>()
@@ -60,7 +58,10 @@ pub async fn run_with(
6058
let contract_addr = deploy(&alice, cache_opt).await?;
6159

6260
let contract = ExtendPyth::new(contract_addr, &alice_wallet);
63-
let id = keccak_const::Keccak256::new().update(b"ETH").finalize().to_vec();
61+
let id = keccak_const::Keccak256::new()
62+
.update(b"ETH")
63+
.finalize()
64+
.to_vec();
6465
let id = TypeFixedBytes::<32>::from_slice(&id);
6566
let time_frame = uint!(10000_U256);
6667
let age = uint!(10000_U256);
@@ -93,13 +94,12 @@ pub async fn run_with(
9394
.collect::<eyre::Result<Vec<_>>>()
9495
}
9596

96-
async fn deploy(
97-
account: &Account,
98-
cache_opt: CacheOpt,
99-
) -> eyre::Result<Address> {
97+
async fn deploy(account: &Account, cache_opt: CacheOpt) -> eyre::Result<Address> {
10098
let pyth_addr = env("MOCK_PYTH_ADDRESS")?;
10199
let address = Address::from_str(&pyth_addr)?;
102-
let args = ExtendPythExample::constructorCall { _pythAddress: address };
100+
let args = ExtendPythExample::constructorCall {
101+
_pythAddress: address,
102+
};
103103
let args = alloy::hex::encode(args.abi_encode());
104104
crate::deploy(account, "extend-pyth", Some(args), cache_opt).await
105105
}

target_chains/ethereum/sdk/stylus/benches/src/lib.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ use std::process::Command;
22

33
use alloy::{
44
primitives::Address,
5-
rpc::types::{
6-
serde_helpers::WithOtherFields, AnyReceiptEnvelope, Log,
7-
TransactionReceipt,
8-
},
5+
rpc::types::{serde_helpers::WithOtherFields, AnyReceiptEnvelope, Log, TransactionReceipt},
96
};
107
use alloy_primitives::U128;
118
use e2e::{Account, ReceiptExt};
@@ -32,17 +29,15 @@ pub enum CacheOpt {
3229
Bid(u32),
3330
}
3431

35-
type ArbTxReceipt =
36-
WithOtherFields<TransactionReceipt<AnyReceiptEnvelope<Log>>>;
32+
type ArbTxReceipt = WithOtherFields<TransactionReceipt<AnyReceiptEnvelope<Log>>>;
3733

3834
async fn deploy(
3935
account: &Account,
4036
contract_name: &str,
4137
args: Option<String>,
4238
cache_opt: CacheOpt,
4339
) -> eyre::Result<Address> {
44-
let manifest_dir =
45-
std::env::current_dir().context("should get current dir from env")?;
40+
let manifest_dir = std::env::current_dir().context("should get current dir from env")?;
4641

4742
let wasm_path = manifest_dir
4843
.join("target")
@@ -92,11 +87,7 @@ async fn deploy(
9287
/// Already cached contracts won't be cached, and this function will not return
9388
/// an error.
9489
/// Output will be forwarded to the child process.
95-
fn cache_contract(
96-
account: &Account,
97-
contract_addr: Address,
98-
bid: u32,
99-
) -> eyre::Result<()> {
90+
fn cache_contract(account: &Account, contract_addr: Address, bid: u32) -> eyre::Result<()> {
10091
// We don't need a status code.
10192
// Since it is not zero when the contract is already cached.
10293
let _ = Command::new("cargo")

target_chains/ethereum/sdk/stylus/benches/src/main.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@ use futures::FutureExt;
33

44
#[tokio::main]
55
async fn main() -> eyre::Result<()> {
6-
let report = futures::future::try_join_all([
7-
extend_pyth::bench().boxed(),
8-
])
9-
.await?
10-
.into_iter()
11-
.fold(BenchmarkReport::default(), BenchmarkReport::merge_with);
6+
let report = futures::future::try_join_all([extend_pyth::bench().boxed()])
7+
.await?
8+
.into_iter()
9+
.fold(BenchmarkReport::default(), BenchmarkReport::merge_with);
1210

1311
println!();
1412
println!("{report}");

target_chains/ethereum/sdk/stylus/benches/src/report.rs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ impl ContractReport {
4040
Ok(self)
4141
}
4242

43-
pub fn add_cached(
44-
mut self,
45-
fn_report: FunctionReport,
46-
) -> eyre::Result<Self> {
43+
pub fn add_cached(mut self, fn_report: FunctionReport) -> eyre::Result<Self> {
4744
self.functions_cached.push(fn_report);
4845
Ok(self)
4946
}
@@ -104,12 +101,8 @@ impl Display for BenchmarkReport {
104101
const HEADER_GAS: &str = "Not Cached";
105102

106103
// Calculating the width of table columns.
107-
let width1 =
108-
self.column_width(ContractReport::signature_max_len, HEADER_SIG);
109-
let width2 = self.column_width(
110-
ContractReport::gas_cached_max_len,
111-
HEADER_GAS_CACHED,
112-
);
104+
let width1 = self.column_width(ContractReport::signature_max_len, HEADER_SIG);
105+
let width2 = self.column_width(ContractReport::gas_cached_max_len, HEADER_GAS_CACHED);
113106
let width3 = self.column_width(ContractReport::gas_max_len, HEADER_GAS);
114107

115108
// Print headers for the table columns.

0 commit comments

Comments
 (0)