Commit 8671462a authored by Cecile Tonglet's avatar Cecile Tonglet
Browse files

Update from parent 'origin/master' (no conflict)

Commit: dd3fa1eb
Parent branch: origin/master
Forked at: 77de8b91
parents 2f5a915a dd3fa1eb
Pipeline #85006 failed with stage
in 2 minutes and 47 seconds
This diff is collapsed.
......@@ -131,6 +131,7 @@ decl_module! {
type Error = Error<T>;
/// Provide candidate receipts for parachains, in ascending order by id.
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
fn more_attestations(origin, _more: MoreAttestations) -> DispatchResult {
ensure_none(origin)?;
ensure!(!DidUpdate::exists(), Error::<T>::TooManyAttestations);
......
......@@ -29,8 +29,9 @@ use serde::{self, Serialize, Deserialize, Serializer, Deserializer};
use sp_runtime::traits::Zero;
use sp_runtime::traits::CheckedSub;
use sp_runtime::{
RuntimeDebug, transaction_validity::{
TransactionLongevity, TransactionValidity, ValidTransaction, InvalidTransaction
RuntimeDebug,
transaction_validity::{
TransactionLongevity, TransactionValidity, ValidTransaction, InvalidTransaction, TransactionSource,
},
};
use primitives::ValidityError;
......@@ -288,7 +289,7 @@ impl<T: Trait> Module<T> {
impl<T: Trait> sp_runtime::traits::ValidateUnsigned for Module<T> {
type Call = Call<T>;
fn validate_unsigned(call: &Self::Call) -> TransactionValidity {
fn validate_unsigned(_source: TransactionSource, call: &Self::Call) -> TransactionValidity {
const PRIORITY: u64 = 100;
match call {
......@@ -607,10 +608,11 @@ mod tests {
#[test]
fn validate_unsigned_works() {
use sp_runtime::traits::ValidateUnsigned;
let source = sp_runtime::transaction_validity::TransactionSource::External;
new_test_ext().execute_with(|| {
assert_eq!(
<Module<Test>>::validate_unsigned(&Call::claim(1, sig::<Test>(&alice(), &1u64.encode()))),
<Module<Test>>::validate_unsigned(source, &Call::claim(1, sig::<Test>(&alice(), &1u64.encode()))),
Ok(ValidTransaction {
priority: 100,
requires: vec![],
......@@ -620,15 +622,15 @@ mod tests {
})
);
assert_eq!(
<Module<Test>>::validate_unsigned(&Call::claim(0, EcdsaSignature([0; 65]))),
<Module<Test>>::validate_unsigned(source, &Call::claim(0, EcdsaSignature([0; 65]))),
InvalidTransaction::Custom(ValidityError::InvalidEthereumSignature.into()).into(),
);
assert_eq!(
<Module<Test>>::validate_unsigned(&Call::claim(1, sig::<Test>(&bob(), &1u64.encode()))),
<Module<Test>>::validate_unsigned(source, &Call::claim(1, sig::<Test>(&bob(), &1u64.encode()))),
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
);
assert_eq!(
<Module<Test>>::validate_unsigned(&Call::claim(0, sig::<Test>(&bob(), &1u64.encode()))),
<Module<Test>>::validate_unsigned(source, &Call::claim(0, sig::<Test>(&bob(), &1u64.encode()))),
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
);
});
......@@ -690,8 +692,9 @@ mod benchmarking {
let account: T::AccountId = account("user", c, SEED);
let signature = sig::<T>(&secret_key, &account.encode());
let call = Call::<T>::claim(account, signature);
let source = sp_runtime::transaction_validity::TransactionSource::External;
}: {
super::Module::<T>::validate_unsigned(&call)?
super::Module::<T>::validate_unsigned(source, &call)?
}
// Benchmark the time it takes to do `repeat` number of keccak256 hashes
......
......@@ -294,6 +294,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()]
fn contribute(origin, #[compact] index: FundIndex, #[compact] value: BalanceOf<T>) {
let who = ensure_signed(origin)?;
......@@ -352,6 +353,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()]
fn fix_deploy_data(origin,
#[compact] index: FundIndex,
code_hash: T::Hash,
......@@ -377,6 +379,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()]
fn onboard(origin,
#[compact] index: FundIndex,
#[compact] para_id: ParaId
......@@ -405,6 +408,7 @@ decl_module! {
}
/// Note that a successful fund has lost its parachain slot, and place it into retirement.
#[weight = SimpleDispatchInfo::default()]
fn begin_retirement(origin, #[compact] index: FundIndex) {
let _ = ensure_signed(origin)?;
......@@ -426,6 +430,7 @@ decl_module! {
}
/// Withdraw full balance of a contributor to an unsuccessful or off-boarded fund.
#[weight = SimpleDispatchInfo::default()]
fn withdraw(origin, #[compact] index: FundIndex) {
let who = ensure_signed(origin)?;
......@@ -456,6 +461,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()]
fn dissolve(origin, #[compact] index: FundIndex) {
let _ = ensure_signed(origin)?;
......
......@@ -1399,7 +1399,7 @@ mod tests {
type SlashDeferDuration = SlashDeferDuration;
type SlashCancelOrigin = system::EnsureRoot<Self::AccountId>;
type SessionInterface = Self;
type Time = timestamp::Module<Test>;
type UnixTime = timestamp::Module<Test>;
type RewardCurve = RewardCurve;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
}
......
......@@ -293,6 +293,7 @@ decl_module! {
/// - `count`: The number of parathreads.
///
/// Must be called from Root origin.
#[weight = SimpleDispatchInfo::default()]
fn set_thread_count(origin, count: u32) {
ensure_root(origin)?;
ThreadCount::put(count);
......@@ -306,6 +307,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()]
fn register_parathread(origin,
code: Vec<u8>,
initial_head_data: Vec<u8>,
......@@ -345,6 +347,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()]
fn select_parathread(origin,
#[compact] _id: ParaId,
_collator: CollatorId,
......@@ -361,6 +364,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()]
fn deregister_parathread(origin) {
let id = parachains::ensure_parachain(<T as Trait>::Origin::from(origin))?;
......@@ -384,6 +388,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()]
fn swap(origin, #[compact] other: ParaId) {
let id = parachains::ensure_parachain(<T as Trait>::Origin::from(origin))?;
......@@ -798,7 +803,7 @@ mod tests {
type SlashDeferDuration = SlashDeferDuration;
type SlashCancelOrigin = system::EnsureRoot<Self::AccountId>;
type SessionInterface = Self;
type Time = timestamp::Module<Test>;
type UnixTime = timestamp::Module<Test>;
type RewardCurve = RewardCurve;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
}
......
......@@ -35,7 +35,9 @@ use runtime_common::{attestations, claims, parachains, registrar, slots,
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill, RuntimeDebug,
transaction_validity::{TransactionValidity, InvalidTransaction, TransactionValidityError},
transaction_validity::{
TransactionValidity, InvalidTransaction, TransactionValidityError, TransactionSource,
},
curve::PiecewiseLinear,
traits::{BlakeTwo256, Block as BlockT, SignedExtension, OpaqueKeys, ConvertInto, IdentityLookup},
};
......@@ -283,7 +285,7 @@ parameter_types! {
impl staking::Trait for Runtime {
type Currency = Balances;
type Time = Timestamp;
type UnixTime = Timestamp;
type CurrencyToVote = CurrencyToVoteHandler<Self>;
type RewardRemainder = Treasury;
type Event = Event;
......@@ -772,8 +774,11 @@ sp_api::impl_runtime_apis! {
}
impl tx_pool_api::runtime_api::TaggedTransactionQueue<Block> for Runtime {
fn validate_transaction(tx: <Block as BlockT>::Extrinsic) -> TransactionValidity {
Executive::validate_transaction(tx)
fn validate_transaction(
source: TransactionSource,
tx: <Block as BlockT>::Extrinsic,
) -> TransactionValidity {
Executive::validate_transaction(source, tx)
}
}
......
......@@ -36,7 +36,9 @@ use primitives::{
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill, RuntimeDebug,
transaction_validity::{TransactionValidity, InvalidTransaction, TransactionValidityError},
transaction_validity::{
TransactionValidity, InvalidTransaction, TransactionValidityError, TransactionSource,
},
curve::PiecewiseLinear,
traits::{
BlakeTwo256, Block as BlockT, SignedExtension, OpaqueKeys, ConvertInto,
......@@ -290,7 +292,7 @@ parameter_types! {
impl staking::Trait for Runtime {
type Currency = Balances;
type Time = Timestamp;
type UnixTime = Timestamp;
type CurrencyToVote = CurrencyToVoteHandler<Self>;
type RewardRemainder = Treasury;
type Event = Event;
......@@ -694,8 +696,11 @@ sp_api::impl_runtime_apis! {
}
impl tx_pool_api::runtime_api::TaggedTransactionQueue<Block> for Runtime {
fn validate_transaction(tx: <Block as BlockT>::Extrinsic) -> TransactionValidity {
Executive::validate_transaction(tx)
fn validate_transaction(
source: TransactionSource,
tx: <Block as BlockT>::Extrinsic,
) -> TransactionValidity {
Executive::validate_transaction(source, tx)
}
}
......
......@@ -35,7 +35,9 @@ use runtime_common::{attestations, claims, parachains, registrar, slots,
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
ApplyExtrinsicResult, Perbill, RuntimeDebug, KeyTypeId,
transaction_validity::{TransactionValidity, InvalidTransaction, TransactionValidityError},
transaction_validity::{
TransactionValidity, InvalidTransaction, TransactionValidityError, TransactionSource,
},
curve::PiecewiseLinear,
traits::{BlakeTwo256, Block as BlockT, StaticLookup, SignedExtension, OpaqueKeys, ConvertInto},
};
......@@ -269,7 +271,7 @@ parameter_types! {
impl staking::Trait for Runtime {
type Currency = Balances;
type Time = Timestamp;
type UnixTime = Timestamp;
type CurrencyToVote = CurrencyToVoteHandler<Self>;
type RewardRemainder = ();
type Event = Event;
......@@ -498,8 +500,11 @@ sp_api::impl_runtime_apis! {
}
impl tx_pool_api::runtime_api::TaggedTransactionQueue<Block> for Runtime {
fn validate_transaction(tx: <Block as BlockT>::Extrinsic) -> TransactionValidity {
Executive::validate_transaction(tx)
fn validate_transaction(
source: TransactionSource,
tx: <Block as BlockT>::Extrinsic,
) -> TransactionValidity {
Executive::validate_transaction(source, tx)
}
}
......
......@@ -335,7 +335,8 @@ pub fn polkadot_staging_testnet_config() -> PolkadotChainSpec {
"polkadot_staging_testnet",
polkadot_staging_testnet_config_genesis,
boot_nodes,
Some(TelemetryEndpoints::new(vec![(POLKADOT_STAGING_TELEMETRY_URL.to_string(), 0)])),
Some(TelemetryEndpoints::new(vec![(POLKADOT_STAGING_TELEMETRY_URL.to_string(), 0)])
.expect("Polkadot Staging telemetry url is valid; qed")),
Some(DEFAULT_PROTOCOL_ID),
None,
Default::default(),
......@@ -350,7 +351,8 @@ pub fn kusama_staging_testnet_config() -> KusamaChainSpec {
"kusama_staging_testnet",
kusama_staging_testnet_config_genesis,
boot_nodes,
Some(TelemetryEndpoints::new(vec![(KUSAMA_STAGING_TELEMETRY_URL.to_string(), 0)])),
Some(TelemetryEndpoints::new(vec![(KUSAMA_STAGING_TELEMETRY_URL.to_string(), 0)])
.expect("Kusama Staging telemetry url is valid; qed")),
Some(DEFAULT_PROTOCOL_ID),
None,
Default::default(),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment