-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from paritytech/rh-vote-graph
Vote Graph and GHOST-hunting
- Loading branch information
Showing
5 changed files
with
612 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
root = true | ||
[*] | ||
indent_style=tab | ||
indent_size=tab | ||
tab_width=4 | ||
end_of_line=lf | ||
charset=utf-8 | ||
trim_trailing_whitespace=true | ||
max_line_length=120 | ||
insert_final_newline=true | ||
|
||
[*.yml] | ||
indent_style=space | ||
indent_size=2 | ||
tab_width=8 | ||
end_of_line=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "finality-afg" | ||
version = "0.1.0" | ||
description = "PBFT-based finality gadget for blockchains" | ||
authors = ["Parity Technologies <[email protected]>"] | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# finality-afg | ||
finality gadget for blockchains, based on PBFT | ||
|
||
Implementation in Rust. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright 2018 Parity Technologies (UK) Ltd. | ||
// This file is part of finality-afg. | ||
|
||
// finality-afg is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// finality-afg is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with finality-afg. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
//! Finality gadget for blockchains. | ||
//! | ||
//! https://hackmd.io/svMTltnGQsSR1GCjRKOPbw | ||
mod vote_graph; | ||
|
||
use std::fmt; | ||
|
||
/// A prevote for a block and its ancestors. | ||
pub struct Prevote<H> { | ||
round: u64, | ||
target: H, | ||
weight: usize, | ||
} | ||
|
||
/// A precommit for a block and its ancestors. | ||
pub struct Precommit<H> { | ||
round: u64, | ||
target: H, | ||
weight: usize, | ||
} | ||
|
||
#[derive(Clone, PartialEq, Debug)] | ||
pub enum Error { | ||
BlockNotInSubtree, | ||
} | ||
|
||
impl fmt::Display for Error { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
match *self { | ||
Error::BlockNotInSubtree => write!(f, "Block not in subtree of base"), | ||
} | ||
} | ||
} | ||
|
||
impl ::std::error::Error for Error { | ||
fn description(&self) -> &str { | ||
match *self { | ||
Error::BlockNotInSubtree => "Block not in subtree of base", | ||
} | ||
} | ||
} | ||
|
||
/// Chain context necessary for implementation of the finality gadget. | ||
pub trait Chain<H> { | ||
/// Get the ancestry of a block up to but not including the base hash. | ||
/// Should be in reverse order from `block`'s parent. | ||
/// | ||
/// If the block is not a descendent of `base`, returns an error. | ||
fn ancestry(&self, base: H, block: H) -> Result<Vec<H>, Error>; | ||
} |
Oops, something went wrong.