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

Pallet grouping macros #300

Merged
merged 66 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from 65 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
b52e836
init using relative paths for now
4meta5 Aug 26, 2024
41d0ebd
not working
4meta5 Aug 27, 2024
9b0d737
cannot define same types with alias names in 2 places relalias todo
4meta5 Aug 27, 2024
de03347
node compiles using impl oz system to abstract over frame system
4meta5 Aug 27, 2024
03b1269
clean
4meta5 Aug 27, 2024
986b60f
timestamp
4meta5 Aug 27, 2024
508d7db
parachain info
4meta5 Aug 27, 2024
dc70159
preimage and scheduler
4meta5 Aug 27, 2024
2e5ddbc
proxy and balances
4meta5 Aug 27, 2024
237d55e
utility and parachain system
4meta5 Aug 27, 2024
1b86792
use construct openzeppelin runtime
4meta5 Sep 10, 2024
187e95c
generic runtime apis
4meta5 Sep 12, 2024
75eda33
pause construct runtime until other macros validated by cross templat…
4meta5 Sep 28, 2024
9c0add3
hold runtime construction until inner macros validated
4meta5 Sep 28, 2024
97b3b72
evm template impl openzeppelin system
4meta5 Sep 28, 2024
f7789d8
revert back to generic construct runtime minimal wrapper for now
4meta5 Sep 30, 2024
866992b
use the trivial versions for the construct runtime and impl runtime a…
4meta5 Sep 30, 2024
ae368b5
fix system grouping macro name
4meta5 Sep 30, 2024
303c782
consensus wrapper in generic template
4meta5 Sep 30, 2024
ced0699
include ExistentialDeposit as explicit system parameter and add asset…
4meta5 Sep 30, 2024
4d1a5cf
wip governance
4meta5 Oct 2, 2024
8a7cb35
wip governnace for generic
4meta5 Oct 3, 2024
c5c30e4
rm placeholders for runtime api and construct runtime until implemented
4meta5 Oct 3, 2024
6920ef4
fix evm template after latest changes to system grouping
4meta5 Oct 3, 2024
d02ccbe
whitelist
4meta5 Oct 3, 2024
e36a3a2
custom origins and referenda to finish governance grouping in generic…
4meta5 Oct 4, 2024
c2d1c6c
init xcm grouping for generic template queue pallets first
4meta5 Oct 4, 2024
9507abe
more xcm
4meta5 Oct 4, 2024
b4252cd
finish updating macros to latest deps on main and confirm compilation…
4meta5 Oct 4, 2024
76bf38e
Merge branch 'main' into amar-system-wrapper-poc2
4meta5 Oct 4, 2024
fa5ae7a
replace direct paths with git url and branch for the macro dep
4meta5 Oct 4, 2024
15c7952
update cargo locks and template fuzzer paths used for constants
4meta5 Oct 4, 2024
e0c2b5c
use consensus macro for evm template
4meta5 Oct 4, 2024
5a6d7ad
fix path in generic templates constant tests
4meta5 Oct 7, 2024
4708aa9
fix more test imports for the generic template
4meta5 Oct 7, 2024
03efdfc
Merge branch 'main' into amar-system-wrapper-poc2
4meta5 Oct 7, 2024
46ead06
fix template fuzzer build for generic template
4meta5 Oct 7, 2024
316c61e
evm template governance and clean generic governance config as well
4meta5 Oct 8, 2024
68122b0
impl xcm for evm template compiles w unused imports
4meta5 Oct 17, 2024
38a5e6d
clean evm template commented out code and init assets impl for evm te…
4meta5 Oct 17, 2024
830ca88
progress on using impl assets for evm template
4meta5 Oct 17, 2024
3083c25
error persists despite moving from impls into scope of macro expansion
4meta5 Oct 17, 2024
f8b0f38
fix imports to fix errors for assets impl for evm template
4meta5 Oct 17, 2024
3eac047
init evm works
4meta5 Oct 17, 2024
08fd70d
generic runtime compiles with most recent changeset
4meta5 Oct 17, 2024
24a93e5
into main without cleaning imports todo update macro expansion to inc…
4meta5 Oct 21, 2024
3fac6a6
update to latest macro changes
4meta5 Oct 21, 2024
2b24598
start merging into still a few things to update
4meta5 Oct 27, 2024
755a86e
move asset manager config into macro expansion as much as possible
4meta5 Oct 27, 2024
83a0496
fix and clean
4meta5 Oct 28, 2024
8130faa
Merge branch 'main' into amar-system-wrapper-poc2
4meta5 Oct 28, 2024
6a7cd0a
update package name use git url and rename marker struct to OpenZeppe…
4meta5 Oct 30, 2024
b25145a
compiles
4meta5 Oct 30, 2024
451375c
batch merge comment suggestions
4meta5 Oct 30, 2024
7a279ad
expose ProxyType and move defn from macro expansion to types file for…
4meta5 Oct 30, 2024
a3c46cf
generic single file config and minimal type aliases
4meta5 Oct 31, 2024
cc7288e
single file evm config need to clean imports and minimize type aliasi…
4meta5 Oct 31, 2024
c2d588b
clean evm template
4meta5 Oct 31, 2024
13ccfa9
generic compiles post macro updates to include 3 more xcm config impls
4meta5 Nov 3, 2024
d73368e
evm compilation post macro updates
4meta5 Nov 3, 2024
2d36540
clean evm runtimes
4meta5 Nov 3, 2024
1c19ca5
clean generic
4meta5 Nov 3, 2024
adfc48f
toml sort
4meta5 Nov 3, 2024
e100d0a
fix
4meta5 Nov 4, 2024
bafb058
Merge branch 'main' into amar-system-wrapper-poc2
4meta5 Nov 4, 2024
34c9c5d
fmt fixes, supported the last changes
KitHat Nov 4, 2024
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
12 changes: 12 additions & 0 deletions evm-template/Cargo.lock

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

