Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add subscriptions support #225

Merged
merged 122 commits into from
May 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
bd3430e
initial new commit struct
Shivani912 Feb 25, 2020
d129ad2
update functions
Shivani912 Mar 10, 2020
b64840b
fixed deserialization for new commit struct
Shivani912 Mar 12, 2020
b893a25
updated links to generator + val_set_test file
Shivani912 Mar 12, 2020
17c3c02
Ismail/commit struct followup (#182)
liamsi Mar 17, 2020
525b419
fix error
Shivani912 Mar 17, 2020
ae3ee39
more json bisection tests
Shivani912 Mar 17, 2020
0e6a073
abci_info struct app_version implemented
greg-szabo Mar 19, 2020
1a9a96e
Fixed fmt
greg-szabo Mar 19, 2020
a3367f3
Updated integration tests to tendermint v0.33 node
greg-szabo Mar 20, 2020
d0b9039
update block result response
Shivani912 Mar 20, 2020
accb997
changes to abci_info and block_results
Shivani912 Mar 24, 2020
e4918c8
Removed CircleCI reference and added codecov reference to Cargo
greg-szabo Mar 24, 2020
e0bce41
removing unwanted Option from DeliverTx struct fields
Shivani912 Mar 25, 2020
06d91d4
last_block_app_hash is now Option<Vec<u8>>
Shivani912 Mar 25, 2020
af430df
AbciInfo.last_block_app_hash is base64 encoded instead of hex
Shivani912 Mar 25, 2020
0ad0537
last_block_app_hash changed to Vec<u8>
Shivani912 Mar 25, 2020
ddbc113
Cherry-pick from 87e888b8a1278297ddeedb3f1823e6cc6f0d4ad7 (Liamsi)
liamsi Dec 12, 2019
323b44a
[88] Fix JSON ID
greg-szabo Mar 29, 2020
95902c6
[192] Fix abci_info compatibility for v0.33
greg-szabo Mar 29, 2020
c0c3ed7
[4] block_results test fix
greg-szabo Mar 29, 2020
3659a30
[184][120] Tendermint v0.33 compatibility fixes + integration tests f…
greg-szabo Mar 29, 2020
6c589c9
Added one abci_query test
greg-szabo Mar 29, 2020
2bf6125
FMT + get rid of warnings
greg-szabo Mar 29, 2020
5e9b62a
Relaxed genesis struct AppHash requirements from strict hex to anything
greg-szabo Mar 29, 2020
0d4952d
Removed unused Protocol struct
greg-szabo Mar 29, 2020
58411ac
Removed unused Protocol struct
greg-szabo Mar 29, 2020
2743f8b
Merge branch 'tendermint/v0.33' of github.com:informalsystems/tenderm…
greg-szabo Mar 29, 2020
7649289
IdType removed and JSON ID made as enum
greg-szabo Mar 29, 2020
f0048c5
Duration looks better now
Shivani912 Mar 30, 2020
a2ae776
fix fmt
Shivani912 Mar 30, 2020
5801875
Update tendermint/src/lite_impl/signed_header.rs
greg-szabo Mar 31, 2020
bceaf4f
Update tendermint/src/lite_impl/signed_header.rs
greg-szabo Mar 31, 2020
624ecae
Removed AsRef from JSON ID
greg-szabo Mar 31, 2020
4e2f2a9
Merge branch 'tendermint/v0.33' of github.com:informalsystems/tenderm…
greg-szabo Mar 31, 2020
ccb7b78
Merge remote-tracking branch 'remotes/origin/master' into tendermint/…
liamsi Apr 8, 2020
51934ba
Update Proof and ProofOp (#206)
liamsi Apr 8, 2020
2993d23
Add missing serializer for TrustThresholdFraction fields (#210)
romac Apr 10, 2020
0eae723
commit followup (#199)
liamsi Apr 10, 2020
39ba45f
Initial support for websocket subscriptions
zmanian Apr 17, 2020
ee80538
Websocker error
zmanian Apr 17, 2020
810a351
Fix formatting
zmanian Apr 17, 2020
719235d
Intitial integration test
zmanian Apr 18, 2020
0cd2972
Fmt
zmanian Apr 18, 2020
89ed138
Missed adding file
zmanian Apr 18, 2020
f0e18a9
Fix url scheme
zmanian Apr 18, 2020
f3b1414
fix url scheme
zmanian Apr 18, 2020
7e05068
Format
zmanian Apr 18, 2020
ab8e799
Debugged event subscription with unit tests
zmanian Apr 19, 2020
a87d02d
Fix clippy lint
zmanian Apr 19, 2020
f17a2e5
Add back in the integration test ignore
zmanian Apr 19, 2020
1412206
Refactor the websocket listener into a seperate struct from the RPC c…
zmanian Apr 21, 2020
eed55a7
Cargo fmt
zmanian Apr 21, 2020
b7ae18c
Merge branch 'master' of https://github.com/informalsystems/tendermin…
zmanian Apr 21, 2020
1bede88
Cargo fmt
zmanian Apr 21, 2020
ceffc44
Fix integration tests
zmanian Apr 21, 2020
7331520
Remove the Box<Errors>
zmanian Apr 21, 2020
4b6961a
Update tendermint/src/rpc/endpoint/subscribe.rs
zmanian Apr 21, 2020
49674ea
Fix the doc comment for subscribe
zmanian Apr 21, 2020
e7cb621
Merge branch 'zaki-event-subscribe' of github.com:iqlusioninc/tenderm…
zmanian Apr 21, 2020
02b7f1f
Moved a TODO comment to correct place
zmanian Apr 21, 2020
4a843f8
Create a more specific type for JSON RPC TX Result responses
zmanian Apr 24, 2020
3248c23
Add a convinience function for extracting the event hashmap
zmanian Apr 24, 2020
2b75213
add an an additional query for helping type the event responses
zmanian Apr 25, 2020
facfaef
switch to borrowed types
zmanian Apr 26, 2020
66cdd43
Remove extra borrow
zmanian Apr 26, 2020
7a44a6b
Remove borrow
zmanian Apr 26, 2020
ebf8cbc
Fmt and fix clippy issues
zmanian Apr 26, 2020
b8b00d7
Improve the extract events function so that we treat any matching que…
zmanian Apr 28, 2020
68f5d72
Derive Clone for the Event type
zmanian Apr 28, 2020
ffb954c
Prevent panics in extract events
zmanian Apr 30, 2020
766a86d
Fix module query
zmanian Apr 30, 2020
97f5c9b
Type events only on message.action
zmanian May 1, 2020
644bbd1
Ensures all that events end up in the hashmap. A little unclear if th…
zmanian May 5, 2020
fef6738
Revert "Type events only on message.action"
zmanian May 5, 2020
81e2bc5
Revert "Type events only on message.action"
zmanian May 5, 2020
85ab966
accept periods in the chain-id
zmanian May 22, 2020
c3044f9
Fmt and clippy
zmanian May 22, 2020
884ed90
Merge branch 'master' of https://github.com/informalsystems/tendermin…
zmanian May 22, 2020
73fe138
review comments
ancazamfir May 22, 2020
b16e1f5
fix build: dbg! macro and catch up with renaming
liamsi May 22, 2020
1ad3f70
simplify match in integration test
liamsi May 22, 2020
1842f71
Fix typo in doc comment
liamsi May 22, 2020
7af4caa
Make queries an enum
zmanian May 23, 2020
4ab7c52
Merge branch 'zaki-event-subscribe' of github.com:iqlusioninc/tenderm…
zmanian May 23, 2020
eb58620
Refactor Enum to remove data field
zmanian May 23, 2020
c611c09
Update tendermint/src/rpc/event_listener.rs
zmanian May 23, 2020
c593880
Explain why we throw away subscription responses
zmanian May 23, 2020
b18e98e
Merge branch 'zaki-event-subscribe' of github.com:iqlusioninc/tenderm…
zmanian May 23, 2020
e1549e8
DRY the top level JSON response type
zmanian May 23, 2020
f2c42a0
Update tendermint/src/rpc/endpoint/subscribe.rs
zmanian May 23, 2020
b99b0d6
DRY some of the Block types
zmanian May 23, 2020
6b1b106
Merge branch 'zaki-event-subscribe' of github.com:iqlusioninc/tenderm…
zmanian May 23, 2020
a3a8e65
Fmt
zmanian May 23, 2020
d342d37
Merge branch 'zaki-event-subscribe' of https://github.com/iqlusioninc…
liamsi May 23, 2020
668696d
return `Box<dyn stdError>` instead of `&'static str`
liamsi May 23, 2020
c884f3b
Fix clippy warnings and errs
liamsi May 23, 2020
6231dcc
Fix typo
liamsi May 23, 2020
3269d58
DRY Block, BlockData, Evidence, Parts
liamsi May 23, 2020
f2da1e1
Remove raw json responses from the public API
zmanian May 23, 2020
395bb93
Merge branch 'zaki-event-subscribe' of github.com:iqlusioninc/tenderm…
zmanian May 23, 2020
9910c3f
Please clippy
zmanian May 23, 2020
09db6a8
Box large variant
zmanian May 23, 2020
9c2fcb0
Box the other variant
zmanian May 23, 2020
aa60b6a
Update the RPCTxResult to the new api
zmanian May 23, 2020
5cb2030
clarify some local var names
liamsi May 23, 2020
b11ea9a
use rpc::response::Response and improve err handling
liamsi May 23, 2020
f9b8899
Fix hyperlink in doc comment
liamsi May 23, 2020
4a4d9cb
Update link on error codes
liamsi May 23, 2020
6dbe426
Make error codes symmetric
liamsi May 23, 2020
42b5cfc
Fix panic string
liamsi May 23, 2020
3193c73
Add some debug output
liamsi May 23, 2020
81748e7
Add some more debug output
liamsi May 23, 2020
fc8fc43
Type alias instead of wrapping the wrapper
liamsi May 23, 2020
0cb9ea3
Revert "DRY Block, BlockData, Evidence, Parts"
liamsi May 23, 2020
fdf8873
DRY Block, BlockData, Evidence, Parts
liamsi May 23, 2020
31e48a8
Let's try an Option
liamsi May 23, 2020
86e3f6a
Another Option?
liamsi May 23, 2020
c2711e8
These events are actually optional
liamsi May 23, 2020
0efbcb8
typo
liamsi May 23, 2020
04053f5
Let it be
liamsi May 23, 2020
9b77399
Fix match arm
liamsi May 23, 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
2 changes: 1 addition & 1 deletion light-node/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl config::Override<LightNodeConfig> for StartCmd {
* trusted state and store it in the store ...
* TODO: this should take traits ... but how to deal with the State ?
* TODO: better name ?
*/
*/
async fn subjective_init(
height: Height,
vals_hash: Hash,
Expand Down
3 changes: 2 additions & 1 deletion tendermint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ thiserror = "1"
toml = { version = "0.5" }
uuid = { version = "0.8", default-features = false }
zeroize = { version = "1.1", features = ["zeroize_derive"] }
async-tungstenite = {version="0.4", features = ["tokio-runtime"]}
tokio = { version = "0.2", features = ["macros"] }
ripemd160 = "0.8"

[dev-dependencies]
serde_json = "1"
tokio = { version = "0.2", features = ["macros"] }
3 changes: 2 additions & 1 deletion tendermint/src/block/commit_sig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use crate::serializers;
use crate::{account, Signature, Time};
use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer};

/// BlockIDFlag is used to indicate the validator has voted either for nil, a particular BlockID or was absent.
/// BlockIDFlag is used to indicate the validator has voted either for nil, a particular BlockID or
/// was absent.
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum BlockIDFlag {
/// BlockIDFlagAbsent - no vote was received from a validator.
Expand Down
2 changes: 1 addition & 1 deletion tendermint/src/chain/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl FromStr for Id {

for byte in name.as_bytes() {
match byte {
b'a'..=b'z' | b'A'..=b'Z' | b'0'..=b'9' | b'-' | b'_' => (),
b'a'..=b'z' | b'A'..=b'Z' | b'0'..=b'9' | b'-' | b'_' | b'.' => (),
_ => return Err(Kind::Parse.into()),
}
}
Expand Down
1 change: 1 addition & 0 deletions tendermint/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
mod client;
pub mod endpoint;
pub mod error;
pub mod event_listener;
mod id;
mod method;
pub mod request;
Expand Down
5 changes: 2 additions & 3 deletions tendermint/src/rpc/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
abci::{self, Transaction},
block::Height,
net,
rpc::{self, endpoint::*, Error, Response},
rpc::{endpoint::*, Error, Request, Response},
Genesis,
};
use bytes::buf::ext::BufExt;
Expand Down Expand Up @@ -153,7 +153,7 @@ impl Client {
/// Perform a request against the RPC endpoint
pub async fn perform<R>(&self, request: R) -> Result<R::Response, Error>
where
R: rpc::Request,
R: Request,
{
let request_body = request.into_json();

Expand Down Expand Up @@ -182,7 +182,6 @@ impl Client {
.unwrap(),
);
}

let http_client = hyper::Client::builder().build_http();
let response = http_client.request(request).await?;
let response_body = hyper::body::aggregate(response.into_body()).await?;
Expand Down
1 change: 1 addition & 0 deletions tendermint/src/rpc/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ pub mod genesis;
pub mod health;
pub mod net_info;
pub mod status;
pub mod subscribe;
pub mod validators;
46 changes: 46 additions & 0 deletions tendermint/src/rpc/endpoint/subscribe.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//! `/subscribe` endpoint JSONRPC wrapper

use crate::rpc;
use serde::{Deserialize, Serialize};
use std::io::Read;

/// Subscribe request for events on websocket
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct Request {
query: String,
}

impl Request {
/// Query the Tendermint nodes event and stream events over web socket
pub fn new(query: String) -> Self {
Self { query }
}
}

impl rpc::Request for Request {
type Response = Response;

fn method(&self) -> rpc::Method {
rpc::Method::Subscribe
}
}

/// Status responses
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Response {}

/// Subcribe is weird RPC endpoint. It's only meaningful at websocket response and there isn't a
/// synchronous reponse offered. It there is an error it's asynchronous and we don't try and stich
/// the async response back together with the request.
impl rpc::Response for Response {
/// We throw away response data JSON string so swallow errors and return the empty Response
fn from_string(_response: impl AsRef<[u8]>) -> Result<Self, rpc::Error> {
Ok(Response {})
}

/// We throw away responses in `subscribe` to swallow errors from the `io::Reader` and provide
/// the Response
fn from_reader(_reader: impl Read) -> Result<Self, rpc::Error> {
Ok(Response {})
liamsi marked this conversation as resolved.
Show resolved Hide resolved
}
}
20 changes: 19 additions & 1 deletion tendermint/src/rpc/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! JSONRPC error types

use async_tungstenite::tungstenite::Error as WSError;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::fmt::{self, Display};
use thiserror::Error;
Expand Down Expand Up @@ -44,6 +45,11 @@ impl Error {
Error::new(Code::InvalidParams, Some(data.to_string()))
}

/// Create a new websocket error
pub fn websocket_error(cause: impl Into<String>) -> Error {
Error::new(Code::WebSocketError, Some(cause.into()))
}

/// Create a new method-not-found error
pub fn method_not_found(name: &str) -> Error {
Error::new(Code::MethodNotFound, Some(name.to_string()))
Expand Down Expand Up @@ -108,16 +114,26 @@ impl From<hyper::Error> for Error {
}
}

impl From<WSError> for Error {
fn from(websocket_error: WSError) -> Error {
Error::websocket_error(websocket_error.to_string())
}
}

/// Tendermint RPC error codes.
///
/// See `func RPC*Error()` definitions in:
/// <https://github.com/tendermint/tendermint/blob/master/rpc/lib/types/types.go>
/// <https://github.com/tendermint/tendermint/blob/master/rpc/jsonrpc/types/types.go>
#[derive(Copy, Clone, Debug, Eq, Error, Hash, PartialEq, PartialOrd, Ord)]
pub enum Code {
/// Low-level HTTP error
#[error("HTTP error")]
HttpError,

/// Low-level Websocket error
#[error("Websocket Error")]
WebSocketError,

/// Parse error i.e. invalid JSON (-32700)
#[error("Parse error. Invalid JSON")]
ParseError,
Expand Down Expand Up @@ -158,6 +174,7 @@ impl From<i32> for Code {
fn from(value: i32) -> Code {
match value {
0 => Code::HttpError,
1 => Code::WebSocketError,
-32700 => Code::ParseError,
-32600 => Code::InvalidRequest,
-32601 => Code::MethodNotFound,
Expand All @@ -173,6 +190,7 @@ impl From<Code> for i32 {
fn from(code: Code) -> i32 {
match code {
Code::HttpError => 0,
Code::WebSocketError => 1,
Code::ParseError => -32700,
Code::InvalidRequest => -32600,
Code::MethodNotFound => -32601,
Expand Down
Loading