informalsystems / tendermint-rs

Client libraries for Tendermint/CometBFT in Rust!
Apache License 2.0
587 stars 213 forks source link

Cannot properly parse block #1403

Closed rllola closed 2 months ago

rllola commented 3 months ago

What went wrong?

We are trying to use tendermint httpclient to query blocks. After a hardfork we are querying the new genesis block but have this error:

invalid block: last_commit is empty on non-first block

Steps to reproduce

(If needed I can provide a minimal example)

Definition of "done"

Allowing parsing any kind of blocks regardless if they have empty commit or not.

romac commented 3 months ago

Right, looks like we have such checks here: https://github.com/informalsystems/tendermint-rs/blob/f11a1be57f4d7f9897ab26030278e199ce00737e/tendermint/src/block.rs?plain=1#L113-L122

Perhaps they should be bypassed when constructing a Block from an RPC response as we do not control the validity of the block we get in the response. But we should probably keep enforcing them when we build a Block by hand so to speak to still catch such mistakes when possible.

romac commented 3 months ago

I just opened a draft PR with a tentative fix.

If you add the following lines at the end of namadexer/Cargo.toml and build it again, does it solve the issue?

[patch.crates-io]
tendermint        = { git = "https://github.com/informalsystems/tendermint-rs.git", branch = "romac/allow-misformed-block" }
tendermint-rpc    = { git = "https://github.com/informalsystems/tendermint-rs.git", branch = "romac/allow-misformed-block" }
tendermint-proto  = { git = "https://github.com/informalsystems/tendermint-rs.git", branch = "romac/allow-misformed-block" }
tendermint-config = { git = "https://github.com/informalsystems/tendermint-rs.git", branch = "romac/allow-misformed-block" }
rllola commented 3 months ago

It is working! Awesome. I really didn't expect to have a solution so fast. 5 stars