Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate pallet-statement and pallet-sudo to use umbrella crate #7106

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fed7211
migrate pallet-statement to use umbrella crate
Nathy-bajo Jan 9, 2025
90c0c6f
Merge remote-tracking branch 'upstream/master'
Nathy-bajo Jan 9, 2025
0122761
migrate pallet-statement to use umbrella crate
Nathy-bajo Jan 9, 2025
cdfa961
migrate pallet-statement to use umbrella crate
Nathy-bajo Jan 10, 2025
181b4da
migrate pallet-statement to use umbrella crate
Nathy-bajo Jan 10, 2025
89f4311
remove sp-statement-store dependency
Nathy-bajo Jan 10, 2025
438d794
Revert "migrate pallet-statement to use umbrella crate"
Nathy-bajo Jan 12, 2025
b7e523e
Revert "migrate pallet-statement to use umbrella crate"
Nathy-bajo Jan 12, 2025
49335d8
Revert "migrate pallet-statement to use umbrella crate"
Nathy-bajo Jan 12, 2025
5f99526
migrate pallet-sudo-and-statement to umbrella crate
Nathy-bajo Jan 12, 2025
63ddbd0
migrate pallet-sudo-and-statement to umbrella crate
Nathy-bajo Jan 12, 2025
0b91c3b
remove frame_benchmarking
Nathy-bajo Jan 12, 2025
d8286b1
remove sp_statement_store
Nathy-bajo Jan 14, 2025
9fea2d8
Update substrate/frame/Cargo.toml
bkchr Jan 15, 2025
768425c
Update substrate/frame/src/lib.rs
bkchr Jan 15, 2025
df99369
Merge branch 'master' into migrate-pallet-statement
bkchr Jan 15, 2025
239c9ef
Update Cargo.lock
bkchr Jan 15, 2025
989452a
Merge branch 'master' into migrate-pallet-statement
bkchr Jan 15, 2025
801675b
Update substrate/frame/sudo/src/weights.rs
bkchr Jan 15, 2025
cd3d522
Update substrate/frame/sudo/src/benchmarking.rs
bkchr Jan 15, 2025
ec43525
Update substrate/frame/sudo/src/mock.rs
bkchr Jan 15, 2025
8e79322
more changes
Nathy-bajo Jan 16, 2025
98c14aa
more changes
Nathy-bajo Jan 16, 2025
80bb25e
more changes
Nathy-bajo Jan 16, 2025
a27447c
more changes
Nathy-bajo Jan 16, 2025
8e86469
remove experimental feature
Nathy-bajo Jan 21, 2025
757e4eb
Merge branch 'master' into migrate-pallet-statement
Nathy-bajo Jan 21, 2025
fd522ad
Merge branch 'master' into migrate-pallet-statement
Nathy-bajo Jan 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions substrate/frame/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ sp-core = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }


bkchr marked this conversation as resolved.
Show resolved Hide resolved
# frame deps, for developing FRAME pallets.
frame-support = { workspace = true }
frame-system = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ pub mod deps {
pub use sp_core;
pub use sp_io;
pub use sp_runtime;

bkchr marked this conversation as resolved.
Show resolved Hide resolved
pub use codec;
pub use scale_info;

Expand Down
18 changes: 3 additions & 15 deletions substrate/frame/statement/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,9 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { features = ["derive"], workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
frame = { workspace = true, features = ["experimental", "runtime"]}
log = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
sp-api = { workspace = true }
sp-core = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }
sp-statement-store = { workspace = true }

[dev-dependencies]
Expand All @@ -33,20 +28,13 @@ pallet-balances = { workspace = true, default-features = true }
default = ["std"]
std = [
"codec/std",
"frame-support/std",
"frame-system/std",
"frame/std",
"log/std",
"pallet-balances/std",
"scale-info/std",
"sp-api/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-statement-store/std",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"pallet-balances/try-runtime",
"sp-runtime/try-runtime",
"frame/try-runtime",
]
10 changes: 3 additions & 7 deletions substrate/frame/statement/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,13 @@

#![cfg_attr(not(feature = "std"), no_std)]

use frame_support::{
pallet_prelude::*,
sp_runtime::{traits::CheckedDiv, SaturatedConversion},
traits::fungible::Inspect,
};
use frame_system::pallet_prelude::*;
use frame::{prelude::*, traits::fungible::Inspect, deps::sp_io};
use sp_statement_store::{
runtime_api::{InvalidStatement, StatementSource, ValidStatement},
Proof, SignatureVerificationResult, Statement,
};


#[cfg(test)]
mod mock;
#[cfg(test)]
Expand All @@ -53,7 +49,7 @@ pub use pallet::*;

const LOG_TARGET: &str = "runtime::statement";

#[frame_support::pallet]
#[frame::pallet]
pub mod pallet {
use super::*;

Expand Down
11 changes: 3 additions & 8 deletions substrate/frame/statement/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@
use super::*;

use crate as pallet_statement;
use frame_support::{
derive_impl, ord_parameter_types,
traits::{ConstU32, ConstU64},
};
use sp_core::Pair;
use sp_runtime::{traits::IdentityLookup, AccountId32, BuildStorage};
use frame::testing_prelude::*;

type Block = frame_system::mocking::MockBlock<Test>;

Expand All @@ -34,7 +29,7 @@ pub const MAX_ALLOWED_STATEMENTS: u32 = 10;
pub const MIN_ALLOWED_BYTES: u32 = 1024;
pub const MAX_ALLOWED_BYTES: u32 = 4096;

frame_support::construct_runtime!(
construct_runtime!(
pub enum Test
{
System: frame_system,
Expand Down Expand Up @@ -72,7 +67,7 @@ impl Config for Test {
type MaxAllowedBytes = ConstU32<MAX_ALLOWED_BYTES>;
}

pub fn new_test_ext() -> sp_io::TestExternalities {
pub fn new_test_ext() -> TestState {
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
let balances = pallet_balances::GenesisConfig::<Test> {
balances: vec![
Expand Down
3 changes: 1 addition & 2 deletions substrate/frame/statement/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

use super::*;
use crate::mock::*;
use sp_core::Pair;
use sp_runtime::AccountId32;
use frame::testing_prelude::*;
use sp_statement_store::{
runtime_api::{InvalidStatement, StatementSource, ValidStatement},
Proof, Statement,
Expand Down
24 changes: 4 additions & 20 deletions substrate/frame/sudo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,22 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { features = ["derive"], workspace = true }
frame = { workspace = true, features = ["experimental", "runtime"]}
frame-benchmarking = { optional = true, workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
scale-info = { features = ["derive"], workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }

docify = { workspace = true }

[dev-dependencies]
sp-core = { workspace = true, default-features = true }

[features]
default = ["std"]
std = [
"codec/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"frame/std",
"scale-info/std",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"frame/runtime-benchmarks"
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"sp-runtime/try-runtime",
"frame/try-runtime"
]
7 changes: 3 additions & 4 deletions substrate/frame/sudo/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
use super::*;
use crate::Pallet;
use alloc::{boxed::Box, vec};
use frame_benchmarking::v2::*;
use frame_support::dispatch::{DispatchInfo, GetDispatchInfo};
use frame_system::RawOrigin;
use sp_runtime::traits::{
use frame::prelude::*;
use frame::benchmarking::prelude::*
bkchr marked this conversation as resolved.
Show resolved Hide resolved
use frame::deps::sp_runtime::traits::{
AsSystemOriginSigner, AsTransactionAuthorizedOrigin, DispatchTransaction, Dispatchable,
};

Expand Down
10 changes: 1 addition & 9 deletions substrate/frame/sudo/src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,8 @@
use crate::{Config, Key};
use codec::{Decode, Encode};
use core::{fmt, marker::PhantomData};
use frame_support::{dispatch::DispatchInfo, ensure, pallet_prelude::TransactionSource};
use scale_info::TypeInfo;
use sp_runtime::{
impl_tx_ext_default,
traits::{AsSystemOriginSigner, DispatchInfoOf, Dispatchable, TransactionExtension},
transaction_validity::{
InvalidTransaction, TransactionPriority, TransactionValidityError, UnknownTransaction,
ValidTransaction,
},
};
use frame::prelude::*;

/// Ensure that signed transactions are only valid if they are signed by sudo account.
///
Expand Down
17 changes: 7 additions & 10 deletions substrate/frame/sudo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@
//! Here's an example of a privileged function in another pallet:
//!
//! ```
//! #[frame_support::pallet]
//! #[frame::pallet]
//! pub mod pallet {
//! use super::*;
//! use frame_support::pallet_prelude::*;
//! use frame_system::pallet_prelude::*;
//! use frame::prelude::*;
//!
//! #[pallet::pallet]
//! pub struct Pallet<T>(_);
Expand Down Expand Up @@ -125,9 +124,7 @@ extern crate alloc;

use alloc::boxed::Box;

use sp_runtime::{traits::StaticLookup, DispatchResult};

use frame_support::{dispatch::GetDispatchInfo, traits::UnfilteredDispatchable};

mod extension;
#[cfg(test)]
Expand All @@ -137,6 +134,7 @@ mod tests;

#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;
use frame::prelude::*;
pub mod weights;
pub use weights::WeightInfo;

Expand All @@ -145,11 +143,10 @@ pub use pallet::*;

type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;

#[frame_support::pallet]
#[frame::pallet]
pub mod pallet {
use super::{DispatchResult, *};
use frame_support::pallet_prelude::*;
use frame_system::{pallet_prelude::*, RawOrigin};
use frame::prelude::*;

/// Default preludes for [`Config`].
pub mod config_preludes {
Expand All @@ -162,7 +159,7 @@ pub mod pallet {
#[derive_impl(frame_system::config_preludes::TestDefaultConfig, no_aggregated_types)]
impl frame_system::DefaultConfig for TestDefaultConfig {}

#[frame_support::register_default_impl(TestDefaultConfig)]
#[frame::register_default_impl(TestDefaultConfig)]
impl DefaultConfig for TestDefaultConfig {
type WeightInfo = ();
#[inject_runtime_type]
Expand Down Expand Up @@ -335,7 +332,7 @@ pub mod pallet {
pub(super) type Key<T: Config> = StorageValue<_, T::AccountId, OptionQuery>;

#[pallet::genesis_config]
#[derive(frame_support::DefaultNoBound)]
#[derive(DefaultNoBound)]
pub struct GenesisConfig<T: Config> {
/// The `AccountId` of the sudo key.
pub key: Option<T::AccountId>,
Expand Down
11 changes: 4 additions & 7 deletions substrate/frame/sudo/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@

use super::*;
use crate as sudo;
use frame_support::{derive_impl, traits::Contains};
use sp_io;
use sp_runtime::BuildStorage;
use frame::testing_prelude::*;

// Logger module to track execution.
#[frame_support::pallet]
#[frame::pallet]
pub mod logger {
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use frame::preliude::*
bkchr marked this conversation as resolved.
Show resolved Hide resolved

#[pallet::config]
pub trait Config: frame_system::Config {
Expand Down Expand Up @@ -127,7 +124,7 @@ pub type SudoCall = sudo::Call<Test>;
pub type LoggerCall = logger::Call<Test>;

// Build test environment by setting the root `key` for the Genesis.
pub fn new_test_ext(root_key: u64) -> sp_io::TestExternalities {
pub fn new_test_ext(root_key: u64) -> TestState {
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
sudo::GenesisConfig::<Test> { key: Some(root_key) }
.assimilate_storage(&mut t)
Expand Down
2 changes: 1 addition & 1 deletion substrate/frame/sudo/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! Tests for the module.

use super::*;
use frame_support::{assert_noop, assert_ok, weights::Weight};
use frame::testing_prelude::*;
use mock::{
new_test_ext, Logger, LoggerCall, RuntimeCall, RuntimeEvent as TestEvent, RuntimeOrigin, Sudo,
SudoCall, System, Test,
Expand Down
3 changes: 1 addition & 2 deletions substrate/frame/sudo/src/weights.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading