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

RPC: Update hash to 32 byte value. #14

Merged
merged 1 commit into from
Sep 7, 2019

Conversation

amanusk
Copy link
Contributor

@amanusk amanusk commented Aug 15, 2019

Update tests to new standard

Update tests to new standard
@amanusk
Copy link
Contributor Author

amanusk commented Aug 15, 2019

Running the simple kvstore example, I am getting an error on parsing the result

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { code: ParseError, message: "Parse error. Invalid JSON", data: Some("expected 40-character hex string, got \"88D4266FD4E6338D13B845FCF289579D209C897823B9217DA3E161936F031589\" at line 9 column 3") }', src/libcore/result.rs:1084:5

It seems hashes have been update from 20 to 32 bytes. https://github.com/tendermint/tendermint/blob/master/CHANGELOG.md#v0260

This PR updates the hash and the tests

@tarcieri
Copy link
Contributor

@ebuchman what are your thoughts on compatibility here? should we just target the latest Tendermint release only?

@ebuchman
Copy link
Member

should we just target the latest Tendermint release only?

Yes, probably for now. We'll figure out a backwards compatibility story a bit later on ...

@@ -87,8 +87,8 @@ impl<'de> Deserialize<'de> for Code {
where
E: serde::de::Error,
{
match val.parse::<u32>() {
Ok(val) => self.visit_u32(val),
match val.parse::<u64>() {
Copy link
Member

Choose a reason for hiding this comment

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

Why did this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For better readability.
This is related to a previous PR #13
In either cases visit_u64 method is called, so thought it would be better if it is explicit in the code.

@@ -11,7 +11,7 @@ use subtle::{self, ConstantTimeEq};
use subtle_encoding::hex;

/// Size of a transaction hash in bytes
pub const LENGTH: usize = 20;
pub const LENGTH: usize = 32;
Copy link
Member

Choose a reason for hiding this comment

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

I introduced HASH_SIZE in https://github.com/interchainio/tendermint-rs/blob/master/src/merkle.rs#L6 ... we'll need to de-duplicate eventually but for now it's fine ....

@@ -155,7 +155,7 @@ mod endpoints {

assert_eq!(
&response.hash.to_string(),
"75CA0F856A4DA078FC4911580360E70CEFB2EBEE"
"88D4266FD4E6338D13B845FCF289579D209C897823B9217DA3E161936F031589"
Copy link
Member

Choose a reason for hiding this comment

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

Do the values of these not matter at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As I understand, these tests only check that parsing work correctly, and do not test the actual correctness of the hash.
Also, the hash is of the sent transaction and not of the response right?

Copy link
Member

Choose a reason for hiding this comment

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

Also, the hash is of the sent transaction and not of the response right?

That's right

@amanusk
Copy link
Contributor Author

amanusk commented Aug 26, 2019

Any other fixes required?

Copy link
Member

@ebuchman ebuchman left a comment

Choose a reason for hiding this comment

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

Thanks!

@ebuchman ebuchman merged commit 5b83c04 into informalsystems:master Sep 7, 2019
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.

None yet

3 participants