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
types: discrepancy between amino and proto3 #2682
Comments
Seems its even worse than this. If I have the following message:
The following test fails:
Namely I get,
Which suggests our varints are wrong?! |
Ok I figured it out. The varints were wrong because we weren't using signed ints properly in the abci.Header (ie. |
Sorry, just saw this. I stumbled upon this too (see tendermint/go-amino#224 (comment)) |
Right I saw that but failed to follow up, and then got bit by it. Proto3 has three types of 64-bit varint: uint64, int64, sint64 For non-negative numbers, my understanding is that uint64 and int64 are encoded the same way, but sint64 uses the zig-zag encoding. However for amino int64 is sint64, and so it's zig-zag encoded, which means non-negative For this reason I had to change all the This means there's no way to use a non-zigzag Meanwhile, we should properly document this. It's also resurfacing the |
@liamsi do you think it would make sense to change the default behaviour for Amino to not use zig-zag on ints? We could consider adding a Also I think that would mean we could upgrade later from int64->uint64 without breaking the encodings |
I feel fairly confident that |
@ValarDragon is right that zigzag encoding doesn't make much sense for unsigned ints. I think changing the default for ints makes sense though. Introducing a tag like in proto to let the dev control the encoding (zigzag or varint) makes sense too. |
I took a first stab on it here: tendermint/go-amino#238 |
There is a pending release in tendermint/go-amino#240 |
Fixed, thanks Ismail! |
The amino encoding of the types.Header doesn't match the proto3 encoding of the abci.Header. See the failing test in #2681.
Even when we use amino v0.13, it still doesn't match. For the empty time, we get:
where the former is Amino encoding, the later is proto3 encoding. Note the proto3 encoding prepends and appends some bytes to the Amino encoding.
This should probably block v0.26
The text was updated successfully, but these errors were encountered: