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

Fix header.hash for height 1 #438

Merged
merged 6 commits into from
Jul 13, 2020
Merged

Fix header.hash for height 1 #438

merged 6 commits into from
Jul 13, 2020

Conversation

liamsi
Copy link
Member

@liamsi liamsi commented Jul 10, 2020

closes #436

  • Referenced an issue explaining the need for the change
  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGES.md

@xla xla added bug Something isn't working rpc serialization labels Jul 11, 2020

Hash::Sha256(simple_hash_from_byte_vectors(fields_bytes))
}
}

fn bytes_enc(bytes: &[u8]) -> Vec<u8> {
let mut chain_id_enc = vec![];
prost_amino::encode_length_delimiter(bytes.len(), &mut chain_id_enc).unwrap();
Copy link
Member Author

Choose a reason for hiding this comment

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

The problem was here: we length-encoded even zero length bytes. In this particular case the app_hash.

@liamsi liamsi marked this pull request as ready for review July 12, 2020 11:26
@liamsi liamsi force-pushed the ismail/fix_commit_height_1 branch from ea9cd4e to 454fc00 Compare July 12, 2020 13:39
@liamsi liamsi added the go Compatibility with Go code label Jul 12, 2020
Copy link
Member

@romac romac left a comment

Choose a reason for hiding this comment

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

Great stuff @liamsi!

I took the liberty of pushing a commit that deduplicates the header hashing code in the light-client crate by just calling to the tender mint::lite::types::Header::hash method. We will want to revisit where such code lives as part of #437 but for now it seems okay to me to leave it in the Header trait.

@liamsi
Copy link
Member Author

liamsi commented Jul 13, 2020

Thanks @romac! I Forgot that this was copied over. The deduplication should probably go in the other direction (into the light-client crate) but it makes sense to have only one tested and working implementation in place 👍

@liamsi liamsi merged commit 2ea453b into master Jul 13, 2020
@liamsi liamsi deleted the ismail/fix_commit_height_1 branch July 13, 2020 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working go Compatibility with Go code rpc serialization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

light-node: can't initialise with header at height 1
3 participants