mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 20:21:03 +00:00
Some error improvements (#1956)
* Use `HeaderChainError` in parachains module * Use MessageProofError instead of 'static str in some places * Avoid implementing Into<'static str> for some errors We avoid deriving `Debug` for the structs that we use in the runtime and we derive `RuntimeDebug` instead in order to avoid bloating th eruntime with static strs. But implementing `Into<'static str>` does the same. So in some places it makes sense to replace `Into<'static str>` with `Debug`. * Move the messages error definition Move the messages error definition outside of `mod target`
This commit is contained in:
committed by
Bastian Köcher
parent
a4a6902bfb
commit
9b44db0fbe
@@ -26,7 +26,7 @@
|
||||
pub use weights::WeightInfo;
|
||||
pub use weights_ext::WeightInfoExt;
|
||||
|
||||
use bp_header_chain::HeaderChain;
|
||||
use bp_header_chain::{HeaderChain, HeaderChainError};
|
||||
use bp_parachains::{parachain_head_storage_key_at_source, ParaInfo, ParaStoredHeaderData};
|
||||
use bp_polkadot_core::parachains::{ParaHash, ParaHead, ParaHeadsProof, ParaId};
|
||||
use bp_runtime::{Chain, HashOf, HeaderId, HeaderIdOf, Parachain, StorageProofError};
|
||||
@@ -125,8 +125,8 @@ pub mod pallet {
|
||||
UnknownRelayChainBlock,
|
||||
/// The number of stored relay block is different from what the relayer has provided.
|
||||
InvalidRelayChainBlockNumber,
|
||||
/// Invalid storage proof has been passed.
|
||||
InvalidStorageProof,
|
||||
/// Error generated by a method defined in `bp-header-chain`.
|
||||
HeaderChain(HeaderChainError),
|
||||
/// Given parachain head is unknown.
|
||||
UnknownParaHead,
|
||||
/// The storage proof doesn't contains storage root. So it is invalid for given header.
|
||||
@@ -430,10 +430,10 @@ pub mod pallet {
|
||||
storage.ensure_no_unused_nodes()
|
||||
},
|
||||
)
|
||||
.and_then(|r| r.map_err(bp_header_chain::HeaderChainError::StorageProof))
|
||||
.and_then(|r| r.map_err(HeaderChainError::StorageProof))
|
||||
.map_err(|e| {
|
||||
log::trace!(target: LOG_TARGET, "Parachain heads storage proof is invalid: {:?}", e);
|
||||
Error::<T, I>::InvalidStorageProof
|
||||
Error::<T, I>::HeaderChain(e)
|
||||
})?;
|
||||
|
||||
Ok(PostDispatchInfo { actual_weight: Some(actual_weight), pays_fee: Pays::Yes })
|
||||
@@ -1379,7 +1379,9 @@ mod tests {
|
||||
// try to import head#5 of parachain#1 at relay chain block #0
|
||||
assert_noop!(
|
||||
import_parachain_1_head(0, Default::default(), parachains, proof),
|
||||
Error::<TestRuntime>::InvalidStorageProof
|
||||
Error::<TestRuntime>::HeaderChain(HeaderChainError::StorageProof(
|
||||
StorageProofError::StorageRootMismatch
|
||||
))
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user