Skip to content

Commit

Permalink
pallet-beefy-mmr: better logging on BEEFY key to ETH address conversi…
Browse files Browse the repository at this point in the history
…on (paritytech#1520)

# Description

Each time the validator set changes, BEEFY validator keys are converted
to ETH addresses and merkelised into a `keyset_commitment` to be used by
light clients.

This commit downgrades `error` to `debug` when individual conversions
from BEEFY keys to ETH addresses fail, and adds cumulative check that
reports total number of failed conversions, if any, on `error`
log-level.

Fixes paritytech#1305

Signed-off-by: Adrian Catangiu <[email protected]>
  • Loading branch information
acatangiu authored Sep 13, 2023
1 parent 0fc148b commit 7cad23b
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion substrate/frame/beefy-mmr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl Convert<sp_consensus_beefy::ecdsa_crypto::AuthorityId, Vec<u8>> for BeefyEc
.to_eth_address()
.map(|v| v.to_vec())
.map_err(|_| {
log::error!(target: "runtime::beefy", "Failed to convert BEEFY PublicKey to ETH address!");
log::debug!(target: "runtime::beefy", "Failed to convert BEEFY PublicKey to ETH address!");
})
.unwrap_or_default()
}
Expand Down Expand Up @@ -199,7 +199,20 @@ impl<T: Config> Pallet<T> {
.cloned()
.map(T::BeefyAuthorityToMerkleLeaf::convert)
.collect::<Vec<_>>();
let default_eth_addr = [0u8; 20];
let len = beefy_addresses.len() as u32;
let uninitialized_addresses = beefy_addresses
.iter()
.filter(|&addr| addr.as_slice().eq(&default_eth_addr))
.count();
if uninitialized_addresses > 0 {
log::error!(
target: "runtime::beefy",
"Failed to convert {} out of {} BEEFY PublicKeys to ETH addresses!",
uninitialized_addresses,
len,
);
}
let keyset_commitment = binary_merkle_tree::merkle_root::<
<T as pallet_mmr::Config>::Hashing,
_,
Expand Down

0 comments on commit 7cad23b

Please sign in to comment.