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

Consensus: Proof of Work #3473

Merged
merged 59 commits into from Sep 6, 2019
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
ea409c6
consensus-pow: init primtives and verifier
sorpaas Aug 23, 2019
ceb0595
consensus-pow: add total difficulty auxiliary
sorpaas Aug 23, 2019
634e789
consensus-pow: implement total difficulty chain selection
sorpaas Aug 23, 2019
19c215c
consensus-pow: implement pow import queue
sorpaas Aug 23, 2019
ba0d5c7
consensus-pow-primitives: add mine into PowApi
sorpaas Aug 23, 2019
6d78b8c
consensus-pow: implement mining
sorpaas Aug 23, 2019
ac6daab
Update lock file
sorpaas Aug 23, 2019
a94a48f
Style fixes
gavofyork Aug 24, 2019
286f260
consensus-pow: refactor register_pow_inherent_data_provider
sorpaas Aug 26, 2019
41d59d3
consensus-pow: make PowApi::mine yieldable
sorpaas Aug 26, 2019
766426f
consensus-pow: better mining loop
sorpaas Aug 26, 2019
a434955
Add missing license header
sorpaas Aug 26, 2019
69b0fc1
consensus-pow-primitives: clarify the meaning of None for PowApi::verify
sorpaas Aug 26, 2019
573c39f
consensus-pow: changing total difficulty addition to use saturating add
sorpaas Aug 26, 2019
dd85dae
consensus-pow: change mine-loop error to log on error! level
sorpaas Aug 26, 2019
67bda93
consensus-pow: allow inserting arbitrary preruntime digest for pow
sorpaas Aug 26, 2019
90e7639
Fix line width
sorpaas Aug 26, 2019
ccb1445
More line width fixes
sorpaas Aug 26, 2019
95d75d7
Merge branch 'master' of https://github.com/paritytech/substrate into…
sorpaas Aug 26, 2019
0198ae5
consensus-pow: separate difficulty, verify API
sorpaas Aug 27, 2019
b0134e0
srml-pow: implementation of average_span difficulty adjustment
sorpaas Aug 27, 2019
942cc9f
srml-pow: basic blake2 algo example
sorpaas Aug 27, 2019
dde1ea2
srml-pow-average-span: make it not require genesis config
sorpaas Aug 27, 2019
c68cee4
srml-pow: add support for authorship
sorpaas Aug 27, 2019
006005b
Missing license headers
sorpaas Aug 27, 2019
2abe98e
consensus-pow: PowAlgorithm trait generalization
sorpaas Aug 27, 2019
4171baf
Missing docs for consensus-pow
sorpaas Aug 27, 2019
43a3df8
More docs
sorpaas Aug 27, 2019
0e9b0b9
node-runtime: bump impl_version
sorpaas Aug 27, 2019
9551717
Add rationale for difficulty type
sorpaas Aug 27, 2019
4385df1
consensus-pow: refactor aux_key
sorpaas Aug 27, 2019
f62ae66
Merge branch 'master' of https://github.com/paritytech/substrate into…
sorpaas Aug 27, 2019
a7182cd
Update lock file
sorpaas Aug 27, 2019
7c3098d
Update core/consensus/pow/src/lib.rs
sorpaas Aug 27, 2019
4866949
Update core/consensus/pow/src/lib.rs
sorpaas Aug 27, 2019
fdc6e67
Update core/consensus/pow/src/lib.rs
sorpaas Aug 27, 2019
acc9d10
Update core/consensus/pow/src/lib.rs
sorpaas Aug 27, 2019
940eb3b
Update core/consensus/pow/src/lib.rs
sorpaas Aug 27, 2019
015893f
Update core/consensus/pow/src/lib.rs
sorpaas Aug 27, 2019
5ea5c1b
Update core/consensus/pow/src/lib.rs
sorpaas Aug 27, 2019
220963b
Update core/consensus/pow/primitives/src/lib.rs
sorpaas Aug 27, 2019
012b664
Update core/consensus/pow/primitives/src/lib.rs
sorpaas Aug 27, 2019
745d604
Remove PowRuntimeAlgorithm
sorpaas Aug 28, 2019
46d35a3
Merge branch 'pow' of https://github.com/paritytech/substrate into pow
sorpaas Aug 28, 2019
6086f3f
block_id -> parent_block_id
sorpaas Aug 29, 2019
221bcd6
Auxiliary data -> auxiliary storage data
sorpaas Aug 29, 2019
44e2885
Fix error message
sorpaas Aug 29, 2019
9c92009
Merge branch 'master' into pow
sorpaas Aug 29, 2019
68efcfe
Fix compile
sorpaas Aug 29, 2019
8d576c9
Merge branch 'pow' of https://github.com/paritytech/substrate into pow
sorpaas Aug 29, 2019
fb6344e
Update core/consensus/pow/primitives/src/lib.rs
sorpaas Aug 29, 2019
5ad5755
Update core/consensus/pow/src/lib.rs
sorpaas Aug 29, 2019
1a6cc58
Merge branch 'master' of https://github.com/paritytech/substrate into…
sorpaas Sep 2, 2019
20b1ab1
Update core/consensus/pow/primitives/src/lib.rs
sorpaas Sep 2, 2019
68316b6
Merge branch 'pow' of https://github.com/paritytech/substrate into pow
sorpaas Sep 2, 2019
bf1576b
Update core/consensus/pow/src/lib.rs
sorpaas Sep 4, 2019
910f173
Fix crate description
sorpaas Sep 5, 2019
4732737
More docs
sorpaas Sep 5, 2019
b227b98
Address grumbles
sorpaas Sep 6, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Expand Up @@ -29,6 +29,7 @@ members = [
"core/consensus/rhd",
"core/consensus/slots",
"core/consensus/uncles",
"core/consensus/pow",
"core/executor",
"core/executor/runtime-test",
"core/finality-grandpa",
Expand Down
2 changes: 1 addition & 1 deletion core/consensus/aura/primitives/Cargo.toml
Expand Up @@ -10,7 +10,7 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features =
substrate-client = { path = "../../../client", default-features = false }
app-crypto = { package = "substrate-application-crypto", path = "../../../application-crypto", default-features = false }
rstd = { package = "sr-std", path = "../../../sr-std", default-features = false }
sr-primitives = { path = "../../../sr-primitives", default-features = false }
sr-primitives = { path = "../../../sr-primitives", default-features = false }

[features]
default = ["std"]
Expand Down
18 changes: 18 additions & 0 deletions core/consensus/pow/Cargo.toml
@@ -0,0 +1,18 @@
[package]
name = "substrate-consensus-pow"
version = "2.0.0"
authors = ["Parity Technologies <admin@parity.io>"]
description = "PoW consensus algorithm for substrate"
edition = "2018"

[dependencies]
codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] }
primitives = { package = "substrate-primitives", path = "../../primitives" }
sr-primitives = { path = "../../sr-primitives" }
client = { package = "substrate-client", path = "../../client" }
srml-timestamp = { path = "../../../srml/timestamp" }
inherents = { package = "substrate-inherents", path = "../../inherents" }
pow-primitives = { package = "substrate-consensus-pow-primitives", path = "primitives" }
consensus-common = { package = "substrate-consensus-common", path = "../common" }
log = "0.4"
futures-preview = { version = "=0.3.0-alpha.17", features = ["compat"] }
21 changes: 21 additions & 0 deletions core/consensus/pow/primitives/Cargo.toml
@@ -0,0 +1,21 @@
[package]
name = "substrate-consensus-pow-primitives"
version = "2.0.0"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Primitives for Aura consensus"
edition = "2018"

