Skip to content

DuplicateVoteEvidence json serialization uses mixed-casing #3528

Closed

Description

@benluelo

DuplicateVoteEvidence is missing json tags on 3 of it's fields, causing some of the fields to be serialized as PascalCase:

TotalVotingPower int64
ValidatorPower int64
Timestamp time.Time

looks like this was addressed previously in tendermint (tendermint/tendermint#4959), but new fields have been added since which do not have the tags tendermint/tendermint@9d354c8#diff-cb290f27b7c170773cbdcfce4b7b612bd82bc7cf16a1d74c923f1c53462f49e5R39-R42

Activity

  1. added
    bug
    needs-triage
    on Jul 18, 2024
  2. cason commented on Jul 19, 2024

    @cason

    Hey, thank you for reporting. Can you provide the context where this information is serialized? The ABCI-provided evidence is not of this type, but a Misbehavior, defined using protobuf.

  3. added
    needs-information
    on Jul 19, 2024
  4. cason commented on Jul 19, 2024

    @cason

    In any case, if we are to add the tags, we should do the same for the LightClientAttackEvidence type declared in the same source file.

  5. benluelo commented on Jul 19, 2024

    @benluelo
    Author
  6. removed
    needs-triage
    needs-information
    on Jul 19, 2024
  7. self-assigned this
    on Jul 22, 2024
  8. moved this from Todo to In Progress in CometBFTon Jul 22, 2024
  9. 3 remaining items

  10. moved this from Ready for Review to Done in CometBFTon Jul 23, 2024
  11. added 3 commits that reference this issue on Jul 23, 2024
    63a42e2
    8141027
    ea0f65f
  12. added 3 commits that reference this issue on Jul 23, 2024
    459e901
    24b39c5
    cb40d01
  13. romac commented on Aug 12, 2024

    @romac
    Contributor

    Sorry for being late, but just wanted to point out that this is is a breaking change for tendermint-rs and Hermes, and will require adaptations in tendermint-rs.

    I believe we will have to change the tendermint-rs code to handle both snake_case and PascalCase when deserializing evidence from JSON. I am not 100% sure how to deal with this when serializing, perhaps we will have serialize these fields in both snake_case and PascalCase. Any thoughts on that?

  14. benluelo commented on Aug 12, 2024

    @benluelo
    Author
  15. romac commented on Aug 12, 2024

    @romac
    Contributor

    you can use serde aliases: https://serde.rs/field-attrs.html#alias (this is what I have done as well)

    Yes that's what I had in mind for deserialization, but that won't work for serialization.

    As I see it, we have two options:

    a) tendermint-rs picks a different serialization scheme depending on the version of Comet running on the node, which is doable but cumbersome
    b) tendermint-rs include both fields in snake_case and PascalCase, and Comet will deserialize only the fields in the specific format it expects (to be confirmed) which is simpler but comes at the expense of more bytes on the wire

    Do you see another way?

  16. sergio-mena commented on Aug 13, 2024

    @sergio-mena
    Collaborator

    Hi @romac and @benluelo , after a discussion with @alesforz, this is what we propose:

    1. We believe that the backports to v0.38.x and v0.37.x have to be backed out, because the change is breaking the (RPC) API.
    2. We will introduce the new json format (snake_case) for Evidence field starting from v1.x

    Now, here are the questions we have for you:

    • @benluelo, is the snake_case a "nice-to-have"? If not (i.e., something is breaking), please explain what is breaking
    • @romac how cumbersome would it be that v1.x, from the very first release, contains only the snake format for Evidence JSON tags (and the old PascalCase format totally disappears in v1.x)?
  17. benluelo commented on Aug 13, 2024

    @benluelo
    Author

    the casing doesn't break anything, it's just inconsistent with the rest of the rpc. it can of course be worked around, but consistency/ least surprise is always best (when it's not breaking existing code of course).

    it would be good to document the exact format of the fields for both 1.x and pre-1.x. when I was implementing our rpc client I was unable to find any explicit docs about the json formats and had assumed these fields were snake case like the rest of the rpc - I was very surprised to find our relayer had exploded overnight on a PascalCase value 😁

  18. added 2 commits that reference this issue on Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugevidence

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions