Add pallet dev mode (#12536)

* stub for construct_dev_runtime!

* revert

* stub for dev_mode proc macro

* preliminary docs for pallet::dev_mode (attribute) proc macro

* add dev_mode to pallet_macros module

* add docs item for dev_mode to frame_support

* parsing of #[pallet(dev_mode)]

* strip out dev_mode stub since it will be an arg for pallet instead

* make pallet Def struct aware of dev mode

* WIP

* revert changes to call.rs

* pass dev_mode to pallet parsing code

* auto-specify default weights when in dev mode if not specified

* add proof / expect for syn::parse in dev mode weight processing

* set all storages to unbounded when in dev mode

* just use 0

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* add invalid pallet arg test

* add passing dev mode pallet test

* add test confirming that dev mode features only work in dev mode

* cargo fmt + clean up

* bump CI

* fix pallet ui test

* add docs for dev mode

* add warning about using dev mode in production circumstances

* remove comment about no other attributes being supported

* fix unneeded assignment

* make warning more explicit

* more explicit warning about using dev mode in production

* simpler assignment for dev_mode boolean

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* add note about MEL requirement

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* add comment specifying why weights can be omitted in example

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* tweak wording of comments

* bump ci

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Sam Johnson
2022-11-07 16:40:55 -05:00
committed by GitHub
parent cf5c78dbe8
commit 7c4bfc9749
14 changed files with 233 additions and 12 deletions
@@ -0,0 +1,35 @@
#![cfg_attr(not(feature = "std"), no_std)]
pub use pallet::*;
#[frame_support::pallet(dev_mode)]
pub mod pallet {
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
// The struct on which we build all of our Pallet logic.
#[pallet::pallet]
pub struct Pallet<T>(_);
// Your Pallet's configuration trait, representing custom external types and interfaces.
#[pallet::config]
pub trait Config: frame_system::Config {}
// The MEL requirement for bounded pallets is skipped by `dev_mode`.
#[pallet::storage]
type MyStorage<T: Config> = StorageValue<_, Vec<u8>>;
// Your Pallet's callable functions.
#[pallet::call]
impl<T: Config> Pallet<T> {
// No need to define a `weight` attribute here because of `dev_mode`.
pub fn my_call(_origin: OriginFor<T>) -> DispatchResult {
Ok(())
}
}
// Your Pallet's internal functions.
impl<T: Config> Pallet<T> {}
}
fn main() {}