[dependencies]
substrate-client = { path = "../../../client", default-features = false }
rstd = { package = "sr-std", path = "../../../sr-std", default-features = false }
sr-primitives = { path = "../../../sr-primitives", default-features = false }
primitives = { package = "substrate-primitives", path = "../../../primitives", default-features = false }

[features]
default = ["std"]
std = [
"rstd/std",
"substrate-client/std",
"sr-primitives/std",
"primitives/std",
]
29 changes: 29 additions & 0 deletions core/consensus/pow/primitives/src/lib.rs
@@ -0,0 +1,29 @@
#![cfg_attr(not(feature = "std"), no_std)]
sorpaas marked this conversation as resolved.
Show resolved Hide resolved

use substrate_client::decl_runtime_apis;
use rstd::vec::Vec;
use sr_primitives::ConsensusEngineId;
use primitives::H256;

/// The `ConsensusEngineId` of PoW.
pub const POW_ENGINE_ID: ConsensusEngineId = [b'p', b'o', b'w', b'_'];
sorpaas marked this conversation as resolved.
Show resolved Hide resolved

/// Type of difficulty.
pub type Difficulty = u128;

/// Type of seal.
pub type Seal = Vec<u8>;

decl_runtime_apis! {
/// API necessary for block authorship with Proof of Work.
pub trait PowApi {
/// Verify a given proof of work against the current difficulty.
/// Note that `pre_hash` is always a hash of a direct child.
///
/// Returns the current difficulty.
sorpaas marked this conversation as resolved.
Show resolved Hide resolved
fn verify(pre_hash: &H256, seal: &Seal) -> Option<Difficulty>;
sorpaas marked this conversation as resolved.
Show resolved Hide resolved
sorpaas marked this conversation as resolved.
Show resolved Hide resolved

/// Mine a seal that satisfy the current difficulty.
fn mine(pre_hash: &H256) -> (Difficulty, Seal);
}
}