Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Prepare for final genesis (#1131)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
6 people authored May 26, 2020
1 parent 9d00ce4 commit 848e1a8
Show file tree
Hide file tree
Showing 29 changed files with 12,217 additions and 527 deletions.
639 changes: 300 additions & 339 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion availability-store/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[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"

Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[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"
Expand Down
1 change: 1 addition & 0 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
2 changes: 1 addition & 1 deletion collator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[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"
Expand Down
2 changes: 1 addition & 1 deletion erasure-coding/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-erasure-coding"
version = "0.7.34-dev"
version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion network/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[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"
Expand Down
2 changes: 1 addition & 1 deletion parachain/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[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"
Expand Down
2 changes: 1 addition & 1 deletion parachain/test-parachains/adder/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[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"
Expand Down
2 changes: 1 addition & 1 deletion parachain/test-parachains/halt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[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"
Expand Down
2 changes: 1 addition & 1 deletion primitives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-primitives"
version = "0.7.34-dev"
version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-rpc"
version = "0.7.34-dev"
version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-runtime-common"
version = "0.7.34-dev"
version = "0.8.0-pre"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

Expand Down
94 changes: 50 additions & 44 deletions runtime/common/src/claims.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down Expand Up @@ -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))],
Expand Down Expand Up @@ -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);
});
}
Expand All @@ -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);
});
Expand All @@ -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);
});
Expand All @@ -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);
Expand All @@ -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());
Expand Down Expand Up @@ -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![],
Expand All @@ -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);
Expand Down Expand Up @@ -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 {
Expand All @@ -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(),
Expand Down Expand Up @@ -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()));
Expand All @@ -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()));
Expand All @@ -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);
Expand Down Expand Up @@ -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)?
Expand All @@ -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 {
Expand Down
Loading

0 comments on commit 848e1a8

Please sign in to comment.