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

Get serde parse error when call block_results #1325

Closed
hashableric opened this issue Jul 11, 2023 · 4 comments · Fixed by #1326
Closed

Get serde parse error when call block_results #1325

hashableric opened this issue Jul 11, 2023 · 4 comments · Fixed by #1326
Assignees
Labels
bug Something isn't working rpc

Comments

@hashableric
Copy link

hashableric commented Jul 11, 2023

What went wrong?

I just write simple code for get latest block result from osmosis json-rpc.
Because the version of osmosis tendermint is v0.34, I tried compat mode V0_34 too. It isnt changed.
When I call the client.perform method, the response always serde parse error

Steps to reproduce

Here's core I wrote

use tendermint_rpc::{endpoint::block_results, Client, HttpClient};

#[tokio::main]
async fn main() {
    let client = HttpClient::new("https://rpc.osmosis.zone:443").unwrap();
    let result = client.perform(block_results::Request::default()).await;

    println!("{:?}", result);
}

I also attach v0.34 code

use tendermint_rpc::{endpoint::block_results, Client, HttpClient, HttpClientUrl};

#[tokio::main]
async fn main() {
    let url = HttpClientUrl::try_from("https://rpc.osmosis.zone:443").unwrap();
    let client = HttpClient::builder(url)
        .compat_mode(tendermint_rpc::client::CompatMode::V0_34)
        .build()
        .unwrap();

    let result = client.perform(block_results::Request::default()).await;

    println!("{:?}", result);
}

Here's the Cargo.toml

[package]
name = "cosmrs-test"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
cosmrs = { version = "0.14.0", features = ["cosmwasm", "rpc", "tokio", "grpc"] }
tokio = { version = "1.29.1", features = ["full"] }
tendermint-rpc = { version = "0.32.0", features = ["http", "tokio"] }

When try to execute program, I got

Err(serde parse error

Caused by:
    invalid type: null, expected a string at line 1 column 196492

Location:
    /Users/eric/.cargo/registry/src/github.com-1ecc6299db9ec823/flex-error-0.4.4/src/tracer_impl/eyre.rs:10:9)

Definition of "done"

Able to get block_results from osmosis json-rpc.

@hashableric hashableric added the bug Something isn't working label Jul 11, 2023
@hashableric
Copy link
Author

EventAttribute's value attribute is currently not nullable. The response of the block_results actually has null suck as memo key. It's cause this error IMO

@mzabaluev mzabaluev self-assigned this Jul 11, 2023
@mzabaluev
Copy link
Contributor

mzabaluev commented Jul 11, 2023

tendermint-rpc = { version = "0.32.0", features = ["http", "tokio"] }

The feature list must have been ["http-client"], otherwise the code does not compile.

I can confirm the error even with the 0.34 compatibility mode. Will investigate.

Unfortunately, this is not expected to work correctly with a 0.34 node, as the protocol has changed and we lack the means to auto-detect it reliably, other than hitting the status endpoint:

use tendermint_rpc::{endpoint::block_results, Client, HttpClient};

#[tokio::main]
async fn main() {
    let client = HttpClient::new("https://rpc.osmosis.zone:443").unwrap();
    let result = client.perform(block_results::Request::default()).await;

    println!("{:?}", result);
}

@mzabaluev
Copy link
Contributor

The cause, in this example, is that the example uses the perform method directly which bypasses the backward compatibility logic. If you use the block_results method, the implementation switches to the perform_v0_34 intrinsic method and the response is parsed successfully.
I noticed, however, that the latest_block_results method does not properly implement this, so there is a bug that needs to be fixed.

It's confusing now that the perform method is exposed in the public API; when initially defined, it wasn't a problem, but with the compatibility mode support added on, this becomes an implementation detail.

@mzabaluev
Copy link
Contributor

This method doc on Client::perform perhaps does not carry enough warning against using the method in consumer code:

    /// This method is used by the default implementations of specific
    /// endpoint methods. The latest protocol dialect is assumed to be invoked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rpc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants