[hardware-wallet] use prost! for protobuf handling #10674
Conversation
cool, unfortunately I don't have access to a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, but testing this on a Trezor seems important!
There's a new EDIT: would require upgrading to |
Fix back ported to |
@@ -118,6 +118,12 @@ enum HidVersion { | |||
V2, | |||
} | |||
|
|||
fn encode_message<M: Message>(message: M) -> Vec<u8> { | |||
let mut result = Vec::with_capacity(message.encoded_len()); | |||
message.encode(&mut result).expect("Vec has unlimited capacity; qed"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, I don't agree with unlimited capacity
because Vec::alloc
will panic when capacity is bigger than isize::max_value
on 32-bit platforms and usize::max_value
on 64-bit platforms.
However, I think that is only
theoretically and would be fine with some like message could be represented as Vec there encodable; qed
Makes cargo audit happy. Haven't actually tested on hardware wallet, but it seems to compile.
https://github.com/paritytech/trezor-sys/compare/prost