-
Notifications
You must be signed in to change notification settings - Fork 216
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
Add subscriptions support #225
Conversation
* initial new commit struct * update functions * fixed deserialization for new commit struct * updated links to generator + val_set_test file * Update tendermint/src/account.rs Co-Authored-By: Ismail Khoffi <Ismail.Khoffi@gmail.com> * fmt * clippy * rpc tests: grab latest example fro commit: - use https://docs.tendermint.com/master/rpc/#/Info/commit - update chain_id: cosmoshub-1 to cosmoshub-2 everywhere else - manually kept `id` a string in JSONrpc responses * Actually let's go cosmoshub-3: - grabbed from: https://rpc.cosmos.network/commit?height=2 * Fix commit test - regenerated commit.json via `curl -X GET "http://localhost:26657/commit?height=10" -H "accept: application/json"` * Fix block test - "regenerated" block.json via `curl -X GET "http://localhost:26657/block?height=10" -H "accept: application/json"` * Fix first_block test - "regenerated" block.json via `curl -X GET "http://localhost:26657/block?height=1" -H "accept: application/json" ` Co-authored-by: Shivani Joshi <joshi.shivani912@gmail.com> Co-authored-by: Shivani Joshi <46731446+Shivani912@users.noreply.github.com>
fix /abci_info & /genesis: - add app_version & use #[serde(default)] to deal with omitted fields in JSON - make app_state in /genesis reply optional - fix string in abci_info test (kvstore wont reply with "GaiaApp") verify tests pass via running `tendermint node --proxy_app=kvstore` and `cargo test -- --nocapture --ignored
…int-rs into tendermint/v0.33
tendermint/src/rpc/event_listener.rs
Outdated
match serde_json::from_str::<JsonRPCBlockResult>(&msg.to_string()) { | ||
Ok(data) => { | ||
if let Some(block_result) = data.0.result { | ||
Ok(Event::JsonRPCBlockResult(Box::new(block_result))) | ||
} else { | ||
// The Websocket should never send an empty block | ||
panic!("Websocket sent us an empty block") | ||
} | ||
} | ||
Err(_) => match serde_json::from_str::<JsonRPCTransactionResult>(&msg.to_string()) { | ||
Ok(data) => { | ||
if let Some(tx_result) = data.0.result { | ||
Ok(Event::JsonRPCTransactionResult(Box::new(tx_result))) | ||
} else { | ||
// The Websocket should never send an empty transaction | ||
panic!("Websocket sent us an empty transaction") | ||
} | ||
} | ||
Err(_) => match serde_json::from_str::<serde_json::Value>(&msg.to_string()) { | ||
Ok(json_value) => Ok(Event::GenericJSONEvent(json_value)), | ||
Err(_) => Ok(Event::GenericStringEvent(msg.to_string())), | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure this can be simplified in a way that serde returns the correct Event
enum variant and you don't need matching here again. Non-blocking for merging this PR though.
- unexport Wrapper fields
Any idea why the integration test receives a You were saying that this does not fail against your local gaia build? Which (tendermint) version does that use? |
I'll try to figure out what is going on with the integration test this afternoon and we should be ready to merge. |
So the integration test fails if Serde fails to deserialize the Block event as a expected type and instead falls through to a Generic JSON event. |
The GOZ code is running
and the integration test appears to pass with this version. |
Exactly. The reason why it's falling through is I doubt this has anything to do with different tendermint versions. |
tendermint/src/rpc/event_listener.rs
Outdated
dbg!("Error:"); | ||
dbg!(e); | ||
dbg!("msg:"); | ||
dbg!(&msg.to_string()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines should be removed before merging.
dbg!("Error:"); | |
dbg!(e); | |
dbg!("msg:"); | |
dbg!(&msg.to_string()); |
tendermint/src/rpc/event_listener.rs
Outdated
match serde_json::from_str::<JsonRPCBlockResult>(&msg.to_string()) { | ||
Ok(data) => { | ||
let block_result = data.into_result()?; | ||
Ok(Event::JsonRPCBlockResult(Box::new(block_result))) | ||
} | ||
Err(e) => { | ||
dbg!("Error:"); | ||
dbg!(e); | ||
dbg!("msg:"); | ||
dbg!(&msg.to_string()); | ||
match serde_json::from_str::<JsonRPCTransactionResult>(&msg.to_string()) { | ||
Ok(data) => { | ||
let tx_result = data.into_result()?; | ||
Ok(Event::JsonRPCTransactionResult(Box::new(tx_result))) | ||
} | ||
Err(_) => match serde_json::from_str::<serde_json::Value>(&msg.to_string()) { | ||
Ok(json_value) => Ok(Event::GenericJSONEvent(json_value)), | ||
Err(_) => Ok(Event::GenericStringEvent(msg.to_string())), | ||
}, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ideally, we would not match case a lot here but instead of jsonrpc wrapping JsonRPCBlockResult
, JsonRPCTransactionResult
separately, we should wrap the whole Event
enum and make it impl response::Response
. serde can very well deal with enums so there is no need to try each variant separately. No need to block this PR on this though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's merge this and deal with these in followup issues:
https://github.com/informalsystems/tendermint-rs/pull/225/files#r429444086
#225 (comment)
#225 (comment)
Thanks @zmanian 💪 Thanks @greg-szabo for helping with the debugging too!
To do