Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ab710bf
Updating substrate-demo
arkpar Sep 4, 2018
a5604d6
Consenus fixes
arkpar Sep 4, 2018
d5a0270
Reverted toolchain change
arkpar Sep 4, 2018
6a5ea57
Merge branch 'master' of github.com:paritytech/substrate into a-demo
arkpar Sep 4, 2018
eab11ad
Adjusted timeout formula
arkpar Aug 23, 2018
04eb184
Simplfied proposal creation
arkpar Sep 4, 2018
91041c3
Merge branch 'master' of github.com:paritytech/substrate into a-demo
arkpar Sep 5, 2018
67107bf
Fixed tests
arkpar Sep 5, 2018
8b7a8bb
Merge branch 'master' of github.com:paritytech/substrate into a-demo
arkpar Sep 5, 2018
f3e9299
Fixed a few small issues
arkpar Sep 5, 2018
b3a96ad
Merge branch 'master' of github.com:paritytech/substrate into a-demo
arkpar Sep 5, 2018
dbf6d0c
2017->2018
arkpar Sep 6, 2018
3e61f36
Merge branch 'master' of github.com:paritytech/substrate into a-demo
arkpar Sep 6, 2018
7d8ef2c
Style
arkpar Sep 6, 2018
7353474
More style
arkpar Sep 6, 2018
946e5e4
Renamed demo executable to substrate
arkpar Sep 6, 2018
a02f2b7
Merge branch 'master' of github.com:paritytech/substrate into a-demo
arkpar Sep 6, 2018
9464a68
Merge branch 'master' of github.com:paritytech/substrate into a-demo
arkpar Sep 7, 2018
c17c8b4
Style
arkpar Sep 7, 2018
a599454
Merge branch 'master' of github.com:paritytech/substrate into a-demo
arkpar Sep 10, 2018
f882159
Fixed compilation after merge
arkpar Sep 10, 2018
544bb89
Merge branch 'master' of github.com:paritytech/substrate into a-demo
arkpar Sep 10, 2018
b3295d6
Style
arkpar Sep 10, 2018
18d67cb
Merge branch 'master' of github.com:paritytech/substrate into a-demo
arkpar Sep 10, 2018
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
Prev Previous commit
Next Next commit
Merge branch 'master' of github.com:paritytech/substrate into a-demo
  • Loading branch information
arkpar committed Sep 7, 2018
commit 9464a684f643ecfbc69e247e13f9694565e92d57
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 9 additions & 15 deletions demo/consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,8 @@ impl<C> bft::Proposer<Block> for Proposer<C>
fn import_misbehavior(&self, misbehavior: Vec<(AuthorityId, bft::Misbehavior<Hash>)>) {
use rhododendron::Misbehavior as GenericMisbehavior;
use runtime_primitives::bft::{MisbehaviorKind, MisbehaviorReport};
use runtime_primitives::MaybeUnsigned;
use demo_primitives::UncheckedExtrinsic as GenericExtrinsic;
use demo_runtime::{Call, Extrinsic, BareExtrinsic, UncheckedExtrinsic, ConsensusCall};
use demo_runtime::{Call, UncheckedExtrinsic, ConsensusCall};

let local_id = self.local_key.public().0.into();
let mut next_index = {
Expand Down Expand Up @@ -403,22 +402,17 @@ impl<C> bft::Proposer<Block> for Proposer<C>
=> MisbehaviorKind::BftDoubleCommit(round as u32, (h1, s1.signature), (h2, s2.signature)),
}
};
let extrinsic = BareExtrinsic {
signed: local_id,
index: next_index,
function: Call::Consensus(ConsensusCall::report_misbehavior(report)),
};

let payload = (next_index, Call::Consensus(ConsensusCall::report_misbehavior(report)));
let signature = self.local_key.sign(&payload.encode()).into();
next_index += 1;

let signature = MaybeUnsigned(self.local_key.sign(&extrinsic.encode()).into());

