Explicitly provide a pre_dispatch which calls validate_unsigned

pre_dispatch is guaranteed by documentation to be called and persisted.
validate_unsigned is not, though the provided pre_dispatch does by default call
validate_unsigned. By explicitly providing our own pre_dispatch, we accomplish
the bounds we require and expect, only being invalidated on Substrate
redefining their API.

We should still test this, yet since we call retire_session in
validate_unsigned, any test of rotation will test it's being properly called.
This commit is contained in:
Luke Parker
2023-10-13 00:31:23 -04:00
parent 88b5efda99
commit ed7300b406
2 changed files with 14 additions and 4 deletions

View File

@@ -108,8 +108,6 @@ pub mod pallet {
let batch = batch.batch;
// TODO: Test validate_unsigned is actually called prior to execution, which is required for
// this to be safe
LastBatchBlock::<T>::insert(batch.network, frame_system::Pallet::<T>::block_number());
LastBatch::<T>::insert(batch.network, batch.id);
@@ -204,6 +202,11 @@ pub mod pallet {
.propagate(true)
.build()
}
// Explicitly provide a pre-dispatch which calls validate_unsigned
fn pre_dispatch(call: &Self::Call) -> Result<(), TransactionValidityError> {
Self::validate_unsigned(TransactionSource::InBlock, call).map(|_| ()).map_err(Into::into)
}
}
}