Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
02b6a57
Update to u64
shawntabrizi Mar 28, 2020
1b8a181
Update bin/node/runtime/src/lib.rs
shawntabrizi Mar 29, 2020
f204dcb
Update weights
shawntabrizi Mar 29, 2020
6d60384
Fix test
shawntabrizi Mar 29, 2020
010fccb
Extra zeros to make gas 1:1 with weight
shawntabrizi Apr 8, 2020
b3e96eb
Merge branch 'master' into shawntabrizi-update-weights
shawntabrizi Apr 8, 2020
d365ecf
Merge branch 'master' into shawntabrizi-update-weights
shawntabrizi Apr 8, 2020
25f8dd4
initial impl DbWeight
shawntabrizi Apr 8, 2020
cfae9bf
Merge branch 'master' into shawntabrizi-update-weights
shawntabrizi Apr 9, 2020
6ed3496
Update weights for balances
shawntabrizi Apr 9, 2020
d239667
multiply all weights by 1_000
shawntabrizi Apr 9, 2020
04ff18d
Fix tests
shawntabrizi Apr 9, 2020
189cbb1
backfill trait
shawntabrizi Apr 9, 2020
42814c0
Missed one
shawntabrizi Apr 9, 2020
f65bbd4
more fixes
shawntabrizi Apr 9, 2020
a16ae55
Fix tests
shawntabrizi Apr 9, 2020
c3ad5fb
update fixed 64 docs
shawntabrizi Apr 10, 2020
428ec84
introduce fixed 128
shawntabrizi Apr 10, 2020
30e4a21
Revert "introduce fixed 128"
shawntabrizi Apr 10, 2020
bec986c
Revert "update fixed 64 docs"
shawntabrizi Apr 10, 2020
9cfb1bc
Merge branch 'master' into shawntabrizi-update-weights
shawntabrizi Apr 13, 2020
06197b4
Add fixed 128
shawntabrizi Apr 13, 2020
0c94fc9
fix types
shawntabrizi Apr 13, 2020
d3f4b4b
Fix test
shawntabrizi Apr 13, 2020
62f6a9b
Fix tests
shawntabrizi Apr 13, 2020
0ce0870
Update impls.rs
shawntabrizi Apr 13, 2020
ab5b865
fix tests
shawntabrizi Apr 13, 2020
b704be9
better comment
shawntabrizi Apr 13, 2020
275d40d
types update
shawntabrizi Apr 13, 2020
d07a623
Use new fixed128 api
shawntabrizi Apr 13, 2020
ec2f0c8
import in test
shawntabrizi Apr 13, 2020
2ccd439
another type update
shawntabrizi Apr 13, 2020
5329496
fix test in example
shawntabrizi Apr 13, 2020
d078d31
remove weight test
shawntabrizi Apr 13, 2020
b371c23
fix warning
shawntabrizi Apr 13, 2020
f0187d9
Simplify RuntimeDbWeight
shawntabrizi Apr 14, 2020
96b217a
Update bin/node/runtime/src/impls.rs
shawntabrizi Apr 14, 2020
fef18aa
Apply suggestions from code review
shawntabrizi Apr 14, 2020
9045ec7
Merge branch 'master' into shawntabrizi-update-weights
shawntabrizi Apr 14, 2020
0e77b6f
improved api @apopiak
shawntabrizi Apr 14, 2020
c204c88
Merge branch 'master' into shawntabrizi-update-weights
shawntabrizi Apr 14, 2020
c7af453
Remove `SimpleDispatchInfo::default()`
shawntabrizi Apr 14, 2020
21f91f1
little more clean up of default weight
shawntabrizi Apr 14, 2020
3b57909
Introduce MINIMUM_WEIGHT const
shawntabrizi Apr 14, 2020
8edc50a
Update bin/node/runtime/src/impls.rs
shawntabrizi Apr 14, 2020
afc5f99
Update test to show trend more clearly
shawntabrizi Apr 14, 2020
1d7f0b8
Merge branch 'shawntabrizi-update-weights' of https://github.com/pari…
shawntabrizi Apr 14, 2020
8af5797
test nit
shawntabrizi Apr 14, 2020
8b4e349
Update fixed64.rs
shawntabrizi Apr 14, 2020
e0a2be8
More fixes
shawntabrizi Apr 14, 2020
f9907bb
missed one
shawntabrizi Apr 14, 2020
d164555
More test fixes
shawntabrizi Apr 14, 2020
2baf8f6
Update lib.rs
shawntabrizi Apr 14, 2020
5564ec0
Merge branch 'master' into shawntabrizi-update-weights
shawntabrizi Apr 14, 2020
e830b11
Update Cargo.lock
shawntabrizi Apr 14, 2020
cf75a56
Bump spec version
shawntabrizi Apr 15, 2020
98dbf61
Clean and fic block weight tests.
kianenigma Apr 15, 2020
8fd3293
fix on-initialize weights
kianenigma Apr 15, 2020
8da68dc
Fix warnings
shawntabrizi Apr 15, 2020
1d6a9f2
fix warnings
shawntabrizi Apr 15, 2020
b1c0914
Merge branch 'master' into shawntabrizi-update-weights
shawntabrizi Apr 15, 2020
6b3fb93
Merge branch 'master' into shawntabrizi-update-weights
shawntabrizi Apr 15, 2020
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
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions bin/node-template/pallets/template/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/// https://github.com/paritytech/substrate/blob/master/frame/example/src/lib.rs

use frame_support::{decl_module, decl_storage, decl_event, decl_error, dispatch};
use frame_support::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT};
use frame_system::{self as system, ensure_signed};

#[cfg(test)]
Expand Down Expand Up @@ -75,7 +76,7 @@ decl_module! {
/// Just a dummy entry point.
/// function that can be called by the external world as an extrinsics call
/// takes a parameter of the type `AccountId`, stores it, and emits an event
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
pub fn do_something(origin, something: u32) -> dispatch::DispatchResult {
// Check it was signed and get the signer. See also: ensure_root and ensure_none
let who = ensure_signed(origin)?;
Expand All @@ -91,7 +92,7 @@ decl_module! {

/// Another dummy entry point.
/// takes no parameters, attempts to increment storage value, and possibly throws an error
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
pub fn cause_error(origin) -> dispatch::DispatchResult {
// Check it was signed and get the signer. See also: ensure_root and ensure_none
let _who = ensure_signed(origin)?;
Expand Down
1 change: 1 addition & 0 deletions bin/node-template/pallets/template/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ impl system::Trait for Test {
type Event = ();
type BlockHashCount = BlockHashCount;
type MaximumBlockWeight = MaximumBlockWeight;
type DbWeight = ();
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
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 @@ -120,7 +120,8 @@ pub fn native_version() -> NativeVersion {

parameter_types! {
pub const BlockHashCount: BlockNumber = 250;
pub const MaximumBlockWeight: Weight = 1_000_000_000;
/// We allow for 2 seconds of compute with a 6 second average block time.
pub const MaximumBlockWeight: Weight = 2_000_000_000_000;
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;
pub const Version: RuntimeVersion = VERSION;
Expand Down Expand Up @@ -151,6 +152,8 @@ impl system::Trait for Runtime {
type BlockHashCount = BlockHashCount;
/// Maximum weight of each block.
type MaximumBlockWeight = MaximumBlockWeight;
/// The weight of database operations that the runtime can invoke.
type DbWeight = ();
/// Maximum size of all encoded transactions (in bytes) that are allowed in one block.
type MaximumBlockLength = MaximumBlockLength;
/// Portion of the block weight that is available to all normal transactions.
Expand Down
16 changes: 7 additions & 9 deletions bin/node/executor/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use sp_core::{
NeverNativeValue, map, traits::Externalities, storage::{well_known_keys, Storage},
};
use sp_runtime::{
ApplyExtrinsicResult, Fixed64,
ApplyExtrinsicResult, Fixed128,
traits::{Hash as HashT, Convert, BlakeTwo256},
transaction_validity::InvalidTransaction,
};
Expand All @@ -51,7 +51,7 @@ use self::common::{*, sign};
pub const BLOATY_CODE: &[u8] = node_runtime::WASM_BINARY_BLOATY;

/// Default transfer fee
fn transfer_fee<E: Encode>(extrinsic: &E, fee_multiplier: Fixed64) -> Balance {
fn transfer_fee<E: Encode>(extrinsic: &E, fee_multiplier: Fixed128) -> Balance {
let length_fee = TransactionByteFee::get() * (extrinsic.encode().len() as Balance);

let weight = default_transfer_call().get_dispatch_info().weight;
Expand Down Expand Up @@ -338,7 +338,7 @@ fn full_native_block_import_works() {
EventRecord {
phase: Phase::ApplyExtrinsic(0),
event: Event::frame_system(frame_system::RawEvent::ExtrinsicSuccess(
DispatchInfo { weight: 10000, class: DispatchClass::Mandatory, pays_fee: true }
DispatchInfo { weight: 10_000_000, class: DispatchClass::Mandatory, pays_fee: true }
)),
topics: vec![],
},
Expand All @@ -359,7 +359,7 @@ fn full_native_block_import_works() {
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: Event::frame_system(frame_system::RawEvent::ExtrinsicSuccess(
DispatchInfo { weight: 1000000, class: DispatchClass::Normal, pays_fee: true }
DispatchInfo { weight: 200_000_000, class: DispatchClass::Normal, pays_fee: true }
)),
topics: vec![],
},
Expand Down Expand Up @@ -391,7 +391,7 @@ fn full_native_block_import_works() {
EventRecord {
phase: Phase::ApplyExtrinsic(0),
event: Event::frame_system(frame_system::RawEvent::ExtrinsicSuccess(
DispatchInfo { weight: 10000, class: DispatchClass::Mandatory, pays_fee: true }
DispatchInfo { weight: 10_000_000, class: DispatchClass::Mandatory, pays_fee: true }
)),
topics: vec![],
},
Expand All @@ -414,7 +414,7 @@ fn full_native_block_import_works() {
EventRecord {
phase: Phase::ApplyExtrinsic(1),
event: Event::frame_system(frame_system::RawEvent::ExtrinsicSuccess(
DispatchInfo { weight: 1000000, class: DispatchClass::Normal, pays_fee: true }
DispatchInfo { weight: 200_000_000, class: DispatchClass::Normal, pays_fee: true }
)),
topics: vec![],
},
Expand All @@ -437,7 +437,7 @@ fn full_native_block_import_works() {
EventRecord {
phase: Phase::ApplyExtrinsic(2),
event: Event::frame_system(frame_system::RawEvent::ExtrinsicSuccess(
DispatchInfo { weight: 1000000, class: DispatchClass::Normal, pays_fee: true }
DispatchInfo { weight: 200_000_000, class: DispatchClass::Normal, pays_fee: true }
)),
topics: vec![],
},
Expand Down Expand Up @@ -817,5 +817,3 @@ fn should_import_block_with_test_client() {

client.import(BlockOrigin::Own, block).unwrap();
}


8 changes: 5 additions & 3 deletions bin/node/executor/tests/fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use frame_support::{
weights::GetDispatchInfo,
};
use sp_core::{NeverNativeValue, map, storage::Storage};
use sp_runtime::{Fixed64, Perbill, traits::{Convert, BlakeTwo256}};
use sp_runtime::{Fixed128, Perbill, traits::{Convert, BlakeTwo256}};
use node_runtime::{
CheckedExtrinsic, Call, Runtime, Balances, TransactionPayment, TransactionBaseFee,
TransactionByteFee, WeightFeeCoefficient,
Expand All @@ -39,7 +39,7 @@ fn fee_multiplier_increases_and_decreases_on_big_weight() {
let mut t = new_test_ext(COMPACT_CODE, false);

// initial fee multiplier must be zero
let mut prev_multiplier = Fixed64::from_parts(0);
let mut prev_multiplier = Fixed128::from_parts(0);

t.execute_with(|| {
assert_eq!(TransactionPayment::next_fee_multiplier(), prev_multiplier);
Expand Down Expand Up @@ -188,7 +188,9 @@ fn transaction_fee_is_correct_ultimate() {
let weight_fee = LinearWeightToFee::<WeightFeeCoefficient>::convert(weight);

// we know that weight to fee multiplier is effect-less in block 1.
assert_eq!(weight_fee as Balance, MILLICENTS);
// 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);
balance_alice -= weight_fee;
balance_alice -= tip;

Expand Down
2 changes: 1 addition & 1 deletion bin/node/executor/tests/submit_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ fn submitted_transaction_should_be_valid() {
let res = Executive::validate_transaction(source, extrinsic);

assert_eq!(res.unwrap(), ValidTransaction {
priority: 2_411_002_000_000,
priority: 2_410_600_000_000,
requires: vec![],
provides: vec![(address, 0).encode()],
longevity: 128,
Expand Down
Loading