Optimization: reduce BLS decompression (#766)

* Add RwLock-style caching for BLS pubkeys

* Tidy docker ignore

* Remove RwLocks

* Merge in master
This commit is contained in:
Paul Hauner
2020-01-10 15:32:10 +11:00
committed by GitHub
parent 5a8f2dd961
commit 370c658c7c
7 changed files with 182 additions and 139 deletions

View File

@@ -248,10 +248,14 @@ fn validator_pubkey<'a, T: EthSpec>(
.ok_or_else(|| Error::ValidatorUnknown(validator_index as u64))?
.pubkey;
pubkey_bytes
.try_into()
.map(|pubkey: PublicKey| Cow::Owned(pubkey.as_raw().point.clone()))
.map_err(|_| Error::BadBlsBytes {
validator_index: validator_index as u64,
})
if let Some(pubkey) = pubkey_bytes.decompressed() {
Ok(Cow::Borrowed(&pubkey.as_raw().point))
} else {
pubkey_bytes
.try_into()
.map(|pubkey: PublicKey| Cow::Owned(pubkey.as_raw().point.clone()))
.map_err(|_| Error::BadBlsBytes {
validator_index: validator_index as u64,
})
}
}