mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-18 16:25:40 +00:00
Update to Substrate master (#176)
* Update to master This introduces a new type `CollatorId`, currently just `SessionKey` but which would forseeably change to its own thing. It seems to work like this (despite there being a lot of the new-incompatible `AccountId` replaced). No idea if it does anything sensible, though. * Cleanups * Fix tests * Remove commented code * Specify commit hash * Remove commented code * Correct version * Update runtime/Cargo.toml Co-Authored-By: gavofyork <github@gavwood.com> * PairT instead of _Pair * Update lock file * Remove rev causing upset
This commit is contained in:
@@ -47,7 +47,8 @@ extern crate substrate_client;
|
||||
use rstd::prelude::*;
|
||||
use runtime_primitives::{generic, traits::Extrinsic};
|
||||
|
||||
pub use runtime_primitives::traits::{BlakeTwo256, Hash as HashT};
|
||||
pub use runtime_primitives::traits::{BlakeTwo256, Hash as HashT, Verify};
|
||||
use primitives::{ed25519, sr25519};
|
||||
|
||||
pub mod parachain;
|
||||
|
||||
@@ -61,16 +62,22 @@ use primitives::bytes;
|
||||
/// TODO: switch to u32
|
||||
pub type BlockNumber = u64;
|
||||
|
||||
/// Alias to 512-bit hash when used in the context of a signature on the relay chain.
|
||||
/// Equipped with logic for possibly "unsigned" messages.
|
||||
pub type Signature = sr25519::Signature;
|
||||
|
||||
/// Alias to Ed25519 pubkey that identifies an account on the relay chain.
|
||||
pub type AccountId = primitives::hash::H256;
|
||||
pub type AccountId = sr25519::Public;
|
||||
|
||||
/// The type for looking up accounts. We don't expect more than 4 billion of them, but you
|
||||
/// never know...
|
||||
pub type AccountIndex = u32;
|
||||
|
||||
/// The Ed25519 pub key of an session that belongs to an authority of the relay chain. This is
|
||||
/// exactly equivalent to what the substrate calls an "authority".
|
||||
pub type SessionKey = primitives::Ed25519AuthorityId;
|
||||
/// Signature with which authorities sign blocks.
|
||||
pub type SessionSignature = ed25519::Signature;
|
||||
|
||||
/// Identity that authorities use.
|
||||
pub type SessionKey = ed25519::Public;
|
||||
|
||||
/// Indentifier for a chain. 32-bit should be plenty.
|
||||
pub type ChainId = u32;
|
||||
@@ -81,10 +88,6 @@ pub type Hash = primitives::H256;
|
||||
/// Index of a transaction in the relay chain. 32-bit should be plenty.
|
||||
pub type Nonce = u64;
|
||||
|
||||
/// Alias to 512-bit hash when used in the context of a signature on the relay chain.
|
||||
/// Equipped with logic for possibly "unsigned" messages.
|
||||
pub type Signature = runtime_primitives::Ed25519Signature;
|
||||
|
||||
/// The balance of an account.
|
||||
/// 128-bits (or 38 significant decimal figures) will allow for 10m currency (10^7) at a resolution
|
||||
/// to all for one second's worth of an annualised 50% reward be paid to a unit holder (10^11 unit
|
||||
@@ -95,7 +98,7 @@ pub type Signature = runtime_primitives::Ed25519Signature;
|
||||
pub type Balance = u128;
|
||||
|
||||
/// Header type.
|
||||
pub type Header = generic::Header<BlockNumber, BlakeTwo256, generic::DigestItem<Hash, SessionKey>>;
|
||||
pub type Header = generic::Header<BlockNumber, BlakeTwo256, generic::DigestItem<Hash, SessionKey, SessionSignature>>;
|
||||
/// Block type.
|
||||
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
|
||||
/// Block ID.
|
||||
|
||||
@@ -18,17 +18,30 @@
|
||||
|
||||
use rstd::prelude::*;
|
||||
use rstd::cmp::Ordering;
|
||||
use super::{Hash, SessionKey};
|
||||
|
||||
use {AccountId};
|
||||
|
||||
use super::Hash;
|
||||
#[cfg(feature = "std")]
|
||||
use primitives::bytes;
|
||||
use primitives::ed25519;
|
||||
|
||||
pub use polkadot_parachain::Id;
|
||||
|
||||
/// Signature on candidate's block data by a collator.
|
||||
pub type CandidateSignature = ::runtime_primitives::Ed25519Signature;
|
||||
/// Identity that collators use.
|
||||
pub type CollatorId = ed25519::Public;
|
||||
|
||||
/// Signature with which collators sign blocks.
|
||||
pub type CollatorSignature = ed25519::Signature;
|
||||
|
||||
/// Identity that parachain validators use when signing validation messages.
|
||||
///
|
||||
/// For now we assert that parachain validator set is exactly equivalent to the (Aura) authority set, and
|
||||
/// so we define it to be the same type as `SessionKey`. In the future it may have different crypto.
|
||||
pub type ValidatorId = super::SessionKey;
|
||||
|
||||
/// Signature with which parachain validators sign blocks.
|
||||
///
|
||||
/// For now we assert that parachain validator set is exactly equivalent to the (Aura) authority set, and
|
||||
/// so we define it to be the same type as `SessionKey`. In the future it may have different crypto.
|
||||
pub type ValidatorSignature = super::SessionSignature;
|
||||
|
||||
/// Identifier for a chain, either one of a number of parachains or the relay chain.
|
||||
#[derive(Copy, Clone, PartialEq, Encode, Decode)]
|
||||
@@ -89,16 +102,14 @@ pub struct Extrinsic {
|
||||
|
||||
/// Candidate receipt type.
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
|
||||
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
|
||||
#[cfg_attr(feature = "std", serde(deny_unknown_fields))]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
pub struct CandidateReceipt {
|
||||
/// The ID of the parachain this is a candidate for.
|
||||
pub parachain_index: Id,
|
||||
/// The collator's relay-chain account ID
|
||||
pub collator: super::AccountId,
|
||||
/// The collator's signing ID
|
||||
pub collator: CollatorId,
|
||||
/// Signature on blake2-256 of the block data by collator.
|
||||
pub signature: CandidateSignature,
|
||||
pub signature: CollatorSignature,
|
||||
/// The head-data
|
||||
pub head_data: HeadData,
|
||||
/// Balance uploads to the relay chain.
|
||||
@@ -147,9 +158,7 @@ impl Ord for CandidateReceipt {
|
||||
|
||||
/// A full collation.
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
|
||||
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
|
||||
#[cfg_attr(feature = "std", serde(deny_unknown_fields))]
|
||||
#[cfg_attr(feature = "std", derive(Debug))]
|
||||
pub struct Collation {
|
||||
/// Block data.
|
||||
pub block_data: BlockData,
|
||||
@@ -228,11 +237,11 @@ pub enum ValidityAttestation {
|
||||
/// implicit validity attestation by issuing.
|
||||
/// This corresponds to issuance of a `Candidate` statement.
|
||||
#[codec(index = "1")]
|
||||
Implicit(CandidateSignature),
|
||||
Implicit(CollatorSignature),
|
||||
/// An explicit attestation. This corresponds to issuance of a
|
||||
/// `Valid` statement.
|
||||
#[codec(index = "2")]
|
||||
Explicit(CandidateSignature),
|
||||
Explicit(CollatorSignature),
|
||||
}
|
||||
|
||||
/// An attested candidate.
|
||||
@@ -242,7 +251,7 @@ pub struct AttestedCandidate {
|
||||
/// The candidate data.
|
||||
pub candidate: CandidateReceipt,
|
||||
/// Validity attestations.
|
||||
pub validity_votes: Vec<(SessionKey, ValidityAttestation)>,
|
||||
pub validity_votes: Vec<(ValidatorId, ValidityAttestation)>,
|
||||
}
|
||||
|
||||
impl AttestedCandidate {
|
||||
@@ -261,7 +270,7 @@ decl_runtime_apis! {
|
||||
/// The API for querying the state of parachains on-chain.
|
||||
pub trait ParachainHost {
|
||||
/// Get the current validators.
|
||||
fn validators() -> Vec<AccountId>;
|
||||
fn validators() -> Vec<ValidatorId>;
|
||||
/// Get the current duty roster.
|
||||
fn duty_roster() -> DutyRoster;
|
||||
/// Get the currently active parachains.
|
||||
|
||||
Reference in New Issue
Block a user