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

Traitify Runtime #104

Merged
merged 79 commits into from
Apr 4, 2018
Merged
Changes from 1 commit
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
f99ccbf
Factor out safe-mix and dispatch
gavofyork Mar 20, 2018
1e38431
Refactor dispatch into something more modular.
gavofyork Mar 20, 2018
909533f
Fix wasm build.
gavofyork Mar 20, 2018
1f464ae
Fix up timestamp
gavofyork Mar 21, 2018
1ce4e97
fix warnings.
gavofyork Mar 21, 2018
d8a16f1
Borked timestamp example
gavofyork Mar 22, 2018
ed929e2
Fix build
gavofyork Mar 22, 2018
834e982
Timestamp as skeleton for traity runtime.
gavofyork Mar 23, 2018
8646e8b
New storage macro.
gavofyork Mar 23, 2018
7cc2806
Dispatch module has traity API.
gavofyork Mar 23, 2018
836da87
Move consensus module to new API
gavofyork Mar 24, 2018
bc5ae7f
Refactoring and outer dispatch
gavofyork Mar 24, 2018
b8ed874
Avoid unnecessary derives.
gavofyork Mar 24, 2018
5696b65
Abstract the low-level half of system.
gavofyork Mar 24, 2018
73822e5
nicer outer dispatch syntax.
gavofyork Mar 24, 2018
77db293
Make runtime compile again (albeit in a heavily simplified state)
gavofyork Mar 24, 2018
b9a0302
Reworking runtime and the upper levels of system.
gavofyork Mar 24, 2018
794d809
Initial reworking of runtime:
gavofyork Mar 25, 2018
7cb0720
Expose an additional function in system
gavofyork Mar 25, 2018
490b63e
Another couple of functions traitified in executive.
gavofyork Mar 25, 2018
5d8ad4b
another function in executive traitified.
gavofyork Mar 25, 2018
ac9f45e
One more function traitified.
gavofyork Mar 25, 2018
d0a4672
Finish traitifying executive!
gavofyork Mar 25, 2018
18f5283
Traitify session module.
gavofyork Mar 25, 2018
193ae03
Cleanups and ensure session gets run.
gavofyork Mar 25, 2018
6bb9819
First part of traitification of staking module.
gavofyork Mar 26, 2018
3c174a5
Bit more of staking traitified.
gavofyork Mar 26, 2018
46a6e78
Additional stuff in staking. Fix up session.
gavofyork Mar 26, 2018
5caac6a
Penultimate part of staking module.
gavofyork Mar 26, 2018
e115db4
Final part of staking (code)
gavofyork Mar 26, 2018
237e825
Update demo runtime to include staking.
gavofyork Mar 26, 2018
1c24cd6
Final tweaks for staking integration.
gavofyork Mar 26, 2018
da1268c
Remove old runtime files.
gavofyork Mar 26, 2018
6930652
Merge branch 'master' into gav-traity-runtime
gavofyork Mar 26, 2018
244d249
Schedule staking.
gavofyork Mar 26, 2018
3533060
Minor fixes
gavofyork Mar 26, 2018
ada68b6
First bits of democracy.
gavofyork Mar 26, 2018
1779190
Democracy module integrated.
gavofyork Mar 27, 2018
443bdca
Fix warning.
gavofyork Mar 27, 2018
86c605b
Traitify and integrate council module
gavofyork Mar 27, 2018
318f175
Council voting.
gavofyork Mar 27, 2018
feb4811
Runtime binary and tweaks.
gavofyork Mar 27, 2018
81460b5
Binary update.
gavofyork Mar 27, 2018
a8c9f8d
Fix `*Type` grumble.
gavofyork Mar 27, 2018
7fd63ab
Fix up genesis_map
gavofyork Mar 27, 2018
d6db86d
Remove NonTrivialSlicable
gavofyork Mar 27, 2018
fd6263c
Staking "test externalities" stuff along with refactor.
gavofyork Mar 27, 2018
15baf8b
Add session test externalities constructor
gavofyork Mar 27, 2018
6436111
Fixed executor tests.
gavofyork Mar 28, 2018
70284cb
Make one test in executive module work.
gavofyork Mar 28, 2018
17cd39a
Remove test framework stuff into common module.
gavofyork Mar 28, 2018
0fda874
Enable other tests in executive
gavofyork Mar 28, 2018
5ca7443
Session tests reinstated, minor refactoring of keyring.
gavofyork Mar 29, 2018
92350f2
Fix staking tests.
gavofyork Mar 29, 2018
bbf9f6f
Fix up democracy tests.
gavofyork Mar 30, 2018
bd78267
First few tests in council.
gavofyork Mar 30, 2018
ef21576
Council tests reinstated :)
gavofyork Mar 30, 2018
d347530
Avoid hardcoding blake2 into Header.
gavofyork Mar 30, 2018
128893c
Fix last few tests.
gavofyork Mar 30, 2018
0c27e0c
Make all primitives generic.
gavofyork Mar 30, 2018
a70d24e
Fix tests.
gavofyork Mar 30, 2018
d895a17
Refactor runtime to remove genesismap.
gavofyork Mar 30, 2018
a396025
Streamline runtime more with macrofied config.
gavofyork Mar 30, 2018
bf438e5
Clean paths
gavofyork Mar 30, 2018
98387bb
Fix warning.
gavofyork Mar 30, 2018
69587a0
Consolidate demo runtime crate.
gavofyork Mar 30, 2018
87147f8
Remove stale code.
gavofyork Mar 30, 2018
e538368
Refactor away dodgy trait.
gavofyork Mar 30, 2018
adb9a13
Add corresponding Aux type.
gavofyork Mar 30, 2018
849c8d5
Merge branch 'master' into gav-traity-runtime
gavofyork Mar 30, 2018
98c24b2
Fixes
gavofyork Mar 30, 2018
f69f56f
Rename Digesty -> Digest
gavofyork Mar 31, 2018
fb147b9
Rename Headery -> Header
gavofyork Mar 31, 2018
b1d9544
Blocky -> Block
gavofyork Mar 31, 2018
df50bd0
Fix wasm build.
gavofyork Apr 3, 2018
e927229
kill warnings
rphmeier Apr 3, 2018
8cb2648
more docs
rphmeier Apr 4, 2018
504c116
minor cleanups
rphmeier Apr 4, 2018
185e54a
Merge branch 'master' into gav-traity-runtime
rphmeier Apr 4, 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
Make all primitives generic.
gavofyork committed Mar 30, 2018
commit 0c27e0cb04b57bf2bfb203c4ea8a961fc26a524e
6 changes: 3 additions & 3 deletions demo/primitives/src/lib.rs
Original file line number Diff line number Diff line change
@@ -52,10 +52,10 @@ pub type Balance = u64;
pub type SessionKey = primitives::AuthorityId;

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

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

