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

Prepare for final genesis #1131

Merged
merged 41 commits into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
8f615f9
Update claim statements
gavofyork May 23, 2020
efb593f
Update URLs
gavofyork May 23, 2020
28127ad
Minor tweak to make enum agree with URL
gavofyork May 23, 2020
1773f00
final html multihashes
keorn May 23, 2020
caad2fa
New hashes
gavofyork May 23, 2020
7d21a8b
Merge branch 'gav-final-claims' of github.com:paritytech/polkadot int…
gavofyork May 25, 2020
ff7f90b
Version
gavofyork May 25, 2020
6b9a118
updated SAFT statement hash
keorn May 25, 2020
b520980
Update runtimes; this relies on substrate #6131
gavofyork May 25, 2020
c2ce841
Bump
gavofyork May 26, 2020
4ab13a0
Share transaction filterer and fix Kusama
gavofyork May 26, 2020
d44241a
Warning
gavofyork May 26, 2020
64c5f4d
Gah!
gavofyork May 26, 2020
3e06219
Tidy
gavofyork May 26, 2020
04a2151
Westend fixes
gavofyork May 26, 2020
c635c80
Westend fix
gavofyork May 26, 2020
5e2be24
Tweak constants
gavofyork May 26, 2020
6f77025
Implement TCF stuff
gavofyork May 26, 2020
a611066
Fix
gavofyork May 26, 2020
c7e57ea
Warning
gavofyork May 26, 2020
00992e1
15 minute lookahead
gavofyork May 26, 2020
f4cccaa
15 minute lookahead in Polkadot
gavofyork May 26, 2020
c539763
update max transactions
NikVolf May 26, 2020
225c66c
Enable utility, disable vested_transfer
gavofyork May 26, 2020
3e13871
Merge remote-tracking branch 'origin/gav-final-claims' into gav-final…
gavofyork May 26, 2020
154d906
Merge remote-tracking branch 'origin/master' into gav-final-claims
gavofyork May 26, 2020
58dbfd5
Update runtime/common/src/lib.rs
gavofyork May 26, 2020
1ae79a7
Filter calls for validate unsigned also
gavofyork May 26, 2020
7cc3951
Deduplicate
gavofyork May 26, 2020
faf6034
Fix
gavofyork May 26, 2020
e00e5bf
Introduce Polkadot (mainnet) chainspec
gavofyork May 26, 2020
b87502a
Fix naming.
gavofyork May 26, 2020
e3400eb
Enable indices and fix comment.
gavofyork May 26, 2020
07e80f9
Fix compilation
tomusdrw May 26, 2020
1724942
Enable indices and fix comment.
gavofyork May 26, 2020
46c9f59
Merge branch 'gav-final-claims' of github.com:paritytech/polkadot int…
tomusdrw May 26, 2020
3705500
polkadot: babe: enable secondary VRF slots
andresilva May 26, 2020
df97d3c
Test JSON
gavofyork May 26, 2020
a2713d1
Allow set_heads
gavofyork May 26, 2020
c2e3177
Fix
gavofyork May 26, 2020
f77c5e5
Raw chain spec added
gavofyork May 26, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 \
cheme marked this conversation as resolved.
Show resolved Hide resolved
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