Skip to content

Commit 3b989e6

Browse files
committed
Apply weight for the bundle/ER validation in the domain extrension
Signed-off-by: linning <[email protected]>
1 parent c057d4f commit 3b989e6

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

crates/pallet-domains/src/extensions.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
//! Extensions for unsigned general extrinsics
22
33
use crate::pallet::Call as DomainsCall;
4+
use crate::weights::WeightInfo;
45
use crate::{Config, FraudProofFor, OpaqueBundleOf, Origin, Pallet as Domains, SingletonReceiptOf};
56
use frame_support::pallet_prelude::{PhantomData, TypeInfo};
7+
use frame_support::weights::Weight;
68
use frame_system::pallet_prelude::RuntimeCallFor;
79
use parity_scale_codec::{Decode, Encode};
810
use scale_info::prelude::fmt;
@@ -175,6 +177,23 @@ where
175177
type Val = ();
176178
type Pre = ();
177179

180+
fn weight(&self, call: &Runtime::RuntimeCall) -> Weight {
181+
// This extension only apply to the following 3 calls thus only return weight for them.
182+
match call.maybe_domains_call() {
183+
Some(DomainsCall::submit_bundle { .. }) => {
184+
<Runtime as Config>::WeightInfo::validate_submit_bundle()
185+
}
186+
Some(DomainsCall::submit_fraud_proof { .. }) => {
187+
// FIXME: proper weight
188+
Weight::zero()
189+
}
190+
Some(DomainsCall::submit_receipt { .. }) => {
191+
<Runtime as Config>::WeightInfo::validate_singleton_receipt()
192+
}
193+
_ => Weight::zero(),
194+
}
195+
}
196+
178197
fn validate(
179198
&self,
180199
origin: DispatchOriginOf<RuntimeCallFor<Runtime>>,
@@ -212,7 +231,4 @@ where
212231
}
213232

214233
impl_tx_ext_default!(RuntimeCallFor<Runtime>; prepare);
215-
216-
// TODO: need benchmarking for this extension.
217-
impl_tx_ext_default!(RuntimeCallFor<Runtime>; weight);
218234
}

0 commit comments

Comments
 (0)