/// Alias to 520-bit hash when used in the context of a signature on the relay chain.
pub type Signature = primitives::hash::H512;
/// Alias to 512-bit hash when used in the context of a signature on the relay chain.
pub type Signature = runtime_primitives::generic::Ed25519Signature;
63 changes: 0 additions & 63 deletions demo/runtime/src/block.rs

This file was deleted.

210 changes: 0 additions & 210 deletions demo/runtime/src/extrinsic.rs

This file was deleted.

2 changes: 0 additions & 2 deletions demo/runtime/src/lib.rs
Original file line number Diff line number Diff line change
@@ -47,7 +47,5 @@ extern crate demo_primitives;
//#[cfg(test)] #[macro_use] extern crate hex_literal;

pub mod runtime;
pub mod block;
pub mod extrinsic;
pub mod api;
#[cfg(feature = "std")] pub mod genesismap;
17 changes: 9 additions & 8 deletions demo/runtime/src/runtime.rs
Original file line number Diff line number Diff line change
@@ -18,9 +18,9 @@
#[cfg(any(feature = "std", test))] use runtime_io;
use runtime_io::BlakeTwo256;
use {block, demo_primitives, extrinsic};
use demo_primitives;
use {consensus, council, democracy, executive, session, staking, system, timestamp};
use runtime_primitives::{Identity, HasPublicAux};
use runtime_primitives::{self as primitives, Identity, HasPublicAux};

