-
Notifications
You must be signed in to change notification settings - Fork 66
Problem (CRO-627) council node pubkey format different from tendermint #657
Conversation
Oh, this one needs to wait for #651 |
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.
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)
chain-core/src/state/tendermint.rs
Outdated
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); |
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.
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
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.
also perhaps just deserialise the string and then call TendermintValidatorPubKey::from_base64
?
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.
Fixed, also brings in thiserror
crate, looks like a decent way to handle error type hierarchies.
chain-core/src/state/tendermint.rs
Outdated
#[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)?); |
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.
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 Report
@@ 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
|
bors try |
tryBuild failed |
Solution: - serialize TendermintValidatorPubKey same as tendermint. - Remove ValidatorPubkey in favor of TendermintValidatorPubKey
Fixed the integration test script error. |
bors retry |
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.
bors r+
tryBuild succeeded |
Build failed |
bors retry |
Build failed |
bors retry |
Build failed |
bors retry |
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>
Solution: