Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Weight V2 (Chromatic Weight) #10918

Closed
wants to merge 103 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
97d70b2
initial stuff
shawntabrizi Feb 14, 2022
89c2b4f
Merge branch 'master' into shawntabrizi-weight-v2
shawntabrizi Feb 23, 2022
8f5a2ea
fix merge
shawntabrizi Feb 23, 2022
5953db8
a direction
shawntabrizi Feb 24, 2022
a4ecc76
more stuff
shawntabrizi Feb 24, 2022
0c66a30
frame_system compiles
shawntabrizi Feb 24, 2022
75a51f7
fix system tests
shawntabrizi Feb 24, 2022
ad38154
fix support tests
shawntabrizi Feb 25, 2022
1ec5af7
update tests
shawntabrizi Feb 25, 2022
c946aeb
simplify
shawntabrizi Feb 25, 2022
6b1806a
fix some todos, add others
shawntabrizi Feb 25, 2022
bf300dc
Update weight_v2.rs
shawntabrizi Feb 25, 2022
0ae536b
fix test
shawntabrizi Feb 25, 2022
d34ce88
move some stuff around
shawntabrizi Feb 25, 2022
132641b
better variable name
shawntabrizi Feb 25, 2022
e843a10
fix mul stuff
shawntabrizi Feb 25, 2022
707c2fd
Merge branch 'master' into shawntabrizi-weight-v2
shawntabrizi Feb 26, 2022
8594902
naming
shawntabrizi Feb 26, 2022
9d90430
naming
shawntabrizi Feb 26, 2022
6f1b4c7
transaction payment
shawntabrizi Feb 26, 2022
134905d
update simple_max
shawntabrizi Feb 26, 2022
8689d2d
fix balances
shawntabrizi Feb 26, 2022
a771ca1
multisig
shawntabrizi Feb 26, 2022
b40ca8d
fixes
shawntabrizi Feb 27, 2022
a72bdeb
Update tests.rs
shawntabrizi Feb 28, 2022
7eef9b4
sudo
shawntabrizi Feb 28, 2022
4c025ad
utility
shawntabrizi Mar 1, 2022
db2567f
updates
shawntabrizi Mar 1, 2022
01a0070
todo update
shawntabrizi Mar 1, 2022
1ab35e0
proxy
shawntabrizi Mar 1, 2022
3d2cef1
switch all Weight to V2
shawntabrizi Mar 14, 2022
4770937
make frame-support tests compile
shawntabrizi Mar 14, 2022
1016747
frame system tests
shawntabrizi Mar 14, 2022
82d4ae2
fmt
shawntabrizi Mar 14, 2022
444bc97
Merge branch 'master' into shawntabrizi-weight-v2
shawntabrizi Apr 6, 2022
542fca3
fix compile
shawntabrizi Apr 6, 2022
64c0547
get transaction payment to compile
shawntabrizi Apr 6, 2022
cfaf708
fix multisig
shawntabrizi Apr 6, 2022
7b75025
society
shawntabrizi Apr 6, 2022
d56bf24
more fixes
shawntabrizi Apr 6, 2022
60d3f27
system fixes
shawntabrizi Apr 6, 2022
6420011
update weight files
shawntabrizi Apr 6, 2022
65ea42f
collective flip
shawntabrizi Apr 6, 2022
64ed2b9
lottery
shawntabrizi Apr 6, 2022
adaae9c
lots of random fixes
shawntabrizi Apr 6, 2022
7df9373
fix compile
shawntabrizi Apr 6, 2022
924deea
atomic swap
shawntabrizi Apr 6, 2022
9a1ad70
fix scored pool
shawntabrizi Apr 6, 2022
e95297f
collective compile
shawntabrizi Apr 6, 2022
7283939
fmt
shawntabrizi Apr 6, 2022
5da5b43
compile scheduler
shawntabrizi Apr 6, 2022
f2f828b
some more updates
shawntabrizi Apr 6, 2022
d7a4f16
fix referenda
shawntabrizi Apr 6, 2022
50c78df
uniques
shawntabrizi Apr 6, 2022
63ef76c
almost fix contracts
shawntabrizi Apr 6, 2022
5b235e6
fmt
shawntabrizi Apr 6, 2022
4edd948
multi phase
shawntabrizi Apr 6, 2022
a22105f
mmr
shawntabrizi Apr 6, 2022
9d0a6c0
treasury
shawntabrizi Apr 6, 2022
3c5fe79
bunch more
shawntabrizi Apr 6, 2022
dc0a36c
staking and grandpa
shawntabrizi Apr 6, 2022
28fa273
make compile
shawntabrizi Apr 6, 2022
7562af1
some more workspace fixes
shawntabrizi Apr 6, 2022
b102039
fix assets-tx-payment-pallet
shawntabrizi Apr 6, 2022
2fb67bb
more fixes
shawntabrizi Apr 6, 2022
ddbcd23
fix node executor tests
shawntabrizi Apr 6, 2022
791eb7b
frame executive compiles, but fails badly
shawntabrizi Apr 6, 2022
4e2f711
unused
shawntabrizi Apr 6, 2022
53fe88f
Remove redundant associated function
athei Apr 11, 2022
0aa17d3
Fix sudo weight annotation
athei Apr 11, 2022
1012d09
Merge branch 'master' into shawntabrizi-weight-v2
athei Apr 11, 2022
2a66520
WeightV2 is just Weight
athei Apr 11, 2022
b3ffd6e
Fix test compilation
athei Apr 11, 2022
9b77b60
fmt
athei Apr 11, 2022
0c6fb3d
Fix benches
athei Apr 11, 2022
0f5b8d9
Get rid of todo functions
athei Apr 11, 2022
6433bcc
Remove duplicated `saturating_add` function
athei Apr 11, 2022
5200fc4
Convert remote_tests to use proper weight type
athei Apr 11, 2022
8a0a0e6
Merge branch 'master' into shawntabrizi-weight-v2
athei Apr 12, 2022
69abb85
Fix contracts
athei Apr 12, 2022
8a1dc6f
Fix executive tests
athei Apr 12, 2022
cb741d2
Merge branch 'master' into shawntabrizi-weight-v2
athei Apr 13, 2022
4125521
Update UI test output
athei Apr 13, 2022
b535356
Fix ui tests
athei Apr 13, 2022
4e11e42
Merge branch 'master' into shawntabrizi-weight-v2
athei Apr 13, 2022
2379b62
Fix decl_module macro
athei Apr 13, 2022
c031ed2
fmt
athei Apr 13, 2022
b1c766a
Merge branch 'master' into shawntabrizi-weight-v2
shawntabrizi May 1, 2022
321cfaa
fix compile
shawntabrizi May 1, 2022
c604332
fix test compile
shawntabrizi May 1, 2022
34a270b
make field private
shawntabrizi May 1, 2022
2640dd3
fix tests
shawntabrizi May 1, 2022
dc9cf66
remove Weightv1
shawntabrizi May 1, 2022
bcab0bf
weight_v1 to computation_weight
shawntabrizi May 1, 2022
2eeacb7
fix doc
shawntabrizi May 1, 2022
4958b7e
computation_only -> from_computation
shawntabrizi May 2, 2022
4922339
fix limit enforced tests
shawntabrizi May 2, 2022
581dcbb
fix other test
shawntabrizi May 2, 2022
376a40c
Merge branch 'master' into shawntabrizi-weight-v2
shawntabrizi May 23, 2022
f6651bd
fix merge
shawntabrizi May 23, 2022
ce882e8
fmt
shawntabrizi May 23, 2022
4f10008
fix test compile
shawntabrizi May 23, 2022
969e4af
fix comments
shawntabrizi May 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .maintain/frame-weight-template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#![allow(unused_parens)]
#![allow(unused_imports)]

use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use frame_support::{traits::Get, weights::{ComputationWeight as Weight, constants::RocksDbWeight}};
use sp_std::marker::PhantomData;

/// Weight functions needed for {{pallet}}.
Expand Down
5 changes: 4 additions & 1 deletion bin/node-template/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ parameter_types! {
pub const Version: RuntimeVersion = VERSION;
/// We allow for 2 seconds of compute with a 6 second average block time.
pub BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights
::with_sensible_defaults(2 * WEIGHT_PER_SECOND, NORMAL_DISPATCH_RATIO);
::with_sensible_defaults(Weight::new()
.set_computation(2 * WEIGHT_PER_SECOND)
shawntabrizi marked this conversation as resolved.
Show resolved Hide resolved
.set_bandwidth(5 * 1024 * 1024), // 5 MB
NORMAL_DISPATCH_RATIO);
pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength
::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
pub const SS58Prefix: u8 = 42;
Expand Down
6 changes: 3 additions & 3 deletions bin/node/executor/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use codec::{Decode, Encode, Joiner};
use frame_support::{
traits::Currency,
weights::{DispatchClass, DispatchInfo, GetDispatchInfo},
weights::{DispatchClass, DispatchInfo, GetDispatchInfo, Weight},
};
use frame_system::{self, AccountInfo, EventRecord, Phase};
use sp_core::{storage::well_known_keys, traits::Externalities, NeverNativeValue};
Expand Down Expand Up @@ -700,7 +700,7 @@ fn deploying_wasm_contract_should_work() {
function: Call::Contracts(
pallet_contracts::Call::instantiate_with_code::<Runtime> {
value: 0,
gas_limit: 500_000_000,
gas_limit: Weight::from_computation(500_000_000),
storage_deposit_limit: None,
code: transfer_code,
data: Vec::new(),
Expand All @@ -713,7 +713,7 @@ fn deploying_wasm_contract_should_work() {
function: Call::Contracts(pallet_contracts::Call::call::<Runtime> {
dest: sp_runtime::MultiAddress::Id(addr.clone()),
value: 10,
gas_limit: 500_000_000,
gas_limit: Weight::from_computation(500_000_000),
storage_deposit_limit: None,
data: vec![0x00, 0x01, 0x02, 0x03],
}),
Expand Down
6 changes: 3 additions & 3 deletions bin/node/executor/tests/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,18 @@ fn transaction_fee_is_correct() {
let mut balance_alice = (100 - 69) * DOLLARS;

let base_weight = ExtrinsicBaseWeight::get();
let base_fee = IdentityFee::<Balance>::calc(&base_weight);
let base_fee = IdentityFee::<Balance>::calc(&base_weight.computation());

let length_fee = TransactionByteFee::get() * (xt.clone().encode().len() as Balance);
balance_alice -= length_fee;

let weight = default_transfer_call().get_dispatch_info().weight;
let weight_fee = IdentityFee::<Balance>::calc(&weight);
let weight_fee = IdentityFee::<Balance>::calc(&weight.computation());

// we know that weight to fee multiplier is effect-less in block 1.
// current weight of transfer = 200_000_000
// Linear weight to fee is 1:1 right now (1 weight = 1 unit of balance)
assert_eq!(weight_fee, weight as Balance);
assert_eq!(weight_fee, weight.computation() as Balance);
balance_alice -= base_fee;
balance_alice -= weight_fee;
balance_alice -= tip;
Expand Down
60 changes: 32 additions & 28 deletions bin/node/runtime/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ mod multiplier_tests {
}

fn target() -> Weight {
TargetBlockFullness::get() * max_normal()
Weight::new()
.set_computation(TargetBlockFullness::get() * max_normal().computation())
.set_bandwidth(TargetBlockFullness::get() * max_normal().bandwidth())
}

// update based on runtime impl.
Expand All @@ -94,13 +96,13 @@ mod multiplier_tests {
let previous_float = previous_float.max(min_multiplier().into_inner() as f64 / accuracy);

// maximum tx weight
let m = max_normal() as f64;
let m = max_normal().computation() as f64;
// block weight always truncated to max weight
let block_weight = (block_weight as f64).min(m);
let block_weight = (block_weight.computation() as f64).min(m);
let v: f64 = AdjustmentVariable::get().to_float();

// Ideal saturation in terms of weight
let ss = target() as f64;
let ss = target().computation() as f64;
// Current saturation in terms of weight
let s = block_weight;

Expand All @@ -119,7 +121,7 @@ mod multiplier_tests {
.unwrap()
.into();
t.execute_with(|| {
System::set_block_consumed_resources(w, 0);
System::set_block_consumed_resources(Some(w.computation()), Some(w.bandwidth()), None);
assertions()
});
}
Expand All @@ -128,9 +130,9 @@ mod multiplier_tests {
fn truth_value_update_poc_works() {
let fm = Multiplier::saturating_from_rational(1, 2);
let test_set = vec![
(0, fm.clone()),
(100, fm.clone()),
(1000, fm.clone()),
(Weight::zero(), fm.clone()),
(Weight::from_computation(100), fm.clone()),
(Weight::from_computation(1000), fm.clone()),
(target(), fm.clone()),
(max_normal() / 2, fm.clone()),
(max_normal(), fm.clone()),
Expand Down Expand Up @@ -160,7 +162,7 @@ mod multiplier_tests {
#[test]
fn multiplier_cannot_go_below_limit() {
// will not go any further below even if block is empty.
run_with_system_weight(0, || {
run_with_system_weight(Weight::zero(), || {
let next = runtime_multiplier_update(min_multiplier());
assert_eq!(next, min_multiplier());
})
Expand All @@ -178,7 +180,7 @@ mod multiplier_tests {
// 1 < 0.00001 * k * 0.1875
// 10^9 / 1875 < k
// k > 533_333 ~ 18,5 days.
run_with_system_weight(0, || {
run_with_system_weight(Weight::zero(), || {
// start from 1, the default.
let mut fm = Multiplier::one();
let mut iterations: u64 = 0;
Expand Down Expand Up @@ -214,7 +216,8 @@ mod multiplier_tests {
// `cargo test congested_chain_simulation -- --nocapture` to get some insight.

// almost full. The entire quota of normal transactions is taken.
let block_weight = BlockWeights::get().get(DispatchClass::Normal).max_total.unwrap() - 100;
let block_weight = BlockWeights::get().get(DispatchClass::Normal).max_total.unwrap() -
Weight::from_computation(100);

// Default substrate weight.
let tx_weight = frame_support::weights::constants::ExtrinsicBaseWeight::get();
Expand All @@ -233,8 +236,9 @@ mod multiplier_tests {
}
fm = next;
iterations += 1;
let fee =
<Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(&tx_weight);
let fee = <Runtime as pallet_transaction_payment::Config>::WeightToFee::calc(
&tx_weight.computation(),
);
let adjusted_fee = fm.saturating_mul_acc_int(fee);
println!(
"iteration {}, new fm = {:?}. Fee at this point is: {} units / {} millicents, \
Expand Down Expand Up @@ -336,27 +340,27 @@ mod multiplier_tests {

#[test]
fn weight_to_fee_should_not_overflow_on_large_weights() {
let kb = 1024 as Weight;
let kb = 1024 as u64;
let mb = kb * kb;
let max_fm = Multiplier::saturating_from_integer(i128::MAX);

// check that for all values it can compute, correctly.
vec![
0,
1,
10,
1000,
kb,
10 * kb,
100 * kb,
mb,
10 * mb,
2147483647,
4294967295,
Weight::zero(),
Weight::one(),
Weight::from_computation(10),
Weight::from_computation(1000),
Weight::from_computation(kb),
Weight::from_computation(10 * kb),
Weight::from_computation(100 * kb),
Weight::from_computation(mb),
Weight::from_computation(10 * mb),
Weight::from_computation(2147483647),
Weight::from_computation(4294967295),
BlockWeights::get().max_block / 2,
BlockWeights::get().max_block,
Weight::max_value() / 2,
Weight::max_value(),
Weight::MAX / 2,
Weight::MAX,
]
.into_iter()
.for_each(|i| {
Expand All @@ -369,7 +373,7 @@ mod multiplier_tests {

// Some values that are all above the target and will cause an increase.
let t = target();
vec![t + 100, t * 2, t * 4].into_iter().for_each(|i| {
vec![t + Weight::from_computation(100), t * 2, t * 4].into_iter().for_each(|i| {
run_with_system_weight(i, || {
let fm = runtime_multiplier_update(max_fm);
// won't grow. The convert saturates everything.
Expand Down
14 changes: 9 additions & 5 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ use sp_runtime::{
generic, impl_opaque_keys,
traits::{
self, BlakeTwo256, Block as BlockT, ConvertInto, NumberFor, OpaqueKeys,
SaturatedConversion, StaticLookup,
SaturatedConversion, Saturating, StaticLookup,
},
transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
ApplyExtrinsicResult, FixedPointNumber, Perbill, Percent, Permill, Perquintill,
Expand Down Expand Up @@ -169,7 +169,9 @@ const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);
/// by Operational extrinsics.
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
/// We allow for 2 seconds of compute with a 6 second average block time.
const MAXIMUM_BLOCK_WEIGHT: Weight = 2 * WEIGHT_PER_SECOND;
const MAXIMUM_BLOCK_WEIGHT: Weight = Weight::new()
.set_computation(2 * WEIGHT_PER_SECOND)
.set_bandwidth(5 * 1024 * 1024); // 5 MB

parameter_types! {
pub const BlockHashCount: BlockNumber = 2400;
Expand Down Expand Up @@ -673,11 +675,11 @@ impl pallet_election_provider_multi_phase::MinerConfig for Runtime {
// The unsigned submissions have to respect the weight of the submit_unsigned call, thus their
// weight estimate function is wired to this call's weight.
fn solution_weight(v: u32, t: u32, a: u32, d: u32) -> Weight {
<
Weight::from_computation(<
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the WeightInfo not now give the new Weight back from its functions?

<Self as pallet_election_provider_multi_phase::Config>::WeightInfo
as
pallet_election_provider_multi_phase::WeightInfo
>::submit_unsigned(v, t, a, d)
>::submit_unsigned(v, t, a, d))
}
}

Expand Down Expand Up @@ -1090,7 +1092,7 @@ parameter_types! {
pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (
<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -
<Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)
)) / 5) as u32;
)).computation() / 5) as u32;
pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();
}

Expand Down Expand Up @@ -1807,6 +1809,7 @@ impl_runtime_apis! {
storage_deposit_limit: Option<Balance>,
input_data: Vec<u8>,
) -> pallet_contracts_primitives::ContractExecResult<Balance> {
let gas_limit = Weight::from_computation(gas_limit);
Contracts::bare_call(origin, dest, value, gas_limit, storage_deposit_limit, input_data, true)
}

Expand All @@ -1820,6 +1823,7 @@ impl_runtime_apis! {
salt: Vec<u8>,
) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, Balance>
{
let gas_limit = Weight::from_computation(gas_limit);
Contracts::bare_instantiate(origin, value, gas_limit, storage_deposit_limit, code, data, salt, true)
}

Expand Down
2 changes: 1 addition & 1 deletion frame/assets/src/weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#![allow(unused_parens)]
#![allow(unused_imports)]

use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
use frame_support::{traits::Get, weights::{ComputationWeight as Weight, constants::RocksDbWeight}};
use sp_std::marker::PhantomData;

/// Weight functions needed for pallet_assets.
Expand Down
12 changes: 6 additions & 6 deletions frame/atomic-swap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ where
}

fn weight(&self) -> Weight {
T::DbWeight::get().reads_writes(1, 1)
Weight::from_computation(T::DbWeight::get().reads_writes(1, 1))
}

fn cancel(&self, source: &AccountId) {
Expand Down Expand Up @@ -281,12 +281,12 @@ pub mod pallet {
/// - `proof`: Revealed proof of the claim.
/// - `action`: Action defined in the swap, it must match the entry in blockchain. Otherwise
/// the operation fails. This is used for weight calculation.
#[pallet::weight(
T::DbWeight::get().reads_writes(1, 1)
#[pallet::weight({
let computation_weight = T::DbWeight::get().reads_writes(1, 1)
.saturating_add(40_000_000)
.saturating_add((proof.len() as Weight).saturating_mul(100))
.saturating_add(action.weight())
)]
.saturating_add((proof.len() as u64).saturating_mul(100));
Weight::from_computation(computation_weight).saturating_add(action.weight())
})]
pub fn claim_swap(
origin: OriginFor<T>,
proof: Vec<u8>,
Expand Down
5 changes: 4 additions & 1 deletion frame/atomic-swap/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ frame_support::construct_runtime!(

parameter_types! {
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::new()
.set_computation(1024)
.set_bandwidth(1024)
);
}
impl frame_system::Config for Test {
type BaseCallFilter = frame_support::traits::Everything;
Expand Down
4 changes: 2 additions & 2 deletions frame/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ pub mod pallet {
// TODO [#3398] Generate offence report for all authorities that skipped their
// slots.

T::DbWeight::get().reads_writes(2, 1)
Weight::from_computation(T::DbWeight::get().reads_writes(2, 1))
} else {
T::DbWeight::get().reads(1)
Weight::from_computation(T::DbWeight::get().reads(1))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion frame/aura/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ pub trait RemoveLastTimestamp: super::Config {
/// This migration requires a type `T` that implements [`RemoveLastTimestamp`].
pub fn remove_last_timestamp<T: RemoveLastTimestamp>() -> Weight {
LastTimestamp::<T>::kill();
T::DbWeight::get().writes(1)
Weight::from_computation(T::DbWeight::get().writes(1))
}
5 changes: 4 additions & 1 deletion frame/aura/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ frame_support::construct_runtime!(

parameter_types! {
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::new()
.set_computation(1024)
.set_bandwidth(1024)
);
}

impl frame_system::Config for Test {
Expand Down
5 changes: 4 additions & 1 deletion frame/authority-discovery/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,10 @@ mod tests {
pub const Period: BlockNumber = 1;
pub const Offset: BlockNumber = 0;
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::new()
.set_computation(1024)
.set_bandwidth(1024)
);
}

impl frame_system::Config for Test {
Expand Down
9 changes: 6 additions & 3 deletions frame/authorship/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use frame_support::{
traits::{FindAuthor, Get, VerifySeal},
};
use sp_authorship::{InherentError, UnclesInherentData, INHERENT_IDENTIFIER};
use sp_runtime::traits::{Header as HeaderT, One, Saturating};
use sp_runtime::traits::{Header as HeaderT, One, Saturating, Zero};
use sp_std::{collections::btree_set::BTreeSet, prelude::*, result};

const MAX_UNCLES: usize = 10;
Expand Down Expand Up @@ -175,7 +175,7 @@ pub mod pallet {
T::EventHandler::note_author(author);
}

0
Weight::zero()
}

fn on_finalize(_: T::BlockNumber) {
Expand Down Expand Up @@ -434,7 +434,10 @@ mod tests {

parameter_types! {
pub BlockWeights: frame_system::limits::BlockWeights =
frame_system::limits::BlockWeights::simple_max(1024);
frame_system::limits::BlockWeights::simple_max(frame_support::weights::Weight::new()
.set_computation(1024)
.set_bandwidth(1024)
);
}

impl frame_system::Config for Test {
Expand Down
Loading