Skip to content

Commit

Permalink
Merge pull request #378 from liberland/BLOCKCHAIN-449/fix-weight-calc…
Browse files Browse the repository at this point in the history
…ulation

BLOCKCHAIN-449 - Fix weight for llm.remark call
  • Loading branch information
DorianSternVukotic authored May 16, 2024
2 parents b3b68ae + 6a1cec9 commit 9c6dafc
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 147 deletions.
9 changes: 9 additions & 0 deletions substrate/frame/llm/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,15 @@ benchmarks! {
verify {
assert_eq!(<<T as Config>::Currency as Currency<T::AccountId>>::total_balance(&user), amount);
}

remark {
let l in 0 .. 64;
let data: RemarkData = [1u8].repeat(l as usize).try_into().unwrap();
}: _(RawOrigin::Root, data.clone())
verify {
let e: <T as Config>::RuntimeEvent = Event::Remarked(data).into();
frame_system::Pallet::<T>::assert_last_event(e.into());
}
}

impl_benchmark_test_suite!(LLM, crate::mock::new_test_ext(), crate::mock::Test,);
4 changes: 2 additions & 2 deletions substrate/frame/llm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,8 +502,8 @@ pub mod pallet {

/// Emit Remarked event. Used by Liberland tooling to annotate transfers.
#[pallet::call_index(7)]
#[pallet::weight(<T as Config>::WeightInfo::treasury_lld_transfer())]
pub fn remark(origin: OriginFor<T>, data: RemarkData) -> DispatchResult {
#[pallet::weight(<T as Config>::WeightInfo::remark(data.len() as u32))]
pub fn remark(_origin: OriginFor<T>, data: RemarkData) -> DispatchResult {
Self::deposit_event(Event::<T>::Remarked(data));
Ok(())
}
Expand Down
Loading

0 comments on commit 9c6dafc

Please sign in to comment.