Skip to content

Commit

Permalink
use default weights for claims
Browse files Browse the repository at this point in the history
  • Loading branch information
1xstj committed Jan 3, 2024
1 parent 300fe74 commit ecc6baf
Show file tree
Hide file tree
Showing 10 changed files with 348 additions and 58 deletions.
8 changes: 3 additions & 5 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{
cli::{Cli, Subcommand},
service,
};
use frame_benchmarking_cli::{BenchmarkCmd, SUBSTRATE_REFERENCE_HARDWARE};

use futures::TryFutureExt;
use sc_cli::SubstrateCli;
use sc_service::PartialComponents;
Expand Down Expand Up @@ -152,9 +152,7 @@ pub fn run() -> sc_cli::Result<()> {
use crate::benchmarking::{
inherent_benchmark_data, RemarkBuilder, TransferKeepAliveBuilder,
};
use frame_benchmarking_cli::{
BenchmarkCmd, ExtrinsicFactory, SUBSTRATE_REFERENCE_HARDWARE,
};
use frame_benchmarking_cli::ExtrinsicFactory;
use tangle_runtime::{Block, ExistentialDeposit};

let runner = cli.create_runner(cmd)?;
Expand Down Expand Up @@ -196,7 +194,7 @@ pub fn run() -> sc_cli::Result<()> {
}
},
#[cfg(not(feature = "runtime-benchmarks"))]
Some(Subcommand::Benchmark) => Err("Benchmarking wasn't enabled when building the node. \
Some(Subcommand::Benchmark(_)) => Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`."
.into()),
Some(Subcommand::FrontierDb(cmd)) => {
Expand Down
43 changes: 8 additions & 35 deletions pallets/claims/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ mod mock;
mod tests;

mod utils;

mod weights;
use weights::WeightInfo;
#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;

Expand All @@ -36,7 +37,6 @@ pub use crate::utils::{
use frame_support::{
ensure,
traits::{Currency, Get, VestingSchedule},
weights::Weight,
};
pub use pallet::*;
use pallet_evm::AddressMapping;
Expand Down Expand Up @@ -79,33 +79,6 @@ type CurrencyOf<T> = <<T as Config>::VestingSchedule as VestingSchedule<
>>::Currency;
type BalanceOf<T> = <CurrencyOf<T> as Currency<<T as frame_system::Config>::AccountId>>::Balance;

pub trait WeightInfo {
fn claim() -> Weight;
fn mint_claim() -> Weight;
fn claim_attest() -> Weight;
fn attest() -> Weight;
fn move_claim() -> Weight;
}

pub struct TestWeightInfo;
impl WeightInfo for TestWeightInfo {
fn claim() -> Weight {
Weight::from_parts(0, 0)
}
fn mint_claim() -> Weight {
Weight::from_parts(0, 0)
}
fn claim_attest() -> Weight {
Weight::from_parts(0, 0)
}
fn attest() -> Weight {
Weight::from_parts(0, 0)
}
fn move_claim() -> Weight {
Weight::from_parts(0, 0)
}
}

/// The kind of statement an account needs to make for a claim to be valid.
#[derive(
Encode, Decode, Clone, Copy, Eq, PartialEq, RuntimeDebug, TypeInfo, Serialize, Deserialize,
Expand Down Expand Up @@ -162,7 +135,7 @@ pub mod pallet {
/// RuntimeOrigin permitted to call force_ extrinsics
type ForceOrigin: EnsureOrigin<Self::RuntimeOrigin>;
type MaxVestingSchedules: Get<u32>;
type WeightInfo: WeightInfo;
type WeightInfo: weights::WeightInfo;
}

#[pallet::event]
Expand Down Expand Up @@ -314,7 +287,7 @@ pub mod pallet {
///
/// Total Complexity: O(1)
/// </weight>
#[pallet::weight({0})]
#[pallet::weight(T::WeightInfo::claim())]
#[pallet::call_index(0)]
pub fn claim(
origin: OriginFor<T>,
Expand Down Expand Up @@ -346,7 +319,7 @@ pub mod pallet {
///
/// Total Complexity: O(1)
/// </weight>
#[pallet::weight({1})]
#[pallet::weight(T::WeightInfo::mint_claim())]
#[pallet::call_index(1)]
pub fn mint_claim(
origin: OriginFor<T>,
Expand Down Expand Up @@ -397,7 +370,7 @@ pub mod pallet {
///
/// Total Complexity: O(1)
/// </weight>
#[pallet::weight({2})]
#[pallet::weight(T::WeightInfo::claim_attest())]
#[pallet::call_index(2)]
pub fn claim_attest(
origin: OriginFor<T>,
Expand All @@ -418,7 +391,7 @@ pub mod pallet {
Ok(())
}

#[pallet::weight({4})]
#[pallet::weight(T::WeightInfo::move_claim())]
#[pallet::call_index(4)]
pub fn move_claim(
origin: OriginFor<T>,
Expand All @@ -435,7 +408,7 @@ pub mod pallet {

/// Set the value for expiryconfig
/// Can only be called by ForceOrigin
#[pallet::weight({5})]
#[pallet::weight(T::WeightInfo::force_set_expiry_config())]
#[pallet::call_index(5)]
pub fn force_set_expiry_config(
origin: OriginFor<T>,
Expand Down
2 changes: 1 addition & 1 deletion pallets/claims/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl Config for Test {
type Prefix = Prefix;
type MaxVestingSchedules = ConstU32<8>;
type MoveClaimOrigin = frame_system::EnsureSignedBy<Six, AccountId32>;
type WeightInfo = TestWeightInfo;
type WeightInfo = ();
}

pub fn run_to_block(n: u64) {
Expand Down
Loading

0 comments on commit ecc6baf

Please sign in to comment.