Skip to content
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

p2p: replace prost-amino with prost #979

Merged
merged 4 commits into from
Sep 17, 2021
Merged

Conversation

tony-iqlusion
Copy link
Collaborator

The only message that prost-amino was still used for was AuthSigMessage, and the only way an amino-encoded version of that message differs from a proto is the amino type prefix on the pub_key field, i.e. tendermint/PubKeyEd25519.

This commit adds a test vector for a serialized amino message, and then changes AuthSigMessage to use prost-derive:

  • An AuthSigMessage::new function takes care of adding the Amino prefix to the public key
  • A TryFrom impl for proto::p2p::AuthSigMessage takes care of verifying and removing it

With that, prost-amino is no longer necessary and this commit therefore removes the last dependency on it.

p2p/Cargo.toml Outdated
Comment on lines 22 to 23
[lib]
test = false
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this was here, but I added a test so I had to remove this to make the test work

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason it is declared is that all tests are in a separate crate over at https://github.com/informalsystems/tendermint-rs/tree/master/test

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aah, ok.

My test was mostly useful for ensuring message equivalence during development. Since I'm fairly confident of that at this point (and hopefully all of this can be removed soon) I can remove it and restore these lines.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or keep the test and add it to the test crate?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thanethomson the API the test is written against isn't public.

I went ahead and removed it for now.

The only message that `prost-amino` was still used for was
`AuthSigMessage`, and the only way an amino-encoded version of that
message differs from a proto is the amino type prefix on the `pub_key`
field, i.e. `tendermint/PubKeyEd25519`.

This commit adds a test vector for a serialized amino message, and then
changes `AuthSigMessage` to use `prost-derive`:

- An `AuthSigMessage::new` function takes care of adding the Amino
  prefix to the public key
- A `TryFrom` impl for `proto::p2p::AuthSigMessage` takes care of
  verifying and removing it

With that, `prost-amino` is no longer necessary and this commit
therefore removes the last dependency on it.
@codecov-commenter
Copy link

codecov-commenter commented Sep 16, 2021

Codecov Report

Merging #979 (1d2216d) into master (51e5646) will increase coverage by 0.2%.
The diff coverage is 83.6%.

❗ Current head 1d2216d differs from pull request most recent head 90e3ff0. Consider uploading reports for the commit 90e3ff0 to get more accurate results
Impacted file tree graph

@@           Coverage Diff            @@
##           master    #979     +/-   ##
========================================
+ Coverage    72.3%   72.5%   +0.2%     
========================================
  Files         204     203      -1     
  Lines       16587   16597     +10     
========================================
+ Hits        12005   12046     +41     
+ Misses       4582    4551     -31     
Impacted Files Coverage Δ
light-client-js/src/lib.rs 6.6% <ø> (ø)
light-client/src/builder/light_client.rs 0.0% <0.0%> (ø)
p2p/src/secret_connection/amino_types.rs 0.0% <0.0%> (ø)
p2p/src/secret_connection/protocol.rs 68.0% <0.0%> (+4.7%) ⬆️
rpc/src/client.rs 16.9% <ø> (ø)
rpc/src/lib.rs 100.0% <ø> (ø)
tendermint/src/block/signed_header.rs 91.6% <ø> (ø)
light-client/src/types.rs 41.0% <52.9%> (+11.5%) ⬆️
light-client/src/operations/commit_validator.rs 98.0% <66.6%> (-2.0%) ⬇️
rpc/src/client/transport/websocket.rs 63.8% <66.6%> (+0.9%) ⬆️
... and 26 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 51e5646...90e3ff0. Read the comment docs.

Copy link
Contributor

@xla xla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I for one welcome the abolishment of amino! Clippy seems to complain in a couple of places and see my comment about tests, other than that this change looks good to me.

p2p/Cargo.toml Outdated
Comment on lines 22 to 23
[lib]
test = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason it is declared is that all tests are in a separate crate over at https://github.com/informalsystems/tendermint-rs/tree/master/test

@xla
Copy link
Contributor

xla commented Sep 16, 2021

Could you also add a changelog entry.

It seems tests are now placed in a `test` crate, however this is a
private API that cannot be called from a separate crate.

Hopefully all Amino support can be removed soon, so now that
compatibility has been achieved it shouldn't really matter.
@tony-iqlusion
Copy link
Collaborator Author

Changelog entry added, and looks like all of the tests are passing now except a docs failure happening internally within prost-derive due to what appears to be overlapping impls with std.

Not sure what to do about that but I would hope #978 can now address it.

Comment on lines -56 to -57
prost-amino = { version = "0.6", optional = true }
prost-amino-derive = { version = "0.6", optional = true }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing 😁

@thanethomson
Copy link
Contributor

Awesome thanks @tony-iqlusion! Yes, #978 should address that. Once I've merged this I'll pull these changes into #978 to make 100% sure.

@thanethomson thanethomson merged commit e21d39d into master Sep 17, 2021
@thanethomson thanethomson deleted the p2p/remove-amino-rs branch September 17, 2021 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants