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
Commits
5628f095
Commit
5628f095
authored
6 months ago
by
Benjamin Gallois
Committed by
Hugo Trentesaux
6 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix
#250
(
!279
)
* add grandpa rpc
parent
7fe42a23
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!279
Fix #250
Pipeline
#38063
passed
6 months ago
Stage: build
Stage: tests
Stage: deploy
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
Cargo.lock
+52
-17
52 additions, 17 deletions
Cargo.lock
Cargo.toml
+2
-0
2 additions, 0 deletions
Cargo.toml
node/Cargo.toml
+2
-0
2 additions, 0 deletions
node/Cargo.toml
node/src/rpc.rs
+47
-4
47 additions, 4 deletions
node/src/rpc.rs
node/src/service.rs
+32
-13
32 additions, 13 deletions
node/src/service.rs
with
135 additions
and
34 deletions
Cargo.lock
+
52
−
17
View file @
5628f095
...
...
@@ -429,13 +429,13 @@ dependencies = [
[[package]]
name = "ark-secret-scalar"
version = "0.0.2"
source = "git+https://github.com/duniter/ring-vrf#
06b60fdb7308c127448ef5799414c45516f6c42b
"
source = "git+https://github.com/duniter/ring-vrf#
27a6b9f6aa0c576bc481947dd5e4f3beff0fe327
"
dependencies = [
"ark-ec",
"ark-ff",
"ark-serialize",
"ark-std",
"ark-transcript",
"ark-transcript
0.0.2 (git+https://github.com/duniter/ring-vrf)
",
"digest 0.10.7",
"getrandom_or_panic",
"zeroize",
...
...
@@ -478,7 +478,20 @@ dependencies = [
[[package]]
name = "ark-transcript"
version = "0.0.2"
source = "git+https://github.com/duniter/ring-vrf#06b60fdb7308c127448ef5799414c45516f6c42b"
source = "git+https://github.com/duniter/ring-vrf#27a6b9f6aa0c576bc481947dd5e4f3beff0fe327"
dependencies = [
"ark-ff",
"ark-serialize",
"ark-std",
"digest 0.10.7",
"rand_core",
"sha3",
]
[[package]]
name = "ark-transcript"
version = "0.0.2"
source = "git+https://github.com/w3f/ring-vrf#0fef8266d851932ad25d6b41bc4b34d834d1e11d"
dependencies = [
"ark-ff",
"ark-serialize",
...
...
@@ -808,7 +821,7 @@ dependencies = [
[[package]]
name = "bandersnatch_vrfs"
version = "0.0.4"
source = "git+https://github.com/duniter/ring-vrf#
06b60fdb7308c127448ef5799414c45516f6c42b
"
source = "git+https://github.com/duniter/ring-vrf#
27a6b9f6aa0c576bc481947dd5e4f3beff0fe327
"
dependencies = [
"ark-bls12-381",
"ark-ec",
...
...
@@ -1487,7 +1500,7 @@ dependencies = [
[[package]]
name = "common"
version = "0.1.0"
source = "git+https://github.com/w3f/ring-proof#
b273d33f9981e2bb3375ab45faeb537f7ee35224
"
source = "git+https://github.com/w3f/ring-proof#
1472ce9cd87cee49c56ce7869a0aba872d837c51
"
dependencies = [
"ark-ec",
"ark-ff",
...
...
@@ -1496,8 +1509,7 @@ dependencies = [
"ark-std",
"fflonk",
"getrandom_or_panic",
"merlin",
"rand_chacha",
"rand_core",
]
[[package]]
...
...
@@ -2401,7 +2413,7 @@ dependencies = [
[[package]]
name = "dleq_vrf"
version = "0.0.2"
source = "git+https://github.com/duniter/ring-vrf#
06b60fdb7308c127448ef5799414c45516f6c42b
"
source = "git+https://github.com/duniter/ring-vrf#
27a6b9f6aa0c576bc481947dd5e4f3beff0fe327
"
dependencies = [
"ark-ec",
"ark-ff",
...
...
@@ -2409,7 +2421,7 @@ dependencies = [
"ark-secret-scalar",
"ark-serialize",
"ark-std",
"ark-transcript",
"ark-transcript
0.0.2 (git+https://github.com/duniter/ring-vrf)
",
"arrayvec 0.7.4",
"zeroize",
]
...
...
@@ -2516,11 +2528,13 @@ dependencies = [
"sc-consensus-babe",
"sc-consensus-babe-rpc",
"sc-consensus-grandpa",
"sc-consensus-grandpa-rpc",
"sc-consensus-manual-seal",
"sc-executor",
"sc-keystore",
"sc-network",
"sc-offchain",
"sc-rpc",
"sc-rpc-api",
"sc-service",
"sc-telemetry",
...
...
@@ -4334,14 +4348,14 @@ checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333"
dependencies = [
"futures-util",
"http 1.1.0",
"hyper 1.
4.0
",
"hyper 1.
3.1
",
"hyper-util",
"rustls 0.23.10",
"rustls-pki-types",
"tokio",
"tokio-rustls 0.26.0",
"tower-service",
"webpki-roots 0.26.
3
",
"webpki-roots 0.26.
5
",
]
[[package]]
...
...
@@ -8175,7 +8189,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684"
dependencies = [
"bytes",
"pin-project-lite
0.2.14
",
"pin-project-lite",
"quinn-proto 0.11.8",
"quinn-udp 0.5.4",
"rustc-hash 2.0.0",
...
...
@@ -8550,7 +8564,7 @@ dependencies = [
"http 1.1.0",
"http-body 1.0.0",
"http-body-util",
"hyper 1.
4.0
",
"hyper 1.
3.1
",
"hyper-rustls 0.27.3",
"hyper-util",
"ipnet",
...
...
@@ -8559,7 +8573,7 @@ dependencies = [
"mime",
"once_cell",
"percent-encoding",
"pin-project-lite
0.2.14
",
"pin-project-lite",
"quinn 0.11.5",
"rustls 0.23.10",
"rustls-pemfile 2.1.2",
...
...
@@ -8575,7 +8589,7 @@ dependencies = [
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"webpki-roots 0.26.
3
",
"webpki-roots 0.26.
5
",
"winreg 0.52.0",
]
...
...
@@ -8602,17 +8616,18 @@ dependencies = [
[[package]]
name = "ring"
version = "0.1.0"
source = "git+https://github.com/w3f/ring-proof#
b273d33f9981e2bb3375ab45faeb537f7ee35224
"
source = "git+https://github.com/w3f/ring-proof#
1472ce9cd87cee49c56ce7869a0aba872d837c51
"
dependencies = [
"ark-ec",
"ark-ff",
"ark-poly",
"ark-serialize",
"ark-std",
"ark-transcript 0.0.2 (git+https://github.com/w3f/ring-vrf)",
"arrayvec 0.7.4",
"blake2 0.10.6",
"common",
"fflonk",
"merlin",
]
[[package]]
...
...
@@ -9316,6 +9331,26 @@ dependencies = [
"thiserror",
]
[[package]]
name = "sc-consensus-grandpa-rpc"
version = "0.19.0"
source = "git+https://github.com/duniter/duniter-polkadot-sdk?branch=duniter-substrate-v1.14.0#bcc60f3e4170c3908689252242f40761270c9a51"
dependencies = [
"finality-grandpa",
"futures 0.3.30",
"jsonrpsee 0.23.2",
"log",
"parity-scale-codec",
"sc-client-api",
"sc-consensus-grandpa",
"sc-rpc",
"serde",
"sp-blockchain",
"sp-core",
"sp-runtime",
"thiserror",
]
[[package]]
name = "sc-consensus-manual-seal"
version = "0.35.0"
...
...
This diff is collapsed.
Click to expand it.
Cargo.toml
+
2
−
0
View file @
5628f095
...
...
@@ -169,6 +169,8 @@ sp-block-builder = { git = 'https://github.com/duniter/duniter-polkadot-sdk', br
sc-client-db
=
{
git
=
'https://github.com/duniter/duniter-polkadot-sdk'
,
branch
=
'duniter-substrate-v1.14.0'
,
default-features
=
false
}
sc-client-api
=
{
git
=
'https://github.com/duniter/duniter-polkadot-sdk'
,
branch
=
'duniter-substrate-v1.14.0'
,
default-features
=
false
}
sc-consensus-grandpa
=
{
git
=
'https://github.com/duniter/duniter-polkadot-sdk'
,
branch
=
'duniter-substrate-v1.14.0'
,
default-features
=
false
}
sc-rpc
=
{
git
=
'https://github.com/duniter/duniter-polkadot-sdk'
,
branch
=
'duniter-substrate-v1.14.0'
,
default-features
=
false
}
sc-consensus-grandpa-rpc
=
{
git
=
'https://github.com/duniter/duniter-polkadot-sdk'
,
branch
=
'duniter-substrate-v1.14.0'
,
default-features
=
false
}
sc-consensus-babe
=
{
git
=
'https://github.com/duniter/duniter-polkadot-sdk'
,
branch
=
'duniter-substrate-v1.14.0'
,
default-features
=
false
}
sc-consensus-babe-rpc
=
{
git
=
'https://github.com/duniter/duniter-polkadot-sdk'
,
branch
=
'duniter-substrate-v1.14.0'
,
default-features
=
false
}
sp-blockchain
=
{
git
=
'https://github.com/duniter/duniter-polkadot-sdk'
,
branch
=
'duniter-substrate-v1.14.0'
,
default-features
=
false
}
...
...
This diff is collapsed.
Click to expand it.
node/Cargo.toml
+
2
−
0
View file @
5628f095
...
...
@@ -139,9 +139,11 @@ sc-chain-spec = { workspace = true, default-features = true }
sc-client-api
=
{
workspace
=
true
,
default-features
=
true
}
sc-client-db
=
{
workspace
=
true
,
default-features
=
true
}
sc-consensus
=
{
workspace
=
true
,
default-features
=
true
}
sc-rpc
=
{
workspace
=
true
,
default-features
=
true
}
sc-consensus-babe
=
{
workspace
=
true
,
default-features
=
true
}
sc-consensus-babe-rpc
=
{
workspace
=
true
,
default-features
=
true
}
sc-consensus-grandpa
=
{
workspace
=
true
,
default-features
=
true
}
sc-consensus-grandpa-rpc
=
{
workspace
=
true
,
default-features
=
true
}
sc-consensus-manual-seal
=
{
workspace
=
true
,
default-features
=
true
}
sc-executor
=
{
workspace
=
true
,
default-features
=
true
}
sc-keystore
=
{
workspace
=
true
,
default-features
=
true
}
...
...
This diff is collapsed.
Click to expand it.
node/src/rpc.rs
+
47
−
4
View file @
5628f095
...
...
@@ -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
{
...
...
This diff is collapsed.
Click to expand it.
node/src/service.rs
+
32
−
13
View file @
5628f095
...
...
@@ -23,8 +23,9 @@ use async_io::Timer;
use
common_runtime
::
Block
;
use
futures
::{
Stream
,
StreamExt
};
use
sc_client_api
::{
client
::
BlockBackend
,
Backend
};
use
sc_consensus_grandpa
::
SharedVoterState
;
use
sc_consensus_grandpa
::
{
FinalityProofProvider
,
SharedVoterState
}
;
use
sc_consensus_manual_seal
::{
run_manual_seal
,
EngineCommand
,
ManualSealParams
};
use
sc_rpc
::
SubscriptionTaskExecutor
;
use
sc_service
::{
error
::
Error
as
ServiceError
,
Configuration
,
PartialComponents
,
TaskManager
,
WarpSyncParams
,
};
...
...
@@ -572,6 +573,12 @@ where
}
}
let
justification_stream
=
grandpa_link
.justification_stream
();
let
shared_authority_set
=
grandpa_link
.shared_authority_set
()
.clone
();
let
shared_voter_state
=
SharedVoterState
::
empty
();
let
finality_proof_provider
=
FinalityProofProvider
::
new_for_service
(
backend
.clone
(),
Some
(
shared_authority_set
.clone
()));
let
rpc_extensions_builder
=
{
let
client
=
client
.clone
();
let
pool
=
transaction_pool
.clone
();
...
...
@@ -581,19 +588,31 @@ where
babe_worker_handle
,
keystore
:
keystore
.clone
(),
});
let
rpc_setup
=
shared_voter_state
.clone
();
Box
::
new
(
move
|
deny_unsafe
,
subscription_task_executor
:
SubscriptionTaskExecutor
|
{
let
grandpa_deps
=
crate
::
rpc
::
GrandpaDeps
{
shared_voter_state
:
rpc_setup
.clone
(),
shared_authority_set
:
shared_authority_set
.clone
(),
justification_stream
:
justification_stream
.clone
(),
subscription_executor
:
subscription_task_executor
.clone
(),
finality_provider
:
finality_proof_provider
.clone
(),
};
Box
::
new
(
move
|
deny_unsafe
,
_
|
{
let
deps
=
crate
::
rpc
::
FullDeps
{
client
:
client
.clone
(),
pool
:
pool
.clone
(),
select_chain
:
select_chain
.clone
()
,
deny_unsafe
,
babe
:
babe_deps
.clone
()
,
command_sink_opt
:
command_sink_opt
.clone
(),
};
let
deps
=
crate
::
rpc
::
FullDeps
{
client
:
client
.clone
(),
pool
:
pool
.clone
(),
select_chain
:
select_chain
.clone
(),
deny_unsafe
,
babe
:
babe_deps
.clone
()
,
grandpa
:
grandpa_deps
,
command_sink_opt
:
command_sink_opt
.clone
(),
};
crate
::
rpc
::
create_full
(
deps
)
.map_err
(
Into
::
into
)
})
crate
::
rpc
::
create_full
(
deps
)
.map_err
(
Into
::
into
)
},
)
};
let
_rpc_handlers
=
sc_service
::
spawn_tasks
(
sc_service
::
SpawnTasksParams
{
...
...
@@ -644,7 +663,7 @@ where
network
,
voting_rule
:
sc_consensus_grandpa
::
VotingRulesBuilder
::
default
()
.build
(),
prometheus_registry
,
shared_voter_state
:
SharedVoterState
::
empty
()
,
shared_voter_state
,
telemetry
:
telemetry
.as_ref
()
.map
(|
x
|
x
.handle
()),
notification_service
:
grandpa_notification_service
,
offchain_tx_pool_factory
:
sc_transaction_pool_api
::
OffchainTransactionPoolFactory
::
new
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment