[author-inherent] Move kick_off_authorship_validation() to post_inherents()#93
[author-inherent] Move kick_off_authorship_validation() to post_inherents()#93arturgontijo wants to merge 1 commit intomainfrom
kick_off_authorship_validation() to post_inherents()#93Conversation
| // TODO better weight. For now we just set a somewhat conservative fudge factor | ||
| #[pallet::call_index(0)] | ||
| #[pallet::weight((T::WeightInfo::kick_off_authorship_validation(), DispatchClass::Mandatory))] | ||
| pub fn kick_off_authorship_validation(origin: OriginFor<T>) -> DispatchResultWithPostInfo { |
There was a problem hiding this comment.
This function is still referenced in benchmarks pallets/author-inherent/src/benchmarks.rs and weights pallets/author-inherent/src/weights.rs.
You can run cargo build --features runtime-benchmarks to check.
| // https://github.com/paritytech/polkadot-sdk/issues/2841#issuecomment-1876040854 | ||
| fn integrity_test() { | ||
| // Test that SlotBeacon can be called and returns a valid slot | ||
| let slot = T::SlotBeacon::slot(); |
There was a problem hiding this comment.
Does this really test what is mentioned in the comment?
There was a problem hiding this comment.
The idea was just to check if it can be called, as it returns u32 that is then used in the can_author() call.
| T::CanAuthor::can_author(&Self::get(), &new_slot), | ||
| "Block invalid, supplied author is not eligible." | ||
| // Test that CanAuthor trait can be called | ||
| let _ = Pallet::<T>::can_author( |
There was a problem hiding this comment.
Here we are discarding the result of the call without testing "// Test that CanAuthor trait can be called".
There was a problem hiding this comment.
The result is false as we are not touching storage there. Not sure if we should touch it though.
| <Author<T>>::put(&author); | ||
| } else { | ||
| None | ||
| panic!("Block invalid, missing author in pre-runtime digest"); |
There was a problem hiding this comment.
Could be useful to add a #[should_panic] test to test this branch of execution.
|
|
||
| [features] | ||
| default = [ "std" ] | ||
| std = [ |
| sp-api = { workspace = true } | ||
| sp-application-crypto = { workspace = true } | ||
| sp-core = { workspace = true } | ||
| sp-inherents = { workspace = true } |
There was a problem hiding this comment.
The GH line comment is not very clear, I mean sp-inherents = { workspace = true }
| @@ -15,6 +15,7 @@ | |||
| scale-info = { workspace = true } | |||
| sp-api = { workspace = true } | |||
There was a problem hiding this comment.
Same here for sp-api = { workspace = true }
| @@ -22,13 +22,10 @@ | |||
|
|
|||
| extern crate alloc; | |||
There was a problem hiding this comment.
Maybe this can be removed
| // You should have received a copy of the GNU General Public License | ||
| // along with Moonkit. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| //! Pallet that allows block authors to include their identity in a block via an inherent. |
There was a problem hiding this comment.
Outdated
//! Pallet that extracts the block author identity from the pre-runtime digest and validates
//! eligibility via a `PostInherents` hook. Currently the author does not _prove_ their identity,
//! just states it. So it should not be used for things like equivocation slashing that require
//! authenticated authorship information.
This PR moves the
kick_off_authorship_validation()logic to thepost_inherents().It also adds
integrity_test()hook with some checks.Note: Do we need more integrity checks there? I decided to keep
tests.rssimple as this new approach is.As we see here,
integrity_testsis also being tested too.