Unverified Commit 848e1a89 authored by Gavin Wood's avatar Gavin Wood Committed by GitHub
Browse files

Prepare for final genesis (#1131)



* Update claim statements

* Update URLs

* Minor tweak to make enum agree with URL

* final html multihashes

* New hashes

* Version

* updated SAFT statement hash

* Update runtimes; this relies on substrate #6131

* Bump

* Share transaction filterer and fix Kusama

* Warning

* Gah!

* Tidy

* Westend fixes

* Westend fix

* Tweak constants

* Implement TCF stuff

* Fix

* Warning

* 15 minute lookahead

* 15 minute lookahead in Polkadot

* update max transactions

* Enable utility, disable vested_transfer

* Update runtime/common/src/lib.rs
Co-authored-by: default avatarTomasz Drwięga <tomusdrw@users.noreply.github.com>

* Filter calls for validate unsigned also

* Deduplicate

* Fix

* Introduce Polkadot (mainnet) chainspec

* Fix naming.

* Enable indices and fix comment.

* Fix compilation

* Enable indices and fix comment.

* polkadot: babe: enable secondary VRF slots

* Test JSON

* Allow set_heads

* Fix

* Raw chain spec added
Co-authored-by: default avatarkeorn <github@i.keorn.org>
Co-authored-by: default avatarNikVolf <nikvolf@gmail.com>
Co-authored-by: default avatarTomasz Drwięga <tomusdrw@users.noreply.github.com>
Co-authored-by: default avatarTomasz Drwięga <tomasz@parity.io>
Co-authored-by: André Silva's avatarAndré Silva <andre.beat@gmail.com>
parent 9d00ce44
Pipeline #94134 failed with stages
in 10 minutes and 22 seconds
This diff is collapsed.
......@@ -4,7 +4,7 @@ path = "src/main.rs"
[package]
name = "polkadot"
version = "0.7.34-dev"
version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......
[package]
name = "polkadot-availability-store"
description = "Persistent database for parachain data"
version = "0.7.34-dev"
version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......
[package]
name = "polkadot-cli"
version = "0.7.34-dev"
version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Polkadot Relay-chain Client Node"
edition = "2018"
......
......@@ -43,6 +43,7 @@ impl SubstrateCli for Cli {
"kusama-dev" => Box::new(service::chain_spec::kusama_development_config()),
"kusama-local" => Box::new(service::chain_spec::kusama_local_testnet_config()),
"kusama-staging" => Box::new(service::chain_spec::kusama_staging_testnet_config()),
"polkadot" => Box::new(service::chain_spec::polkadot_config()?),
"westend" => Box::new(service::chain_spec::westend_config()?),
"kusama" | "" => Box::new(service::chain_spec::kusama_config()?),
"westend-dev" => Box::new(service::chain_spec::westend_development_config()),
......
[package]
name = "polkadot-collator"
version = "0.7.34-dev"
version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Collator node implementation"
edition = "2018"
......
[package]
name = "polkadot-erasure-coding"
version = "0.7.34-dev"
version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......
[package]
name = "polkadot-network"
version = "0.7.34-dev"
version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Polkadot-specific networking protocol"
edition = "2018"
......
[package]
name = "polkadot-parachain"
version = "0.7.34-dev"
version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Types and utilities for creating and working with parachains"
edition = "2018"
......
[package]
name = "test-parachain-adder"
version = "0.7.34-dev"
version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Test parachain which adds to a number as its state transition"
edition = "2018"
......
[package]
name = "test-parachain-halt"
version = "0.7.34-dev"
version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Test parachain which executes forever"
edition = "2018"
......
[package]
name = "polkadot-primitives"
version = "0.7.34-dev"
version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......
[package]
name = "polkadot-rpc"
version = "0.7.34-dev"
version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......
[package]
name = "polkadot-runtime-common"
version = "0.7.34-dev"
version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
......
......@@ -48,29 +48,35 @@ pub trait Trait: system::Trait {
type Prefix: Get<&'static [u8]>;
}
/// The kind of a statement this account needs to make for a claim to be valid.
/// The kind of a statement an account needs to make for a claim to be valid.
#[derive(Encode, Decode, Clone, Copy, Eq, PartialEq, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum StatementKind {
/// One kind of statement; this is the default.
Default,
/// Another kind of statement(!).
Alternative,
/// Statement required to be made by non-SAFT holders.
Regular,
/// Statement required to be made by SAFT holders.
Saft,
}
impl StatementKind {
/// Convert this to the (English) statement it represents.
fn to_text(self) -> &'static [u8] {
match self {
StatementKind::Default => &b"Default"[..],
StatementKind::Alternative => &b"Alternative"[..],
StatementKind::Regular =>
&b"I hereby agree to the terms of the statement whose SHA-256 multihash is \
Qmc1XYqT6S39WNp2UeiRUrZichUWUPpGEThDE6dAb3f6Ny. (This may be found at the URL: \
https://statement.polkadot.network/regular.html)"[..],
StatementKind::Saft =>
&b"I hereby agree to the terms of the statement whose SHA-256 multihash is \
QmXEkMahfhHJPzT3RjkXiZVFi77ZeVeuxtAjhojGRNYckz. (This may be found at the URL: \
https://statement.polkadot.network/saft.html)"[..],
}
}
}
impl Default for StatementKind {
fn default() -> Self {
StatementKind::Default
StatementKind::Regular
}
}
......@@ -716,8 +722,8 @@ mod tests {
GenesisConfig::<Test>{
claims: vec![
(eth(&alice()), 100, None, None),
(eth(&dave()), 200, None, Some(StatementKind::Default)),
(eth(&eve()), 300, Some(42), Some(StatementKind::Alternative)),
(eth(&dave()), 200, None, Some(StatementKind::Regular)),
(eth(&eve()), 300, Some(42), Some(StatementKind::Saft)),
(eth(&frank()), 400, Some(43), None),
],
vesting: vec![(eth(&alice()), (50, 10, 1))],
......@@ -782,22 +788,22 @@ mod tests {
fn attest_claiming_works() {
new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0);
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Alternative.to_text());
let r = Claims::claim_attest(Origin::NONE, 42, s.clone(), StatementKind::Alternative.to_text().to_vec());
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Saft.to_text());
let r = Claims::claim_attest(Origin::NONE, 42, s.clone(), StatementKind::Saft.to_text().to_vec());
assert_noop!(r, Error::<Test>::InvalidStatement);
let r = Claims::claim_attest(Origin::NONE, 42, s, StatementKind::Default.to_text().to_vec());
let r = Claims::claim_attest(Origin::NONE, 42, s, StatementKind::Regular.to_text().to_vec());
assert_noop!(r, Error::<Test>::SignerHasNoClaim);
// ^^^ we use ecdsa_recover, so an invalid signature just results in a random signer id
// being recovered, which realistically will never have a claim.
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Default.to_text());
assert_ok!(Claims::claim_attest(Origin::NONE, 42, s, StatementKind::Default.to_text().to_vec()));
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Regular.to_text());
assert_ok!(Claims::claim_attest(Origin::NONE, 42, s, StatementKind::Regular.to_text().to_vec()));
assert_eq!(Balances::free_balance(&42), 200);
assert_eq!(Claims::total(), total_claims() - 200);
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Default.to_text());
let r = Claims::claim_attest(Origin::NONE, 42, s, StatementKind::Default.to_text().to_vec());
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Regular.to_text());
let r = Claims::claim_attest(Origin::NONE, 42, s, StatementKind::Regular.to_text().to_vec());
assert_noop!(r, Error::<Test>::SignerHasNoClaim);
});
}
......@@ -806,9 +812,9 @@ mod tests {
fn attesting_works() {
new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0);
assert_noop!(Claims::attest(Origin::signed(69), StatementKind::Alternative.to_text().to_vec()), Error::<Test>::SenderHasNoClaim);
assert_noop!(Claims::attest(Origin::signed(42), StatementKind::Default.to_text().to_vec()), Error::<Test>::InvalidStatement);
assert_ok!(Claims::attest(Origin::signed(42), StatementKind::Alternative.to_text().to_vec()));
assert_noop!(Claims::attest(Origin::signed(69), StatementKind::Saft.to_text().to_vec()), Error::<Test>::SenderHasNoClaim);
assert_noop!(Claims::attest(Origin::signed(42), StatementKind::Regular.to_text().to_vec()), Error::<Test>::InvalidStatement);
assert_ok!(Claims::attest(Origin::signed(42), StatementKind::Saft.to_text().to_vec()));
assert_eq!(Balances::free_balance(&42), 300);
assert_eq!(Claims::total(), total_claims() - 300);
});
......@@ -822,7 +828,7 @@ mod tests {
assert_ok!(Claims::claim(Origin::NONE, 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])));
assert_eq!(Balances::free_balance(&42), 100);
// Eve's claim is 300 through Account 42
assert_ok!(Claims::attest(Origin::signed(42), StatementKind::Alternative.to_text().to_vec()));
assert_ok!(Claims::attest(Origin::signed(42), StatementKind::Saft.to_text().to_vec()));
assert_eq!(Balances::free_balance(&42), 100 + 300);
assert_eq!(Claims::total(), total_claims() - 400);
});
......@@ -832,7 +838,7 @@ mod tests {
fn valid_attest_transactions_are_free() {
new_test_ext().execute_with(|| {
let p = PrevalidateAttests::<Test>::new();
let c = Call::Claims(ClaimsCall::attest(StatementKind::Alternative.to_text().to_vec()));
let c = Call::Claims(ClaimsCall::attest(StatementKind::Saft.to_text().to_vec()));
let di = c.get_dispatch_info();
assert_eq!(di.pays_fee, Pays::No);
let r = p.validate(&42, &c, &di, 20);
......@@ -844,11 +850,11 @@ mod tests {
fn invalid_attest_transactions_are_recognised() {
new_test_ext().execute_with(|| {
let p = PrevalidateAttests::<Test>::new();
let c = Call::Claims(ClaimsCall::attest(StatementKind::Default.to_text().to_vec()));
let c = Call::Claims(ClaimsCall::attest(StatementKind::Regular.to_text().to_vec()));
let di = c.get_dispatch_info();
let r = p.validate(&42, &c, &di, 20);
assert!(r.is_err());
let c = Call::Claims(ClaimsCall::attest(StatementKind::Alternative.to_text().to_vec()));
let c = Call::Claims(ClaimsCall::attest(StatementKind::Saft.to_text().to_vec()));
let di = c.get_dispatch_info();
let r = p.validate(&69, &c, &di, 20);
assert!(r.is_err());
......@@ -909,18 +915,18 @@ mod tests {
fn add_claim_with_statement_works() {
new_test_ext().execute_with(|| {
assert_noop!(
Claims::mint_claim(Origin::signed(42), eth(&bob()), 200, None, Some(StatementKind::Default)),
Claims::mint_claim(Origin::signed(42), eth(&bob()), 200, None, Some(StatementKind::Regular)),
sp_runtime::traits::BadOrigin,
);
assert_eq!(Balances::free_balance(42), 0);
let signature = sig::<Test>(&bob(), &69u64.encode(), StatementKind::Default.to_text());
let signature = sig::<Test>(&bob(), &69u64.encode(), StatementKind::Regular.to_text());
assert_noop!(
Claims::claim_attest(
Origin::NONE, 69, signature.clone(), StatementKind::Default.to_text().to_vec()
Origin::NONE, 69, signature.clone(), StatementKind::Regular.to_text().to_vec()
),
Error::<Test>::SignerHasNoClaim
);
assert_ok!(Claims::mint_claim(Origin::ROOT, eth(&bob()), 200, None, Some(StatementKind::Default)));
assert_ok!(Claims::mint_claim(Origin::ROOT, eth(&bob()), 200, None, Some(StatementKind::Regular)));
assert_noop!(
Claims::claim_attest(
Origin::NONE, 69, signature.clone(), vec![],
......@@ -929,7 +935,7 @@ mod tests {
);
assert_ok!(
Claims::claim_attest(
Origin::NONE, 69, signature.clone(), StatementKind::Default.to_text().to_vec()
Origin::NONE, 69, signature.clone(), StatementKind::Regular.to_text().to_vec()
)
);
assert_eq!(Balances::free_balance(&69), 200);
......@@ -1036,8 +1042,8 @@ mod tests {
<Module<Test>>::validate_unsigned(source, &ClaimsCall::claim(1, sig::<Test>(&bob(), &1u64.encode(), &[][..]))),
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
);
let s = sig::<Test>(&dave(), &1u64.encode(), StatementKind::Default.to_text());
let call = ClaimsCall::claim_attest(1, s, StatementKind::Default.to_text().to_vec());
let s = sig::<Test>(&dave(), &1u64.encode(), StatementKind::Regular.to_text());
let call = ClaimsCall::claim_attest(1, s, StatementKind::Regular.to_text().to_vec());
assert_eq!(
<Module<Test>>::validate_unsigned(source, &call),
Ok(ValidTransaction {
......@@ -1052,27 +1058,27 @@ mod tests {
<Module<Test>>::validate_unsigned(
source,
&ClaimsCall::claim_attest(1, EcdsaSignature([0; 65]),
StatementKind::Default.to_text().to_vec())
StatementKind::Regular.to_text().to_vec())
),
InvalidTransaction::Custom(ValidityError::InvalidEthereumSignature.into()).into(),
);
let s = sig::<Test>(&bob(), &1u64.encode(), StatementKind::Default.to_text());
let call = ClaimsCall::claim_attest(1, s, StatementKind::Default.to_text().to_vec());
let s = sig::<Test>(&bob(), &1u64.encode(), StatementKind::Regular.to_text());
let call = ClaimsCall::claim_attest(1, s, StatementKind::Regular.to_text().to_vec());
assert_eq!(
<Module<Test>>::validate_unsigned(source, &call),
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
);
let s = sig::<Test>(&dave(), &1u64.encode(), StatementKind::Alternative.to_text());
let call = ClaimsCall::claim_attest(1, s, StatementKind::Default.to_text().to_vec());
let s = sig::<Test>(&dave(), &1u64.encode(), StatementKind::Saft.to_text());
let call = ClaimsCall::claim_attest(1, s, StatementKind::Regular.to_text().to_vec());
assert_eq!(
<Module<Test>>::validate_unsigned(source, &call),
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
);
let s = sig::<Test>(&dave(), &1u64.encode(), StatementKind::Alternative.to_text());
let call = ClaimsCall::claim_attest(1, s, StatementKind::Alternative.to_text().to_vec());
let s = sig::<Test>(&dave(), &1u64.encode(), StatementKind::Saft.to_text());
let call = ClaimsCall::claim_attest(1, s, StatementKind::Saft.to_text().to_vec());
assert_eq!(
<Module<Test>>::validate_unsigned(source, &call),
InvalidTransaction::Custom(ValidityError::InvalidStatement.into()).into(),
......@@ -1148,7 +1154,7 @@ mod benchmarking {
let c in ...;
let eth_address = account("eth_address", c, SEED);
let vesting = Some((100_000.into(), 1_000.into(), 100.into()));
let statement = StatementKind::Default;
let statement = StatementKind::Regular;
}: _(RawOrigin::Root, eth_address, VALUE.into(), vesting, Some(statement))
verify {
assert_eq!(Claims::<T>::get(eth_address), Some(VALUE.into()));
......@@ -1162,7 +1168,7 @@ mod benchmarking {
let eth_address = eth(&secret_key);
let account: T::AccountId = account("user", u, SEED);
let vesting = Some((100_000.into(), 1_000.into(), 100.into()));
let statement = StatementKind::Default;
let statement = StatementKind::Regular;
let signature = sig::<T>(&secret_key, &account.encode(), statement.to_text());
super::Module::<T>::mint_claim(RawOrigin::Root.into(), eth_address, VALUE.into(), vesting, Some(statement))?;
assert_eq!(Claims::<T>::get(eth_address), Some(VALUE.into()));
......@@ -1179,7 +1185,7 @@ mod benchmarking {
let eth_address = eth(&secret_key);
let account: T::AccountId = account("user", u, SEED);
let vesting = Some((100_000.into(), 1_000.into(), 100.into()));
let statement = StatementKind::Default;
let statement = StatementKind::Regular;
let signature = sig::<T>(&secret_key, &account.encode(), statement.to_text());
super::Module::<T>::mint_claim(RawOrigin::Root.into(), eth_address, VALUE.into(), vesting, Some(statement))?;
Preclaims::<T>::insert(&account, eth_address);
......@@ -1209,8 +1215,8 @@ mod benchmarking {
let attest_c = u32::max_value() - c;
let secret_key = secp256k1::SecretKey::parse(&keccak_256(&attest_c.encode())).unwrap();
let account: T::AccountId = account("user", c, SEED);
let signature = sig::<T>(&secret_key, &account.encode(), StatementKind::Default.to_text());
let call = Call::<T>::claim_attest(account, signature, StatementKind::Default.to_text().to_vec());
let signature = sig::<T>(&secret_key, &account.encode(), StatementKind::Regular.to_text());
let call = Call::<T>::claim_attest(account, signature, StatementKind::Regular.to_text().to_vec());
let source = sp_runtime::transaction_validity::TransactionSource::External;
}: {
super::Module::<T>::validate_unsigned(source, &call)?
......@@ -1223,7 +1229,7 @@ mod benchmarking {
let eth_address = eth(&secret_key);
let account: T::AccountId = account("user", c, SEED);
Preclaims::<T>::insert(&account, eth_address);
let call = super::Call::attest(StatementKind::Default.to_text().to_vec());
let call = super::Call::attest(StatementKind::Regular.to_text().to_vec());
// We have to copy the validate statement here because of trait issues... :(
let validate = |who: &T::AccountId, call: &super::Call<T>| -> DispatchResult {
if let Call::attest(attested_statement) = call {
......
......@@ -27,10 +27,15 @@ pub mod slots;
pub mod crowdfund;
pub mod impls;
use primitives::BlockNumber;
use sp_runtime::{traits::Saturating, Perbill};
use sp_std::marker::PhantomData;
use codec::{Encode, Decode};
use primitives::{BlockNumber, AccountId, ValidityError};
use sp_runtime::{
Perbill, traits::{Saturating, SignedExtension, DispatchInfoOf},
transaction_validity::{TransactionValidityError, TransactionValidity, InvalidTransaction}
};
use frame_support::{
parameter_types, traits::Currency,
parameter_types, traits::{Currency, Filter},
weights::{Weight, constants::WEIGHT_PER_SECOND},
};
......@@ -47,6 +52,7 @@ pub use parachains::Call as ParachainsCall;
/// Implementations of some helper traits passed into runtime modules as associated types.
pub use impls::{CurrencyToVoteHandler, TargetedFeeAdjustment, ToAuthor};
use sp_runtime::traits::Dispatchable;
pub type NegativeImbalance<T> = <balances::Module<T> as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;
......@@ -58,3 +64,67 @@ parameter_types! {
.saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();
pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;
}
/// Apply a given filter to transactions.
pub struct TransactionCallFilter<T: Filter<Call>, Call>(PhantomData<(T, Call)>);
impl<F: Filter<Call>, Call> Default for TransactionCallFilter<F, Call> {
fn default() -> Self { Self::new() }
}
impl<F: Filter<Call>, Call> Encode for TransactionCallFilter<F, Call> {
fn using_encoded<R, FO: FnOnce(&[u8]) -> R>(&self, f: FO) -> R { f(&b""[..]) }
}
impl<F: Filter<Call>, Call> Decode for TransactionCallFilter<F, Call> {
fn decode<I: codec::Input>(_: &mut I) -> Result<Self, codec::Error> { Ok(Self::new()) }
}
impl<F: Filter<Call>, Call> Clone for TransactionCallFilter<F, Call> {
fn clone(&self) -> Self { Self::new() }
}
impl<F: Filter<Call>, Call> Eq for TransactionCallFilter<F, Call> {}
impl<F: Filter<Call>, Call> PartialEq for TransactionCallFilter<F, Call> {
fn eq(&self, _: &Self) -> bool { true }
}
impl<F: Filter<Call>, Call> sp_std::fmt::Debug for TransactionCallFilter<F, Call> {
fn fmt(&self, _: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result { Ok(()) }
}
fn validate<F: Filter<Call>, Call>(call: &Call) -> TransactionValidity {
if F::filter(call) {
Ok(Default::default())
} else {
Err(InvalidTransaction::Custom(ValidityError::NoPermission.into()).into())
}
}
impl<F: Filter<Call> + Send + Sync, Call: Dispatchable + Send + Sync>
SignedExtension for TransactionCallFilter<F, Call>
{
const IDENTIFIER: &'static str = "TransactionCallFilter";
type AccountId = AccountId;
type Call = Call;
type AdditionalSigned = ();
type Pre = ();
fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { Ok(()) }
fn validate(&self,
_: &Self::AccountId,
call: &Call,
_: &DispatchInfoOf<Self::Call>,
_: usize,
) -> TransactionValidity { validate::<F, _>(call) }
fn validate_unsigned(
call: &Self::Call,
_info: &DispatchInfoOf<Self::Call>,
_len: usize,
) -> TransactionValidity { validate::<F, _>(call) }
}
impl<F: Filter<Call>, Call> TransactionCallFilter<F, Call> {
/// Create a new instance.
pub fn new() -> Self {
Self(sp_std::marker::PhantomData)
}
}
[package]
name = "kusama-runtime"
version = "0.7.34-dev"
version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
build = "build.rs"
......
......@@ -25,24 +25,22 @@ use sp_core::u32_trait::{_1, _2, _3, _4, _5};
use codec::{Encode, Decode};
use primitives::{
AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, Signature, Moment,
parachain::{self, ActiveParas, AbridgedCandidateReceipt, SigningContext}, ValidityError,
parachain::{self, ActiveParas, AbridgedCandidateReceipt, SigningContext},
};
use runtime_common::{attestations, claims, parachains, registrar, slots,
impls::{CurrencyToVoteHandler, TargetedFeeAdjustment, ToAuthor},
NegativeImbalance, BlockHashCount, MaximumBlockWeight, AvailableBlockRatio,
MaximumBlockLength, BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight,
MaximumExtrinsicWeight
MaximumExtrinsicWeight, TransactionCallFilter,
};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, ModuleId,
ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill, Perquintill, RuntimeDebug,
transaction_validity::{
TransactionValidity, InvalidTransaction, TransactionValidityError, TransactionSource, TransactionPriority,
},
ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill, Perquintill,
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
curve::PiecewiseLinear,
traits::{
BlakeTwo256, Block as BlockT, SignedExtension, OpaqueKeys, ConvertInto, IdentityLookup,
DispatchInfoOf, Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, IdentityLookup,
Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
},
};
#[cfg(feature = "runtime-benchmarks")]
......@@ -55,7 +53,7 @@ use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex;
use frame_support::{
parameter_types, construct_runtime, debug,
traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness, LockIdentifier},
traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness, LockIdentifier, Filter},
weights::Weight,
};
use im_online::sr25519::AuthorityId as ImOnlineId;
......@@ -102,31 +100,10 @@ pub fn native_version() -> NativeVersion {
}
/// Avoid processing transactions from slots and parachain registrar.
#[derive(Default, Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug)]
pub struct RestrictFunctionality;
impl SignedExtension for RestrictFunctionality {
const IDENTIFIER: &'static str = "RestrictFunctionality";
type AccountId = AccountId;
type Call = Call;
type AdditionalSigned = ();
type Pre = ();
fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { Ok(()) }
fn validate(
&self,
_: &Self::AccountId,
call: &Self::Call,
_: &DispatchInfoOf<Self::Call>,
_: usize
)
-> TransactionValidity
{
match call {
Call::Slots(_) | Call::Registrar(_)
=> Err(InvalidTransaction::Custom(ValidityError::NoPermission.into()).into()),
_ => Ok(Default::default()),
}
pub struct IsCallable;
impl Filter<Call> for IsCallable {
fn filter(call: &Call) -> bool {
!matches!(call, Call::Slots(_) | Call::Registrar(_))
}
}
......@@ -605,7 +582,7 @@ impl<LocalCall> system::offchain::CreateSignedTransaction<LocalCall> for Runtime
.saturating_sub(1);
let tip = 0;
let extra: SignedExtra = (
RestrictFunctionality,
TransactionCallFilter::<IsCallable, Call>::new(),
system::CheckSpecVersion::<Runtime>::new(),
system::CheckTxVersion::<Runtime>::new(),
system::CheckGenesis::<Runtime>::new(),
......@@ -719,6 +696,7 @@ impl utility::Trait for Runtime {
type MultisigDepositBase = MultisigDepositBase;
type MultisigDepositFactor = MultisigDepositFactor;
type MaxSignatories = MaxSignatories;
type IsCallable = IsCallable;
}
parameter_types! {
......@@ -856,7 +834,7 @@ pub type SignedBlock = generic::SignedBlock<Block>;
pub type BlockId = generic::BlockId<Block>;
/// The SignedExtension to the basic transaction logic.
pub type SignedExtra = (
RestrictFunctionality,
TransactionCallFilter<IsCallable, Call>,
system::CheckSpecVersion<Runtime>,
system::CheckTxVersion<Runtime>,
system::CheckGenesis<Runtime>,
......
[package]
name = "polkadot-runtime"
version = "0.7.34-dev"
version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
build = "build.rs"
......@@ -58,6 +58,7 @@ system_rpc_runtime_api = { package = "frame-system-rpc-runtime-api", git = "http