This repository was archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Equivocation misbehaviour reports #2923
Closed
Closed
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
0eb8b9d
Implement ValidateUnsigned for Aura equivocation report
seerscode 37c46ac
Add transaction pool to check_header in Aura
seerscode 6d82c3f
Add constructor api to Aura
seerscode a7536b1
Submit report from Aura
seerscode f6055b9
Add Grandpa constructor calls
seerscode 157320c
Submit grandpa reports, need to fix tests
seerscode 1b1e516
Fix Grandpa Test
seerscode 808fdb8
Aura construct call
seerscode 86f4793
Add types Prevote/Precommit Equivocation
seerscode d52f8ab
Add handlers for grandpa reports
seerscode 129fb1c
Fix test-runtime
seerscode e65252a
Add Babe ValidateUnsigned
seerscode 4b558b5
Fix test
seerscode 1a4b980
Remove unused imports
seerscode e4a5cc1
Add test for check_header submiting in aura
seerscode 1ad7ce5
Add test for srml aura
seerscode 5b95415
Add test for Grandpa srml
seerscode 9a3a560
Merge master
seerscode 1d1d3f3
Fix fg test
seerscode d3ddf6b
Add new GrandpaApi version
seerscode 755bf45
Remove unwrap
seerscode cc01912
Remove bunch of warnings
seerscode 6a293c0
Refactor submitters
seerscode e1c025e
Refactor aura report
seerscode 042ee9b
Merge master
seerscode 529d4b5
Rename accountable safety
seerscode 9f80e81
Remove mock for tx pool
seerscode 5c2a007
Fix some nits
seerscode File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 @@ | ||
| [package] | ||
| name = "substrate-consensus-accountable-safety" | ||
| version = "2.0.0" | ||
| authors = ["Parity Technologies <admin@parity.io>"] | ||
| description = "Common utilities for accountable safety" | ||
| edition = "2018" | ||
|
|
||
| [dependencies] | ||
| client = { package = "substrate-client", path = "../../client" } | ||
| transaction_pool = { package = "substrate-transaction-pool", path = "../../transaction-pool" } | ||
| node-runtime = { path = "../../../node/runtime" } | ||
| runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" } | ||
| substrate-primitives = { path = "../../primitives" } | ||
| grandpa = { package = "finality-grandpa", git = "https://github.com/paritytech/finality-grandpa/", branch = "mod-equivocation-reports", features = ["derive-codec"] } | ||
| parity-codec = "3.5.1" | ||
| log = "0.4" |
This file contains hidden or 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,9 @@ | ||
| [package] | ||
| name = "substrate-consensus-accountable-safety-primitives" | ||
| version = "2.0.0" | ||
| authors = ["Parity Technologies <admin@parity.io>"] | ||
| description = "Primitives for Accountable Safety" | ||
| edition = "2018" | ||
|
|
||
| [dependencies] | ||
| runtime_primitives = { package = "sr-primitives", path = "../../../sr-primitives", default-features = false } |
This file contains hidden or 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,41 @@ | ||
| // Copyright 2019 Parity Technologies (UK) Ltd. | ||
| // This file is part of Substrate. | ||
|
|
||
| // Substrate 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. | ||
|
|
||
| // Substrate 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 Substrate. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| //! Common utilities for accountable safety in Substrate. | ||
|
|
||
| #![cfg_attr(not(feature = "std"), no_std)] | ||
|
|
||
| pub trait AuthorshipEquivocationProof<H, S> { | ||
| /// Create an equivocation proof for AuRa or Babe. | ||
| fn new( | ||
| first_header: H, | ||
| second_header: H, | ||
| first_signature: S, | ||
| second_signature: S, | ||
| ) -> Self; | ||
|
|
||
| /// Get the first header involved in the equivocation. | ||
| fn first_header(&self) -> &H; | ||
|
|
||
| /// Get the second header involved in the equivocation. | ||
| fn second_header(&self) -> &H; | ||
|
|
||
| /// Get signature for the first header involved in the equivocation. | ||
| fn first_signature(&self) -> &S; | ||
|
|
||
| /// Get signature for the second header involved in the equivocation. | ||
| fn second_signature(&self) -> &S; | ||
| } |
This file contains hidden or 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,52 @@ | ||
| // Copyright 2019 Parity Technologies (UK) Ltd. | ||
| // This file is part of Substrate. | ||
|
|
||
| // Substrate 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. | ||
|
|
||
| // Substrate 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 Substrate. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| //! Common utilities for accountable safety in Substrate. | ||
|
|
||
| #![forbid(missing_docs, unsafe_code)] | ||
|
|
||
| use client; | ||
| use transaction_pool::txpool::{self, PoolApi}; | ||
| use parity_codec::{Encode, Decode}; | ||
| use runtime_primitives::traits::{Block as BlockT}; | ||
| use runtime_primitives::generic::BlockId; | ||
| use log::info; | ||
| use client::blockchain::HeaderBackend; | ||
|
|
||
| /// Trait to submit report calls to the transaction pool. | ||
| pub trait SubmitReport<C, Block> { | ||
| /// Submit report call to the transaction pool. | ||
| fn submit_report_call(&self, client: &C, extrinsic: &[u8]); | ||
| } | ||
|
|
||
| impl<C, Block, T: PoolApi + Send + Sync + 'static> SubmitReport<C, Block> for T | ||
| where | ||
| Block: BlockT + 'static, | ||
| <T as PoolApi>::Api: txpool::ChainApi<Block=Block> + 'static, | ||
| C: HeaderBackend<Block>, | ||
| { | ||
| fn submit_report_call(&self, client: &C, mut extrinsic: &[u8]) { | ||
| info!(target: "accountable-safety", "Submitting report call to tx pool"); | ||
| if let Some(uxt) = Decode::decode(&mut extrinsic) { | ||
| let block_id = BlockId::<Block>::number(client.info().best_number); | ||
| if let Err(e) = self.submit_one(&block_id, uxt) { | ||
| info!(target: "accountable-safety", "Error importing misbehavior report: {:?}", e); | ||
| } | ||
| } else { | ||
| info!(target: "accountable-safety", "Error decoding report call"); | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. I almost made the same change for BABE in my on-chain randomness work, but reverted it.