Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
polkadot
Commits
be1e2b31
Unverified
Commit
be1e2b31
authored
Apr 16, 2020
by
Shawn Tabrizi
Committed by
GitHub
Apr 16, 2020
Browse files
Companion PR for substrate#5446 (Update Weights to u64) (#994)
parent
b7fba731
Pipeline
#88164
passed with stages
in 31 minutes and 37 seconds
Changes
16
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Cargo.lock
View file @
be1e2b31
This diff is collapsed.
Click to expand it.
runtime/common/src/attestations.rs
View file @
be1e2b31
...
...
@@ -22,7 +22,10 @@
use
sp_std
::
prelude
::
*
;
use
codec
::{
Encode
,
Decode
};
use
frame_support
::{
decl_storage
,
decl_module
,
decl_error
,
ensure
,
dispatch
::
DispatchResult
,
traits
::
Get
decl_storage
,
decl_module
,
decl_error
,
ensure
,
dispatch
::
DispatchResult
,
traits
::
Get
,
weights
::{
MINIMUM_WEIGHT
,
SimpleDispatchInfo
},
};
use
primitives
::{
Hash
,
parachain
::{
AttestedCandidate
,
AbridgedCandidateReceipt
,
Id
as
ParaId
}};
...
...
@@ -131,7 +134,7 @@ decl_module! {
type
Error
=
Error
<
T
>
;
/// Provide candidate receipts for parachains, in ascending order by id.
#[weight
=
frame_support::weights::
SimpleDispatchInfo::FixedMandatory(
10_000
)]
#[weight
=
SimpleDispatchInfo::FixedMandatory(
MINIMUM_WEIGHT
)]
fn
more_attestations
(
origin
,
_more
:
MoreAttestations
)
->
DispatchResult
{
ensure_none
(
origin
)
?
;
ensure!
(
!
DidUpdate
::
exists
(),
Error
::
<
T
>
::
TooManyAttestations
);
...
...
runtime/common/src/claims.rs
View file @
be1e2b31
...
...
@@ -184,7 +184,7 @@ decl_module! {
///
/// Total Complexity: O(1)
/// </weight>
#[weight
=
SimpleDispatchInfo::FixedNormal(
1_000_000
)]
#[weight
=
SimpleDispatchInfo::FixedNormal(
1_000_000
_000
)]
fn
claim
(
origin
,
dest
:
T
::
AccountId
,
ethereum_signature
:
EcdsaSignature
)
{
ensure_none
(
origin
)
?
;
...
...
@@ -231,7 +231,7 @@ decl_module! {
///
/// Total Complexity: O(1)
/// </weight>
#[weight
=
SimpleDispatchInfo::FixedNormal(
30_000
)]
#[weight
=
SimpleDispatchInfo::FixedNormal(
30_000
_000
)]
fn
mint_claim
(
origin
,
who
:
EthereumAddress
,
value
:
BalanceOf
<
T
>
,
...
...
@@ -390,6 +390,7 @@ mod tests {
type
Event
=
();
type
BlockHashCount
=
BlockHashCount
;
type
MaximumBlockWeight
=
MaximumBlockWeight
;
type
DbWeight
=
();
type
MaximumBlockLength
=
MaximumBlockLength
;
type
AvailableBlockRatio
=
AvailableBlockRatio
;
type
Version
=
();
...
...
runtime/common/src/crowdfund.rs
View file @
be1e2b31
...
...
@@ -67,15 +67,16 @@
//! funds ultimately end up in module's fund sub-account.
use
frame_support
::{
decl_module
,
decl_storage
,
decl_event
,
decl_error
,
storage
::
child
,
ensure
,
traits
::{
decl_module
,
decl_storage
,
decl_event
,
decl_error
,
storage
::
child
,
ensure
,
traits
::{
Currency
,
Get
,
OnUnbalanced
,
WithdrawReason
,
ExistenceRequirement
::
AllowDeath
}
},
weights
::{
MINIMUM_WEIGHT
,
SimpleDispatchInfo
},
};
use
system
::
ensure_signed
;
use
sp_runtime
::{
ModuleId
,
traits
::{
AccountIdConversion
,
Hash
,
Saturating
,
Zero
,
CheckedAdd
}
};
use
frame_support
::
weights
::
SimpleDispatchInfo
;
use
crate
::
slots
;
use
codec
::{
Encode
,
Decode
};
use
sp_std
::
vec
::
Vec
;
...
...
@@ -250,7 +251,7 @@ decl_module! {
fn
deposit_event
()
=
default
;
/// Create a new crowdfunding campaign for a parachain slot deposit for the current auction.
#[weight
=
SimpleDispatchInfo::FixedNormal(
100_000
)]
#[weight
=
SimpleDispatchInfo::FixedNormal(
100_000
_000
)]
fn
create
(
origin
,
#[compact]
cap
:
BalanceOf
<
T
>
,
#[compact]
first_slot
:
T
::
BlockNumber
,
...
...
@@ -294,7 +295,7 @@ decl_module! {
/// Contribute to a crowd sale. This will transfer some balance over to fund a parachain
/// slot. It will be withdrawable in two instances: the parachain becomes retired; or the
/// slot is unable to be purchased and the timeout expires.
#[weight
=
SimpleDispatchInfo::
default(
)]
#[weight
=
SimpleDispatchInfo::
FixedNormal(MINIMUM_WEIGHT
)]
fn
contribute
(
origin
,
#[compact]
index
:
FundIndex
,
#[compact]
value
:
BalanceOf
<
T
>
)
{
let
who
=
ensure_signed
(
origin
)
?
;
...
...
@@ -353,7 +354,7 @@ decl_module! {
/// - `index` is the fund index that `origin` owns and whose deploy data will be set.
/// - `code_hash` is the hash of the parachain's Wasm validation function.
/// - `initial_head_data` is the parachain's initial head data.
#[weight
=
SimpleDispatchInfo::
default(
)]
#[weight
=
SimpleDispatchInfo::
FixedNormal(MINIMUM_WEIGHT
)]
fn
fix_deploy_data
(
origin
,
#[compact]
index
:
FundIndex
,
code_hash
:
T
::
Hash
,
...
...
@@ -379,7 +380,7 @@ decl_module! {
///
/// - `index` is the fund index that `origin` owns and whose deploy data will be set.
/// - `para_id` is the parachain index that this fund won.
#[weight
=
SimpleDispatchInfo::
default(
)]
#[weight
=
SimpleDispatchInfo::
FixedNormal(MINIMUM_WEIGHT
)]
fn
onboard
(
origin
,
#[compact]
index
:
FundIndex
,
#[compact]
para_id
:
ParaId
...
...
@@ -408,7 +409,7 @@ decl_module! {
}
/// Note that a successful fund has lost its parachain slot, and place it into retirement.
#[weight
=
SimpleDispatchInfo::
default(
)]
#[weight
=
SimpleDispatchInfo::
FixedNormal(MINIMUM_WEIGHT
)]
fn
begin_retirement
(
origin
,
#[compact]
index
:
FundIndex
)
{
let
_
=
ensure_signed
(
origin
)
?
;
...
...
@@ -430,7 +431,7 @@ decl_module! {
}
/// Withdraw full balance of a contributor to an unsuccessful or off-boarded fund.
#[weight
=
SimpleDispatchInfo::
default(
)]
#[weight
=
SimpleDispatchInfo::
FixedNormal(MINIMUM_WEIGHT
)]
fn
withdraw
(
origin
,
#[compact]
index
:
FundIndex
)
{
let
who
=
ensure_signed
(
origin
)
?
;
...
...
@@ -461,7 +462,7 @@ decl_module! {
/// Remove a fund after either: it was unsuccessful and it timed out; or it was successful
/// but it has been retired from its parachain slot. This places any deposits that were not
/// withdrawn into the treasury.
#[weight
=
SimpleDispatchInfo::
default(
)]
#[weight
=
SimpleDispatchInfo::
FixedNormal(MINIMUM_WEIGHT
)]
fn
dissolve
(
origin
,
#[compact]
index
:
FundIndex
)
{
let
_
=
ensure_signed
(
origin
)
?
;
...
...
@@ -619,6 +620,7 @@ mod tests {
type
Event
=
();
type
BlockHashCount
=
BlockHashCount
;
type
MaximumBlockWeight
=
MaximumBlockWeight
;
type
DbWeight
=
();
type
MaximumBlockLength
=
MaximumBlockLength
;
type
AvailableBlockRatio
=
AvailableBlockRatio
;
type
Version
=
();
...
...
runtime/common/src/impls.rs
View file @
be1e2b31
...
...
@@ -16,8 +16,9 @@
//! Auxillary struct/enums for polkadot runtime.
use
core
::
num
::
NonZeroI128
;
use
sp_runtime
::
traits
::{
Convert
,
Saturating
};
use
sp_runtime
::{
Fixed
64
,
Per
b
ill
};
use
sp_runtime
::{
Fixed
128
,
Per
quint
ill
};
use
frame_support
::
traits
::{
OnUnbalanced
,
Imbalance
,
Currency
,
Get
};
use
crate
::{
MaximumBlockWeight
,
NegativeImbalance
};
...
...
@@ -75,16 +76,16 @@ where
/// Update the given multiplier based on the following formula
///
/// diff = (
target_weight - previous_block
_weight
)
/// diff = (
previous_block_weight - target_weight)/max
_weight
/// v = 0.00004
/// next_weight = weight * (1 + (v
.
diff) + (v
.
diff)^2 / 2)
/// next_weight = weight * (1 + (v
*
diff) + (v
*
diff)^2 / 2)
///
/// Where `target_weight` must be given as the `Get` implementation of the `T` generic type.
/// https://research.web3.foundation/en/latest/polkadot/Token%20Economics/#relay-chain-transaction-fees
pub
struct
TargetedFeeAdjustment
<
T
,
R
>
(
sp_std
::
marker
::
PhantomData
<
(
T
,
R
)
>
);
impl
<
T
:
Get
<
Per
b
ill
>
,
R
:
system
::
Trait
>
Convert
<
Fixed
64
,
Fixed
64
>
for
TargetedFeeAdjustment
<
T
,
R
>
{
fn
convert
(
multiplier
:
Fixed
64
)
->
Fixed
64
{
impl
<
T
:
Get
<
Per
quint
ill
>
,
R
:
system
::
Trait
>
Convert
<
Fixed
128
,
Fixed
128
>
for
TargetedFeeAdjustment
<
T
,
R
>
{
fn
convert
(
multiplier
:
Fixed
128
)
->
Fixed
128
{
let
block_weight
=
<
system
::
Module
<
R
>>
::
all_extrinsics_weight
();
let
max_weight
=
MaximumBlockWeight
::
get
();
let
target_weight
=
(
T
::
get
()
*
max_weight
)
as
u128
;
...
...
@@ -93,19 +94,20 @@ impl<T: Get<Perbill>, R: system::Trait> Convert<Fixed64, Fixed64> for TargetedFe
// determines if the first_term is positive
let
positive
=
block_weight
>=
target_weight
;
let
diff_abs
=
block_weight
.max
(
target_weight
)
-
block_weight
.min
(
target_weight
);
// diff is within u32, safe.
let
diff
=
Fixed64
::
from_rational
(
diff_abs
as
i64
,
max_weight
as
u64
);
// safe, diff_abs cannot exceed u64 and it can always be computed safely even with the lossy
// `Fixed128::from_rational`.
let
diff
=
Fixed128
::
from_rational
(
diff_abs
as
i128
,
NonZeroI128
::
new
(
max_weight
.max
(
1
)
as
i128
)
.unwrap
(),
);
let
diff_squared
=
diff
.saturating_mul
(
diff
);
// 0.00004 = 4/100_000 = 40_000/10^9
let
v
=
Fixed64
::
from_rational
(
4
,
100_000
);
// 0.00004^2 = 16/10^10 ~= 2/10^9. Taking the future /2 into account, then it is just 1
// parts from a billionth.
let
v_squared_2
=
Fixed64
::
from_rational
(
1
,
1_000_000_000
);
let
v
=
Fixed128
::
from_rational
(
4
,
NonZeroI128
::
new
(
100_000
)
.unwrap
());
// 0.00004^2 = 16/10^10 Taking the future /2 into account... 8/10^10
let
v_squared_2
=
Fixed128
::
from_rational
(
8
,
NonZeroI128
::
new
(
10_000_000_000
)
.unwrap
());
let
first_term
=
v
.saturating_mul
(
diff
);
// It is very unlikely that this will exist (in our poor perbill estimate) but we are giving
// it a shot.
let
second_term
=
v_squared_2
.saturating_mul
(
diff_squared
);
if
positive
{
...
...
@@ -114,15 +116,15 @@ impl<T: Get<Perbill>, R: system::Trait> Convert<Fixed64, Fixed64> for TargetedFe
let
excess
=
first_term
.saturating_add
(
second_term
);
multiplier
.saturating_add
(
excess
)
}
else
{
//
Proof
: first_term > second_term. Safe subtraction.
let
negative
=
first_term
-
second_term
;
//
Defensive-only
: first_term > second_term. Safe subtraction.
let
negative
=
first_term
.saturating_sub
(
second_term
)
;
multiplier
.saturating_sub
(
negative
)
// despite the fact that apply_to saturates weight (final fee cannot go below 0)
// it is crucially important to stop here and don't further reduce the weight fee
// multiplier. While at -1, it means that the network is so un-congested that all
// transactions have no weight fee. We stop here and only increase if the network
// became more busy.
.max
(
Fixed
64
::
from_
r
at
ion
al
(
-
1
,
1
))
.max
(
Fixed
128
::
from_
n
at
ur
al
(
-
1
))
}
}
}
runtime/common/src/lib.rs
View file @
be1e2b31
...
...
@@ -50,7 +50,7 @@ pub type NegativeImbalance<T> = <balances::Module<T> as Currency<<T as system::T
parameter_types!
{
pub
const
BlockHashCount
:
BlockNumber
=
250
;
pub
const
MaximumBlockWeight
:
Weight
=
1
_000_000_000
;
pub
const
MaximumBlockWeight
:
Weight
=
2_000
_000_000_000
;
pub
const
AvailableBlockRatio
:
Perbill
=
Perbill
::
from_percent
(
75
);
pub
const
MaximumBlockLength
:
u32
=
5
*
1024
*
1024
;
}
runtime/common/src/parachains.rs
View file @
be1e2b31
...
...
@@ -36,7 +36,7 @@ use sp_staking::{
use
frame_support
::{
traits
::
KeyOwnerProofSystem
,
dispatch
::{
IsSubType
},
weights
::{
SimpleDispatchInfo
,
Weight
,
WeighData
},
weights
::{
SimpleDispatchInfo
,
Weight
,
MINIMUM_WEIGHT
},
};
use
primitives
::{
Balance
,
...
...
@@ -538,7 +538,7 @@ decl_module! {
Self
::
do_old_code_pruning
(
now
);
// TODO https://github.com/paritytech/polkadot/issues/977: set correctly
SimpleDispatchInfo
::
default
()
.weigh_data
(())
MINIMUM_WEIGHT
}
fn
on_finalize
()
{
...
...
@@ -546,7 +546,7 @@ decl_module! {
}
/// Provide candidate receipts for parachains, in ascending order by id.
#[weight
=
SimpleDispatchInfo::FixedMandatory(
1_000_000
)]
#[weight
=
SimpleDispatchInfo::FixedMandatory(
1_000_000
_000
)]
pub
fn
set_heads
(
origin
,
heads
:
Vec
<
AttestedCandidate
>
)
->
DispatchResult
{
ensure_none
(
origin
)
?
;
ensure!
(
!<
DidUpdate
>
::
exists
(),
Error
::
<
T
>
::
TooManyHeadUpdates
);
...
...
@@ -1593,6 +1593,7 @@ mod tests {
type
Event
=
();
type
BlockHashCount
=
BlockHashCount
;
type
MaximumBlockWeight
=
MaximumBlockWeight
;
type
DbWeight
=
();
type
MaximumBlockLength
=
MaximumBlockLength
;
type
AvailableBlockRatio
=
AvailableBlockRatio
;
type
Version
=
();
...
...
runtime/common/src/registrar.rs
View file @
be1e2b31
...
...
@@ -31,7 +31,7 @@ use sp_runtime::{
use
frame_support
::{
decl_storage
,
decl_module
,
decl_event
,
decl_error
,
ensure
,
dispatch
::{
DispatchResult
,
IsSubType
},
traits
::{
Get
,
Currency
,
ReservableCurrency
},
weights
::{
SimpleDispatchInfo
,
Weight
,
WeighData
},
weights
::{
SimpleDispatchInfo
,
Weight
,
MINIMUM_WEIGHT
},
};
use
system
::{
self
,
ensure_root
,
ensure_signed
};
use
primitives
::
parachain
::{
...
...
@@ -264,7 +264,7 @@ decl_module! {
///
/// Unlike the `Registrar` trait function of the same name, this
/// checks the code and head data against size limits.
#[weight
=
SimpleDispatchInfo::FixedOperational(
5_000_000
)]
#[weight
=
SimpleDispatchInfo::FixedOperational(
5_000_000
_000
)]
pub
fn
register_para
(
origin
,
#[compact]
id
:
ParaId
,
info
:
ParaInfo
,
...
...
@@ -289,7 +289,7 @@ decl_module! {
}
/// Deregister a parachain with given id
#[weight
=
SimpleDispatchInfo::FixedOperational(
10_000
)]
#[weight
=
SimpleDispatchInfo::FixedOperational(
10_000
_000
)]
pub
fn
deregister_para
(
origin
,
#[compact]
id
:
ParaId
)
->
DispatchResult
{
ensure_root
(
origin
)
?
;
<
Self
as
Registrar
<
T
::
AccountId
>>
::
deregister_para
(
id
)
...
...
@@ -300,7 +300,7 @@ decl_module! {
/// - `count`: The number of parathreads.
///
/// Must be called from Root origin.
#[weight
=
SimpleDispatchInfo::
default(
)]
#[weight
=
SimpleDispatchInfo::
FixedNormal(MINIMUM_WEIGHT
)]
fn
set_thread_count
(
origin
,
count
:
u32
)
{
ensure_root
(
origin
)
?
;
ThreadCount
::
put
(
count
);
...
...
@@ -314,7 +314,7 @@ decl_module! {
/// Unlike `register_para`, this function does check that the maximum code size
/// and head data size are respected, as parathread registration is an atomic
/// action.
#[weight
=
SimpleDispatchInfo::
default(
)]
#[weight
=
SimpleDispatchInfo::
FixedNormal(MINIMUM_WEIGHT
)]
fn
register_parathread
(
origin
,
code
:
ValidationCode
,
initial_head_data
:
HeadData
,
...
...
@@ -354,7 +354,7 @@ decl_module! {
/// This is a kind of special transaction that should be heavily prioritized in the
/// transaction pool according to the `value`; only `ThreadCount` of them may be presented
/// in any single block.
#[weight
=
SimpleDispatchInfo::
default(
)]
#[weight
=
SimpleDispatchInfo::
FixedNormal(MINIMUM_WEIGHT
)]
fn
select_parathread
(
origin
,
#[compact]
_id
:
ParaId
,
_collator
:
CollatorId
,
...
...
@@ -371,7 +371,7 @@ decl_module! {
/// Ensure that before calling this that any funds you want emptied from the parathread's
/// account is moved out; after this it will be impossible to retrieve them (without
/// governance intervention).
#[weight
=
SimpleDispatchInfo::
default(
)]
#[weight
=
SimpleDispatchInfo::
FixedNormal(MINIMUM_WEIGHT
)]
fn
deregister_parathread
(
origin
)
{
let
id
=
parachains
::
ensure_parachain
(
<
T
as
Trait
>
::
Origin
::
from
(
origin
))
?
;
...
...
@@ -395,7 +395,7 @@ decl_module! {
/// `ParaId` to be a long-term identifier of a notional "parachain". However, their
/// scheduling info (i.e. whether they're a parathread or parachain), auction information
/// and the auction deposit are switched.
#[weight
=
SimpleDispatchInfo::
default(
)]
#[weight
=
SimpleDispatchInfo::
FixedNormal(MINIMUM_WEIGHT
)]
fn
swap
(
origin
,
#[compact]
other
:
ParaId
)
{
let
id
=
parachains
::
ensure_parachain
(
<
T
as
Trait
>
::
Origin
::
from
(
origin
))
?
;
...
...
@@ -466,7 +466,7 @@ decl_module! {
Active
::
put
(
paras
);
SimpleDispatchInfo
::
default
()
.weigh_data
(())
MINIMUM_WEIGHT
}
fn
on_finalize
()
{
...
...
@@ -726,6 +726,7 @@ mod tests {
type
Event
=
();
type
BlockHashCount
=
BlockHashCount
;
type
MaximumBlockWeight
=
MaximumBlockWeight
;
type
DbWeight
=
();
type
MaximumBlockLength
=
MaximumBlockLength
;
type
AvailableBlockRatio
=
AvailableBlockRatio
;
type
Version
=
();
...
...
runtime/common/src/slots.rs
View file @
be1e2b31
...
...
@@ -26,7 +26,7 @@ use codec::{Encode, Decode, Codec};
use
frame_support
::{
decl_module
,
decl_storage
,
decl_event
,
decl_error
,
ensure
,
dispatch
::
DispatchResult
,
traits
::{
Currency
,
ReservableCurrency
,
WithdrawReason
,
ExistenceRequirement
,
Get
,
Randomness
},
weights
::{
SimpleDispatchInfo
,
WeighData
,
Weight
},
weights
::{
MINIMUM_WEIGHT
,
SimpleDispatchInfo
,
Weight
},
};
use
primitives
::
parachain
::{
SwapAux
,
PARACHAIN_INFO
,
Id
as
ParaId
,
ValidationCode
,
HeadData
,
...
...
@@ -286,7 +286,7 @@ decl_module! {
Self
::
manage_lease_period_start
(
lease_period_index
);
}
SimpleDispatchInfo
::
default
()
.weigh_data
(())
MINIMUM_WEIGHT
}
fn
on_finalize
(
now
:
T
::
BlockNumber
)
{
...
...
@@ -309,7 +309,7 @@ decl_module! {
/// This can only happen when there isn't already an auction in progress and may only be
/// called by the root origin. Accepts the `duration` of this auction and the
/// `lease_period_index` of the initial lease period of the four that are to be auctioned.
#[weight
=
SimpleDispatchInfo::FixedOperational(
100_000
)]
#[weight
=
SimpleDispatchInfo::FixedOperational(
100_000
_000
)]
pub
fn
new_auction
(
origin
,
#[compact]
duration
:
T
::
BlockNumber
,
#[compact]
lease_period_index
:
LeasePeriodOf
<
T
>
...
...
@@ -344,7 +344,7 @@ decl_module! {
/// absolute lease period index value, not an auction-specific offset.
/// - `amount` is the amount to bid to be held as deposit for the parachain should the
/// bid win. This amount is held throughout the range.
#[weight
=
SimpleDispatchInfo::FixedNormal(
500_000
)]
#[weight
=
SimpleDispatchInfo::FixedNormal(
500_000
_000
)]
pub
fn
bid
(
origin
,
#[compact]
sub
:
SubId
,
#[compact]
auction_index
:
AuctionIndex
,
...
...
@@ -372,7 +372,7 @@ decl_module! {
/// absolute lease period index value, not an auction-specific offset.
/// - `amount` is the amount to bid to be held as deposit for the parachain should the
/// bid win. This amount is held throughout the range.
#[weight
=
SimpleDispatchInfo::FixedNormal(
500_000
)]
#[weight
=
SimpleDispatchInfo::FixedNormal(
500_000
_000
)]
fn
bid_renew
(
origin
,
#[compact]
auction_index
:
AuctionIndex
,
#[compact]
first_slot
:
LeasePeriodOf
<
T
>
,
...
...
@@ -391,7 +391,7 @@ decl_module! {
/// The origin *must* be a parachain account.
///
/// - `dest` is the destination account to receive the parachain's deposit.
#[weight
=
SimpleDispatchInfo::FixedNormal(
1_000_000
)]
#[weight
=
SimpleDispatchInfo::FixedNormal(
1_000_000
_000
)]
pub
fn
set_offboarding
(
origin
,
dest
:
<
T
::
Lookup
as
StaticLookup
>
::
Source
)
{
let
who
=
ensure_signed
(
origin
)
?
;
let
dest
=
T
::
Lookup
::
lookup
(
dest
)
?
;
...
...
@@ -407,7 +407,7 @@ decl_module! {
/// - `para_id` is the parachain ID allotted to the winning bidder.
/// - `code_hash` is the hash of the parachain's Wasm validation function.
/// - `initial_head_data` is the parachain's initial head data.
#[weight
=
SimpleDispatchInfo::FixedNormal(
500_000
)]
#[weight
=
SimpleDispatchInfo::FixedNormal(
500_000
_000
)]
pub
fn
fix_deploy_data
(
origin
,
#[compact]
sub
:
SubId
,
#[compact]
para_id
:
ParaId
,
...
...
@@ -449,7 +449,7 @@ decl_module! {
/// - `_origin` is irrelevant.
/// - `para_id` is the parachain ID whose code will be elaborated.
/// - `code` is the preimage of the registered `code_hash` of `para_id`.
#[weight
=
SimpleDispatchInfo::FixedNormal(
5_000_000
)]
#[weight
=
SimpleDispatchInfo::FixedNormal(
5_000_000
_000
)]
pub
fn
elaborate_deploy_data
(
_origin
,
#[compact]
para_id
:
ParaId
,
...
...
@@ -921,6 +921,7 @@ mod tests {
type
Event
=
();
type
BlockHashCount
=
BlockHashCount
;
type
MaximumBlockWeight
=
MaximumBlockWeight
;
type
DbWeight
=
();
type
MaximumBlockLength
=
MaximumBlockLength
;
type
AvailableBlockRatio
=
AvailableBlockRatio
;
type
Version
=
();
...
...
runtime/kusama/src/constants.rs
View file @
be1e2b31
...
...
@@ -71,8 +71,8 @@ pub mod fee {
pub
struct
WeightToFee
;
impl
Convert
<
Weight
,
Balance
>
for
WeightToFee
{
fn
convert
(
x
:
Weight
)
->
Balance
{
// in Kusama a weight of 10_000 (smallest non-zero weight) is mapped to 1/10 CENT:
Balance
::
from
(
x
)
.saturating_mul
(
super
::
currency
::
CENTS
/
(
10
*
10_000
))
// in Kusama a weight of 10_000
_000
(smallest non-zero weight) is mapped to 1/10 CENT:
Balance
::
from
(
x
)
.saturating_mul
(
super
::
currency
::
CENTS
/
(
10
*
10_000
_000
))
}
}
}
runtime/kusama/src/lib.rs
View file @
be1e2b31
...
...
@@ -34,7 +34,7 @@ use runtime_common::{attestations, claims, parachains, registrar, slots,
};
use
sp_runtime
::{
create_runtime_str
,
generic
,
impl_opaque_keys
,
ApplyExtrinsicResult
,
KeyTypeId
,
Percent
,
Permill
,
Perbill
,
RuntimeDebug
,
ApplyExtrinsicResult
,
KeyTypeId
,
Percent
,
Permill
,
Perbill
,
Perquintill
,
RuntimeDebug
,
transaction_validity
::{
TransactionValidity
,
InvalidTransaction
,
TransactionValidityError
,
TransactionSource
,
TransactionPriority
,
},
...
...
@@ -83,8 +83,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name
:
create_runtime_str!
(
"kusama"
),
impl_name
:
create_runtime_str!
(
"parity-kusama"
),
authoring_version
:
2
,
spec_version
:
105
7
,
impl_version
:
1
,
spec_version
:
105
8
,
impl_version
:
0
,
apis
:
RUNTIME_API_VERSIONS
,
};
...
...
@@ -143,6 +143,7 @@ impl system::Trait for Runtime {
type
Event
=
Event
;
type
BlockHashCount
=
BlockHashCount
;
type
MaximumBlockWeight
=
MaximumBlockWeight
;
type
DbWeight
=
();
type
MaximumBlockLength
=
MaximumBlockLength
;
type
AvailableBlockRatio
=
AvailableBlockRatio
;
type
Version
=
Version
;
...
...
@@ -207,7 +208,7 @@ parameter_types! {
pub
const
TransactionBaseFee
:
Balance
=
1
*
CENTS
;
pub
const
TransactionByteFee
:
Balance
=
10
*
MILLICENTS
;
// for a sane configuration, this should always be less than `AvailableBlockRatio`.
pub
const
TargetBlockFullness
:
Per
b
ill
=
Per
b
ill
::
from_percent
(
25
);
pub
const
TargetBlockFullness
:
Per
quint
ill
=
Per
quint
ill
::
from_percent
(
25
);
}
impl
transaction_payment
::
Trait
for
Runtime
{
...
...
runtime/polkadot/src/constants.rs
View file @
be1e2b31
...
...
@@ -63,8 +63,8 @@ pub mod fee {
pub
struct
WeightToFee
;
impl
Convert
<
Weight
,
Balance
>
for
WeightToFee
{
fn
convert
(
x
:
Weight
)
->
Balance
{
// in Polkadot a weight of 10_000 (smallest non-zero weight) is mapped to
(
1/10 CENT
)
:
Balance
::
from
(
x
)
.saturating_mul
(
super
::
currency
::
CENTS
/
(
10
*
10_000
))
// in Polkadot a weight of 10_000
_000
(smallest non-zero weight) is mapped to 1/10 CENT:
Balance
::
from
(
x
)
.saturating_mul
(
super
::
currency
::
CENTS
/
(
10
*
10_000
_000
))
}
}
}
runtime/polkadot/src/lib.rs
View file @
be1e2b31
...
...
@@ -35,7 +35,7 @@ use primitives::{
};
use
sp_runtime
::{
create_runtime_str
,
generic
,
impl_opaque_keys
,
ApplyExtrinsicResult
,
KeyTypeId
,
Percent
,
Permill
,
Perbill
,
RuntimeDebug
,
ApplyExtrinsicResult
,
KeyTypeId
,
Percent
,
Permill
,
Perbill
,
Perquintill
,
RuntimeDebug
,
transaction_validity
::{
TransactionValidity
,
InvalidTransaction
,
TransactionValidityError
,
TransactionSource
,
TransactionPriority
,
},
...
...
@@ -85,7 +85,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name
:
create_runtime_str!
(
"polkadot"
),
impl_name
:
create_runtime_str!
(
"parity-polkadot"
),
authoring_version
:
2
,
spec_version
:
100
6
,
spec_version
:
100
7
,
impl_version
:
0
,
apis
:
RUNTIME_API_VERSIONS
,
};
...
...
@@ -148,6 +148,7 @@ impl system::Trait for Runtime {
type
Event
=
Event
;
type
BlockHashCount
=
BlockHashCount
;
type
MaximumBlockWeight
=
MaximumBlockWeight
;
type
DbWeight
=
();
type
MaximumBlockLength
=
MaximumBlockLength
;
type
AvailableBlockRatio
=
AvailableBlockRatio
;
type
Version
=
Version
;
...
...
@@ -212,7 +213,7 @@ parameter_types! {
pub
const
TransactionBaseFee
:
Balance
=
1
*
CENTS
;
pub
const
TransactionByteFee
:
Balance
=
10
*
MILLICENTS
;
// for a sane configuration, this should always be less than `AvailableBlockRatio`.
pub
const
TargetBlockFullness
:
Per
b
ill
=
Per
b
ill
::
from_percent
(
25
);
pub
const
TargetBlockFullness
:
Per
quint
ill
=
Per
quint
ill
::
from_percent
(
25
);
}
impl
transaction_payment
::
Trait
for
Runtime
{
...
...
runtime/test-runtime/src/constants.rs
View file @
be1e2b31
...
...
@@ -65,8 +65,8 @@ pub mod fee {
pub
struct
WeightToFee
;
impl
Convert
<
Weight
,
Balance
>
for
WeightToFee
{
fn
convert
(
x
:
Weight
)
->
Balance
{
// in Kusama a weight of 10_000 (smallest non-zero weight) is mapped to 1/10 CENT:
Balance
::
from
(
x
)
.saturating_mul
(
super
::
currency
::
CENTS
/
(
10
*
10_000
))
// in Kusama a weight of 10_000
_000
(smallest non-zero weight) is mapped to 1/10 CENT:
Balance
::
from
(
x
)
.saturating_mul
(
super
::
currency
::
CENTS
/
(
10
*
10_000
_000
))
}
}
}
runtime/test-runtime/src/lib.rs
View file @
be1e2b31
...
...
@@ -34,7 +34,7 @@ use runtime_common::{attestations, claims, parachains, registrar, slots,
use
sp_runtime
::{
create_runtime_str
,
generic
,
impl_opaque_keys
,
ApplyExtrinsicResult
,
Perbill
,
RuntimeDebug
,
KeyTypeId
,
ApplyExtrinsicResult
,
Perbill
,
Perquintill
,
RuntimeDebug
,
KeyTypeId
,
transaction_validity
::{
TransactionValidity
,
InvalidTransaction
,
TransactionValidityError
,
TransactionSource
,
TransactionPriority
,
},
...
...
@@ -79,7 +79,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name
:
create_runtime_str!
(
"polkadot-test-runtime"
),
impl_name
:
create_runtime_str!
(
"parity-polkadot-test-runtime"
),
authoring_version
:
2
,
spec_version
:
10
49
,
spec_version
:
10
50
,
impl_version
:
0
,
apis
:
RUNTIME_API_VERSIONS
,
};
...
...
@@ -139,6 +139,7 @@ impl system::Trait for Runtime {
type
Event
=
Event
;
type
BlockHashCount
=
BlockHashCount
;
type
MaximumBlockWeight
=
MaximumBlockWeight
;
type
DbWeight
=
();
type
MaximumBlockLength
=
MaximumBlockLength
;
type
AvailableBlockRatio
=
AvailableBlockRatio
;
type
Version
=
Version
;
...
...
@@ -188,7 +189,7 @@ parameter_types! {
pub
const
TransactionBaseFee
:
Balance
=
1
*
CENTS
;
pub
const
TransactionByteFee
:
Balance
=
10
*
MILLICENTS
;
// for a sane configuration, this should always be less than `AvailableBlockRatio`.
pub
const
TargetBlockFullness
:
Per
b
ill
=
Per
b
ill
::
from_percent
(
25
);
pub
const
TargetBlockFullness
:
Per
quint
ill
=
Per
quint
ill
::
from_percent
(
25
);
}
impl
transaction_payment
::
Trait
for
Runtime
{
...
...
runtime/westend/src/lib.rs
View file @
be1e2b31
...
...
@@ -32,7 +32,7 @@ use runtime_common::{attestations, parachains, registrar,
};
use
sp_runtime
::{
create_runtime_str
,
generic
,
impl_opaque_keys
,
ApplyExtrinsicResult
,
KeyTypeId
,
Perbill
,
RuntimeDebug
,
ApplyExtrinsicResult
,
KeyTypeId
,
Perbill
,
Perquintill
,
RuntimeDebug
,
transaction_validity
::{
TransactionValidity
,
InvalidTransaction
,
TransactionValidityError
,
TransactionSource
,
TransactionPriority
,
...
...
@@ -80,8 +80,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name
:
create_runtime_str!
(
"westend"
),
impl_name
:
create_runtime_str!
(
"parity-westend"
),
authoring_version
:
2
,
spec_version
:
2
,
impl_version
:
1
,
spec_version
:
3
,
impl_version
:
0
,
apis
:
RUNTIME_API_VERSIONS
,
};
...
...
@@ -140,6 +140,7 @@ impl system::Trait for Runtime {
type
Event
=
Event
;
type
BlockHashCount
=
BlockHashCount
;
type
MaximumBlockWeight
=
MaximumBlockWeight
;
type
DbWeight
=
();
type
MaximumBlockLength
=
MaximumBlockLength
;
type
AvailableBlockRatio
=
AvailableBlockRatio
;
type
Version
=
Version
;
...
...
@@ -196,7 +197,7 @@ parameter_types! {
pub
const
TransactionBaseFee
:
Balance
=
1
*
CENTS
;
pub
const
TransactionByteFee
:
Balance
=
10
*
MILLICENTS
;
// for a sane configuration, this should always be less than `AvailableBlockRatio`.
pub
const
TargetBlockFullness
:
Per
b
ill
=
Per
b
ill
::
from_percent
(
25
);
pub
const
TargetBlockFullness
:
Per
quint
ill
=
Per
quint
ill
::
from_percent
(
25
);
}
impl
transaction_payment
::
Trait
for
Runtime
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment