Skip to content

Commit

Permalink
Consistent error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ntn-x2 committed Apr 23, 2024
1 parent dc8b990 commit f99015d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion crates/kilt-dip-primitives/src/state_proofs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ where
let storage_proof = StorageProof::new(state_proof);
let mut revealed_leaves = read_proof_check::<MerkleHasher, _>(state_root, storage_proof, [storage_key].iter())
.map_err(|e| {
log::info!(target: LOG_TARGET, "Storage proof failed with error {:#?}", e);
log::info!(target: LOG_TARGET, "Failed verification of storage proof with error {:#?}", e);
MerkleProofError::InvalidProof
})?;

Expand Down
22 changes: 11 additions & 11 deletions crates/kilt-dip-primitives/src/verifier/parachain/v0/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl<
let inner_error = DipProofComponentTooLargeError::ParachainHeadProofTooManyLeaves;
log::info!(
target: LOG_TARGET,
"Proof verification failed with error {:#?}",
"Failed to verify DIP proof with error {:#?}",
inner_error
);
return Err(DipParachainStateProofVerifierError::ProofComponentTooLarge(
Expand All @@ -194,7 +194,7 @@ impl<
let inner_error = DipProofComponentTooLargeError::ParachainHeadProofLeafTooLarge;
log::info!(
target: LOG_TARGET,
"Proof verification failed with error {:#?}",
"Failed to verify DIP proof with error {:#?}",
inner_error
);
return Err(DipParachainStateProofVerifierError::ProofComponentTooLarge(
Expand All @@ -207,7 +207,7 @@ impl<
KILT_PARA_ID,
)
.map_err(|e| {
log::info!(target: LOG_TARGET, "Proof verification failed with error {:#?}", e);
log::info!(target: LOG_TARGET, "Failed to verify DIP proof with error {:#?}", e);
DipParachainStateProofVerifierError::ProofVerification(e)
})?;
log::info!(
Expand All @@ -222,7 +222,7 @@ impl<
let inner_error = DipProofComponentTooLargeError::DipCommitmentProofTooManyLeaves;
log::info!(
target: LOG_TARGET,
"Proof verification failed with error {:#?}",
"Failed to verify DIP proof with error {:#?}",
inner_error
);
return Err(DipParachainStateProofVerifierError::ProofComponentTooLarge(
Expand All @@ -239,7 +239,7 @@ impl<
let inner_error = DipProofComponentTooLargeError::DipCommitmentProofLeafTooLarge;
log::info!(
target: LOG_TARGET,
"Proof verification failed with error {:#?}",
"Failed to verify DIP proof with error {:#?}",
inner_error
);
return Err(DipParachainStateProofVerifierError::ProofComponentTooLarge(
Expand All @@ -261,7 +261,7 @@ impl<
let inner_error = DipProofComponentTooLargeError::DipProofTooManyLeaves;
log::info!(
target: LOG_TARGET,
"Proof verification failed with error {:#?}",
"Failed to verify DIP proof with error {:#?}",
inner_error
);
return Err(DipParachainStateProofVerifierError::ProofComponentTooLarge(
Expand All @@ -278,7 +278,7 @@ impl<
let inner_error = DipProofComponentTooLargeError::DipProofLeafTooLarge;
log::info!(
target: LOG_TARGET,
"Proof verification failed with error {:#?}",
"Failed to verify DIP proof with error {:#?}",
inner_error
);
return Err(DipParachainStateProofVerifierError::ProofComponentTooLarge(
Expand All @@ -289,7 +289,7 @@ impl<
let proof_without_dip_merkle = proof_without_parachain
.verify_dip_proof::<KiltRuntime::Hashing, MAX_DID_MERKLE_LEAVES_REVEALED>()
.map_err(|e| {
log::info!(target: LOG_TARGET, "Proof verification failed with error {:#?}", e);
log::info!(target: LOG_TARGET, "Failed to verify DIP proof with error {:#?}", e);
DipParachainStateProofVerifierError::ProofVerification(e)
})?;
log::info!(
Expand Down Expand Up @@ -319,17 +319,17 @@ impl<
.verify_signature_time(&current_block_number)
.and_then(|p| p.retrieve_signing_leaves_for_payload(&encoded_payload[..]))
.map_err(|e| {
log::info!(target: LOG_TARGET, "Proof verification failed with error {:#?}", e);
log::info!(target: LOG_TARGET, "Failed to verify DIP proof with error {:#?}", e);
DipParachainStateProofVerifierError::ProofVerification(e)
})?;

// 5. Verify the signing key fulfills the requirements
let signing_keys = revealed_did_info.get_signing_leaves().map_err(|e| {
log::info!(target: LOG_TARGET, "Proof verification failed with error {:#?}", e);
log::info!(target: LOG_TARGET, "Failed to verify DIP proof with error {:#?}", e);
DipParachainStateProofVerifierError::ProofVerification(e)
})?;
DidCallVerifier::check_call_origin_info(call, &signing_keys.cloned().collect::<Vec<_>>()).map_err(|e| {
log::info!(target: LOG_TARGET, "Proof verification failed with error {:#?}", e);
log::info!(target: LOG_TARGET, "Failed to verify DIP proof with error {:#?}", e);
DipParachainStateProofVerifierError::DidOriginError(e)
})?;

Expand Down
18 changes: 9 additions & 9 deletions crates/kilt-dip-primitives/src/verifier/relaychain/v0/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl<
) -> Result<Self::VerificationResult, Self::Error> {
// 1. Verify provided relaychain header.
let proof_without_header = proof.verify_relay_header::<ConsumerBlockHashStore>().map_err(|e| {
log::info!(target: LOG_TARGET, "Proof verification failed with error {:#?}", e);
log::info!(target: LOG_TARGET, "Failed to verify DIP proof with error {:#?}", e);
DipRelaychainStateProofVerifierError::ProofVerification(e)
})?;
log::info!(
Expand All @@ -169,7 +169,7 @@ impl<
let inner_error = DipProofComponentTooLargeError::ParachainHeadProofTooManyLeaves;
log::info!(
target: LOG_TARGET,
"Proof verification failed with error {:#?}",
"Failed to verify DIP proof with error {:#?}",
inner_error
);
return Err(DipRelaychainStateProofVerifierError::ProofComponentTooLarge(
Expand All @@ -186,7 +186,7 @@ impl<
let inner_error = DipProofComponentTooLargeError::ParachainHeadProofLeafTooLarge;
log::info!(
target: LOG_TARGET,
"Proof verification failed with error {:#?}",
"Failed to verify DIP proof with error {:#?}",
inner_error
);
return Err(DipRelaychainStateProofVerifierError::ProofComponentTooLarge(
Expand All @@ -209,7 +209,7 @@ impl<
let inner_error = DipProofComponentTooLargeError::DipCommitmentProofTooManyLeaves;
log::info!(
target: LOG_TARGET,
"Proof verification failed with error {:#?}",
"Failed to verify DIP proof with error {:#?}",
inner_error
);
return Err(DipRelaychainStateProofVerifierError::ProofComponentTooLarge(
Expand All @@ -225,7 +225,7 @@ impl<
let inner_error = DipProofComponentTooLargeError::DipCommitmentProofLeafTooLarge;
log::info!(
target: LOG_TARGET,
"Proof verification failed with error {:#?}",
"Failed to verify DIP proof with error {:#?}",
inner_error
);
return Err(DipRelaychainStateProofVerifierError::ProofComponentTooLarge(
Expand All @@ -247,7 +247,7 @@ impl<
let inner_error = DipProofComponentTooLargeError::DipProofTooManyLeaves;
log::info!(
target: LOG_TARGET,
"Proof verification failed with error {:#?}",
"Failed to verify DIP proof with error {:#?}",
inner_error
);
return Err(DipRelaychainStateProofVerifierError::ProofComponentTooLarge(
Expand All @@ -264,7 +264,7 @@ impl<
let inner_error = DipProofComponentTooLargeError::DipProofLeafTooLarge;
log::info!(
target: LOG_TARGET,
"Proof verification failed with error {:#?}",
"Failed to verify DIP proof with error {:#?}",
inner_error
);
return Err(DipRelaychainStateProofVerifierError::ProofComponentTooLarge(
Expand Down Expand Up @@ -297,11 +297,11 @@ impl<

// 6. Verify the signing key fulfills the requirements
let signing_keys = revealed_did_info.get_signing_leaves().map_err(|e| {
log::info!(target: LOG_TARGET, "Proof verification failed with error {:#?}", e);
log::info!(target: LOG_TARGET, "Failed to verify DIP proof with error {:#?}", e);
DipRelaychainStateProofVerifierError::ProofVerification(e)
})?;
DidCallVerifier::check_call_origin_info(call, &signing_keys.cloned().collect::<Vec<_>>()).map_err(|e| {
log::info!(target: LOG_TARGET, "Proof verification failed with error {:#?}", e);
log::info!(target: LOG_TARGET, "Failed to verify DIP proof with error {:#?}", e);
DipRelaychainStateProofVerifierError::DidOriginError(e)
})?;

Expand Down
2 changes: 1 addition & 1 deletion pallets/pallet-deposit-storage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ pub mod pallet {
T::DepositHooks::on_deposit_reclaimed(&namespace, &key, deposit).map_err(|e| {
log::info!(
target: LOG_TARGET,
"Deposit hook failed when removing deposit for namespace {:#?} and key {:#?} with error {:#?}",
"Failed to invoke `DepositHooks::on_deposit_reclaimed` for {:#?} and key {:#?} with error {:#?}",
namespace,
key,
e
Expand Down
2 changes: 1 addition & 1 deletion pallets/pallet-dip-consumer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ pub mod pallet {
.map_err(|e| {
log::info!(
target: LOG_TARGET,
"Identity proof verification for identifier {:#?} failed with error {:#?}",
"Failed to verify identity proof for identifier {:#?} with error {:#?}",
identifier,
e
);
Expand Down
2 changes: 1 addition & 1 deletion pallets/pallet-dip-provider/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ pub mod pallet {
T::ProviderHooks::on_commitment_removed(identifier, dispatcher, &commitment, version).map_err(|e| {
log::info!(
target: LOG_TARGET,
"Provider hook failed when removing commitment for {:#?} with error {:#?}",
"Failed to invoke `ProviderHooks::on_commitment_removed` for commitment {:#?} with error {:#?}",
identifier,
e
);
Expand Down

0 comments on commit f99015d

Please sign in to comment.