Skip to content

Commit 6fb8666

Browse files
pgherveouathei
andauthored
Contracts: Fix terminate benchmark (paritytech#3558)
Co-authored-by: Alexander Theißen <alex.theissen@me.com> Co-authored-by: command-bot <>
1 parent 101f1bb commit 6fb8666

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

substrate/frame/contracts/src/benchmarking/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ benchmarks! {
927927
value: code_hashes_bytes,
928928
},
929929
],
930-
deploy_body: Some(body::repeated_dyn(r, vec![
930+
deploy_body: Some(body::repeated_dyn(T::MaxDelegateDependencies::get(), vec![
931931
Counter(beneficiary_len as u32, code_hash_len as u32), // code_hash_ptr
932932
Regular(Instruction::Call(1)),
933933
])),
@@ -943,6 +943,7 @@ benchmarks! {
943943
assert_eq!(T::Currency::total_balance(&beneficiary), 0u32.into());
944944
assert_eq!(T::Currency::balance(&instance.account_id), Pallet::<T>::min_balance() * 2u32.into());
945945
assert_ne!(T::Currency::balance_on_hold(&HoldReason::StorageDepositReserve.into(), &instance.account_id), 0u32.into());
946+
assert_eq!(ContractInfoOf::<T>::get(&instance.account_id).unwrap().delegate_dependencies_count() as u32, T::MaxDelegateDependencies::get());
946947
}: call(origin, instance.addr.clone(), 0u32.into(), Weight::MAX, None, vec![])
947948
verify {
948949
if r > 0 {

substrate/frame/contracts/src/storage.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ impl<T: Config> ContractInfo<T> {
108108
Ok(contract)
109109
}
110110

111+
/// Returns the number of locked delegate dependencies.
112+
pub fn delegate_dependencies_count(&self) -> usize {
113+
self.delegate_dependencies.len()
114+
}
115+
111116
/// Associated child trie unique id is built from the hash part of the trie id.
112117
pub fn child_trie_info(&self) -> ChildInfo {
113118
ChildInfo::new_default(self.trie_id.as_ref())

0 commit comments

Comments
 (0)