tendermint::Hash
can not be used as a return value when used with jsonrpsee
#1474
Labels
bug
Something isn't working
We are from Lumina, a Celestia light node written in Rust. When we started the project we forked
tendermint-rs
to adjust it to Celestia's modifications. Now we are looking to migrate away form our fork.What went wrong?
We are using jsonrpsee for calling into Celestia's node API. The API is using some types from
tendermint-rs
, such astendermint::Hash
.Any struct that uses
tendermint::Hash
internally (e.g.SyncState
) fails to deserialize and gives the following error:We debugged the issue and this happens because:
jsonrpsee
firsts deserializes toserde_json::Value
and from there toSyncState
.tendermint::Hash
uses<&str>::deserialize(deserializer)
.<&str>::deserialize(deserializer)
can not be used onserde_json::Value
due to borrowing issues.The pattern that
jsonrpsee
uses (i.e.&str
->serde_json::Value
->T
) is valid and it may be used from other crates too.Steps to reproduce
Definition of "done"
We need to stop using
<&str>::deserialize
. One way is to useString
but allocates. Another way is to use theCowStr
we implemented in our fork, which allocates on demand.The text was updated successfully, but these errors were encountered: