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 1 commit
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
Prev Previous commit
Next Next commit
Remove SimpleDispatchInfo::default()
  • Loading branch information
shawntabrizi committed Apr 14, 2020
commit c7af45393c3814db830d2c3e0301280781cce356
4 changes: 2 additions & 2 deletions bin/node-template/pallets/template/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,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 = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
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 +91,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 = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
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
6 changes: 3 additions & 3 deletions frame/assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ decl_module! {
/// Issue a new class of fungible assets. There are, and will only ever be, `total`
/// such assets and they'll all belong to the `origin` initially. It will have an
/// identifier `AssetId` instance: this will be specified in the `Issued` event.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
fn issue(origin, #[compact] total: T::Balance) {
let origin = ensure_signed(origin)?;

Expand All @@ -171,7 +171,7 @@ decl_module! {
}

/// Move some assets from one holder to another.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
fn transfer(origin,
#[compact] id: T::AssetId,
target: <T::Lookup as StaticLookup>::Source,
Expand All @@ -190,7 +190,7 @@ decl_module! {
}

/// Destroy any assets of `id` owned by `origin`.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
fn destroy(origin, #[compact] id: T::AssetId) {
let origin = ensure_signed(origin)?;
let balance = <Balances<T>>::take((id, &origin));
Expand Down
2 changes: 1 addition & 1 deletion frame/authorship/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ decl_module! {

T::EventHandler::note_author(Self::author());

SimpleDispatchInfo::default().weigh_data(())
SimpleDispatchInfo::FixedNormal(10_000_000).weigh_data(())
}

fn on_finalize() {
Expand Down
2 changes: 1 addition & 1 deletion frame/babe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ decl_module! {
fn on_initialize(now: T::BlockNumber) -> Weight {
Self::do_initialize(now);

SimpleDispatchInfo::default().weigh_data(())
SimpleDispatchInfo::FixedNormal(10_000_000).weigh_data(())
}

/// Block finalization
Expand Down
26 changes: 13 additions & 13 deletions frame/benchmark/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ decl_module! {
fn deposit_event() = default;

/// Do nothing.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
pub fn do_nothing(_origin, input: u32) {
if input > 0 {
return Ok(());
Expand All @@ -82,15 +82,15 @@ decl_module! {
/// storage database, however, the `repeat` calls will all pull from the
/// storage overlay cache. You must consider this when analyzing the
/// results of the benchmark.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
pub fn read_value(_origin, repeat: u32) {
for _ in 0..repeat {
MyValue::get();
}
}

/// Put a value into a storage value.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
pub fn put_value(_origin, repeat: u32) {
for r in 0..repeat {
MyValue::put(r);
Expand All @@ -102,69 +102,69 @@ decl_module! {
/// storage database, however, the `repeat` calls will all pull from the
/// storage overlay cache. You must consider this when analyzing the
/// results of the benchmark.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
pub fn exists_value(_origin, repeat: u32) {
for _ in 0..repeat {
MyValue::exists();
}
}

/// Remove a value from storage `repeat` number of times.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
pub fn remove_value(_origin, repeat: u32) {
for r in 0..repeat {
MyMap::remove(r);
}
}

/// Read a value from storage map `repeat` number of times.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
pub fn read_map(_origin, repeat: u32) {
for r in 0..repeat {
MyMap::get(r);
}
}

/// Insert a value into a map.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
pub fn insert_map(_origin, repeat: u32) {
for r in 0..repeat {
MyMap::insert(r, r);
}
}

/// Check is a map contains a value `repeat` number of times.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
pub fn contains_key_map(_origin, repeat: u32) {
for r in 0..repeat {
MyMap::contains_key(r);
}
}

/// Read a value from storage `repeat` number of times.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
pub fn remove_prefix(_origin, repeat: u32) {
for r in 0..repeat {
MyDoubleMap::remove_prefix(r);
}
}

/// Add user to the list.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
pub fn add_member_list(origin) {
let who = ensure_signed(origin)?;
MyMemberList::<T>::mutate(|x| x.push(who));
}

/// Append user to the list.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
pub fn append_member_list(origin) {
let who = ensure_signed(origin)?;
MyMemberList::<T>::append(&[who])?;
}

/// Encode a vector of accounts to bytes.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
pub fn encode_accounts(_origin, accounts: Vec<T::AccountId>) {
let bytes = accounts.encode();

Expand All @@ -176,7 +176,7 @@ decl_module! {
}

/// Decode bytes into a vector of accounts.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
pub fn decode_accounts(_origin, bytes: Vec<u8>) {
let accounts: Vec<T::AccountId> = Decode::decode(&mut bytes.as_slice()).map_err(|_| "Could not decode")?;

Expand Down
4 changes: 2 additions & 2 deletions frame/benchmarking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ decl_storage! {

decl_module! {
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
fn set_value(origin, n: u32) -> DispatchResult {
let _sender = ensure_signed(origin)?;
Value::put(n);
Ok(())
}

#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
fn dummy(origin, _n: u32) -> DispatchResult {
let _sender = ensure_none(origin)?;
Ok(())
Expand Down
10 changes: 5 additions & 5 deletions frame/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ decl_module! {
/// Updates the schedule for metering contracts.
///
/// The schedule must have a greater version than the stored schedule.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
pub fn update_schedule(origin, schedule: Schedule) -> DispatchResult {
ensure_root(origin)?;
if <Module<T>>::current_schedule().version >= schedule.version {
Expand All @@ -565,7 +565,7 @@ decl_module! {

/// Stores the given binary Wasm code into the chain's storage and returns its `codehash`.
/// You can instantiate contracts only with stored code.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
pub fn put_code(
origin,
#[compact] gas_limit: Gas,
Expand Down Expand Up @@ -593,7 +593,7 @@ decl_module! {
/// * If the account is a regular account, any value will be transferred.
/// * If no account exists and the call value is not less than `existential_deposit`,
/// a regular account will be created and any value will be transferred.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
pub fn call(
origin,
dest: <T::Lookup as StaticLookup>::Source,
Expand All @@ -619,7 +619,7 @@ decl_module! {
/// after the execution is saved as the `code` of the account. That code will be invoked
/// upon any call received by this account.
/// - The contract is initialized.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
pub fn instantiate(
origin,
#[compact] endowment: BalanceOf<T>,
Expand All @@ -642,7 +642,7 @@ decl_module! {
///
/// If contract is not evicted as a result of this call, no actions are taken and
/// the sender is not eligible for the reward.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
fn claim_surcharge(origin, dest: T::AccountId, aux_sender: Option<T::AccountId>) {
let origin = origin.into();
let (signed, rewarded) = match (origin, aux_sender) {
Expand Down
4 changes: 2 additions & 2 deletions frame/democracy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ decl_module! {
fn on_runtime_upgrade() -> Weight {
Self::migrate();

SimpleDispatchInfo::default().weigh_data(())
SimpleDispatchInfo::FixedNormal(10_000_000).weigh_data(())
}

/// Propose a sensitive action to be taken.
Expand Down Expand Up @@ -848,7 +848,7 @@ decl_module! {
sp_runtime::print(e);
}

SimpleDispatchInfo::default().weigh_data(())
SimpleDispatchInfo::FixedNormal(10_000_000).weigh_data(())
}

/// Specify a proxy that is already open to us. Called by the stash.
Expand Down
4 changes: 2 additions & 2 deletions frame/elections-phragmen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ decl_module! {
fn on_runtime_upgrade() -> Weight {
migration::migrate::<T>();

SimpleDispatchInfo::default().weigh_data(())
SimpleDispatchInfo::FixedNormal(10_000_000).weigh_data(())
}

const CandidacyBond: BalanceOf<T> = T::CandidacyBond::get();
Expand Down Expand Up @@ -510,7 +510,7 @@ decl_module! {
print(e);
}

SimpleDispatchInfo::default().weigh_data(())
SimpleDispatchInfo::FixedNormal(10_000_000).weigh_data(())
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion frame/elections/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ decl_module! {
print("Guru meditation");
print(e);
}
SimpleDispatchInfo::default().weigh_data(())
SimpleDispatchInfo::FixedNormal(10_000_000).weigh_data(())
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion frame/example/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ decl_module! {
// Anything that needs to be done at the start of the block.
// We don't do anything here.

SimpleDispatchInfo::default().weigh_data(())
SimpleDispatchInfo::FixedNormal(10_000_000).weigh_data(())
}

// The signature could also look like: `fn on_finalize()`
Expand Down
12 changes: 6 additions & 6 deletions frame/generic-asset/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,14 @@ decl_module! {
fn deposit_event() = default;

/// Create a new kind of asset.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
fn create(origin, options: AssetOptions<T::Balance, T::AccountId>) -> DispatchResult {
let origin = ensure_signed(origin)?;
Self::create_asset(None, Some(origin), options)
}

/// Transfer some liquid free balance to another account.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
pub fn transfer(origin, #[compact] asset_id: T::AssetId, to: T::AccountId, #[compact] amount: T::Balance) {
let origin = ensure_signed(origin)?;
ensure!(!amount.is_zero(), Error::<T>::ZeroAmount);
Expand All @@ -377,7 +377,7 @@ decl_module! {
/// Updates permission for a given `asset_id` and an account.
///
/// The `origin` must have `update` permission.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
fn update_permission(
origin,
#[compact] asset_id: T::AssetId,
Expand All @@ -400,7 +400,7 @@ decl_module! {

/// Mints an asset, increases its total issuance.
/// The origin must have `mint` permissions.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
fn mint(origin, #[compact] asset_id: T::AssetId, to: T::AccountId, amount: T::Balance) -> DispatchResult {
let who = ensure_signed(origin)?;
Self::mint_free(&asset_id, &who, &to, &amount)?;
Expand All @@ -410,7 +410,7 @@ decl_module! {

/// Burns an asset, decreases its total issuance.
/// The `origin` must have `burn` permissions.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
fn burn(origin, #[compact] asset_id: T::AssetId, to: T::AccountId, amount: T::Balance) -> DispatchResult {
let who = ensure_signed(origin)?;
Self::burn_free(&asset_id, &who, &to, &amount)?;
Expand All @@ -420,7 +420,7 @@ decl_module! {

/// Can be used to create reserved tokens.
/// Requires Root call.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
fn create_reserved(
origin,
asset_id: T::AssetId,
Expand Down
2 changes: 1 addition & 1 deletion frame/grandpa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ decl_module! {
fn deposit_event() = default;

/// Report some misbehavior.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
fn report_misbehavior(origin, _report: Vec<u8>) {
ensure_signed(origin)?;
// FIXME: https://github.com/paritytech/substrate/issues/1112
Expand Down
4 changes: 2 additions & 2 deletions frame/im-online/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
//!
//! decl_module! {
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
//! #[weight = frame_support::weights::SimpleDispatchInfo::default()]
//! #[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
//! pub fn is_online(origin, authority_index: u32) -> dispatch::DispatchResult {
//! let _sender = ensure_signed(origin)?;
//! let _is_online = <im_online::Module<T>>::is_online(authority_index);
Expand Down Expand Up @@ -316,7 +316,7 @@ decl_module! {

fn deposit_event() = default;

#[weight = frame_support::weights::SimpleDispatchInfo::default()]
#[weight = frame_support::weights::SimpleDispatchInfo::FixedNormal(10_000_000)]
fn heartbeat(
origin,
heartbeat: Heartbeat<T::BlockNumber>,
Expand Down
Loading