contracts: Remove unused benchmarks (#3185)

Those were used for some adhoc comparison of solang vs ink! with regards
to ERC20 transfers. Not been used for a while.

Benchmarking is done here now:
[smart-bench](https://github.com/paritytech/smart-bench): Weight based
benchmark to test how much transaction actually fit into a block with
the current Weights
[schlau](https://github.com/ascjones/schlau): Time based benchmarks to
compare performance
This commit is contained in:
Alexander Theißen
2024-02-08 15:39:38 +01:00
committed by GitHub
parent 28463a12f0
commit 7fa05518b0
8 changed files with 3 additions and 1527 deletions
@@ -29,7 +29,7 @@ use self::{
sandbox::Sandbox,
};
use crate::{
exec::{AccountIdOf, Key},
exec::Key,
migration::{
codegen::LATEST_MIGRATION_VERSION, v09, v10, v11, v12, v13, v14, v15, MigrationStep,
},
@@ -184,24 +184,6 @@ fn caller_funding<T: Config>() -> BalanceOf<T> {
BalanceOf::<T>::max_value() / 10_000u32.into()
}
/// Load the specified contract file from disk by including it into the runtime.
///
/// We need to load a different version of ink! contracts when the benchmark is run as
/// a test. This is because ink! contracts depend on the sizes of types that are defined
/// differently in the test environment. Solang is more lax in that regard.
macro_rules! load_benchmark {
($name:expr) => {{
#[cfg(not(test))]
{
include_bytes!(concat!("../../benchmarks/", $name, ".wasm"))
}
#[cfg(test)]
{
include_bytes!(concat!("../../benchmarks/", $name, "_test.wasm"))
}
}};
}
benchmarks! {
where_clause { where
<BalanceOf<T> as codec::HasCompact>::Type: Clone + Eq + PartialEq + sp_std::fmt::Debug + scale_info::TypeInfo + codec::Encode,
@@ -2643,86 +2625,6 @@ benchmarks! {
");
}: {}
// Execute one erc20 transfer using the ink! erc20 example contract.
#[extra]
#[pov_mode = Measured]
ink_erc20_transfer {
let code = load_benchmark!("ink_erc20");
let data = {
let new: ([u8; 4], BalanceOf<T>) = ([0x9b, 0xae, 0x9d, 0x5e], 1000u32.into());
new.encode()
};
let instance = Contract::<T>::new(
WasmModule::from_code(code), data,
)?;
let data = {
let transfer: ([u8; 4], AccountIdOf<T>, BalanceOf<T>) = (
[0x84, 0xa1, 0x5d, 0xa1],
account::<T::AccountId>("receiver", 0, 0),
1u32.into(),
);
transfer.encode()
};
}: {
<Contracts<T>>::bare_call(
instance.caller,
instance.account_id,
0u32.into(),
Weight::MAX,
None,
data,
DebugInfo::Skip,
CollectEvents::Skip,
Determinism::Enforced,
)
.result?;
}
// Execute one erc20 transfer using the open zeppelin erc20 contract compiled with solang.
#[extra]
#[pov_mode = Measured]
solang_erc20_transfer {
let code = include_bytes!("../../benchmarks/solang_erc20.wasm");
let caller = account::<T::AccountId>("instantiator", 0, 0);
let mut balance = [0u8; 32];
balance[0] = 100;
let data = {
let new: ([u8; 4], &str, &str, [u8; 32], AccountIdOf<T>) = (
[0xa6, 0xf1, 0xf5, 0xe1],
"KSM",
"K",
balance,
caller.clone(),
);
new.encode()
};
let instance = Contract::<T>::with_caller(
caller, WasmModule::from_code(code), data,
)?;
balance[0] = 1;
let data = {
let transfer: ([u8; 4], AccountIdOf<T>, [u8; 32]) = (
[0x6a, 0x46, 0x73, 0x94],
account::<T::AccountId>("receiver", 0, 0),
balance,
);
transfer.encode()
};
}: {
<Contracts<T>>::bare_call(
instance.caller,
instance.account_id,
0u32.into(),
Weight::MAX,
None,
data,
DebugInfo::Skip,
CollectEvents::Skip,
Determinism::Enforced,
)
.result?;
}
impl_benchmark_test_suite!(
Contracts,
crate::tests::ExtBuilder::default().build(),