// TODO: refactor so that each module gets to be able to attempt to extract a PrivCall into
// Some(its own PrivCall) or None.
@@ -51,13 +51,13 @@ impl consensus::Trait for Concrete {
pub type Consensus = consensus::Module<Concrete>;

impl system::Trait for Concrete {
type Index = demo_primitives::TxOrder;
type Index = demo_primitives::Index;
type BlockNumber = demo_primitives::BlockNumber;
type Hash = demo_primitives::Hash;
type Hashing = BlakeTwo256;
type Digest = demo_primitives::header::Digest;
type Digest = primitives::generic::Digest<Vec<u8>>;
type AccountId = demo_primitives::AccountId;
type Header = demo_primitives::header::Header;
type Header = primitives::generic::Header<demo_primitives::BlockNumber, demo_primitives::Hash, Vec<u8>>;
}
pub type System = system::Module<Concrete>;

@@ -103,10 +103,11 @@ impl_outer_dispatch! {
}

pub type Executive = executive::Executive<
extrinsic::UncheckedExtrinsic,
extrinsic::CheckedExtrinsic,
Concrete,
block::Block,
primitives::generic::Block<
demo_primitives::BlockNumber, demo_primitives::Hash, Vec<u8>,
demo_primitives::AccountId, demo_primitives::Index, Call, demo_primitives::Signature
>,
Staking,
(((((), Council), Democracy), Staking), Session),
>;
31 changes: 11 additions & 20 deletions substrate/runtime/executive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -39,30 +39,21 @@ use primitives::{Zero, One, Headery, Blocky, Checkable, Applyable, CheckEqual, E
use codec::Slicable;

pub struct Executive<
Unchecked,
Checked,
System,
Block,
Payment,
Finalisation,
>(PhantomData<(Unchecked, Checked, System, Block, Payment, Finalisation)>);
>(PhantomData<(System, Block, Payment, Finalisation)>);

impl<
Unchecked: Checkable<
Checked = Checked
> + PartialEq + Eq + Clone + Slicable,
Checked: Applyable<
Index = System::Index,
AccountId = System::AccountId
>,
System: system::Trait,
Block: Blocky<
Extrinsic = Unchecked,
Header = System::Header
>,
Block: Blocky<Header = System::Header>,
Payment: MakePayment<System::AccountId>,
Finalisation: Executable,
> Executive<Unchecked, Checked, System, Block, Payment, Finalisation> {
> Executive<System, Block, Payment, Finalisation> where
Block::Extrinsic: Checkable + Slicable,
<Block::Extrinsic as Checkable>::Checked: Applyable<Index = System::Index, AccountId = System::AccountId>
{
/// Start the execution of a particular block.
pub fn initialise_block(header: &System::Header) {
<system::Module<System>>::initialise(header.number(), header.parent_hash(), header.extrinsics_root());
@@ -120,17 +111,17 @@ impl<

/// Apply outside of the block execution function.
/// This doesn't attempt to validate anything regarding the block.
pub fn apply_extrinsic(utx: Unchecked) {
pub fn apply_extrinsic(utx: Block::Extrinsic) {
// Verify the signature is good.
let tx = match utx.check() {
Ok(tx) => tx,
Err(_) => panic!("All transactions should be properly signed"),
};

{
// check nonce
let expected_nonce = <system::Module<System>>::account_index(tx.sender());
assert!(tx.index() == &expected_nonce, "All transactions should have the correct nonce");
// check index
let expected_index = <system::Module<System>>::account_index(tx.sender());
assert!(tx.index() == &expected_index, "All transactions should have the correct nonce");

// increment nonce in storage
<system::Module<System>>::inc_account_index(tx.sender());
@@ -198,7 +189,7 @@ mod tests {
}

type TestXt = primitives::testing::TestXt<Call<Test>>;
type Executive = super::Executive<TestXt, TestXt, Test, Block<TestXt>, staking::Module<Test>, (session::Module<Test>, staking::Module<Test>)>;
type Executive = super::Executive<Test, Block<TestXt>, staking::Module<Test>, (session::Module<Test>, staking::Module<Test>)>;

#[test]
fn staking_balance_transfer_dispatch_works() {
407 changes: 407 additions & 0 deletions substrate/runtime/primitives/src/generic.rs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions substrate/runtime/primitives/src/lib.rs
Original file line number Diff line number Diff line change
@@ -38,6 +38,8 @@ use rstd::ops::{Add, Sub, Mul, Div, Rem, AddAssign, SubAssign, MulAssign, DivAss
#[cfg(feature = "std")]
pub mod testing;

pub mod generic;

#[cfg(feature = "std")]
pub trait MakeTestExternalities {
fn test_externalities(self) -> runtime_io::TestExternalities;