let extrinsic = Extrinsic {
signed: extrinsic.signed.into(),
index: extrinsic.index,
function: extrinsic.function,
let local_id = self.local_key.public().0.into();
let extrinsic = UncheckedExtrinsic {
signature: Some((demo_runtime::RawAddress::Id(local_id), signature)),
index: payload.0,
function: payload.1,
};
let uxt: GenericExtrinsic = Decode::decode(&mut UncheckedExtrinsic::new(extrinsic, signature).encode().as_slice()).expect("Encoded extrinsic is valid");
let uxt: GenericExtrinsic = Decode::decode(&mut extrinsic.encode().as_slice()).expect("Encoded extrinsic is valid");
self.transaction_pool.submit_one(&BlockId::hash(self.parent_hash), uxt)
.expect("locally signed extrinsic is valid; qed");
}
Expand Down
43 changes: 16 additions & 27 deletions demo/executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ mod tests {
use primitives::{twox_128, KeccakHasher};
use demo_primitives::{Hash, BlockNumber, AccountId};
use runtime_primitives::traits::Header as HeaderT;
use runtime_primitives::{ApplyOutcome, ApplyError, ApplyResult, MaybeUnsigned};
use runtime_primitives::{ApplyOutcome, ApplyError, ApplyResult};
use {balances, staking, session, system, consensus, timestamp};
use system::{EventRecord, Phase};
use demo_runtime::{Header, Block, UncheckedExtrinsic, CheckedExtrinsic, Call, Runtime, Balances,
Expand Down Expand Up @@ -241,17 +241,7 @@ mod tests {
fn construct_block(number: BlockNumber, parent_hash: Hash, state_root: Hash, extrinsics: Vec<CheckedExtrinsic>) -> (Vec<u8>, Hash) {
use triehash::ordered_trie_root;

let extrinsics = extrinsics.into_iter().map(|extrinsic| {
let public = Keyring::from_public(Public::from_raw(extrinsic.signed.0.clone()));
let signature = MaybeUnsigned(public.map(|p| Pair::from(p).sign(&extrinsic.encode()).into()).unwrap_or_default());
let extrinsic = Extrinsic {
signed: extrinsic.signed.into(),
index: extrinsic.index,
function: extrinsic.function,
};
UncheckedExtrinsic::new(extrinsic, signature)
}).collect::<Vec<_>>();

let extrinsics = extrinsics.into_iter().map(sign).collect::<Vec<_>>();
let extrinsics_root = ordered_trie_root::<KeccakHasher, _, _>(extrinsics.iter().map(Encode::encode)).0.into();

let header = Header {
Expand All @@ -273,16 +263,15 @@ mod tests {
// Blake
// hex!("3437bf4b182ab17bb322af5c67e55f6be487a77084ad2b4e27ddac7242e4ad21").into(),
// Keccak

hex!("3f39c78ad382abdf07e22d8850c4d5ed82c64671d4f3cb34bbfad159ac7f870e").into(),
vec![
BareExtrinsic {
signed: Default::default(),
CheckedExtrinsic {
signed: None,
index: 0,
function: Call::Timestamp(timestamp::Call::set(42)),
},
BareExtrinsic {
signed: alice(),
CheckedExtrinsic {
signed: Some(alice()),
index: 0,
function: Call::Balances(balances::Call::transfer(bob().into(), 69)),
},
Expand All @@ -297,15 +286,15 @@ mod tests {
// Blake
// hex!("741fcb660e6fa9f625fbcd993b49f6c1cc4040f5e0cc8727afdedf11fd3c464b").into(),
// Keccak
hex!("a4b56027b5f889d9dd3d144b3f8a337f4354321415bdd4ad064f2fe274021af6").into(),
hex!("892f270de5c640d7713c0f21f1267d396b99a5836d3580464bf863c3aed8b28b").into(),
vec![
BareExtrinsic {
signed: Default::default(),
CheckedExtrinsic {
signed: None,
index: 0,
function: Call::Timestamp(timestamp::Call::set(52)),
},
BareExtrinsic {
signed: bob(),
CheckedExtrinsic {
signed: Some(bob()),
index: 0,
function: Call::Balances(balances::Call::transfer(alice().into(), 5)),
},
Expand All @@ -327,15 +316,15 @@ mod tests {
// Keccak
hex!("208c206ba9721c99cdc9ccaef941d867f75441866ca58db73fae289d8c504892").into(),
vec![
BareExtrinsic {
signed: Default::default(),
CheckedExtrinsic {
signed: None,
index: 0,
function: Call::Timestamp(timestamp::Call::set(42)),
},
BareExtrinsic {
signed: alice(),
CheckedExtrinsic {
signed: Some(alice()),
index: 0,
function: Call::Consensus(consensus::Call::remark(vec![0; 60000])),
function: Call::Consensus(consensus::Call::remark(vec![0; 120000])),
}
]
)
Expand Down
12 changes: 6 additions & 6 deletions demo/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use runtime_primitives::traits::{BlakeTwo256, DigestItem};
/// An index to a block.
pub type BlockNumber = u64;

/// Alias to Ed25519 pubkey that identifies an account on the relay chain. This will almost
/// Alias to Ed25519 pubkey that identifies an account on the chain. This will almost
/// certainly continue to be the same as the substrate's `AuthorityId`.
pub type AccountId = ::primitives::H256;

Expand All @@ -56,18 +56,18 @@ pub type AccountIndex = u32;
/// Balance of an account.
pub type Balance = u64;

/// The Ed25519 pub key of an session that belongs to an authority of the relay chain. This is
/// The Ed25519 pub key of an session that belongs to an authority of the chain. This is
/// exactly equivalent to what the substrate calls an "authority".
pub type SessionKey = primitives::AuthorityId;

/// Index of a transaction in the relay chain.
/// Index of a transaction in the chain.
pub type Index = u64;

/// A hash of some data used by the relay chain.
/// A hash of some data used by the chain.
pub type Hash = primitives::H256;

/// Alias to 512-bit hash when used in the context of a signature on the relay chain.
pub type Signature = runtime_primitives::MaybeUnsigned<runtime_primitives::Ed25519Signature>;
/// Alias to 512-bit hash when used in the context of a signature on the chain.
pub type Signature = runtime_primitives::Ed25519Signature;

/// A timestamp: seconds since the unix epoch.
pub type Timestamp = u64;
Expand Down
6 changes: 3 additions & 3 deletions demo/runtime/src/checked_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl CheckedBlock {
/// Create a new checked block. Fails if the block is not structurally valid.
pub fn new(block: Block) -> Result<Self, Block> {
let has_timestamp = block.extrinsics.get(TIMESTAMP_SET_POSITION as usize).map_or(false, |xt| {
!xt.is_signed() && match xt.extrinsic.function {
!xt.is_signed() && match xt.function {
Call::Timestamp(TimestampCall::set(_)) => true,
_ => false,
}
Expand All @@ -55,7 +55,7 @@ impl CheckedBlock {

/// Extract the timestamp from the block.
pub fn timestamp(&self) -> ::demo_primitives::Timestamp {
let x = self.inner.extrinsics.get(TIMESTAMP_SET_POSITION as usize).and_then(|xt| match xt.extrinsic.function {
let x = self.inner.extrinsics.get(TIMESTAMP_SET_POSITION as usize).and_then(|xt| match xt.function {
Call::Timestamp(TimestampCall::set(x)) => Some(x),
_ => None
});
Expand All @@ -68,7 +68,7 @@ impl CheckedBlock {

/// Extract the noted missed proposal validator indices (if any) from the block.
pub fn noted_offline(&self) -> &[u32] {
self.inner.extrinsics.get(NOTE_OFFLINE_POSITION as usize).and_then(|xt| match xt.extrinsic.function {
self.inner.extrinsics.get(NOTE_OFFLINE_POSITION as usize).and_then(|xt| match xt.function {
Call::Consensus(ConsensusCall::note_offline(ref x)) => Some(&x[..]),
_ => None,
}).unwrap_or(&[])
Expand Down
37 changes: 8 additions & 29 deletions demo/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,26 +201,6 @@ impl_outer_dispatch! {
}
}

/// The address format for describing accounts.
pub use balances::address::Address as RawAddress;
/// The address format for describing accounts.
pub type Address = balances::Address<Runtime>;
/// Block header type as expected by this runtime.
pub type Header = generic::Header<BlockNumber, BlakeTwo256, Log>;
/// Block type as expected by this runtime.
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
/// BlockId type as expected by this runtime.
pub type BlockId = generic::BlockId<Block>;
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Index, Call, Signature>;
/// Extrinsic type as expected by this runtime. This is not the type that is signed.
pub type Extrinsic = generic::Extrinsic<Address, Index, Call>;
/// Extrinsic type that is signed.
pub type BareExtrinsic = generic::Extrinsic<AccountId, Index, Call>;
/// Executive: handles dispatch to the various modules.
pub type Executive = executive::Executive<Runtime, Block, Balances, Balances,
((((((), Council), Democracy), Staking), Session), Timestamp)>;

impl_outer_config! {
pub struct GenesisConfig for Runtime {
ConsensusConfig => consensus,
Expand All @@ -244,6 +224,8 @@ impl DigestItem for Log {
}
}

/// The address format for describing accounts.
pub use balances::address::Address as RawAddress;
/// The address format for describing accounts.
pub type Address = balances::Address<Runtime>;
/// Block header type as expected by this runtime.
Expand All @@ -258,7 +240,7 @@ pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Index, Call,
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Index, Call>;
/// Executive: handles dispatch to the various modules.
pub type Executive = executive::Executive<Runtime, Block, Balances, Balances,
(((((), Council), Democracy), Staking), Session)>;
((((((), Council), Democracy), Staking), Session), Timestamp)>;

pub mod api {
impl_stubs!(
Expand All @@ -280,14 +262,11 @@ pub mod api {

/// Produces the list of inherent extrinsics.
fn inherent_extrinsics(data: InherentData, _spec_version: u32) -> Vec<UncheckedExtrinsic> {
let make_inherent = |function| UncheckedExtrinsic::new(
Extrinsic {
signed: Default::default(),
function,
index: 0,
},
Default::default(),
);
let make_inherent = |function| UncheckedExtrinsic {
signature: Default::default(),
function,
index: 0,
};

let mut inherent = vec![
make_inherent(Call::Timestamp(TimestampCall::set(data.timestamp))),
Expand Down
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion demo/transaction-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl<A> extrinsic_pool::ChainApi for ChainApi<A> where
RawAddress::Index(_) => Err("Index based addresses are not supported".into()),// TODO: Make index addressing optional in substrate
}
})?;
let sender = checked.signed.clone();
let sender = checked.signed.expect("Only signed extrinsics are allowed at this point");


if encoded_size < 1024 {
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.