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

light-node: can't initialise with header at height 1 #436

Closed
xla opened this issue Jul 10, 2020 · 0 comments · Fixed by #438
Closed

light-node: can't initialise with header at height 1 #436

xla opened this issue Jul 10, 2020 · 0 comments · Fixed by #438
Assignees
Labels
bug Something isn't working go Compatibility with Go code light-client Issues/features which involve the light client

Comments

@xla
Copy link
Contributor

xla commented Jul 10, 2020

An attempt to init with the header at height 1 fails.

Potentially reproducible with:

  • run a tendermint full node
  • curl -X GET "http://localhost:26657/block?height=1” -H "accept: application/json"
  • deserialise in Rust and investigate why header.hash() != block_id.hash

Potential causes:

  • latest 0.33 changed something
  • a potential bug when one of the last_ fields is not present in

fn hash(&self) -> Hash {
// Note that if there is an encoding problem this will
// panic (as the golang code would):
// https://github.com/tendermint/tendermint/blob/134fe2896275bb926b49743c1e25493f6b24cc31/types/block.go#L393
// https://github.com/tendermint/tendermint/blob/134fe2896275bb926b49743c1e25493f6b24cc31/types/encoding_helper.go#L9:6
let mut fields_bytes: Vec<Vec<u8>> = Vec::with_capacity(16);
fields_bytes.push(AminoMessage::bytes_vec(&ConsensusVersion::from(
&self.version,
)));
fields_bytes.push(bytes_enc(self.chain_id.as_bytes()));
fields_bytes.push(encode_varint(self.height.value()));
fields_bytes.push(AminoMessage::bytes_vec(&TimeMsg::from(self.time)));
fields_bytes.push(
self.last_block_id
.as_ref()
.map_or(vec![], |id| AminoMessage::bytes_vec(&BlockId::from(id))),
);
fields_bytes.push(self.last_commit_hash.as_ref().map_or(vec![], encode_hash));
fields_bytes.push(self.data_hash.as_ref().map_or(vec![], encode_hash));
fields_bytes.push(encode_hash(&self.validators_hash));
fields_bytes.push(encode_hash(&self.next_validators_hash));
fields_bytes.push(encode_hash(&self.consensus_hash));
fields_bytes.push(bytes_enc(&self.app_hash));
fields_bytes.push(self.last_results_hash.as_ref().map_or(vec![], encode_hash));
fields_bytes.push(self.evidence_hash.as_ref().map_or(vec![], encode_hash));
fields_bytes.push(bytes_enc(self.proposer_address.as_bytes()));
Hash::Sha256(simple_hash_from_byte_vectors(fields_bytes))
}
}

@xla xla added the light-client Issues/features which involve the light client label Jul 10, 2020
@xla xla self-assigned this Jul 10, 2020
@liamsi liamsi self-assigned this Jul 12, 2020
@liamsi liamsi added bug Something isn't working go Compatibility with Go code labels Jul 12, 2020
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 light-client Issues/features which involve the light client
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants