astriaorg / astria

A monorepo containing all the custom components of the Astria network, a decentralized system that replaces traditional sequencers, offering a shared, permissionless sequencer network.
https://www.astria.org/
Apache License 2.0
112 stars 76 forks source link

use tendermint-rs types for block commits #98

Closed itamarreif closed 1 year ago

itamarreif commented 1 year ago

Currently we are redefining CometBFT's Commit, CommitSig, BlockId and PartSetHeader types in our astria-proto/proto/sequencer/v1/data.proto (for wire types) and sequencer-relayer/src/types.rs (for domain types) as well as manually converting them. See the to_proto() and from_proto() funcs across types.rs, linked above.

This is done because CometBFT and tendermint-rs's protos definitions for these types do not properly serialize Base64 strings, which are used for hashes and signatures. For example, types that do properly serialize to Base64 have the following proc macro in their definition: https://github.com/informalsystems/tendermint-rs/blob/main/rpc/src/endpoint/evidence.rs#L42

tasks:

noot commented 1 year ago

to add more context on why this is blocked: tendermint-rs's Hash type, which is contained is basically everything to do with blocks, commits, etc. supports deserialization from hex strings only, not base64 strings. however, since we are getting these types with hashes encoded as base64, we are unable to deserialize them into a Hash

for example, this is the result we get from metro:

$ curl http://localhost:1317/cosmos/base/tendermint/v1beta1/blocks/latest
{
  "block_id": {
    "hash": "JEEXrSESfa01mbd3nH6q4ZSGPKn8NHtlL5wivJB/iYA=",
    "part_set_header": {
      "total": 1,
      "hash": "MerMvPanzEuYLiBfsd1sQ7wvwVBbbxALOMzFHi8EKgw="
    }
  },
// extra stuff omitted

see the tendermint-rs type here: https://github.com/informalsystems/tendermint-rs/blob/main/proto/src/prost/v0_37/tendermint.types.rs#L63

it only is able to deserialize the Hash via hex.

note that this appears to be due to the cosmos-sdk specifically, as tendermint itself returns hashes encoded in hex: https://docs.tendermint.com/v0.37/rpc/#/Info/block

this means using "retro" will fix this issue.

blocked by #99