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: Tomasz 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: keorn <github@i.keorn.org>
Co-authored-by: NikVolf <nikvolf@gmail.com>
Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
Co-authored-by: Tomasz Drwięga <tomasz@parity.io>
Co-authored-by: André Silva <andre.beat@gmail.com>
This commit is contained in:
Gavin Wood
2020-05-26 15:27:48 +02:00
committed by GitHub
parent cbb412f515
commit b170d9674f
29 changed files with 12217 additions and 527 deletions
+300 -339
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -4,7 +4,7 @@ path = "src/main.rs"
[package] [package]
name = "polkadot" name = "polkadot"
version = "0.7.34-dev" version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
+1 -1
View File
@@ -1,7 +1,7 @@
[package] [package]
name = "polkadot-availability-store" name = "polkadot-availability-store"
description = "Persistent database for parachain data" description = "Persistent database for parachain data"
version = "0.7.34-dev" version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "polkadot-cli" name = "polkadot-cli"
version = "0.7.34-dev" version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
description = "Polkadot Relay-chain Client Node" description = "Polkadot Relay-chain Client Node"
edition = "2018" edition = "2018"
+1
View File
@@ -43,6 +43,7 @@ impl SubstrateCli for Cli {
"kusama-dev" => Box::new(service::chain_spec::kusama_development_config()), "kusama-dev" => Box::new(service::chain_spec::kusama_development_config()),
"kusama-local" => Box::new(service::chain_spec::kusama_local_testnet_config()), "kusama-local" => Box::new(service::chain_spec::kusama_local_testnet_config()),
"kusama-staging" => Box::new(service::chain_spec::kusama_staging_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()?), "westend" => Box::new(service::chain_spec::westend_config()?),
"kusama" | "" => Box::new(service::chain_spec::kusama_config()?), "kusama" | "" => Box::new(service::chain_spec::kusama_config()?),
"westend-dev" => Box::new(service::chain_spec::westend_development_config()), "westend-dev" => Box::new(service::chain_spec::westend_development_config()),
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "polkadot-collator" name = "polkadot-collator"
version = "0.7.34-dev" version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
description = "Collator node implementation" description = "Collator node implementation"
edition = "2018" edition = "2018"
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "polkadot-erasure-coding" name = "polkadot-erasure-coding"
version = "0.7.34-dev" version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "polkadot-network" name = "polkadot-network"
version = "0.7.34-dev" version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
description = "Polkadot-specific networking protocol" description = "Polkadot-specific networking protocol"
edition = "2018" edition = "2018"
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "polkadot-parachain" name = "polkadot-parachain"
version = "0.7.34-dev" version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
description = "Types and utilities for creating and working with parachains" description = "Types and utilities for creating and working with parachains"
edition = "2018" edition = "2018"
@@ -1,6 +1,6 @@
[package] [package]
name = "test-parachain-adder" name = "test-parachain-adder"
version = "0.7.34-dev" version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
description = "Test parachain which adds to a number as its state transition" description = "Test parachain which adds to a number as its state transition"
edition = "2018" edition = "2018"
@@ -1,6 +1,6 @@
[package] [package]
name = "test-parachain-halt" name = "test-parachain-halt"
version = "0.7.34-dev" version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
description = "Test parachain which executes forever" description = "Test parachain which executes forever"
edition = "2018" edition = "2018"
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "polkadot-primitives" name = "polkadot-primitives"
version = "0.7.34-dev" version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "polkadot-rpc" name = "polkadot-rpc"
version = "0.7.34-dev" version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "polkadot-runtime-common" name = "polkadot-runtime-common"
version = "0.7.34-dev" version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
+50 -44
View File
@@ -48,29 +48,35 @@ pub trait Trait: system::Trait {
type Prefix: Get<&'static [u8]>; 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)] #[derive(Encode, Decode, Clone, Copy, Eq, PartialEq, RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))] #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
pub enum StatementKind { pub enum StatementKind {
/// One kind of statement; this is the default. /// Statement required to be made by non-SAFT holders.
Default, Regular,
/// Another kind of statement(!). /// Statement required to be made by SAFT holders.
Alternative, Saft,
} }
impl StatementKind { impl StatementKind {
/// Convert this to the (English) statement it represents. /// Convert this to the (English) statement it represents.
fn to_text(self) -> &'static [u8] { fn to_text(self) -> &'static [u8] {
match self { match self {
StatementKind::Default => &b"Default"[..], StatementKind::Regular =>
StatementKind::Alternative => &b"Alternative"[..], &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 { impl Default for StatementKind {
fn default() -> Self { fn default() -> Self {
StatementKind::Default StatementKind::Regular
} }
} }
@@ -716,8 +722,8 @@ mod tests {
GenesisConfig::<Test>{ GenesisConfig::<Test>{
claims: vec![ claims: vec![
(eth(&alice()), 100, None, None), (eth(&alice()), 100, None, None),
(eth(&dave()), 200, None, Some(StatementKind::Default)), (eth(&dave()), 200, None, Some(StatementKind::Regular)),
(eth(&eve()), 300, Some(42), Some(StatementKind::Alternative)), (eth(&eve()), 300, Some(42), Some(StatementKind::Saft)),
(eth(&frank()), 400, Some(43), None), (eth(&frank()), 400, Some(43), None),
], ],
vesting: vec![(eth(&alice()), (50, 10, 1))], vesting: vec![(eth(&alice()), (50, 10, 1))],
@@ -782,22 +788,22 @@ mod tests {
fn attest_claiming_works() { fn attest_claiming_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0); assert_eq!(Balances::free_balance(42), 0);
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Alternative.to_text()); let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Saft.to_text());
let r = Claims::claim_attest(Origin::NONE, 42, s.clone(), StatementKind::Alternative.to_text().to_vec()); let r = Claims::claim_attest(Origin::NONE, 42, s.clone(), StatementKind::Saft.to_text().to_vec());
assert_noop!(r, Error::<Test>::InvalidStatement); 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); assert_noop!(r, Error::<Test>::SignerHasNoClaim);
// ^^^ we use ecdsa_recover, so an invalid signature just results in a random signer id // ^^^ we use ecdsa_recover, so an invalid signature just results in a random signer id
// being recovered, which realistically will never have a claim. // being recovered, which realistically will never have a claim.
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Default.to_text()); let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Regular.to_text());
assert_ok!(Claims::claim_attest(Origin::NONE, 42, s, StatementKind::Default.to_text().to_vec())); assert_ok!(Claims::claim_attest(Origin::NONE, 42, s, StatementKind::Regular.to_text().to_vec()));
assert_eq!(Balances::free_balance(&42), 200); assert_eq!(Balances::free_balance(&42), 200);
assert_eq!(Claims::total(), total_claims() - 200); assert_eq!(Claims::total(), total_claims() - 200);
let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Default.to_text()); let s = sig::<Test>(&dave(), &42u64.encode(), StatementKind::Regular.to_text());
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); assert_noop!(r, Error::<Test>::SignerHasNoClaim);
}); });
} }
@@ -806,9 +812,9 @@ mod tests {
fn attesting_works() { fn attesting_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_eq!(Balances::free_balance(42), 0); 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(69), StatementKind::Saft.to_text().to_vec()), Error::<Test>::SenderHasNoClaim);
assert_noop!(Claims::attest(Origin::signed(42), StatementKind::Default.to_text().to_vec()), Error::<Test>::InvalidStatement); assert_noop!(Claims::attest(Origin::signed(42), StatementKind::Regular.to_text().to_vec()), Error::<Test>::InvalidStatement);
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), 300); assert_eq!(Balances::free_balance(&42), 300);
assert_eq!(Claims::total(), total_claims() - 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_ok!(Claims::claim(Origin::NONE, 42, sig::<Test>(&alice(), &42u64.encode(), &[][..])));
assert_eq!(Balances::free_balance(&42), 100); assert_eq!(Balances::free_balance(&42), 100);
// Eve's claim is 300 through Account 42 // 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!(Balances::free_balance(&42), 100 + 300);
assert_eq!(Claims::total(), total_claims() - 400); assert_eq!(Claims::total(), total_claims() - 400);
}); });
@@ -832,7 +838,7 @@ mod tests {
fn valid_attest_transactions_are_free() { fn valid_attest_transactions_are_free() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
let p = PrevalidateAttests::<Test>::new(); 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(); let di = c.get_dispatch_info();
assert_eq!(di.pays_fee, Pays::No); assert_eq!(di.pays_fee, Pays::No);
let r = p.validate(&42, &c, &di, 20); let r = p.validate(&42, &c, &di, 20);
@@ -844,11 +850,11 @@ mod tests {
fn invalid_attest_transactions_are_recognised() { fn invalid_attest_transactions_are_recognised() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
let p = PrevalidateAttests::<Test>::new(); 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 di = c.get_dispatch_info();
let r = p.validate(&42, &c, &di, 20); let r = p.validate(&42, &c, &di, 20);
assert!(r.is_err()); 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 di = c.get_dispatch_info();
let r = p.validate(&69, &c, &di, 20); let r = p.validate(&69, &c, &di, 20);
assert!(r.is_err()); assert!(r.is_err());
@@ -909,18 +915,18 @@ mod tests {
fn add_claim_with_statement_works() { fn add_claim_with_statement_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
assert_noop!( 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, sp_runtime::traits::BadOrigin,
); );
assert_eq!(Balances::free_balance(42), 0); 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!( assert_noop!(
Claims::claim_attest( 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 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!( assert_noop!(
Claims::claim_attest( Claims::claim_attest(
Origin::NONE, 69, signature.clone(), vec![], Origin::NONE, 69, signature.clone(), vec![],
@@ -929,7 +935,7 @@ mod tests {
); );
assert_ok!( assert_ok!(
Claims::claim_attest( 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); 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(), &[][..]))), <Module<Test>>::validate_unsigned(source, &ClaimsCall::claim(1, sig::<Test>(&bob(), &1u64.encode(), &[][..]))),
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(), InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
); );
let s = sig::<Test>(&dave(), &1u64.encode(), StatementKind::Default.to_text()); let s = sig::<Test>(&dave(), &1u64.encode(), StatementKind::Regular.to_text());
let call = ClaimsCall::claim_attest(1, s, StatementKind::Default.to_text().to_vec()); let call = ClaimsCall::claim_attest(1, s, StatementKind::Regular.to_text().to_vec());
assert_eq!( assert_eq!(
<Module<Test>>::validate_unsigned(source, &call), <Module<Test>>::validate_unsigned(source, &call),
Ok(ValidTransaction { Ok(ValidTransaction {
@@ -1052,27 +1058,27 @@ mod tests {
<Module<Test>>::validate_unsigned( <Module<Test>>::validate_unsigned(
source, source,
&ClaimsCall::claim_attest(1, EcdsaSignature([0; 65]), &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(), InvalidTransaction::Custom(ValidityError::InvalidEthereumSignature.into()).into(),
); );
let s = sig::<Test>(&bob(), &1u64.encode(), StatementKind::Default.to_text()); let s = sig::<Test>(&bob(), &1u64.encode(), StatementKind::Regular.to_text());
let call = ClaimsCall::claim_attest(1, s, StatementKind::Default.to_text().to_vec()); let call = ClaimsCall::claim_attest(1, s, StatementKind::Regular.to_text().to_vec());
assert_eq!( assert_eq!(
<Module<Test>>::validate_unsigned(source, &call), <Module<Test>>::validate_unsigned(source, &call),
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(), InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
); );
let s = sig::<Test>(&dave(), &1u64.encode(), StatementKind::Alternative.to_text()); let s = sig::<Test>(&dave(), &1u64.encode(), StatementKind::Saft.to_text());
let call = ClaimsCall::claim_attest(1, s, StatementKind::Default.to_text().to_vec()); let call = ClaimsCall::claim_attest(1, s, StatementKind::Regular.to_text().to_vec());
assert_eq!( assert_eq!(
<Module<Test>>::validate_unsigned(source, &call), <Module<Test>>::validate_unsigned(source, &call),
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(), InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
); );
let s = sig::<Test>(&dave(), &1u64.encode(), StatementKind::Alternative.to_text()); let s = sig::<Test>(&dave(), &1u64.encode(), StatementKind::Saft.to_text());
let call = ClaimsCall::claim_attest(1, s, StatementKind::Alternative.to_text().to_vec()); let call = ClaimsCall::claim_attest(1, s, StatementKind::Saft.to_text().to_vec());
assert_eq!( assert_eq!(
<Module<Test>>::validate_unsigned(source, &call), <Module<Test>>::validate_unsigned(source, &call),
InvalidTransaction::Custom(ValidityError::InvalidStatement.into()).into(), InvalidTransaction::Custom(ValidityError::InvalidStatement.into()).into(),
@@ -1148,7 +1154,7 @@ mod benchmarking {
let c in ...; let c in ...;
let eth_address = account("eth_address", c, SEED); let eth_address = account("eth_address", c, SEED);
let vesting = Some((100_000.into(), 1_000.into(), 100.into())); 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)) }: _(RawOrigin::Root, eth_address, VALUE.into(), vesting, Some(statement))
verify { verify {
assert_eq!(Claims::<T>::get(eth_address), Some(VALUE.into())); assert_eq!(Claims::<T>::get(eth_address), Some(VALUE.into()));
@@ -1162,7 +1168,7 @@ mod benchmarking {
let eth_address = eth(&secret_key); let eth_address = eth(&secret_key);
let account: T::AccountId = account("user", u, SEED); let account: T::AccountId = account("user", u, SEED);
let vesting = Some((100_000.into(), 1_000.into(), 100.into())); 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()); 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))?; 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())); assert_eq!(Claims::<T>::get(eth_address), Some(VALUE.into()));
@@ -1179,7 +1185,7 @@ mod benchmarking {
let eth_address = eth(&secret_key); let eth_address = eth(&secret_key);
let account: T::AccountId = account("user", u, SEED); let account: T::AccountId = account("user", u, SEED);
let vesting = Some((100_000.into(), 1_000.into(), 100.into())); 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()); 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))?; super::Module::<T>::mint_claim(RawOrigin::Root.into(), eth_address, VALUE.into(), vesting, Some(statement))?;
Preclaims::<T>::insert(&account, eth_address); Preclaims::<T>::insert(&account, eth_address);
@@ -1209,8 +1215,8 @@ mod benchmarking {
let attest_c = u32::max_value() - c; let attest_c = u32::max_value() - c;
let secret_key = secp256k1::SecretKey::parse(&keccak_256(&attest_c.encode())).unwrap(); let secret_key = secp256k1::SecretKey::parse(&keccak_256(&attest_c.encode())).unwrap();
let account: T::AccountId = account("user", c, SEED); let account: T::AccountId = account("user", c, SEED);
let signature = sig::<T>(&secret_key, &account.encode(), StatementKind::Default.to_text()); let signature = sig::<T>(&secret_key, &account.encode(), StatementKind::Regular.to_text());
let call = Call::<T>::claim_attest(account, signature, StatementKind::Default.to_text().to_vec()); let call = Call::<T>::claim_attest(account, signature, StatementKind::Regular.to_text().to_vec());
let source = sp_runtime::transaction_validity::TransactionSource::External; let source = sp_runtime::transaction_validity::TransactionSource::External;
}: { }: {
super::Module::<T>::validate_unsigned(source, &call)? super::Module::<T>::validate_unsigned(source, &call)?
@@ -1223,7 +1229,7 @@ mod benchmarking {
let eth_address = eth(&secret_key); let eth_address = eth(&secret_key);
let account: T::AccountId = account("user", c, SEED); let account: T::AccountId = account("user", c, SEED);
Preclaims::<T>::insert(&account, eth_address); 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... :( // We have to copy the validate statement here because of trait issues... :(
let validate = |who: &T::AccountId, call: &super::Call<T>| -> DispatchResult { let validate = |who: &T::AccountId, call: &super::Call<T>| -> DispatchResult {
if let Call::attest(attested_statement) = call { if let Call::attest(attested_statement) = call {
+73 -3
View File
@@ -27,10 +27,15 @@ pub mod slots;
pub mod crowdfund; pub mod crowdfund;
pub mod impls; pub mod impls;
use primitives::BlockNumber; use sp_std::marker::PhantomData;
use sp_runtime::{traits::Saturating, Perbill}; 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::{ use frame_support::{
parameter_types, traits::Currency, parameter_types, traits::{Currency, Filter},
weights::{Weight, constants::WEIGHT_PER_SECOND}, 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. /// Implementations of some helper traits passed into runtime modules as associated types.
pub use impls::{CurrencyToVoteHandler, TargetedFeeAdjustment, ToAuthor}; 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; 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(); .saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();
pub const MaximumBlockLength: u32 = 5 * 1024 * 1024; 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)
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "kusama-runtime" name = "kusama-runtime"
version = "0.7.34-dev" version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
build = "build.rs" build = "build.rs"
+14 -36
View File
@@ -25,24 +25,22 @@ use sp_core::u32_trait::{_1, _2, _3, _4, _5};
use codec::{Encode, Decode}; use codec::{Encode, Decode};
use primitives::{ use primitives::{
AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, Signature, Moment, 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, use runtime_common::{attestations, claims, parachains, registrar, slots,
impls::{CurrencyToVoteHandler, TargetedFeeAdjustment, ToAuthor}, impls::{CurrencyToVoteHandler, TargetedFeeAdjustment, ToAuthor},
NegativeImbalance, BlockHashCount, MaximumBlockWeight, AvailableBlockRatio, NegativeImbalance, BlockHashCount, MaximumBlockWeight, AvailableBlockRatio,
MaximumBlockLength, BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, MaximumBlockLength, BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight,
MaximumExtrinsicWeight MaximumExtrinsicWeight, TransactionCallFilter,
}; };
use sp_runtime::{ use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, ModuleId, create_runtime_str, generic, impl_opaque_keys, ModuleId,
ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill, Perquintill, RuntimeDebug, ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill, Perquintill,
transaction_validity::{ transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
TransactionValidity, InvalidTransaction, TransactionValidityError, TransactionSource, TransactionPriority,
},
curve::PiecewiseLinear, curve::PiecewiseLinear,
traits::{ traits::{
BlakeTwo256, Block as BlockT, SignedExtension, OpaqueKeys, ConvertInto, IdentityLookup, BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, IdentityLookup,
DispatchInfoOf, Extrinsic as ExtrinsicT, SaturatedConversion, Verify, Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
}, },
}; };
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
@@ -55,7 +53,7 @@ use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex; use sp_staking::SessionIndex;
use frame_support::{ use frame_support::{
parameter_types, construct_runtime, debug, parameter_types, construct_runtime, debug,
traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness, LockIdentifier}, traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness, LockIdentifier, Filter},
weights::Weight, weights::Weight,
}; };
use im_online::sr25519::AuthorityId as ImOnlineId; use im_online::sr25519::AuthorityId as ImOnlineId;
@@ -102,31 +100,10 @@ pub fn native_version() -> NativeVersion {
} }
/// Avoid processing transactions from slots and parachain registrar. /// Avoid processing transactions from slots and parachain registrar.
#[derive(Default, Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug)] pub struct IsCallable;
pub struct RestrictFunctionality; impl Filter<Call> for IsCallable {
impl SignedExtension for RestrictFunctionality { fn filter(call: &Call) -> bool {
const IDENTIFIER: &'static str = "RestrictFunctionality"; !matches!(call, Call::Slots(_) | Call::Registrar(_))
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()),
}
} }
} }
@@ -605,7 +582,7 @@ impl<LocalCall> system::offchain::CreateSignedTransaction<LocalCall> for Runtime
.saturating_sub(1); .saturating_sub(1);
let tip = 0; let tip = 0;
let extra: SignedExtra = ( let extra: SignedExtra = (
RestrictFunctionality, TransactionCallFilter::<IsCallable, Call>::new(),
system::CheckSpecVersion::<Runtime>::new(), system::CheckSpecVersion::<Runtime>::new(),
system::CheckTxVersion::<Runtime>::new(), system::CheckTxVersion::<Runtime>::new(),
system::CheckGenesis::<Runtime>::new(), system::CheckGenesis::<Runtime>::new(),
@@ -719,6 +696,7 @@ impl utility::Trait for Runtime {
type MultisigDepositBase = MultisigDepositBase; type MultisigDepositBase = MultisigDepositBase;
type MultisigDepositFactor = MultisigDepositFactor; type MultisigDepositFactor = MultisigDepositFactor;
type MaxSignatories = MaxSignatories; type MaxSignatories = MaxSignatories;
type IsCallable = IsCallable;
} }
parameter_types! { parameter_types! {
@@ -856,7 +834,7 @@ pub type SignedBlock = generic::SignedBlock<Block>;
pub type BlockId = generic::BlockId<Block>; pub type BlockId = generic::BlockId<Block>;
/// The SignedExtension to the basic transaction logic. /// The SignedExtension to the basic transaction logic.
pub type SignedExtra = ( pub type SignedExtra = (
RestrictFunctionality, TransactionCallFilter<IsCallable, Call>,
system::CheckSpecVersion<Runtime>, system::CheckSpecVersion<Runtime>,
system::CheckTxVersion<Runtime>, system::CheckTxVersion<Runtime>,
system::CheckGenesis<Runtime>, system::CheckGenesis<Runtime>,
+2 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "polkadot-runtime" name = "polkadot-runtime"
version = "0.7.34-dev" version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
build = "build.rs" build = "build.rs"
@@ -58,6 +58,7 @@ system_rpc_runtime_api = { package = "frame-system-rpc-runtime-api", git = "http
timestamp = { package = "pallet-timestamp", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } timestamp = { package = "pallet-timestamp", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
treasury = { package = "pallet-treasury", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } treasury = { package = "pallet-treasury", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sudo = { package = "pallet-sudo", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } sudo = { package = "pallet-sudo", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
utility = { package = "pallet-utility", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
vesting = { package = "pallet-vesting", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false } vesting = { package = "pallet-vesting", git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true } frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
+62 -47
View File
@@ -24,7 +24,7 @@ use runtime_common::{attestations, claims, parachains, registrar, slots,
impls::{CurrencyToVoteHandler, TargetedFeeAdjustment, ToAuthor}, impls::{CurrencyToVoteHandler, TargetedFeeAdjustment, ToAuthor},
NegativeImbalance, BlockHashCount, MaximumBlockWeight, AvailableBlockRatio, NegativeImbalance, BlockHashCount, MaximumBlockWeight, AvailableBlockRatio,
MaximumBlockLength, BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, MaximumBlockLength, BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight,
MaximumExtrinsicWeight, MaximumExtrinsicWeight, TransactionCallFilter,
}; };
use sp_std::prelude::*; use sp_std::prelude::*;
@@ -32,19 +32,18 @@ use sp_core::u32_trait::{_1, _2, _3, _4, _5};
use codec::{Encode, Decode}; use codec::{Encode, Decode};
use primitives::{ use primitives::{
AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, Signature, Moment, AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, Signature, Moment,
parachain::{self, ActiveParas, AbridgedCandidateReceipt, SigningContext}, ValidityError, parachain::{self, ActiveParas, AbridgedCandidateReceipt, SigningContext},
}; };
use sp_runtime::{ use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, ModuleId, create_runtime_str, generic, impl_opaque_keys, ModuleId,
ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill, Perquintill, RuntimeDebug, ApplyExtrinsicResult, KeyTypeId, Percent, Permill, Perbill, Perquintill,
transaction_validity::{ transaction_validity::{
TransactionValidity, InvalidTransaction, TransactionValidityError, TransactionSource, TransactionPriority, TransactionValidity, TransactionSource, TransactionPriority,
}, },
curve::PiecewiseLinear, curve::PiecewiseLinear,
traits::{ traits::{
BlakeTwo256, Block as BlockT, SignedExtension, OpaqueKeys, ConvertInto, BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, IdentityLookup,
DispatchInfoOf, IdentityLookup, Extrinsic as ExtrinsicT, SaturatedConversion, Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
Verify,
}, },
}; };
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
@@ -57,7 +56,7 @@ use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex; use sp_staking::SessionIndex;
use frame_support::{ use frame_support::{
parameter_types, construct_runtime, debug, parameter_types, construct_runtime, debug,
traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness, LockIdentifier}, traits::{KeyOwnerProofSystem, SplitTwoWays, Randomness, LockIdentifier, Filter},
weights::Weight, weights::Weight,
}; };
use im_online::sr25519::AuthorityId as ImOnlineId; use im_online::sr25519::AuthorityId as ImOnlineId;
@@ -88,11 +87,11 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
pub const VERSION: RuntimeVersion = RuntimeVersion { pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("polkadot"), spec_name: create_runtime_str!("polkadot"),
impl_name: create_runtime_str!("parity-polkadot"), impl_name: create_runtime_str!("parity-polkadot"),
authoring_version: 2, authoring_version: 0,
spec_version: 1011, spec_version: 0,
impl_version: 0, impl_version: 0,
apis: RUNTIME_API_VERSIONS, apis: RUNTIME_API_VERSIONS,
transaction_version: 1, transaction_version: 0,
}; };
/// Native version. /// Native version.
@@ -104,34 +103,29 @@ pub fn native_version() -> NativeVersion {
} }
} }
/// Avoid processing transactions that are anything except staking and claims. pub struct IsCallable;
/// impl Filter<Call> for IsCallable {
/// RELEASE: This is only relevant for the initial PoA run-in period and may be removed fn filter(call: &Call) -> bool {
/// from the release runtime.
#[derive(Default, Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug)]
pub struct OnlyStakingAndClaims;
impl SignedExtension for OnlyStakingAndClaims {
const IDENTIFIER: &'static str = "OnlyStakingAndClaims";
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 { match call {
Call::Slots(_) | Call::Registrar(_) Call::Parachains(parachains::Call::set_heads(..)) => true,
=> Err(InvalidTransaction::Custom(ValidityError::NoPermission.into()).into()),
_ => Ok(Default::default()), // Governance stuff
Call::Democracy(_) | Call::Council(_) | Call::TechnicalCommittee(_) |
Call::ElectionsPhragmen(_) | Call::TechnicalMembership(_) | Call::Treasury(_) |
// Parachains stuff
Call::Parachains(_) | Call::Attestations(_) | Call::Slots(_) | Call::Registrar(_) |
// Balances and Vesting's transfer (which can be used to transfer)
Call::Balances(_) | Call::Vesting(vesting::Call::vested_transfer(..)) =>
false,
// These modules are all allowed to be called by transactions:
Call::System(_) | Call::Scheduler(_) | Call::Indices(_) |
Call::Babe(_) | Call::Timestamp(_) |
Call::Authorship(_) | Call::Staking(_) | Call::Offences(_) |
Call::Session(_) | Call::FinalityTracker(_) | Call::Grandpa(_) | Call::ImOnline(_) |
Call::AuthorityDiscovery(_) |
Call::Utility(_) | Call::Claims(_) | Call::Vesting(_) | Call::Sudo(_) =>
true,
} }
} }
} }
@@ -187,7 +181,7 @@ impl babe::Trait for Runtime {
} }
parameter_types! { parameter_types! {
pub const IndexDeposit: Balance = 1 * DOLLARS; pub const IndexDeposit: Balance = 10 * DOLLARS;
} }
impl indices::Trait for Runtime { impl indices::Trait for Runtime {
@@ -308,7 +302,7 @@ parameter_types! {
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE; pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
pub const MaxNominatorRewardedPerValidator: u32 = 64; pub const MaxNominatorRewardedPerValidator: u32 = 64;
// quarter of the last session will be for election. // quarter of the last session will be for election.
pub const ElectionLookahead: BlockNumber = EPOCH_DURATION_IN_BLOCKS / 4; pub const ElectionLookahead: BlockNumber = EPOCH_DURATION_IN_BLOCKS / 16;
pub const MaxIterations: u32 = 5; pub const MaxIterations: u32 = 5;
} }
@@ -344,7 +338,7 @@ parameter_types! {
pub const CooloffPeriod: BlockNumber = 7 * DAYS; pub const CooloffPeriod: BlockNumber = 7 * DAYS;
// One cent: $10,000 / MB // One cent: $10,000 / MB
pub const PreimageByteDeposit: Balance = 1 * CENTS; pub const PreimageByteDeposit: Balance = 1 * CENTS;
pub const InstantAllowed: bool = false; pub const InstantAllowed: bool = true;
pub const MaxVotes: u32 = 100; pub const MaxVotes: u32 = 100;
} }
@@ -612,7 +606,7 @@ impl<LocalCall> system::offchain::CreateSignedTransaction<LocalCall> for Runtime
.saturating_sub(1); .saturating_sub(1);
let tip = 0; let tip = 0;
let extra: SignedExtra = ( let extra: SignedExtra = (
OnlyStakingAndClaims, TransactionCallFilter::<IsCallable, Call>::new(),
system::CheckSpecVersion::<Runtime>::new(), system::CheckSpecVersion::<Runtime>::new(),
system::CheckTxVersion::<Runtime>::new(), system::CheckTxVersion::<Runtime>::new(),
system::CheckGenesis::<Runtime>::new(), system::CheckGenesis::<Runtime>::new(),
@@ -699,6 +693,24 @@ impl vesting::Trait for Runtime {
type MinVestedTransfer = MinVestedTransfer; type MinVestedTransfer = MinVestedTransfer;
} }
parameter_types! {
// One storage item; value is size 4+4+16+32 bytes = 56 bytes.
pub const MultisigDepositBase: Balance = 30 * CENTS;
// Additional storage item size of 32 bytes.
pub const MultisigDepositFactor: Balance = 5 * CENTS;
pub const MaxSignatories: u16 = 100;
}
impl utility::Trait for Runtime {
type Event = Event;
type Call = Call;
type Currency = Balances;
type MultisigDepositBase = MultisigDepositBase;
type MultisigDepositFactor = MultisigDepositFactor;
type MaxSignatories = MaxSignatories;
type IsCallable = IsCallable;
}
impl sudo::Trait for Runtime { impl sudo::Trait for Runtime {
type Event = Event; type Event = Event;
type Call = Call; type Call = Call;
@@ -734,7 +746,8 @@ construct_runtime! {
ImOnline: im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>}, ImOnline: im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
AuthorityDiscovery: authority_discovery::{Module, Call, Config}, AuthorityDiscovery: authority_discovery::{Module, Call, Config},
// Governance stuff; uncallable initially. // Governance stuff; uncallable initially. Calls should be uncommented once we're ready to
// enable governance.
Democracy: democracy::{Module, Call, Storage, Config, Event<T>}, Democracy: democracy::{Module, Call, Storage, Config, Event<T>},
Council: collective::<Instance1>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>}, Council: collective::<Instance1>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
TechnicalCommittee: collective::<Instance2>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>}, TechnicalCommittee: collective::<Instance2>::{Module, Call, Storage, Origin<T>, Event<T>, Config<T>},
@@ -743,7 +756,8 @@ construct_runtime! {
Treasury: treasury::{Module, Call, Storage, Event<T>}, Treasury: treasury::{Module, Call, Storage, Event<T>},
// Parachains stuff; slots are disabled (no auctions initially). The rest are safe as they // Parachains stuff; slots are disabled (no auctions initially). The rest are safe as they
// have no public dispatchables. // have no public dispatchables. Disabled `Call` on all of them, but this should be
// uncommented once we're ready to start parachains.
Parachains: parachains::{Module, Call, Storage, Config, Inherent, Origin}, Parachains: parachains::{Module, Call, Storage, Config, Inherent, Origin},
Attestations: attestations::{Module, Call, Storage}, Attestations: attestations::{Module, Call, Storage},
Slots: slots::{Module, Call, Storage, Event<T>}, Slots: slots::{Module, Call, Storage, Event<T>},
@@ -753,6 +767,8 @@ construct_runtime! {
Claims: claims::{Module, Call, Storage, Event<T>, Config<T>, ValidateUnsigned}, Claims: claims::{Module, Call, Storage, Event<T>, Config<T>, ValidateUnsigned},
// Vesting. Usable initially, but removed once all vesting is finished. // Vesting. Usable initially, but removed once all vesting is finished.
Vesting: vesting::{Module, Call, Storage, Event<T>, Config<T>}, Vesting: vesting::{Module, Call, Storage, Event<T>, Config<T>},
// Cunning utilities. Usable initially.
Utility: utility::{Module, Call, Storage, Event<T>},
// Sudo. Last module. Usable initially, but removed once governance enabled. // Sudo. Last module. Usable initially, but removed once governance enabled.
Sudo: sudo::{Module, Call, Storage, Config<T>, Event<T>}, Sudo: sudo::{Module, Call, Storage, Config<T>, Event<T>},
@@ -771,8 +787,7 @@ pub type SignedBlock = generic::SignedBlock<Block>;
pub type BlockId = generic::BlockId<Block>; pub type BlockId = generic::BlockId<Block>;
/// The SignedExtension to the basic transaction logic. /// The SignedExtension to the basic transaction logic.
pub type SignedExtra = ( pub type SignedExtra = (
// RELEASE: remove this for release build. TransactionCallFilter<IsCallable, Call>,
OnlyStakingAndClaims,
system::CheckSpecVersion<Runtime>, system::CheckSpecVersion<Runtime>,
system::CheckTxVersion<Runtime>, system::CheckTxVersion<Runtime>,
system::CheckGenesis<Runtime>, system::CheckGenesis<Runtime>,
@@ -939,7 +954,7 @@ sp_api::impl_runtime_apis! {
c: PRIMARY_PROBABILITY, c: PRIMARY_PROBABILITY,
genesis_authorities: Babe::authorities(), genesis_authorities: Babe::authorities(),
randomness: Babe::randomness(), randomness: Babe::randomness(),
allowed_slots: babe_primitives::AllowedSlots::PrimaryAndSecondaryPlainSlots, allowed_slots: babe_primitives::AllowedSlots::PrimaryAndSecondaryVRFSlots,
} }
} }
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "polkadot-test-runtime" name = "polkadot-test-runtime"
version = "0.7.34-dev" version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
build = "build.rs" build = "build.rs"
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "westend-runtime" name = "westend-runtime"
version = "0.7.34-dev" version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
build = "build.rs" build = "build.rs"
+15 -38
View File
@@ -24,24 +24,21 @@ use sp_std::prelude::*;
use codec::{Encode, Decode}; use codec::{Encode, Decode};
use primitives::{ use primitives::{
AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, Signature, Moment, AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, Signature, Moment,
parachain::{self, ActiveParas, AbridgedCandidateReceipt, SigningContext}, ValidityError, parachain::{self, ActiveParas, AbridgedCandidateReceipt, SigningContext},
}; };
use runtime_common::{attestations, parachains, registrar, use runtime_common::{attestations, parachains, registrar,
impls::{CurrencyToVoteHandler, TargetedFeeAdjustment, ToAuthor}, impls::{CurrencyToVoteHandler, TargetedFeeAdjustment, ToAuthor},
BlockHashCount, MaximumBlockWeight, AvailableBlockRatio, MaximumBlockLength, BlockHashCount, MaximumBlockWeight, AvailableBlockRatio, MaximumBlockLength,
BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, MaximumExtrinsicWeight BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, MaximumExtrinsicWeight,
TransactionCallFilter,
}; };
use sp_runtime::{ use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys, create_runtime_str, generic, impl_opaque_keys,
ApplyExtrinsicResult, KeyTypeId, Perbill, Perquintill, RuntimeDebug, ApplyExtrinsicResult, KeyTypeId, Perbill, Perquintill, curve::PiecewiseLinear,
transaction_validity::{ transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
TransactionValidity, InvalidTransaction, TransactionValidityError, TransactionSource,
TransactionPriority,
},
curve::PiecewiseLinear,
traits::{ traits::{
BlakeTwo256, Block as BlockT, SignedExtension, OpaqueKeys, ConvertInto, IdentityLookup, BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, IdentityLookup,
DispatchInfoOf, Extrinsic as ExtrinsicT, SaturatedConversion, Verify, Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
}, },
}; };
#[cfg(feature = "runtime-benchmarks")] #[cfg(feature = "runtime-benchmarks")]
@@ -54,7 +51,7 @@ use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex; use sp_staking::SessionIndex;
use frame_support::{ use frame_support::{
parameter_types, construct_runtime, debug, parameter_types, construct_runtime, debug,
traits::{KeyOwnerProofSystem, Randomness}, traits::{KeyOwnerProofSystem, Randomness, Filter},
weights::Weight, weights::Weight,
}; };
use im_online::sr25519::AuthorityId as ImOnlineId; use im_online::sr25519::AuthorityId as ImOnlineId;
@@ -100,31 +97,10 @@ pub fn native_version() -> NativeVersion {
} }
/// Avoid processing transactions from slots and parachain registrar. /// Avoid processing transactions from slots and parachain registrar.
#[derive(Default, Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug)] pub struct IsCallable;
pub struct RestrictFunctionality; impl Filter<Call> for IsCallable {
impl SignedExtension for RestrictFunctionality { fn filter(call: &Call) -> bool {
const IDENTIFIER: &'static str = "RestrictFunctionality"; !matches!(call, Call::Registrar(_))
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::Registrar(_)
=> Err(InvalidTransaction::Custom(ValidityError::NoPermission.into()).into()),
_ => Ok(Default::default()),
}
} }
} }
@@ -460,7 +436,7 @@ impl<LocalCall> system::offchain::CreateSignedTransaction<LocalCall> for Runtime
.saturating_sub(1); .saturating_sub(1);
let tip = 0; let tip = 0;
let extra: SignedExtra = ( let extra: SignedExtra = (
RestrictFunctionality, TransactionCallFilter::<IsCallable, Call>::new(),
system::CheckSpecVersion::<Runtime>::new(), system::CheckSpecVersion::<Runtime>::new(),
system::CheckTxVersion::<Runtime>::new(), system::CheckTxVersion::<Runtime>::new(),
system::CheckGenesis::<Runtime>::new(), system::CheckGenesis::<Runtime>::new(),
@@ -550,6 +526,7 @@ impl utility::Trait for Runtime {
type MultisigDepositBase = MultisigDepositBase; type MultisigDepositBase = MultisigDepositBase;
type MultisigDepositFactor = MultisigDepositFactor; type MultisigDepositFactor = MultisigDepositFactor;
type MaxSignatories = MaxSignatories; type MaxSignatories = MaxSignatories;
type IsCallable = IsCallable;
} }
parameter_types! { parameter_types! {
@@ -652,7 +629,7 @@ pub type SignedBlock = generic::SignedBlock<Block>;
pub type BlockId = generic::BlockId<Block>; pub type BlockId = generic::BlockId<Block>;
/// The SignedExtension to the basic transaction logic. /// The SignedExtension to the basic transaction logic.
pub type SignedExtra = ( pub type SignedExtra = (
RestrictFunctionality, TransactionCallFilter<IsCallable, Call>,
system::CheckSpecVersion<Runtime>, system::CheckSpecVersion<Runtime>,
system::CheckTxVersion<Runtime>, system::CheckTxVersion<Runtime>,
system::CheckGenesis<Runtime>, system::CheckGenesis<Runtime>,
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "polkadot-service" name = "polkadot-service"
version = "0.7.34-dev" version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
File diff suppressed because one or more lines are too long
+4
View File
@@ -71,6 +71,10 @@ pub type WestendChainSpec = service::GenericChainSpec<
Extensions, Extensions,
>; >;
pub fn polkadot_config() -> Result<PolkadotChainSpec, String> {
PolkadotChainSpec::from_json_bytes(&include_bytes!("../res/polkadot.json")[..])
}
pub fn kusama_config() -> Result<KusamaChainSpec, String> { pub fn kusama_config() -> Result<KusamaChainSpec, String> {
KusamaChainSpec::from_json_bytes(&include_bytes!("../res/kusama.json")[..]) KusamaChainSpec::from_json_bytes(&include_bytes!("../res/kusama.json")[..])
} }
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "polkadot-statement-table" name = "polkadot-statement-table"
version = "0.7.34-dev" version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "polkadot-validation" name = "polkadot-validation"
version = "0.7.34-dev" version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"] authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018" edition = "2018"
+1 -1
View File
@@ -274,7 +274,7 @@ impl<Client, TxPool, Backend> CreateProposalData<Client, TxPool, Backend> where
) -> Result<Proposal<Block, sp_api::TransactionFor<Client, Block>>, Error> { ) -> Result<Proposal<Block, sp_api::TransactionFor<Client, Block>>, Error> {
use runtime_primitives::traits::{Hash as HashT, BlakeTwo256}; use runtime_primitives::traits::{Hash as HashT, BlakeTwo256};
const MAX_TRANSACTIONS: usize = 40; const MAX_TRANSACTIONS: usize = 1200;
let mut inherent_data = self.inherent_data let mut inherent_data = self.inherent_data
.take() .take()