Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

GenesisBuild<T,I> deprecated. BuildGenesisConfig added. #14306

Merged
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
692de3a
frame::support: GenesisConfig types for Runtime enabled
michalkucharczyk May 30, 2023
98398b4
frame::support: macro generating GenesisBuild::build for RuntimeGenes…
michalkucharczyk May 17, 2023
6017dad
frame: ambiguity BuildStorage vs GenesisBuild fixed
michalkucharczyk May 24, 2023
477d7ad
fix
michalkucharczyk Jun 6, 2023
5fc8e30
Merge remote-tracking branch 'origin/master' into mku-genesis-build-f…
Jun 9, 2023
3c131b6
RuntimeGenesisBuild added
michalkucharczyk Jun 12, 2023
2b1ecd4
Revert "frame: ambiguity BuildStorage vs GenesisBuild fixed"
michalkucharczyk Jun 12, 2023
fd7fa62
Revert "fix"
michalkucharczyk Jun 12, 2023
e72ab34
Merge remote-tracking branch 'origin/master' into mku-genesis-build-f…
Jun 12, 2023
ef35f75
Revert "RuntimeGenesisBuild added"
michalkucharczyk Jun 13, 2023
ccfcc50
Revert "Revert "frame: ambiguity BuildStorage vs GenesisBuild fixed""
michalkucharczyk Jun 13, 2023
59071b8
Revert "Revert "fix""
michalkucharczyk Jun 13, 2023
87d969a
Code review suggestions
michalkucharczyk Jun 13, 2023
8b01b12
frame: BuildGenesisConfig added, BuildGenesis deprecated
michalkucharczyk Jun 14, 2023
6e2923a
frame: some pallets updated with BuildGenesisConfig
michalkucharczyk Jun 14, 2023
e30bd48
constuct_runtime: support for BuildGenesisConfig
michalkucharczyk Jun 14, 2023
6d7c910
frame::support: genesis_build macro supports BuildGenesisConfig
michalkucharczyk Jun 14, 2023
cbf963a
frame: BuildGenesisConfig added, BuildGenesis deprecated
michalkucharczyk Jun 15, 2023
37c4132
Merge remote-tracking branch 'origin/master' into mku-genesis-build-f…
michalkucharczyk Jun 15, 2023
6ab7787
Cargo.lock update
michalkucharczyk Jun 15, 2023
a634ee0
test-runtime: fixes
michalkucharczyk Jun 15, 2023
8054181
Revert "fix"
michalkucharczyk Jun 16, 2023
b265703
Revert "frame: ambiguity BuildStorage vs GenesisBuild fixed"
michalkucharczyk Jun 16, 2023
908e60c
self review
michalkucharczyk Jun 16, 2023
d48c130
doc fixed
michalkucharczyk Jun 16, 2023
14af66b
ui tests fixed
michalkucharczyk Jun 16, 2023
d8c0602
Merge remote-tracking branch 'origin/master' into mku-genesis-build-f…
michalkucharczyk Jun 16, 2023
79424ae
fmt
michalkucharczyk Jun 16, 2023
fa5fe32
tests fixed
michalkucharczyk Jun 16, 2023
fd71ead
genesis_build macrto fixed for non-generic GenesisConfig
michalkucharczyk Jun 16, 2023
1ef1976
BuildGenesisConfig constraints added
michalkucharczyk Jun 16, 2023
06ea765
warning fixed
michalkucharczyk Jun 16, 2023
e178f0c
some duplication removed
michalkucharczyk Jun 16, 2023
f8afcb0
fmt
michalkucharczyk Jun 16, 2023
beafa9a
fix
michalkucharczyk Jun 16, 2023
9f9c214
doc tests fix
michalkucharczyk Jun 16, 2023
96a8400
doc fix
michalkucharczyk Jun 16, 2023
7ee89a2
cleanup: remove BuildModuleGenesisStorage
michalkucharczyk Jun 16, 2023
cff8186
Merge remote-tracking branch 'origin/master' into mku-genesis-build-f…
michalkucharczyk Jun 19, 2023
11d8f89
self review comments
michalkucharczyk Jun 19, 2023
436cdda
fix
michalkucharczyk Jun 19, 2023
702e444
Update frame/treasury/src/tests.rs
michalkucharczyk Jun 20, 2023
c6b10bd
Update frame/support/src/traits/hooks.rs
michalkucharczyk Jun 20, 2023
27c8b52
doc fix: GenesisBuild exposed
michalkucharczyk Jun 20, 2023
473b826
".git/.scripts/commands/fmt/fmt.sh"
Jun 20, 2023
28e448b
Merge remote-tracking branch 'origin/master' into mku-genesis-build-f…
michalkucharczyk Jun 20, 2023
1f5ec07
frame: more serde(skip) + cleanup
michalkucharczyk Jun 20, 2023
b21c50a
Merge remote-tracking branch 'origin/master' into mku-genesis-build-f…
Jun 22, 2023
48fe1da
Update frame/support/src/traits/hooks.rs
michalkucharczyk Jun 26, 2023
17ace4e
frame: phantom fields moved to the end of structs
michalkucharczyk Jun 26, 2023
fcff039
chain-spec: Default::default cleanup
michalkucharczyk Jun 26, 2023
a46eb4b
test-runtime: phantom at the end
michalkucharczyk Jun 26, 2023
cce714f
Merge remote-tracking branch 'origin/master' into mku-genesis-build-f…
michalkucharczyk Jun 26, 2023
1db4121
merge master fixes
michalkucharczyk Jun 26, 2023
9b7c6c0
fix
michalkucharczyk Jun 27, 2023
8735bb8
fix
michalkucharczyk Jun 27, 2023
478069d
Merge branch 'master' into mku-genesis-build-for-runtime-genesis-config
michalkucharczyk Jun 30, 2023
01d6f42
fix
michalkucharczyk Jun 30, 2023
d4fa972
fix
michalkucharczyk Jun 30, 2023
4c46d96
fix (facepalm)
michalkucharczyk Jun 30, 2023
afbff0a
Merge remote-tracking branch 'origin/master' into mku-genesis-build-f…
Jul 4, 2023
0fbda66
Update frame/support/procedural/src/pallet/expand/genesis_build.rs
michalkucharczyk Jul 5, 2023
54ffd12
fmt
michalkucharczyk Jul 5, 2023
0625f87
fix
michalkucharczyk Jul 5, 2023
879e358
Merge remote-tracking branch 'origin/master' into mku-genesis-build-f…
michalkucharczyk Jul 5, 2023
8b766f4
fix
michalkucharczyk Jul 5, 2023
73f1d20
Merge remote-tracking branch 'origin/master' into mku-genesis-build-f…
michalkucharczyk Jul 12, 2023
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
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions bin/node-template/node/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ fn testnet_genesis(
system: SystemConfig {
// Add Wasm runtime to storage.
code: wasm_binary.to_vec(),
..Default::default()
},
balances: BalancesConfig {
// Configure endowed accounts with initial balance of 1 << 60.
Expand All @@ -146,6 +147,7 @@ fn testnet_genesis(
},
grandpa: GrandpaConfig {
authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(),
..Default::default()
},
sudo: SudoConfig {
// Assign network admin rights.
Expand Down
3 changes: 2 additions & 1 deletion bin/node-template/pallets/template/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use sp_core::H256;
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
BuildStorage,
};

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
Expand Down Expand Up @@ -55,5 +56,5 @@ impl pallet_template::Config for Test {

// Build genesis storage according to the mock runtime.
pub fn new_test_ext() -> sp_io::TestExternalities {
frame_system::GenesisConfig::default().build_storage::<Test>().unwrap().into()
frame_system::GenesisConfig::<Test>::default().build_storage().unwrap().into()
}
8 changes: 5 additions & 3 deletions bin/node/cli/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ pub fn testnet_genesis(
const STASH: Balance = ENDOWMENT / 1000;

RuntimeGenesisConfig {
system: SystemConfig { code: wasm_binary_unwrap().to_vec() },
system: SystemConfig { code: wasm_binary_unwrap().to_vec(), ..Default::default() },
balances: BalancesConfig {
balances: endowed_accounts.iter().cloned().map(|x| (x, ENDOWMENT)).collect(),
},
Expand Down Expand Up @@ -342,10 +342,11 @@ pub fn testnet_genesis(
babe: BabeConfig {
authorities: vec![],
epoch_config: Some(kitchensink_runtime::BABE_GENESIS_EPOCH_CONFIG),
..Default::default()
},
im_online: ImOnlineConfig { keys: vec![] },
authority_discovery: AuthorityDiscoveryConfig { keys: vec![] },
grandpa: GrandpaConfig { authorities: vec![] },
authority_discovery: AuthorityDiscoveryConfig { keys: vec![], ..Default::default() },
grandpa: GrandpaConfig { authorities: vec![], ..Default::default() },
michalkucharczyk marked this conversation as resolved.
Show resolved Hide resolved
technical_membership: Default::default(),
treasury: Default::default(),
society: SocietyConfig { pot: 0 },
Expand All @@ -369,6 +370,7 @@ pub fn testnet_genesis(
compute: Default::default(),
storage: Default::default(),
trash_data_count: Default::default(),
..Default::default()
michalkucharczyk marked this conversation as resolved.
Show resolved Hide resolved
},
}
}
Expand Down
8 changes: 4 additions & 4 deletions bin/node/executor/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ use codec::{Decode, Encode};
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use frame_support::Hashable;
use kitchensink_runtime::{
constants::currency::*, Block, BuildStorage, CheckedExtrinsic, GenesisConfig, Header,
RuntimeCall, UncheckedExtrinsic,
constants::currency::*, Block, BuildStorage, CheckedExtrinsic, Header, RuntimeCall,
RuntimeGenesisConfig, UncheckedExtrinsic,
};
use node_executor::ExecutorDispatch;
use node_primitives::{BlockNumber, Hash};
Expand Down Expand Up @@ -67,7 +67,7 @@ fn sign(xt: CheckedExtrinsic) -> UncheckedExtrinsic {
node_testing::keyring::sign(xt, SPEC_VERSION, TRANSACTION_VERSION, GENESIS_HASH)
}

fn new_test_ext(genesis_config: &GenesisConfig) -> TestExternalities<BlakeTwo256> {
fn new_test_ext(genesis_config: &RuntimeGenesisConfig) -> TestExternalities<BlakeTwo256> {
let mut test_ext = TestExternalities::new_with_code(
compact_code_unwrap(),
genesis_config.build_storage().unwrap(),
Expand Down Expand Up @@ -157,7 +157,7 @@ fn construct_block<E: Externalities>(
}

fn test_blocks(
genesis_config: &GenesisConfig,
genesis_config: &RuntimeGenesisConfig,
executor: &NativeElseWasmExecutor<ExecutorDispatch>,
) -> Vec<(Vec<u8>, Hash)> {
let mut test_ext = new_test_ext(genesis_config);
Expand Down
6 changes: 3 additions & 3 deletions bin/node/runtime/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ mod multiplier_tests {
use sp_runtime::{
assert_eq_error_rate,
traits::{Convert, One, Zero},
FixedPointNumber,
BuildStorage, FixedPointNumber,
};

use crate::{
Expand Down Expand Up @@ -197,8 +197,8 @@ mod multiplier_tests {
where
F: Fn() -> (),
{
let mut t: sp_io::TestExternalities = frame_system::GenesisConfig::default()
.build_storage::<Runtime>()
let mut t: sp_io::TestExternalities = frame_system::GenesisConfig::<Runtime>::default()
.build_storage()
.unwrap()
.into();
t.execute_with(|| {
Expand Down
10 changes: 8 additions & 2 deletions bin/node/testing/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub fn config_endowed(code: Option<&[u8]>, extra_endowed: Vec<AccountId>) -> Run
RuntimeGenesisConfig {
system: SystemConfig {
code: code.map(|x| x.to_vec()).unwrap_or_else(|| wasm_binary_unwrap().to_vec()),
..Default::default()
},
indices: IndicesConfig { indices: vec![] },
balances: BalancesConfig { balances: endowed },
Expand All @@ -76,8 +77,12 @@ pub fn config_endowed(code: Option<&[u8]>, extra_endowed: Vec<AccountId>) -> Run
invulnerables: vec![alice(), bob(), charlie()],
..Default::default()
},
babe: BabeConfig { authorities: vec![], epoch_config: Some(BABE_GENESIS_EPOCH_CONFIG) },
grandpa: GrandpaConfig { authorities: vec![] },
babe: BabeConfig {
authorities: vec![],
epoch_config: Some(BABE_GENESIS_EPOCH_CONFIG),
..Default::default()
},
grandpa: GrandpaConfig { authorities: vec![], _config: Default::default() },
im_online: Default::default(),
authority_discovery: Default::default(),
democracy: Default::default(),
Expand All @@ -100,6 +105,7 @@ pub fn config_endowed(code: Option<&[u8]>, extra_endowed: Vec<AccountId>) -> Run
compute: Default::default(),
storage: Default::default(),
trash_data_count: Default::default(),
..Default::default()
},
}
}
3 changes: 2 additions & 1 deletion frame/alliance/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,12 @@ pub mod pallet {
pub struct GenesisConfig<T: Config<I>, I: 'static = ()> {
pub fellows: Vec<T::AccountId>,
pub allies: Vec<T::AccountId>,
#[serde(skip)]
pub phantom: PhantomData<(T, I)>,
}

#[pallet::genesis_build]
impl<T: Config<I>, I: 'static> GenesisBuild<T, I> for GenesisConfig<T, I> {
impl<T: Config<I>, I: 'static> BuildGenesisConfig for GenesisConfig<T, I> {
fn build(&self) {
for m in self.fellows.iter().chain(self.allies.iter()) {
assert!(Pallet::<T, I>::has_identity(m).is_ok(), "Member does not set identity!");
Expand Down
18 changes: 8 additions & 10 deletions frame/alliance/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use sp_std::convert::{TryFrom, TryInto};

pub use frame_support::{
assert_noop, assert_ok, ord_parameter_types, parameter_types,
traits::{EitherOfDiverse, GenesisBuild, SortedMembers},
traits::{EitherOfDiverse, SortedMembers},
BoundedVec,
};
use frame_system::{EnsureRoot, EnsureSignedBy};
Expand Down Expand Up @@ -256,7 +256,7 @@ frame_support::construct_runtime!(
);

pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();

pallet_balances::GenesisConfig::<Test> {
balances: vec![
Expand All @@ -274,14 +274,12 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
.assimilate_storage(&mut t)
.unwrap();

GenesisBuild::<Test>::assimilate_storage(
&pallet_alliance::GenesisConfig {
fellows: vec![],
allies: vec![],
phantom: Default::default(),
},
&mut t,
)
pallet_alliance::GenesisConfig::<Test> {
fellows: vec![],
allies: vec![],
phantom: Default::default(),
}
.assimilate_storage(&mut t)
.unwrap();

let mut ext = sp_io::TestExternalities::new(t);
Expand Down
4 changes: 2 additions & 2 deletions frame/asset-conversion/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ use sp_core::H256;
use sp_runtime::{
testing::Header,
traits::{AccountIdConversion, BlakeTwo256, IdentityLookup},
BuildStorage,
};

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

Expand Down Expand Up @@ -183,7 +183,7 @@ impl Config for Test {
}

pub(crate) fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();

pallet_balances::GenesisConfig::<Test> {
balances: vec![(1, 10000), (2, 20000), (3, 30000), (4, 40000)],
Expand Down
3 changes: 2 additions & 1 deletion frame/asset-rate/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use sp_core::H256;
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
BuildStorage,
};

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
Expand Down Expand Up @@ -96,5 +97,5 @@ impl pallet_asset_rate::Config for Test {

// Build genesis storage according to the mock runtime.
pub fn new_test_ext() -> sp_io::TestExternalities {
frame_system::GenesisConfig::default().build_storage::<Test>().unwrap().into()
frame_system::GenesisConfig::<Test>::default().build_storage().unwrap().into()
}
2 changes: 1 addition & 1 deletion frame/assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ pub mod pallet {
}

#[pallet::genesis_build]
impl<T: Config<I>, I: 'static> GenesisBuild<T, I> for GenesisConfig<T, I> {
impl<T: Config<I>, I: 'static> BuildGenesisConfig for GenesisConfig<T, I> {
fn build(&self) {
for (id, owner, is_sufficient, min_balance) in &self.assets {
assert!(!Asset::<T, I>::contains_key(id), "Asset id already in use");
Expand Down
7 changes: 4 additions & 3 deletions frame/assets/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ use crate as pallet_assets;
use codec::Encode;
use frame_support::{
construct_runtime, parameter_types,
traits::{AsEnsureOriginWithArg, ConstU32, ConstU64, GenesisBuild},
traits::{AsEnsureOriginWithArg, ConstU32, ConstU64},
};
use sp_core::H256;
use sp_io::storage;
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
BuildStorage,
};

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
Expand All @@ -41,7 +42,7 @@ construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
Assets: pallet_assets::{Pallet, Call, Storage, Event<T>},
}
Expand Down Expand Up @@ -205,7 +206,7 @@ pub(crate) fn take_hooks() -> Vec<Hook> {
}

pub(crate) fn new_test_ext() -> sp_io::TestExternalities {
let mut storage = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
let mut storage = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();

let config: pallet_assets::GenesisConfig<Test> = pallet_assets::GenesisConfig {
assets: vec![
Expand Down
5 changes: 3 additions & 2 deletions frame/atomic-swap/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use sp_core::H256;
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
BuildStorage,
};

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
Expand All @@ -19,7 +20,7 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
AtomicSwap: pallet_atomic_swap::{Pallet, Call, Event<T>},
}
Expand Down Expand Up @@ -78,7 +79,7 @@ const A: u64 = 1;
const B: u64 = 2;

pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
let genesis = pallet_balances::GenesisConfig::<Test> { balances: vec![(A, 100), (B, 200)] };
genesis.assimilate_storage(&mut t).unwrap();
t.into()
Expand Down
2 changes: 1 addition & 1 deletion frame/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ pub mod pallet {
}

#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
Pallet::<T>::initialize_authorities(&self.authorities);
}
Expand Down
7 changes: 4 additions & 3 deletions frame/aura/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@
use crate as pallet_aura;
use frame_support::{
parameter_types,
traits::{ConstU32, ConstU64, DisabledValidators, GenesisBuild},
traits::{ConstU32, ConstU64, DisabledValidators},
};
use sp_consensus_aura::{ed25519::AuthorityId, AuthorityIndex};
use sp_core::H256;
use sp_runtime::{
testing::{Header, UintAuthorityId},
traits::IdentityLookup,
BuildStorage,
};

type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
Expand All @@ -40,7 +41,7 @@ frame_support::construct_runtime!(
NodeBlock = Block,
UncheckedExtrinsic = UncheckedExtrinsic,
{
System: frame_system::{Pallet, Call, Config, Storage, Event<T>},
System: frame_system::{Pallet, Call, Config<T>, Storage, Event<T>},
Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
Aura: pallet_aura::{Pallet, Storage, Config<T>},
}
Expand Down Expand Up @@ -111,7 +112,7 @@ impl pallet_aura::Config for Test {
}

pub fn new_test_ext(authorities: Vec<u64>) -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
let mut t = frame_system::GenesisConfig::<Test>::default().build_storage().unwrap();
pallet_aura::GenesisConfig::<Test> {
authorities: authorities.into_iter().map(|a| UintAuthorityId(a).to_public_key()).collect(),
}
Expand Down
Loading