3 changes: 3 additions & 0 deletions evm-template/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ serde_derive = { version = "1.0.121", default-features = false }
serde_json = "1.0.121"
smallvec = "1.11.0"

# TODO: update to release
openzeppelin-polkadot-wrappers = { path = "../../polkadot-runtime-wrappers", default-features = false }

# Substrate
frame-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
frame-benchmarking-cli = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, tag = "polkadot-stable2407-1" }
Expand Down
3 changes: 3 additions & 0 deletions evm-template/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ parity-scale-codec = { workspace = true, features = [ "derive" ] }
scale-info = { workspace = true, features = [ "derive" ] }
smallvec = { workspace = true }

openzeppelin-polkadot-wrappers = { workspace = true }

# Substrate
frame-benchmarking = { workspace = true, optional = true }
frame-executive = { workspace = true }
Expand Down Expand Up @@ -141,6 +143,7 @@ std = [
"frame-system/std",
"frame-try-runtime?/std",
"log/std",
"openzeppelin-polkadot-wrappers/std",
"orml-xtokens/std",
"pallet-asset-manager/std",
"pallet-assets/std",
Expand Down
73 changes: 11 additions & 62 deletions evm-template/runtime/src/configs/asset_config.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use frame_support::{
dispatch::GetDispatchInfo, parameter_types, traits::AsEnsureOriginWithArg, weights::Weight,
};
use frame_system::{EnsureRoot, EnsureSigned};
use parity_scale_codec::{Compact, Decode, Encode};
use frame_support::{dispatch::GetDispatchInfo, weights::Weight};
use parity_scale_codec::{Decode, Encode};
use scale_info::TypeInfo;
use sp_core::{H160, H256};
use sp_runtime::traits::Hash as THash;
Expand All @@ -13,21 +10,10 @@ use sp_std::{
use xcm::latest::Location;

use crate::{
constants::currency::{deposit, CENTS, MILLICENTS},
types::{AccountId, AssetId, Balance},
weights, AssetManager, Assets, Balances, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
AssetManager, Assets, Runtime, RuntimeCall, RuntimeOrigin,
};

parameter_types! {
pub const AssetDeposit: Balance = 10 * CENTS;
pub const AssetAccountDeposit: Balance = deposit(1, 16);
pub const ApprovalDeposit: Balance = MILLICENTS;
pub const StringLimit: u32 = 50;
pub const MetadataDepositBase: Balance = deposit(1, 68);
pub const MetadataDepositPerByte: Balance = deposit(0, 1);
pub const RemoveItemsLimit: u32 = 1000;
}

// Required for runtime benchmarks
pallet_assets::runtime_benchmarks_enabled! {
pub struct BenchmarkHelper;
Expand All @@ -41,31 +27,6 @@ pallet_assets::runtime_benchmarks_enabled! {
}
}

// Foreign assets
impl pallet_assets::Config for Runtime {
type ApprovalDeposit = ApprovalDeposit;
type AssetAccountDeposit = AssetAccountDeposit;
type AssetDeposit = AssetDeposit;
type AssetId = AssetId;
type AssetIdParameter = Compact<AssetId>;
type Balance = Balance;
#[cfg(feature = "runtime-benchmarks")]
type BenchmarkHelper = BenchmarkHelper;
type CallbackHandle = ();
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
type Currency = Balances;
type Extra = ();
type ForceOrigin = EnsureRoot<AccountId>;
type Freezer = ();
type MetadataDepositBase = MetadataDepositBase;
type MetadataDepositPerByte = MetadataDepositPerByte;
type RemoveItemsLimit = RemoveItemsLimit;
type RuntimeEvent = RuntimeEvent;
type StringLimit = StringLimit;
/// Rerun benchmarks if you are making changes to runtime configuration.
type WeightInfo = weights::pallet_assets::WeightInfo<Runtime>;
}

// Our AssetType. For now we only handle Xcm Assets
#[derive(Clone, Eq, Debug, PartialEq, Ord, PartialOrd, Encode, Decode, TypeInfo)]
pub enum AssetType {
Expand Down Expand Up @@ -114,6 +75,14 @@ impl From<AssetType> for AssetId {
}
}

#[derive(Clone, Default, Eq, Debug, PartialEq, Ord, PartialOrd, Encode, Decode, TypeInfo)]
pub struct AssetRegistrarMetadata {
pub name: Vec<u8>,
pub symbol: Vec<u8>,
pub decimals: u8,
pub is_frozen: bool,
}

// We instruct how to register the Assets
// In this case, we tell it to Create an Asset in pallet-assets
pub struct AssetRegistrar;
Expand Down Expand Up @@ -165,26 +134,6 @@ impl pallet_asset_manager::AssetRegistrar<Runtime> for AssetRegistrar {
}
}

#[derive(Clone, Default, Eq, Debug, PartialEq, Ord, PartialOrd, Encode, Decode, TypeInfo)]
pub struct AssetRegistrarMetadata {
pub name: Vec<u8>,
pub symbol: Vec<u8>,
pub decimals: u8,
pub is_frozen: bool,
}

impl pallet_asset_manager::Config for Runtime {
type AssetId = AssetId;
type AssetRegistrar = AssetRegistrar;
type AssetRegistrarMetadata = AssetRegistrarMetadata;
type Balance = Balance;
type ForeignAssetModifierOrigin = EnsureRoot<AccountId>;
type ForeignAssetType = AssetType;
type RuntimeEvent = RuntimeEvent;
/// Rerun benchmarks if you are making changes to runtime configuration.
type WeightInfo = weights::pallet_asset_manager::WeightInfo<Runtime>;
}

/// This trait ensure we can convert AccountIds to AssetIds.
pub trait AccountIdAssetIdConversion<Account, AssetId> {
// Get assetId and prefix from account
Expand Down
78 changes: 4 additions & 74 deletions evm-template/runtime/src/configs/governance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,80 +2,10 @@

pub mod origins;
pub use origins::{Spender, WhitelistedCaller};
mod tracks;

use frame_support::{
parameter_types,
traits::{ConstU32, EitherOf},
};
use frame_system::{EnsureRoot, EnsureRootWithSuccess, EnsureSigned};
pub mod tracks;

use crate::{
constants::{
currency::{CENTS, GRAND},
DAYS,
},
types::{AccountId, Balance, BlockNumber},
weights, Balances, Preimage, Referenda, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin,
Scheduler, Treasury,
constants::currency::{CENTS, GRAND},
types::{Balance, BlockNumber},
RuntimeOrigin,
};

parameter_types! {
pub const VoteLockingPeriod: BlockNumber = 7 * DAYS;
}

impl pallet_conviction_voting::Config for Runtime {
type Currency = Balances;
type MaxTurnout =
frame_support::traits::tokens::currency::ActiveIssuanceOf<Balances, Self::AccountId>;
type MaxVotes = ConstU32<512>;
type Polls = Referenda;
type RuntimeEvent = RuntimeEvent;
type VoteLockingPeriod = VoteLockingPeriod;
/// Rerun benchmarks if you are making changes to runtime configuration.
type WeightInfo = weights::pallet_conviction_voting::WeightInfo<Runtime>;
}

parameter_types! {
pub const MaxBalance: Balance = Balance::MAX;
}
pub type TreasurySpender = EitherOf<EnsureRootWithSuccess<AccountId, MaxBalance>, Spender>;

impl origins::pallet_custom_origins::Config for Runtime {}

impl pallet_whitelist::Config for Runtime {
type DispatchWhitelistedOrigin = EitherOf<EnsureRoot<Self::AccountId>, WhitelistedCaller>;
type Preimages = Preimage;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
/// Rerun benchmarks if you are making changes to runtime configuration.
type WeightInfo = weights::pallet_whitelist::WeightInfo<Runtime>;
type WhitelistOrigin = EnsureRoot<Self::AccountId>;
}

parameter_types! {
pub const AlarmInterval: BlockNumber = 1;
pub const SubmissionDeposit: Balance = 3 * CENTS;
pub const UndecidingTimeout: BlockNumber = 14 * DAYS;
}

impl pallet_referenda::Config for Runtime {
type AlarmInterval = AlarmInterval;
type CancelOrigin = EnsureRoot<AccountId>;
type Currency = Balances;
type KillOrigin = EnsureRoot<AccountId>;
type MaxQueued = ConstU32<20>;
type Preimages = Preimage;
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type Scheduler = Scheduler;
type Slash = Treasury;
type SubmissionDeposit = SubmissionDeposit;
type SubmitOrigin = EnsureSigned<AccountId>;
type Tally = pallet_conviction_voting::TallyOf<Runtime>;
type Tracks = tracks::TracksInfo;
type UndecidingTimeout = UndecidingTimeout;
type Votes = pallet_conviction_voting::VotesOf<Runtime>;
/// Rerun benchmarks if you are making changes to runtime configuration.
type WeightInfo = weights::pallet_referenda::WeightInfo<Runtime>;
}
Loading
Loading