Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Duniter v2S
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
Duniter v2S
Merge requests
!279
Fix
#250
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Fix
#250
fix-250
into
master
Overview
2
Commits
1
Pipelines
10
Changes
5
1 unresolved thread
Hide all comments
Merged
Benjamin Gallois
requested to merge
fix-250
into
master
5 months ago
Overview
2
Commits
1
Pipelines
10
Changes
5
1 unresolved thread
Hide all comments
Expand
Fix
#250 (closed)
by adding the RPC module for Grandpa.
Note:
proveFinality
call will only work after the first authority set change.
Edited
5 months ago
by
Benjamin Gallois
1
0
Merge request reports
Viewing commit
b27ee1da
Show latest version
5 files
+
135
−
34
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
5
Search (e.g. *.vue) (Ctrl+P)
b27ee1da
add grandpa rpc
· b27ee1da
bgallois
authored
5 months ago
node/src/rpc.rs
+
47
−
4
Options
@@ -23,9 +23,13 @@
pub
use
sc_rpc_api
::
DenyUnsafe
;
use
common_runtime
::{
AccountId
,
Balance
,
Block
,
Index
};
use
common_runtime
::{
AccountId
,
Balance
,
Block
,
BlockNumber
,
Hash
,
Index
};
use
jsonrpsee
::
RpcModule
;
use
sc_consensus_babe
::{
BabeApi
,
BabeWorkerHandle
};
use
sc_consensus_grandpa
::{
self
,
FinalityProofProvider
,
GrandpaJustificationStream
,
SharedAuthoritySet
,
SharedVoterState
,
};
use
sc_rpc
::
SubscriptionTaskExecutor
;
use
sc_transaction_pool_api
::
TransactionPool
;
use
sp_api
::
ProvideRuntimeApi
;
use
sp_block_builder
::
BlockBuilder
;
@@ -43,8 +47,23 @@ pub struct BabeDeps {
pub
keystore
:
KeystorePtr
,
}
/// Dependencies for GRANDPA
#[derive(Clone)]
pub
struct
GrandpaDeps
<
B
>
{
/// Voting round info.
pub
shared_voter_state
:
SharedVoterState
,
/// Authority set info.
pub
shared_authority_set
:
SharedAuthoritySet
<
Hash
,
BlockNumber
>
,
/// Receives notifications about justification events from Grandpa.
pub
justification_stream
:
GrandpaJustificationStream
<
Block
>
,
/// Executor to drive the subscription manager in the Grandpa RPC handler.
pub
subscription_executor
:
SubscriptionTaskExecutor
,
/// Finality proof provider.
pub
finality_provider
:
Arc
<
FinalityProofProvider
<
B
,
Block
>>
,
}
/// Full client dependencies.
pub
struct
FullDeps
<
C
,
P
,
SC
>
{
pub
struct
FullDeps
<
C
,
P
,
SC
,
B
>
{
/// The client instance to use.
pub
client
:
Arc
<
C
>
,
/// Transaction pool instance.
@@ -59,11 +78,13 @@ pub struct FullDeps<C, P, SC> {
>
,
/// BABE specific dependencies.
pub
babe
:
Option
<
BabeDeps
>
,
/// GRANDPA specific dependencies.
pub
grandpa
:
GrandpaDeps
<
B
>
,
}
/// Instantiate all full RPC extensions.
pub
fn
create_full
<
C
,
P
,
SC
>
(
deps
:
FullDeps
<
C
,
P
,
SC
>
,
pub
fn
create_full
<
C
,
P
,
SC
,
B
>
(
deps
:
FullDeps
<
C
,
P
,
SC
,
B
>
,
)
->
Result
<
RpcModule
<
()
>
,
Box
<
dyn
std
::
error
::
Error
+
Send
+
Sync
>>
where
C
:
ProvideRuntimeApi
<
Block
>
,
@@ -75,9 +96,11 @@ where
C
::
Api
:
BlockBuilder
<
Block
>
,
P
:
TransactionPool
+
'static
,
SC
:
SelectChain
<
Block
>
+
'static
,
B
:
sc_client_api
::
Backend
<
Block
>
+
'static
,
{
use
pallet_transaction_payment_rpc
::{
TransactionPayment
,
TransactionPaymentApiServer
};
use
sc_consensus_babe_rpc
::{
Babe
,
BabeApiServer
};
use
sc_consensus_grandpa_rpc
::{
Grandpa
,
GrandpaApiServer
};
use
sc_consensus_manual_seal
::
rpc
::{
ManualSeal
,
ManualSealApiServer
};
use
substrate_frame_rpc_system
::{
System
,
SystemApiServer
};
@@ -89,6 +112,7 @@ where
deny_unsafe
,
command_sink_opt
,
babe
,
grandpa
,
}
=
deps
;
if
let
Some
(
babe
)
=
babe
{
@@ -107,6 +131,25 @@ where
.into_rpc
(),
)
?
;
}
let
GrandpaDeps
{
shared_voter_state
,
shared_authority_set
,
justification_stream
,
subscription_executor
,
finality_provider
,
}
=
grandpa
;
module
.merge
(
Grandpa
::
new
(
subscription_executor
,
shared_authority_set
,
shared_voter_state
,
justification_stream
,
finality_provider
,
)
.into_rpc
(),
)
?
;
module
.merge
(
System
::
new
(
client
.clone
(),
pool
,
deny_unsafe
)
.into_rpc
())
?
;
module
.merge
(
TransactionPayment
::
new
(
client
)
.into_rpc
())
?
;
if
let
Some
(
command_sink
)
=
command_sink_opt
{
Loading