Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
2f5367f
Rough skeleton for what I think the RPC should look like
HCastano Apr 8, 2020
9d369ac
Create channel for sending justifications
HCastano Apr 10, 2020
0095b78
WIP: Add subscribers for justifications to Grandpa
HCastano Apr 18, 2020
7719292
WIP: Add a struct for managing subscriptions
HCastano Apr 21, 2020
8c35b1e
Make naming more clear and lock data in Arc
HCastano Apr 21, 2020
07ef5fa
Rough idea of what RPC would look like
HCastano Apr 21, 2020
c9aa9e2
Remove code from previous approach
HCastano Apr 22, 2020
78250b7
Missed some things
HCastano Apr 22, 2020
fe31500
Update client/rpc-api/src/chain/mod.rs
HCastano Apr 22, 2020
ba13ee6
Update client/rpc-api/src/chain/mod.rs
HCastano Apr 22, 2020
fe360b9
Split justification subscription into sender and receiver halves
HCastano Apr 26, 2020
254bebe
Replace RwLock with a Mutex
HCastano Apr 26, 2020
9c996ea
Add sample usage from the Service's point of view
HCastano Apr 26, 2020
8090161
Merge branch 'master' into hc-add-subscription-rpc-for-finality
HCastano Apr 29, 2020
1150e5d
Merge branch 'master' into hc-add-subscription-rpc-for-finality
HCastano May 7, 2020
130a871
Merge branch 'master' into hc-add-subscription-rpc-for-finality
HCastano May 15, 2020
f42b6c3
Remove code that referred to "chain_" RPC
HCastano May 15, 2020
d61d7ec
Use the Justification sender/receivers from Grandpa LinkHalf
HCastano May 17, 2020
56e716b
Add some PubSub boilerplate
HCastano May 18, 2020
c0c6508
Merge branch 'master' into hc-add-subscription-rpc-for-finality
HCastano May 18, 2020
1bc9103
Merge branch 'master' into hc-add-subscription-rpc-for-finality
HCastano Jun 1, 2020
30e3831
Merge branch 'master' into hc-add-subscription-rpc-for-finality
HCastano Jun 3, 2020
8b0850a
Add guiding comments
HCastano Jun 3, 2020
cf07f2f
TMP: comment out to fix compilation
octol Jun 8, 2020
ab64ecb
Merge branch 'master' into hc-add-subscription-rpc-for-finality
octol Jun 9, 2020
b1c04ba
Return MetaIoHandler from PubSubHandler in create_full
octol Jun 10, 2020
ebad4d7
Uncomment pubsub methods in rpc handler (fails to build)
octol Jun 10, 2020
caaaa61
node/rpc: make Metadata concrete in create_full to fix compilation
octol Jun 11, 2020
f3cc272
node: pass in SubscriptionManger to grandpa rpc handler
octol Jun 11, 2020
3c4505a
grandpa-rpc: use SubscriptionManger to add subscriber
octol Jun 12, 2020
9a225ac
grandpa-rpc: attempt at setting up the justification stream (fails to…
octol Jun 16, 2020
a85dd53
grandpa-rpc: fix compilation of connecting stream to sink
octol Jun 16, 2020
1b0344f
grandpa-rpc: implement unsubscribe
octol Jun 16, 2020
12dd5df
grandpa-rpc: update older tests
octol Jun 18, 2020
bca6a13
grandpa-rpc: add full prefix to avoid confusing rust-analyzer
octol Jun 22, 2020
efaa0d1
grandpa-rpc: add test for pubsub not available
octol Jun 22, 2020
9632988
grandpa-rpc: tidy up leftover code
octol Jun 22, 2020
964f1e3
grandpa-rpc: add test for sub and unsub of justifications
octol Jun 22, 2020
82004cb
grandpa-rpc: minor stylistic changes
octol Jun 23, 2020
e526f95
grandpa-rpc: split unit test
octol Jun 23, 2020
6c71b8f
grandpa-rpc: minor stylistic changes in test
octol Jun 23, 2020
8bfb560
grandpa-rpc: skip returning future when cancelling
octol Jun 25, 2020
be7cb78
grandpa-rpc: reuse testing executor from sc-rpc
octol Jun 25, 2020
ac81cdf
grandpa-rpc: don't need to use PubSubHandler in tests
octol Jun 25, 2020
3f8630d
node-rpc: use MetaIoHandler rather than PubSubHandler
octol Jun 26, 2020
3b387e6
grandpa: log if getting header failed
octol Jun 26, 2020
bf4b19a
grandpa: move justification channel creation into factory function
octol Jun 26, 2020
4c96b73
grandpa: make the justification sender optional
octol Jun 26, 2020
12158a2
grandpa: fix compilation warnings
octol Jun 27, 2020
e2584e5
grandpa: move justification notification types to new file
octol Jun 27, 2020
dc3c888
grandpa-rpc: move JustificationNotification to grandpa-rpc
octol Jun 27, 2020
410af1f
grandpa-rpc: move JustificationNotification to its own file
octol Jun 27, 2020
fb3ad63
grandpa: rename justification channel pairs
octol Jun 27, 2020
5d80399
grandpa: rename notifier types
octol Jun 27, 2020
3f33fd2
grandpa: pass justification as GrandpaJustification to the rpc module
octol Jun 29, 2020
57f1963
Merge branch 'master' into hc-add-subscription-rpc-for-finality
octol Jun 29, 2020
90ae56e
Move Metadata to sc-rpc-api
tomusdrw Jun 30, 2020
be1df4f
grandpa-rpc: remove unsed error code
octol Jun 29, 2020
d4cddf3
grandpa: fix bug for checking if channel is closed before sendind
octol Jul 1, 2020
8bd9e5c
grandpa-rpc: unit test for sending justifications
octol Jun 30, 2020
127c19e
Merge branch 'master' into hc-add-subscription-rpc-for-finality
octol Jul 2, 2020
f43ee9b
grandpa-rpc: update comments for the pubsub test
octol Jul 2, 2020
39640c1
grandpa-rpc: update pubsub tests with more steps
octol Jul 2, 2020
f3c6c54
grandpa-rpc: fix pubsub test
octol Jul 2, 2020
44ba73e
grandpa-rpc: minor indendation
octol Jul 3, 2020
01f7d73
Merge branch 'master' into hc-add-subscription-rpc-for-finality
octol Jul 22, 2020
3f3b136
grandpa-rpc: decode instead of encode in test
octol Jul 23, 2020
908cf15
Merge branch 'master' into hc-add-subscription-rpc-for-finality
octol Jul 27, 2020
bb9ad4b
Merge branch 'master' into hc-add-subscription-rpc-for-finality
octol Jul 27, 2020
410ddea
grandpa: fix review comments
octol Jul 31, 2020
ca126fd
Merge branch 'master' into hc-add-subscription-rpc-for-finality
octol Aug 4, 2020
452024f
grandpa: remove unused serde dependency
octol Aug 4, 2020
8b0cf76
Merge branch 'master' into hc-add-subscription-rpc-for-finality
octol Aug 5, 2020
7ddffef
Merge branch 'master' into hc-add-subscription-rpc-for-finality
octol Aug 6, 2020
817b425
Merge remote-tracking branch 'upstream/master' into hc-add-subscripti…
octol Aug 7, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
use std::sync::Arc;
use sc_consensus_babe;
use grandpa::{
self, FinalityProofProvider as GrandpaFinalityProofProvider, StorageAndProofProvider,
self,
FinalityProofProvider as GrandpaFinalityProofProvider,
StorageAndProofProvider,
};
use node_executor;
use node_primitives::Block;
Expand Down Expand Up @@ -105,6 +107,7 @@ macro_rules! new_full_start {
let grandpa_link = import_setup.as_ref().map(|s| &s.1)
.expect("GRANDPA LinkHalf is present for full services or set up failed; qed.");

let justification_receiver = grandpa_link.justification_receiver();
let shared_authority_set = grandpa_link.shared_authority_set().clone();
let shared_voter_state = grandpa::SharedVoterState::empty();

Expand All @@ -122,7 +125,7 @@ macro_rules! new_full_start {
.expect("SelectChain is present for full services or set up failed; qed.");
let keystore = builder.keystore().clone();

Ok(move |deny_unsafe| {
Ok(move |deny_unsafe, subscriptions| {
let deps = node_rpc::FullDeps {
client: client.clone(),
pool: pool.clone(),
Expand All @@ -136,6 +139,8 @@ macro_rules! new_full_start {
grandpa: node_rpc::GrandpaDeps {
shared_voter_state: shared_voter_state.clone(),
shared_authority_set: shared_authority_set.clone(),
justification_receiver: justification_receiver.clone(),
subscriptions,
},
};

Expand Down
2 changes: 2 additions & 0 deletions bin/node/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
sc-client-api = { version = "2.0.0-rc3", path = "../../../client/api" }
jsonrpc-core = "14.2.0"
jsonrpc-pubsub = "14.2.0"
node-primitives = { version = "2.0.0-rc3", path = "../primitives" }
node-runtime = { version = "2.0.0-rc3", path = "../runtime" }
sp-runtime = { version = "2.0.0-rc3", path = "../../../primitives/runtime" }
Expand All @@ -31,3 +32,4 @@ sp-blockchain = { version = "2.0.0-rc3", path = "../../../primitives/blockchain"
sc-finality-grandpa = { version = "0.8.0-rc3", path = "../../../client/finality-grandpa" }
sc-finality-grandpa-rpc = { version = "0.8.0-rc3", path = "../../../client/finality-grandpa/rpc" }
sc-rpc-api = { version = "0.8.0-rc3", path = "../../../client/rpc-api" }
sc-rpc = { version = "2.0.0-rc3", path = "../../../client/rpc" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently it's used due to using a concrete sc_rpc::Metadata instead of the generic one used before. I'll try again to see if we can switch back to a generic type

21 changes: 14 additions & 7 deletions bin/node/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ use sp_consensus_babe::BabeApi;
use sc_consensus_epochs::SharedEpochChanges;
use sc_consensus_babe::{Config, Epoch};
use sc_consensus_babe_rpc::BabeRpcHandler;
use sc_finality_grandpa::{SharedVoterState, SharedAuthoritySet};
use sc_finality_grandpa::{SharedVoterState, SharedAuthoritySet, GrandpaJustificationReceiver};
use sc_finality_grandpa_rpc::GrandpaRpcHandler;
use sc_rpc_api::DenyUnsafe;
use jsonrpc_pubsub::manager::SubscriptionManager;

/// Light client extra dependencies.
pub struct LightDeps<C, F, P> {
Expand Down Expand Up @@ -75,6 +76,10 @@ pub struct GrandpaDeps {
pub shared_voter_state: SharedVoterState,
/// Authority set info.
pub shared_authority_set: SharedAuthoritySet<Hash, BlockNumber>,
/// Receives notifications about justification events from Grandpa.
pub justification_receiver: GrandpaJustificationReceiver<Block>,
/// Subscription manager to keep track of pubsub subscribers.
pub subscriptions: SubscriptionManager,
}

/// Full client dependencies.
Expand All @@ -94,9 +99,9 @@ pub struct FullDeps<C, P, SC> {
}

/// Instantiate all Full RPC extensions.
pub fn create_full<C, P, M, SC>(
pub fn create_full<C, P, SC>(
deps: FullDeps<C, P, SC>,
) -> jsonrpc_core::IoHandler<M> where
) -> jsonrpc_core::MetaIoHandler<sc_rpc::Metadata> where
C: ProvideRuntimeApi<Block>,
C: HeaderBackend<Block> + HeaderMetadata<Block, Error=BlockChainError> + 'static,
C: Send + Sync + 'static,
Expand All @@ -106,14 +111,13 @@ pub fn create_full<C, P, M, SC>(
C::Api: BabeApi<Block>,
<C::Api as sp_api::ApiErrorExt>::Error: fmt::Debug,
P: TransactionPool + 'static,
M: jsonrpc_core::Metadata + Default,
SC: SelectChain<Block> +'static,
{
use substrate_frame_rpc_system::{FullSystem, SystemApi};
use pallet_contracts_rpc::{Contracts, ContractsApi};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};

let mut io = jsonrpc_core::IoHandler::default();
let mut io = jsonrpc_pubsub::PubSubHandler::new(jsonrpc_core::MetaIoHandler::default());
let FullDeps {
client,
pool,
Expand All @@ -122,6 +126,7 @@ pub fn create_full<C, P, M, SC>(
babe,
grandpa,
} = deps;

let BabeDeps {
keystore,
babe_config,
Expand All @@ -130,6 +135,8 @@ pub fn create_full<C, P, M, SC>(
let GrandpaDeps {
shared_voter_state,
shared_authority_set,
justification_receiver,
subscriptions,
} = grandpa;

io.extend_with(
Expand Down Expand Up @@ -158,11 +165,11 @@ pub fn create_full<C, P, M, SC>(
);
io.extend_with(
sc_finality_grandpa_rpc::GrandpaApi::to_delegate(
GrandpaRpcHandler::new(shared_authority_set, shared_voter_state)
GrandpaRpcHandler::new(shared_authority_set, shared_voter_state, justification_receiver, subscriptions)
)
);

io
io.into()
}

/// Instantiate all Light RPC extensions.
Expand Down
1 change: 1 addition & 0 deletions client/finality-grandpa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ sp-core = { version = "2.0.0-rc3", path = "../../primitives/core" }
sp-api = { version = "2.0.0-rc3", path = "../../primitives/api" }
sc-telemetry = { version = "2.0.0-rc3", path = "../telemetry" }
sc-keystore = { version = "2.0.0-rc3", path = "../keystore" }
serde = { version = "1.0", features=["derive"] }
serde_json = "1.0.41"
sc-client-api = { version = "2.0.0-rc3", path = "../api" }
sp-inherents = { version = "2.0.0-rc3", path = "../../primitives/inherents" }
Expand Down
6 changes: 6 additions & 0 deletions client/finality-grandpa/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"

[dependencies]
sc-finality-grandpa = { version = "0.8.0-rc3", path = "../" }
sc-rpc = { version = "2.0.0-rc3", path = "../../rpc" }
sp-runtime = { version = "2.0.0-rc3", path = "../../../primitives/runtime" }
finality-grandpa = { version = "0.12.3", features = ["derive-codec"] }
jsonrpc-core = "14.2.0"
jsonrpc-core-client = "14.2.0"
jsonrpc-derive = "14.2.1"
jsonrpc-pubsub = "14.2.0"
futures = { version = "0.3.4", features = ["compat"] }
serde = { version = "1.0.105", features = ["derive"] }
serde_json = "1.0.50"
log = "0.4.8"
derive_more = "0.99.2"
parking_lot = "0.10.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused?


[dev-dependencies]
sp-core = { version = "2.0.0-rc3", path = "../../../primitives/core" }
lazy_static = "1.4"
sc-network-test = { version = "0.8.0-rc3", path = "../../network/test" }
Loading