Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Problem (CRO-627) council node pubkey format different from tendermint #657

Merged
merged 1 commit into from
Dec 9, 2019

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented Dec 5, 2019

Solution:

  • serialize TendermintValidatorPubKey the same as tendermint.
  • Remove ValidatorPubkey in favor of TendermintValidatorPubKey.

@yihuang
Copy link
Collaborator Author

yihuang commented Dec 5, 2019

Oh, this one needs to wait for #651

Copy link
Contributor

@tomtau tomtau left a comment

Choose a reason for hiding this comment

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

this is great! since #651 was merged, this can be rebased + as the byte length were removed from the initconfig validations, they should be done in the de/serialisers (instead of panic)

let bytes = base64::decode(String::deserialize(deserializer)?.as_bytes())
.map_err(|e| D::Error::custom(format!("{}", e)))?;
let mut result = [0u8; PUBLIC_KEY_SIZE];
result.copy_from_slice(&bytes);
Copy link
Contributor

Choose a reason for hiding this comment

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

copy_from_slice will panic if the lengths don't match, so ideally before this, there should be a check on bytes.len() == PUBLIC_KEY_SIZE

Copy link
Contributor

Choose a reason for hiding this comment

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

also perhaps just deserialise the string and then call TendermintValidatorPubKey::from_base64 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed, also brings in thiserror crate, looks like a decent way to handle error type hierarchies.

#[cfg(feature = "base64")]
pub fn from_base64(bytes: &[u8]) -> Result<TendermintValidatorPubKey, base64::DecodeError> {
let mut result = [0u8; PUBLIC_KEY_SIZE];
result.copy_from_slice(&base64::decode(bytes)?);
Copy link
Contributor

Choose a reason for hiding this comment

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

copy_from_slice will panic if the lengths don't match, so ideally before this, there should be a check on bytes.len() == PUBLIC_KEY_SIZE

@codecov
Copy link

codecov bot commented Dec 6, 2019

Codecov Report

Merging #657 into master will decrease coverage by 0.03%.
The diff coverage is 76.92%.

@@            Coverage Diff             @@
##           master     #657      +/-   ##
==========================================
- Coverage   70.17%   70.14%   -0.04%     
==========================================
  Files         133      133              
  Lines       16384    16374      -10     
==========================================
- Hits        11497    11485      -12     
- Misses       4887     4889       +2
Impacted Files Coverage Δ
client-common/src/tendermint/mock.rs 0% <ø> (ø) ⬆️
chain-core/src/init/params.rs 82.06% <ø> (-0.72%) ⬇️
dev-utils/src/commands/genesis_dev_config.rs 0% <0%> (ø) ⬆️
dev-utils/src/commands/init_command.rs 0% <0%> (ø) ⬆️
chain-core/src/init/config.rs 76.85% <100%> (-0.01%) ⬇️
test-common/src/block_generator.rs 92.42% <100%> (+0.1%) ⬆️
test-common/src/chain_env.rs 93.89% <100%> (+0.37%) ⬆️
chain-core/tests/verify_config.rs 100% <100%> (ø) ⬆️
chain-abci/tests/abci_app.rs 93.9% <100%> (+0.11%) ⬆️
chain-core/src/state/tendermint.rs 63.72% <76%> (+3.72%) ⬆️
... and 1 more

@tomtau
Copy link
Contributor

tomtau commented Dec 6, 2019

bors try

bors bot added a commit that referenced this pull request Dec 6, 2019
@bors
Copy link
Contributor

bors bot commented Dec 6, 2019

try

Build failed

Solution:
- serialize TendermintValidatorPubKey same as tendermint.
- Remove ValidatorPubkey in favor of TendermintValidatorPubKey
@yihuang
Copy link
Collaborator Author

yihuang commented Dec 6, 2019

Fixed the integration test script error.

@tomtau
Copy link
Contributor

tomtau commented Dec 6, 2019

bors retry

bors bot added a commit that referenced this pull request Dec 6, 2019
Copy link
Contributor

@tomtau tomtau left a comment

Choose a reason for hiding this comment

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

bors r+

bors bot added a commit that referenced this pull request Dec 6, 2019
657: Problem (CRO-627) council node pubkey format different from tendermint r=tomtau a=yihuang

Solution:
- serialize TendermintValidatorPubKey the same as tendermint.
- Remove ValidatorPubkey in favor of TendermintValidatorPubKey.

Co-authored-by: yihuang <yi.codeplayer@gmail.com>
@bors
Copy link
Contributor

bors bot commented Dec 6, 2019

@bors
Copy link
Contributor

bors bot commented Dec 6, 2019

Build failed

@tomtau
Copy link
Contributor

tomtau commented Dec 6, 2019

bors retry

bors bot added a commit that referenced this pull request Dec 6, 2019
657: Problem (CRO-627) council node pubkey format different from tendermint r=tomtau a=yihuang

Solution:
- serialize TendermintValidatorPubKey the same as tendermint.
- Remove ValidatorPubkey in favor of TendermintValidatorPubKey.

Co-authored-by: yihuang <yi.codeplayer@gmail.com>
@bors
Copy link
Contributor

bors bot commented Dec 6, 2019

Build failed

@tomtau
Copy link
Contributor

tomtau commented Dec 9, 2019

bors retry

bors bot added a commit that referenced this pull request Dec 9, 2019
657: Problem (CRO-627) council node pubkey format different from tendermint r=tomtau a=yihuang

Solution:
- serialize TendermintValidatorPubKey the same as tendermint.
- Remove ValidatorPubkey in favor of TendermintValidatorPubKey.

Co-authored-by: yihuang <yi.codeplayer@gmail.com>
@bors
Copy link
Contributor

bors bot commented Dec 9, 2019

Build failed

@tomtau
Copy link
Contributor

tomtau commented Dec 9, 2019

bors retry

bors bot added a commit that referenced this pull request Dec 9, 2019
657: Problem (CRO-627) council node pubkey format different from tendermint r=tomtau a=yihuang

Solution:
- serialize TendermintValidatorPubKey the same as tendermint.
- Remove ValidatorPubkey in favor of TendermintValidatorPubKey.

658: Problem: monetary expansion calculation could panic for misconfigration r=tomtau a=yihuang

Solution:
- Checked the arithemetic error, when happends print a warning
  and don't mint new coins.

Co-authored-by: yihuang <yi.codeplayer@gmail.com>
@bors
Copy link
Contributor

bors bot commented Dec 9, 2019

@bors bors bot merged commit 7d1ae7e into crypto-com:master Dec 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants