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.7k
grandpa-rpc: use FinalityProofProvider to check finality for rpc #6215
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
4eab2a4
grandpa-rpc: use FinalityProofProvider to check finality for rpc
octol 5953803
Merge branch 'master' into jon/on-demand-grandpa-finality-api
octol 0fc9cd5
Merge branch 'master' into jon/on-demand-grandpa-finality-api
octol 06b04f5
grandpa-rpc: minor tidy
octol 34522c1
grandpa-rpc: remove dyn FinalityProofProvider
octol 9fe866e
grandpa-rpc: remove unused dependencies
octol 8591352
node: move finality_proof_provider setup
octol 80f6c53
grandpa-rpc: print error reported by finality_proof_provider
octol 136c257
grandpa-rpc: add note about unnecessary encode/decode
octol eab8404
grandpa-rpc: dont encode/decode and use correct hash
octol d3e8d30
grandpa-rpc: set_id is optional
octol 801b3e6
grandpa-rpc: create test for prove_finality
octol 56f32a3
grandpa-rpc: set visibility back to how it was
octol c1e50d5
grandpa-rpc: remove unused dependency
octol 3b5a3c6
grandpa-rpc: minor tidy
octol a892236
grandpa: doc strings
octol 2db4ba0
grandpa-rpc: rename to prove_finality
octol 3c543e6
grandpa-rpc: use current set id if none is provided
octol 0e89cee
Merge branch 'master' into jon/on-demand-grandpa-finality-api
octol 7b1ed8f
grandpa-rpc: remove unnecessary check in test
octol ca1e2a8
Merge branch 'master' into jon/on-demand-grandpa-finality-api
octol 9a3b43f
node: group finality_proof_provider in rpc_setup
octol f294b47
grandpa: make prove_finality concrete in FinalityProofProvider
octol 6c7adb1
grandpa-rpc: wrap finality output in struct and store as Bytes
octol 026f542
grandpa-rpc: exhaustive error codes and wrap
octol cf2375d
Merge branch 'master' into jon/on-demand-grandpa-finality-api
octol bdf931a
grandpa-rpc: let prove_finality take a range instead of a starting point
octol 9d43c11
Merge branch 'master' into jon/on-demand-grandpa-finality-api
octol 354c589
grandpa-rpc: fix test for changed API
octol c353f81
grandpa-rpc: fix line length
octol de666ff
Merge branch 'master' into jon/on-demand-grandpa-finality-api
octol ff6d612
Merge branch 'master' into jon/on-demand-grandpa-finality-api
octol 21afc7d
Merge branch 'master' into jon/on-demand-grandpa-finality-api
octol 37b9507
grandpa: fix reviewer nits
octol 1212782
Merge branch 'master' into jon/on-demand-grandpa-finality-api
octol 6c79a1e
node/rpc: fix reviewer comments
octol c284665
Merge remote-tracking branch 'upstream/master' into jon/on-demand-gra…
octol 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// This file is part of Substrate. | ||
|
||
// Copyright (C) 2020 Parity Technologies (UK) Ltd. | ||
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 | ||
|
||
// This program 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. | ||
|
||
// This program 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 this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
use serde::{Serialize, Deserialize}; | ||
|
||
use sc_finality_grandpa::FinalityProofProvider; | ||
use sp_runtime::traits::{Block as BlockT, NumberFor}; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct EncodedFinalityProofs(pub sp_core::Bytes); | ||
|
||
/// Local trait mainly to allow mocking in tests. | ||
pub trait RpcFinalityProofProvider<Block: BlockT> { | ||
/// Return finality proofs for the given authorities set id, if it is provided, otherwise the | ||
/// current one will be used. | ||
fn rpc_prove_finality( | ||
&self, | ||
begin: Block::Hash, | ||
end: Block::Hash, | ||
authorities_set_id: u64, | ||
) -> Result<Option<EncodedFinalityProofs>, sp_blockchain::Error>; | ||
} | ||
|
||
impl<B, Block> RpcFinalityProofProvider<Block> for FinalityProofProvider<B, Block> | ||
where | ||
Block: BlockT, | ||
NumberFor<Block>: finality_grandpa::BlockNumberOps, | ||
B: sc_client_api::backend::Backend<Block> + Send + Sync + 'static, | ||
{ | ||
fn rpc_prove_finality( | ||
&self, | ||
begin: Block::Hash, | ||
end: Block::Hash, | ||
authorities_set_id: u64, | ||
) -> Result<Option<EncodedFinalityProofs>, sp_blockchain::Error> { | ||
self.prove_finality(begin, end, authorities_set_id) | ||
.map(|x| x.map(|y| EncodedFinalityProofs(y.into()))) | ||
} | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.