mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-22 07:55:42 +00:00
Make parameter types implementation more flexible (#3112)
* Make parameter types implementation more flexible * Bump `impl_version`
This commit is contained in:
committed by
Gavin Wood
parent
9ee79d5c5e
commit
c42d73d302
@@ -70,7 +70,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||||||
// implementation changes and behavior does not, then leave spec_version as
|
// implementation changes and behavior does not, then leave spec_version as
|
||||||
// is and increment impl_version.
|
// is and increment impl_version.
|
||||||
spec_version: 110,
|
spec_version: 110,
|
||||||
impl_version: 110,
|
impl_version: 111,
|
||||||
apis: RUNTIME_API_VERSIONS,
|
apis: RUNTIME_API_VERSIONS,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -341,21 +341,11 @@ impl treasury::Trait for Runtime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
parameter_types! {
|
parameter_types! {
|
||||||
pub const SignedClaimHandicap: BlockNumber = 2;
|
|
||||||
pub const TombstoneDeposit: Balance = 16;
|
|
||||||
pub const StorageSizeOffset: u32 = 8;
|
|
||||||
pub const RentByteFee: Balance = 4;
|
|
||||||
pub const RentDepositOffset: Balance = 1000;
|
|
||||||
pub const SurchargeReward: Balance = 150;
|
|
||||||
pub const ContractTransferFee: Balance = 1 * CENTS;
|
pub const ContractTransferFee: Balance = 1 * CENTS;
|
||||||
pub const ContractCreationFee: Balance = 1 * CENTS;
|
pub const ContractCreationFee: Balance = 1 * CENTS;
|
||||||
pub const ContractTransactionBaseFee: Balance = 1 * CENTS;
|
pub const ContractTransactionBaseFee: Balance = 1 * CENTS;
|
||||||
pub const ContractTransactionByteFee: Balance = 10 * MILLICENTS;
|
pub const ContractTransactionByteFee: Balance = 10 * MILLICENTS;
|
||||||
pub const ContractFee: Balance = 1 * CENTS;
|
pub const ContractFee: Balance = 1 * CENTS;
|
||||||
pub const CallBaseFee: Gas = 1000;
|
|
||||||
pub const CreateBaseFee: Gas = 1000;
|
|
||||||
pub const MaxDepth: u32 = 1024;
|
|
||||||
pub const BlockGasLimit: Gas = 10_000_000;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl contracts::Trait for Runtime {
|
impl contracts::Trait for Runtime {
|
||||||
@@ -366,21 +356,21 @@ impl contracts::Trait for Runtime {
|
|||||||
type ComputeDispatchFee = contracts::DefaultDispatchFeeComputor<Runtime>;
|
type ComputeDispatchFee = contracts::DefaultDispatchFeeComputor<Runtime>;
|
||||||
type TrieIdGenerator = contracts::TrieIdFromParentCounter<Runtime>;
|
type TrieIdGenerator = contracts::TrieIdFromParentCounter<Runtime>;
|
||||||
type GasPayment = ();
|
type GasPayment = ();
|
||||||
type SignedClaimHandicap = SignedClaimHandicap;
|
type SignedClaimHandicap = contracts::DefaultSignedClaimHandicap;
|
||||||
type TombstoneDeposit = TombstoneDeposit;
|
type TombstoneDeposit = contracts::DefaultTombstoneDeposit;
|
||||||
type StorageSizeOffset = StorageSizeOffset;
|
type StorageSizeOffset = contracts::DefaultStorageSizeOffset;
|
||||||
type RentByteFee = RentByteFee;
|
type RentByteFee = contracts::DefaultRentByteFee;
|
||||||
type RentDepositOffset = RentDepositOffset;
|
type RentDepositOffset = contracts::DefaultRentDepositOffset;
|
||||||
type SurchargeReward = SurchargeReward;
|
type SurchargeReward = contracts::DefaultSurchargeReward;
|
||||||
type TransferFee = ContractTransferFee;
|
type TransferFee = ContractTransferFee;
|
||||||
type CreationFee = ContractCreationFee;
|
type CreationFee = ContractCreationFee;
|
||||||
type TransactionBaseFee = ContractTransactionBaseFee;
|
type TransactionBaseFee = ContractTransactionBaseFee;
|
||||||
type TransactionByteFee = ContractTransactionByteFee;
|
type TransactionByteFee = ContractTransactionByteFee;
|
||||||
type ContractFee = ContractFee;
|
type ContractFee = ContractFee;
|
||||||
type CallBaseFee = CallBaseFee;
|
type CallBaseFee = contracts::DefaultCallBaseFee;
|
||||||
type CreateBaseFee = CreateBaseFee;
|
type CreateBaseFee = contracts::DefaultCreateBaseFee;
|
||||||
type MaxDepth = MaxDepth;
|
type MaxDepth = contracts::DefaultMaxDepth;
|
||||||
type BlockGasLimit = BlockGasLimit;
|
type BlockGasLimit = contracts::DefaultBlockGasLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl sudo::Trait for Runtime {
|
impl sudo::Trait for Runtime {
|
||||||
|
|||||||
@@ -543,7 +543,6 @@ mod tests {
|
|||||||
// old uncles can't get in.
|
// old uncles can't get in.
|
||||||
{
|
{
|
||||||
assert_eq!(System::block_number(), 8);
|
assert_eq!(System::block_number(), 8);
|
||||||
assert_eq!(<Test as Trait>::UncleGenerations::get(), 5);
|
|
||||||
|
|
||||||
let gen_2 = seal_header(
|
let gen_2 = seal_header(
|
||||||
create_header(2, canon_chain.canon_hash(1), [3; 32].into()),
|
create_header(2, canon_chain.canon_hash(1), [3; 32].into()),
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
//! The Contract module is a work in progress. The following examples show how this Contract module can be
|
//! The Contract module is a work in progress. The following examples show how this Contract module can be
|
||||||
//! used to create and call contracts.
|
//! used to create and call contracts.
|
||||||
//!
|
//!
|
||||||
//! * [`ink`](https://github.com/paritytech/ink) is
|
//! * [`ink`](https://github.com/paritytech/ink) is
|
||||||
//! an [`eDSL`](https://wiki.haskell.org/Embedded_domain_specific_language) that enables writing
|
//! an [`eDSL`](https://wiki.haskell.org/Embedded_domain_specific_language) that enables writing
|
||||||
//! WebAssembly based smart contracts in the Rust programming language. This is a work in progress.
|
//! WebAssembly based smart contracts in the Rust programming language. This is a work in progress.
|
||||||
//!
|
//!
|
||||||
@@ -104,7 +104,8 @@ use runtime_primitives::traits::{
|
|||||||
};
|
};
|
||||||
use srml_support::dispatch::{Result, Dispatchable};
|
use srml_support::dispatch::{Result, Dispatchable};
|
||||||
use srml_support::{
|
use srml_support::{
|
||||||
Parameter, StorageMap, StorageValue, decl_module, decl_event, decl_storage, storage::child
|
Parameter, StorageMap, StorageValue, decl_module, decl_event, decl_storage, storage::child,
|
||||||
|
parameter_types,
|
||||||
};
|
};
|
||||||
use srml_support::traits::{OnFreeBalanceZero, OnUnbalanced, Currency, Get};
|
use srml_support::traits::{OnFreeBalanceZero, OnUnbalanced, Currency, Get};
|
||||||
use system::{ensure_signed, RawOrigin, ensure_root};
|
use system::{ensure_signed, RawOrigin, ensure_root};
|
||||||
@@ -280,21 +281,38 @@ pub type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as system::Trait>
|
|||||||
pub type NegativeImbalanceOf<T> =
|
pub type NegativeImbalanceOf<T> =
|
||||||
<<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;
|
<<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;
|
||||||
|
|
||||||
pub const DEFAULT_SIGNED_CLAIM_HANDICAP: u32 = 0;
|
parameter_types! {
|
||||||
pub const DEFAULT_TOMBSTONE_DEPOSIT: u32 = 0;
|
/// A resonable default value for [`Trait::SignedClaimedHandicap`].
|
||||||
pub const DEFAULT_STORAGE_SIZE_OFFSET: u32 = 0;
|
pub const DefaultSignedClaimHandicap: u32 = 2;
|
||||||
pub const DEFAULT_RENT_BYTE_FEE: u32 = 0;
|
/// A resonable default value for [`Trait::TombstoneDeposit`].
|
||||||
pub const DEFAULT_RENT_DEPOSIT_OFFSET: u32 = 0;
|
pub const DefaultTombstoneDeposit: u32 = 16;
|
||||||
pub const DEFAULT_SURCHARGE_REWARD: u32 = 0;
|
/// A resonable default value for [`Trait::StorageSizeOffset`].
|
||||||
pub const DEFAULT_TRANSFER_FEE: u32 = 0;
|
pub const DefaultStorageSizeOffset: u32 = 8;
|
||||||
pub const DEFAULT_CREATION_FEE: u32 = 0;
|
/// A resonable default value for [`Trait::RentByteFee`].
|
||||||
pub const DEFAULT_TRANSACTION_BASE_FEE: u32 = 0;
|
pub const DefaultRentByteFee: u32 = 4;
|
||||||
pub const DEFAULT_TRANSACTION_BYTE_FEE: u32 = 0;
|
/// A resonable default value for [`Trait::RentDepositOffset`].
|
||||||
pub const DEFAULT_CONTRACT_FEE: u32 = 21;
|
pub const DefaultRentDepositOffset: u32 = 1000;
|
||||||
pub const DEFAULT_CALL_BASE_FEE: u32 = 135;
|
/// A resonable default value for [`Trait::SurchargeReward`].
|
||||||
pub const DEFAULT_CREATE_BASE_FEE: u32 = 175;
|
pub const DefaultSurchargeReward: u32 = 150;
|
||||||
pub const DEFAULT_MAX_DEPTH: u32 = 100;
|
/// A resonable default value for [`Trait::TransferFee`].
|
||||||
pub const DEFAULT_BLOCK_GAS_LIMIT: u32 = 10_000_000;
|
pub const DefaultTransferFee: u32 = 0;
|
||||||
|
/// A resonable default value for [`Trait::CreationFee`].
|
||||||
|
pub const DefaultCreationFee: u32 = 0;
|
||||||
|
/// A resonable default value for [`Trait::TransactionBaseFee`].
|
||||||
|
pub const DefaultTransactionBaseFee: u32 = 0;
|
||||||
|
/// A resonable default value for [`Trait::TransactionByteFee`].
|
||||||
|
pub const DefaultTransactionByteFee: u32 = 0;
|
||||||
|
/// A resonable default value for [`Trait::ContractFee`].
|
||||||
|
pub const DefaultContractFee: u32 = 21;
|
||||||
|
/// A resonable default value for [`Trait::CallBaseFee`].
|
||||||
|
pub const DefaultCallBaseFee: u32 = 1000;
|
||||||
|
/// A resonable default value for [`Trait::CreateBaseFee`].
|
||||||
|
pub const DefaultCreateBaseFee: u32 = 1000;
|
||||||
|
/// A resonable default value for [`Trait::MaxDepth`].
|
||||||
|
pub const DefaultMaxDepth: u32 = 1024;
|
||||||
|
/// A resonable default value for [`Trait::BlockGasLimit`].
|
||||||
|
pub const DefaultBlockGasLimit: u32 = 10_000_000;
|
||||||
|
}
|
||||||
|
|
||||||
pub trait Trait: timestamp::Trait {
|
pub trait Trait: timestamp::Trait {
|
||||||
type Currency: Currency<Self::AccountId>;
|
type Currency: Currency<Self::AccountId>;
|
||||||
@@ -361,24 +379,19 @@ pub trait Trait: timestamp::Trait {
|
|||||||
/// The fee to be paid for making a transaction; the per-byte portion.
|
/// The fee to be paid for making a transaction; the per-byte portion.
|
||||||
type TransactionByteFee: Get<BalanceOf<Self>>;
|
type TransactionByteFee: Get<BalanceOf<Self>>;
|
||||||
|
|
||||||
/// The fee required to create a contract instance. A reasonable default value
|
/// The fee required to create a contract instance.
|
||||||
/// is 21.
|
|
||||||
type ContractFee: Get<BalanceOf<Self>>;
|
type ContractFee: Get<BalanceOf<Self>>;
|
||||||
|
|
||||||
/// The base fee charged for calling into a contract. A reasonable default
|
/// The base fee charged for calling into a contract.
|
||||||
/// value is 135.
|
|
||||||
type CallBaseFee: Get<Gas>;
|
type CallBaseFee: Get<Gas>;
|
||||||
|
|
||||||
/// The base fee charged for creating a contract. A reasonable default value
|
/// The base fee charged for creating a contract.
|
||||||
/// is 175.
|
|
||||||
type CreateBaseFee: Get<Gas>;
|
type CreateBaseFee: Get<Gas>;
|
||||||
|
|
||||||
/// The maximum nesting level of a call/create stack. A reasonable default
|
/// The maximum nesting level of a call/create stack.
|
||||||
/// value is 100.
|
|
||||||
type MaxDepth: Get<u32>;
|
type MaxDepth: Get<u32>;
|
||||||
|
|
||||||
/// The maximum amount of gas that could be expended per block. A reasonable
|
/// The maximum amount of gas that could be expended per block.
|
||||||
/// default value is 10_000_000.
|
|
||||||
type BlockGasLimit: Get<Gas>;
|
type BlockGasLimit: Get<Gas>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1369,16 +1369,9 @@ mod tests {
|
|||||||
assert_eq!(Elections::next_vote_from(4), 4);
|
assert_eq!(Elections::next_vote_from(4), 4);
|
||||||
assert_eq!(Elections::next_vote_from(5), 8);
|
assert_eq!(Elections::next_vote_from(5), 8);
|
||||||
assert_eq!(Elections::vote_index(), 0);
|
assert_eq!(Elections::vote_index(), 0);
|
||||||
assert_eq!(<Test as Trait>::CandidacyBond::get(), 3);
|
|
||||||
assert_eq!(<Test as Trait>::VotingBond::get(), 0);
|
|
||||||
assert_eq!(<Test as Trait>::VotingFee::get(), 0);
|
|
||||||
assert_eq!(<Test as Trait>::PresentSlashPerVoter::get(), 1);
|
|
||||||
assert_eq!(Elections::presentation_duration(), 2);
|
assert_eq!(Elections::presentation_duration(), 2);
|
||||||
assert_eq!(<Test as Trait>::InactiveGracePeriod::get(), 1);
|
|
||||||
assert_eq!(<Test as Trait>::VotingPeriod::get(), 4);
|
|
||||||
assert_eq!(Elections::term_duration(), 5);
|
assert_eq!(Elections::term_duration(), 5);
|
||||||
assert_eq!(Elections::desired_seats(), 2);
|
assert_eq!(Elections::desired_seats(), 2);
|
||||||
assert_eq!(<Test as Trait>::CarryCount::get(), 2);
|
|
||||||
|
|
||||||
assert_eq!(Elections::members(), vec![]);
|
assert_eq!(Elections::members(), vec![]);
|
||||||
assert_eq!(Elections::next_tally(), Some(4));
|
assert_eq!(Elections::next_tally(), Some(4));
|
||||||
|
|||||||
@@ -85,19 +85,28 @@ pub use runtime_primitives::ConsensusEngineId;
|
|||||||
/// ```
|
/// ```
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! parameter_types {
|
macro_rules! parameter_types {
|
||||||
(pub const $name:ident: $type:ty = $value:expr; $( $rest:tt )*) => (
|
(
|
||||||
pub struct $name;
|
$( #[ $attr:meta ] )*
|
||||||
$crate::parameter_types!{IMPL $name , $type , $value}
|
$vis:vis const $name:ident: $type:ty = $value:expr;
|
||||||
$crate::parameter_types!{ $( $rest )* }
|
$( $rest:tt )*
|
||||||
);
|
) => (
|
||||||
(const $name:ident: $type:ty = $value:expr; $( $rest:tt )*) => (
|
$( #[ $attr ] )*
|
||||||
struct $name;
|
$vis struct $name;
|
||||||
$crate::parameter_types!{IMPL $name , $type , $value}
|
$crate::parameter_types!{IMPL $name , $type , $value}
|
||||||
$crate::parameter_types!{ $( $rest )* }
|
$crate::parameter_types!{ $( $rest )* }
|
||||||
);
|
);
|
||||||
() => ();
|
() => ();
|
||||||
(IMPL $name:ident , $type:ty , $value:expr) => {
|
(IMPL $name:ident , $type:ty , $value:expr) => {
|
||||||
impl $crate::traits::Get<$type> for $name { fn get() -> $type { $value } }
|
impl $name {
|
||||||
|
fn get() -> $type {
|
||||||
|
$value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<I: From<$type>> $crate::traits::Get<I> for $name {
|
||||||
|
fn get() -> I {
|
||||||
|
I::from($value)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user