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

Restructure frame_support macro related exports #14745

Merged
merged 33 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1dfc9b4
make reexports private
juangirini Aug 10, 2023
dccfaeb
make reexports private 2
juangirini Aug 10, 2023
9706353
make reexports private for runtime-benchmarking
juangirini Aug 10, 2023
7d6c124
make reexports private for try-runtime
juangirini Aug 10, 2023
87fd6de
fix for try-runtime
juangirini Aug 10, 2023
1ffc743
make reexports private for tests
juangirini Aug 10, 2023
222b45d
rebase and fix conflicts
juangirini Aug 10, 2023
e795557
fmt
juangirini Aug 10, 2023
4c9ef13
make reexports private for tests
juangirini Aug 10, 2023
4d0b806
make reexports private for experimental
juangirini Aug 10, 2023
e32c82f
fix beefy
juangirini Aug 10, 2023
4386de3
fix ui test
juangirini Aug 10, 2023
54657c0
fix ui test
juangirini Aug 10, 2023
3566961
fix benches
juangirini Aug 14, 2023
08de067
Merge branch 'master' into jg/restructure-macro-related-exports
juangirini Aug 14, 2023
c419d4a
".git/.scripts/commands/fmt/fmt.sh"
Aug 14, 2023
b931ecb
fix contracts use
juangirini Aug 15, 2023
f4e5f55
wip
juangirini Aug 15, 2023
4ecbfff
wip
juangirini Aug 15, 2023
b7eaa34
Merge remote-tracking branch 'origin/master' into jg/restructure-macr…
juangirini Aug 15, 2023
095356c
do not reexport sp_api::metadata_ir
juangirini Aug 16, 2023
3bc2ddc
Merge branch 'master' into jg/restructure-macro-related-exports
juangirini Aug 16, 2023
3816fc4
fix CI checks
juangirini Aug 16, 2023
32f74a6
fix support tests
juangirini Aug 16, 2023
7d7d73b
".git/.scripts/commands/fmt/fmt.sh"
Aug 16, 2023
86ddd81
Update frame/support/src/lib.rs
juangirini Aug 17, 2023
5d00dfd
import codec directly
juangirini Aug 17, 2023
a6a4e3d
fmt
juangirini Aug 17, 2023
4df379c
Merge remote-tracking branch 'origin/master' into jg/restructure-macr…
Aug 17, 2023
0fcc322
fix node-cli tests
juangirini Aug 18, 2023
daf3dcb
Merge remote-tracking branch 'origin/master' into jg/restructure-macr…
Aug 21, 2023
e94e54b
Merge remote-tracking branch 'origin/master' into jg/restructure-macr…
Aug 22, 2023
20a95f2
Merge branch 'master' into jg/restructure-macro-related-exports
juangirini Aug 23, 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
10 changes: 10 additions & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ use frame_support::{
},
ConstantMultiplier, IdentityFee, Weight,
},
BoundedVec, PalletId, RuntimeDebug,
BoundedVec, PalletId,
};
use frame_system::{
limits::{BlockLength, BlockWeights},
Expand Down Expand Up @@ -78,6 +78,7 @@ use sp_runtime::{
},
transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
ApplyExtrinsicResult, FixedPointNumber, FixedU128, Perbill, Percent, Permill, Perquintill,
RuntimeDebug,
};
use sp_std::prelude::*;
#[cfg(any(feature = "std", test))]
Expand Down
4 changes: 2 additions & 2 deletions frame/alliance/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ pub mod migration;
mod types;
pub mod weights;

use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*;
use sp_runtime::{
Expand All @@ -103,20 +104,19 @@ use sp_runtime::{
use sp_std::{convert::TryInto, prelude::*};

use frame_support::{
codec::{Decode, Encode, MaxEncodedLen},
dispatch::{
DispatchError, DispatchResult, DispatchResultWithPostInfo, Dispatchable, GetDispatchInfo,
PostDispatchInfo,
},
ensure,
scale_info::TypeInfo,
traits::{
ChangeMembers, Currency, Get, InitializeMembers, IsSubType, OnUnbalanced,
ReservableCurrency,
},
weights::Weight,
};
use pallet_identity::IdentityField;
use scale_info::TypeInfo;

pub use pallet::*;
pub use types::*;
Expand Down
2 changes: 2 additions & 0 deletions frame/assets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false }
log = { version = "0.4.17", default-features = false }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
sp-std = { version = "8.0.0", default-features = false, path = "../../primitives/std" }
# Needed for various traits. In our case, `OnFinalize`.
Expand All @@ -34,6 +35,7 @@ pallet-balances = { version = "4.0.0-dev", path = "../balances" }
default = ["std"]
std = [
"codec/std",
"log/std",
"scale-info/std",
"sp-core/std",
"sp-std/std",
Expand Down
3 changes: 2 additions & 1 deletion frame/assets/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
// limitations under the License.

use super::*;
use frame_support::{log, traits::OnRuntimeUpgrade};
use frame_support::traits::OnRuntimeUpgrade;
use log;

#[cfg(feature = "try-runtime")]
use sp_runtime::TryRuntimeError;
Expand Down
2 changes: 2 additions & 0 deletions frame/aura/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive", "max-encoded-len"] }
log = { version = "0.4.17", default-features = false }
scale-info = { version = "2.5.0", default-features = false, features = ["derive"] }
frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" }
frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" }
Expand All @@ -31,6 +32,7 @@ sp-io = { version = "23.0.0", path = "../../primitives/io" }
default = ["std"]
std = [
"codec/std",
"log/std",
"frame-support/std",
"frame-system/std",
"pallet-timestamp/std",
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 @@ -40,10 +40,10 @@

use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::{
log,
traits::{DisabledValidators, FindAuthor, Get, OnTimestampSet, OneSessionHandler},
BoundedSlice, BoundedVec, ConsensusEngineId, Parameter,
};
use log;
use sp_consensus_aura::{AuthorityIndex, ConsensusLog, Slot, AURA_ENGINE_ID};
use sp_runtime::{
generic::DigestItem,
Expand Down
4 changes: 2 additions & 2 deletions frame/balances/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ use frame_support::{
StorageMapShim, StoredMap, WhitelistedStorageKeys,
},
weights::{IdentityFee, Weight},
RuntimeDebug,
};
use frame_system::{self as system, RawOrigin};
use pallet_transaction_payment::{ChargeTransactionPayment, CurrencyAdapter, Multiplier};
Expand All @@ -39,7 +38,8 @@ use sp_core::{hexdisplay::HexDisplay, H256};
use sp_io;
use sp_runtime::{
traits::{BadOrigin, IdentityLookup, SignedExtension, Zero},
ArithmeticError, BuildStorage, DispatchError, DispatchResult, FixedPointNumber, TokenError,
ArithmeticError, BuildStorage, DispatchError, DispatchResult, FixedPointNumber, RuntimeDebug,
TokenError,
};
use std::collections::BTreeSet;

Expand Down
7 changes: 2 additions & 5 deletions frame/balances/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@
use crate::{Config, CreditOf, Event, Pallet};
use codec::{Decode, Encode, MaxEncodedLen};
use core::ops::BitOr;
use frame_support::{
traits::{Imbalance, LockIdentifier, OnUnbalanced, WithdrawReasons},
RuntimeDebug,
};
use frame_support::traits::{Imbalance, LockIdentifier, OnUnbalanced, WithdrawReasons};
use scale_info::TypeInfo;
use sp_runtime::Saturating;
use sp_runtime::{RuntimeDebug, Saturating};

/// Simplified reasons for withdrawing balance.
#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, MaxEncodedLen, TypeInfo)]
Expand Down
4 changes: 3 additions & 1 deletion frame/beefy-mmr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ sp-io = { version = "23.0.0", default-features = false, path = "../../primitives
sp-runtime = { version = "24.0.0", default-features = false, path = "../../primitives/runtime" }
sp-std = { version = "8.0.0", default-features = false, path = "../../primitives/std" }
sp-api = { version = "4.0.0-dev", default-features = false, path = "../../primitives/api" }
sp-state-machine = { version = "0.28.0", default-features = false, path = "../../primitives/state-machine" }

[dev-dependencies]
array-bytes = "6.1"
Expand All @@ -51,7 +52,8 @@ std = [
"sp-runtime/std",
"sp-std/std",
"sp-api/std",
"sp-staking/std"
"sp-staking/std",
"sp-state-machine/std"
]
try-runtime = [
"frame-support/try-runtime",
Expand Down
4 changes: 2 additions & 2 deletions frame/beefy-mmr/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ use std::vec;
use codec::Encode;
use frame_support::{
construct_runtime, parameter_types,
sp_io::TestExternalities,
traits::{ConstU16, ConstU32, ConstU64},
BasicExternalities,
};
use sp_consensus_beefy::mmr::MmrLeafVersion;
use sp_core::H256;
use sp_io::TestExternalities;
use sp_runtime::{
app_crypto::ecdsa::Public,
impl_opaque_keys,
traits::{BlakeTwo256, ConvertInto, IdentityLookup, Keccak256, OpaqueKeys},
BuildStorage,
};
use sp_state_machine::BasicExternalities;

use crate as pallet_beefy_mmr;

Expand Down
6 changes: 5 additions & 1 deletion frame/beefy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ homepage = "https://substrate.io"

[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = ["derive"] }
log = { version = "0.4.17", default-features = false }
scale-info = { version = "2.5.0", default-features = false, features = ["derive", "serde"] }
serde = { version = "1.0.163", optional = true }
frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" }
Expand All @@ -32,11 +33,13 @@ pallet-timestamp = { version = "4.0.0-dev", path = "../timestamp" }
sp-core = { version = "21.0.0", path = "../../primitives/core" }
sp-io = { version = "23.0.0", path = "../../primitives/io" }
sp-staking = { version = "4.0.0-dev", path = "../../primitives/staking" }
sp-state-machine = { version = "0.28.0", default-features = false, path = "../../primitives/state-machine" }

[features]
default = ["std"]
std = [
"codec/std",
"log/std",
"frame-support/std",
"frame-system/std",
"pallet-authorship/std",
Expand All @@ -54,7 +57,8 @@ std = [
"pallet-staking/std",
"pallet-timestamp/std",
"sp-core/std",
"sp-io/std"
"sp-io/std",
"sp-state-machine/std"
]
try-runtime = [
"frame-support/try-runtime",
Expand Down
5 changes: 1 addition & 4 deletions frame/beefy/src/equivocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@
//! definition.

use codec::{self as codec, Decode, Encode};
use frame_support::{
log,
traits::{Get, KeyOwnerProofSystem},
};
use frame_support::traits::{Get, KeyOwnerProofSystem};
use frame_system::pallet_prelude::BlockNumberFor;
use log::{error, info};
use sp_consensus_beefy::{EquivocationProof, ValidatorSetId, KEY_TYPE as BEEFY_KEY_TYPE};
Expand Down
2 changes: 1 addition & 1 deletion frame/beefy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use codec::{Encode, MaxEncodedLen};

use frame_support::{
dispatch::{DispatchResultWithPostInfo, Pays},
log,
pallet_prelude::*,
traits::{Get, OneSessionHandler},
weights::Weight,
Expand All @@ -31,6 +30,7 @@ use frame_system::{
ensure_none, ensure_signed,
pallet_prelude::{BlockNumberFor, OriginFor},
};
use log;
use sp_runtime::{
generic::DigestItem,
traits::{IsMember, Member},
Expand Down
4 changes: 2 additions & 2 deletions frame/beefy/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ use frame_election_provider_support::{
};
use frame_support::{
construct_runtime, parameter_types,
sp_io::TestExternalities,
traits::{ConstU16, ConstU32, ConstU64, KeyOwnerProofSystem, OnFinalize, OnInitialize},
BasicExternalities,
};
use pallet_session::historical as pallet_session_historical;
use sp_core::{crypto::KeyTypeId, ConstU128, H256};
use sp_io::TestExternalities;
use sp_runtime::{
app_crypto::ecdsa::Public,
curve::PiecewiseLinear,
Expand All @@ -38,6 +37,7 @@ use sp_runtime::{
BuildStorage, Perbill,
};
use sp_staking::{EraIndex, SessionIndex};
use sp_state_machine::BasicExternalities;

use crate as pallet_beefy;

Expand Down
4 changes: 2 additions & 2 deletions frame/benchmarking/src/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,13 +446,13 @@ macro_rules! benchmarks_iter {
>:: [< new_call_variant_ $dispatch >] (
$($arg),*
);
let __benchmarked_call_encoded = $crate::frame_support::codec::Encode::encode(
let __benchmarked_call_encoded = $crate::frame_support::__private::codec::Encode::encode(
&__call
);
}: {
let __call_decoded = <
Call<T $(, $instance )?>
as $crate::frame_support::codec::Decode
as $crate::frame_support::__private::codec::Decode
Comment on lines +449 to +455
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels..wrong.

curious why we need to do it this way, and can't just pull Encode and Decode from their codec crate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make it correct, you would need to re-export codec from frame-benchmarking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, benchmarking re-exports will follow in the parent issue https://github.com/paritytech/substrate/issues/14213

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because its a macro that emits code. The emitted code cannot make the assumption that codec is in the Cargo.toml of the crate that it is being used by.
We therefore need to ship a macro will all exports that it needs.

>::decode(&mut &__benchmarked_call_encoded[..])
.expect("call is encoded above, encoding must be correct");
let __origin = $crate::to_origin!($origin $(, $origin_type)?);
Expand Down
2 changes: 1 addition & 1 deletion frame/collective/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![recursion_limit = "128"]

use codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_io::storage;
use sp_runtime::{traits::Hash, RuntimeDebug};
use sp_std::{marker::PhantomData, prelude::*, result};

use frame_support::{
codec::{Decode, Encode, MaxEncodedLen},
dispatch::{
DispatchError, DispatchResult, DispatchResultWithPostInfo, Dispatchable, GetDispatchInfo,
Pays, PostDispatchInfo,
Expand Down
7 changes: 5 additions & 2 deletions frame/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ use frame_support::{
ConstU32, Contains, Get, Randomness, Time,
},
weights::Weight,
BoundedVec, RuntimeDebug, RuntimeDebugNoBound,
BoundedVec, RuntimeDebugNoBound,
};
use frame_system::{ensure_signed, pallet_prelude::OriginFor, EventRecord, Pallet as System};
use pallet_contracts_primitives::{
Expand All @@ -132,7 +132,10 @@ use pallet_contracts_primitives::{
};
use scale_info::TypeInfo;
use smallvec::Array;
use sp_runtime::traits::{Convert, Hash, Saturating, StaticLookup, Zero};
use sp_runtime::{
traits::{Convert, Hash, Saturating, StaticLookup, Zero},
RuntimeDebug,
};
use sp_std::{fmt::Debug, prelude::*};

pub use crate::{
Expand Down
1 change: 0 additions & 1 deletion frame/contracts/src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ include!(concat!(env!("OUT_DIR"), "/migration_codegen.rs"));
use crate::{weights::WeightInfo, Config, Error, MigrationInProgress, Pallet, Weight, LOG_TARGET};
use codec::{Codec, Decode};
use frame_support::{
codec,
pallet_prelude::*,
traits::{ConstU32, OnRuntimeUpgrade},
};
Expand Down
Loading