-
Notifications
You must be signed in to change notification settings - Fork 10
feat(mainnet): introduce assets #465
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
Merged
al3mart
merged 25 commits into
al3mart/refactor-mainnet-config
from
al3mart/refactor-mainnet-assets
Feb 14, 2025
Merged
Changes from 5 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
cf99ad4
refactor(mainnet): include assets
al3mart 726b377
test(assets): add nfts config unit tests
al3mart e614927
refactor(proxy): Add assets & smart contract proxy type
al3mart f8fdeea
refactor(assets): implement nfts runtime api
al3mart 6b4b505
fix(pallet-nfts-api): workspace linters are not defined
al3mart 5c75dc7
docs(assets): clarify deposits
al3mart e94a545
chore(proxy): improve usage of references
al3mart 13a2392
docs(assets): update src reference
al3mart 47b3c92
chore(assets): update MetadataDepositBase
al3mart e5f4212
docs(assets): remove TODOs
al3mart 6a7fb18
refactor(proxy): revert SmartContract ProxyType
al3mart 88f5eab
revert: e614927728f48ae8b176f86ee4207083c062c71a
al3mart fb92342
style(Cargo): revert format changes on dep comments
al3mart 84188ad
chore(assets): apply feedback to tests
al3mart b813b52
chore(assets): removed unused type
al3mart 5263090
revert: fb9234215336ce342c3edb6c15fff56ec2130c98
al3mart 8708e32
docs(assets): better comments
al3mart 976a845
chore(assets): lower nfts deposit costs
al3mart 84790c1
chore(assets): reduced deposit cost for AssetAccountDeposit
al3mart b332ba1
chore(assets): use SDK's pallet_nfts
al3mart 759e51a
chore(assets): better deposits & fmt Cargo
al3mart f10ccd8
chore(assets): better comments
al3mart 645fb3d
chore(assets): more explicit comments for deposits
al3mart 08b3369
chore(assets): provide src for NftsCollectionDeposit deposit
al3mart 098a035
chore(assets): apply feedback
al3mart File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,147 +1,77 @@ | ||
| #![cfg_attr(not(feature = "std"), no_std)] | ||
| use frame_support::weights::{constants::WEIGHT_REF_TIME_PER_SECOND, Weight}; | ||
| // Cumulus types re-export | ||
| // These types are shared between the devnet and testnet runtimes | ||
| pub use parachains_common::{AccountId, AuraId, Balance, Block, BlockNumber, Hash, Signature}; | ||
| pub use polkadot_primitives::MAX_POV_SIZE; | ||
| use sp_runtime::Perbill; | ||
|
|
||
| pub mod proxy; | ||
|
|
||
| /// Nonce for an account | ||
| pub type Nonce = u32; | ||
|
|
||
| #[docify::export] | ||
| mod block_times { | ||
| /// This determines the average expected block time that we are targeting. | ||
| /// Blocks will be produced at a minimum duration defined by `SLOT_DURATION`. | ||
| /// `SLOT_DURATION` is picked up by `pallet_timestamp` which is in turn picked | ||
| /// up by `pallet_aura` to implement `fn slot_duration()`. | ||
| /// | ||
| /// Change this to adjust the block time. | ||
| pub const MILLISECS_PER_BLOCK: u64 = 6000; | ||
| /// The duration of a slot. | ||
| // NOTE: Currently it is not possible to change the slot duration after the chain has started. | ||
| // Attempting to do so will brick block production. | ||
| pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; | ||
| } | ||
| pub use block_times::*; | ||
|
|
||
| // Time is measured by number of blocks. | ||
| /// A minute, measured by number of blocks. | ||
| pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); | ||
| /// An hour, measured by number of blocks. | ||
| pub const HOURS: BlockNumber = MINUTES * 60; | ||
| /// A day, measured by number of blocks. | ||
| pub const DAYS: BlockNumber = HOURS * 24; | ||
|
|
||
| /// We assume that ~5% of the block weight is consumed by `on_initialize` handlers. This is | ||
| /// used to limit the maximal weight of a single extrinsic. | ||
| pub const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(5); | ||
|
|
||
| /// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used by | ||
| /// `Operational` extrinsics. | ||
| pub const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75); | ||
|
|
||
| /// We allow for 2 seconds of compute with a 6-second average block. | ||
| #[docify::export(max_block_weight)] | ||
| pub const MAXIMUM_BLOCK_WEIGHT: Weight = | ||
| Weight::from_parts(WEIGHT_REF_TIME_PER_SECOND.saturating_mul(2), MAX_POV_SIZE as u64); | ||
|
|
||
| /// A unit of the native asset. | ||
| pub const UNIT: Balance = 10_000_000_000; // 10 decimals | ||
| /// A milli-unit of the native asset. | ||
| pub const MILLI_UNIT: Balance = UNIT / 1_000; // 10_000_000 | ||
| /// A micro-unit of the native asset. | ||
| pub const MICRO_UNIT: Balance = UNIT / 1_000_000; // 10_000 | ||
|
|
||
| /// Deposits. | ||
| pub const fn deposit(items: u32, bytes: u32) -> Balance { | ||
| (items as Balance * UNIT + (bytes as Balance) * (5 * MILLI_UNIT / 100)) / 10 | ||
| } | ||
| /// The existential deposit. Set to 1/1_000 of the Connected Relay Chain. | ||
| pub const EXISTENTIAL_DEPOSIT: Balance = MILLI_UNIT; | ||
|
|
||
| #[docify::export] | ||
| mod async_backing_params { | ||
| /// Maximum number of blocks simultaneously accepted by the Runtime, not yet included | ||
| /// into the relay chain. | ||
| pub const UNINCLUDED_SEGMENT_CAPACITY: u32 = 3; | ||
| /// How many parachain blocks are processed by the relay chain per parent. Limits the | ||
| /// number of blocks authored per slot. | ||
| pub const BLOCK_PROCESSING_VELOCITY: u32 = 1; | ||
| /// Relay chain slot duration, in milliseconds. | ||
| // Value is 6000 millisecs. If `MILLISECS_PER_BLOCK` changes this needs addressing. | ||
| pub const RELAY_CHAIN_SLOT_DURATION_MILLIS: u32 = 6000; | ||
| } | ||
| pub use async_backing_params::*; | ||
|
Check warning on line 77 in runtime/common/src/lib.rs
|
||
|
|
||
| /// Proxy commons for Pop runtimes | ||
| pub mod proxy { | ||
|
|
||
| use codec::{Decode, Encode, MaxEncodedLen}; | ||
| use frame_support::parameter_types; | ||
| use sp_runtime::RuntimeDebug; | ||
|
|
||
| use super::{deposit, Balance}; | ||
|
|
||
| parameter_types! { | ||
| // One storage item; key size 32, value size 8; . | ||
| pub const ProxyDepositBase: Balance = deposit(1, 40); | ||
| // Additional storage item size of 33 bytes. | ||
| pub const ProxyDepositFactor: Balance = deposit(0, 33); | ||
| pub const MaxProxies: u16 = 32; | ||
| // One storage item; key size 32, value size 16 | ||
| pub const AnnouncementDepositBase: Balance = deposit(1, 48); | ||
| pub const AnnouncementDepositFactor: Balance = deposit(0, 66); | ||
| pub const MaxPending: u16 = 32; | ||
| } | ||
|
|
||
| /// The type used to represent the kinds of proxying allowed. | ||
| #[derive( | ||
| Copy, | ||
| Clone, | ||
| Eq, | ||
| PartialEq, | ||
| Ord, | ||
| PartialOrd, | ||
| Encode, | ||
| Decode, | ||
| RuntimeDebug, | ||
| MaxEncodedLen, | ||
| scale_info::TypeInfo, | ||
| )] | ||
| pub enum ProxyType { | ||
| /// Fully permissioned proxy. Can execute any call on behalf of _proxied_. | ||
| Any, | ||
| /// Can execute any call that does not transfer funds or assets. | ||
| NonTransfer, | ||
| /// Proxy with the ability to reject time-delay proxy announcements. | ||
| CancelProxy, | ||
| /// Assets proxy. Can execute any call from `assets`, **including asset transfers**. | ||
| Assets, | ||
| /// Owner proxy. Can execute calls related to asset ownership. | ||
| AssetOwner, | ||
| /// Asset manager. Can execute calls related to asset management. | ||
| AssetManager, | ||
| /// Collator selection proxy. Can execute calls related to collator selection mechanism. | ||
| Collator, | ||
| } | ||
| impl Default for ProxyType { | ||
| fn default() -> Self { | ||
| Self::Any | ||
| } | ||
| } | ||
|
|
||
| impl ProxyType { | ||
| pub fn is_superset(s: &ProxyType, o: &ProxyType) -> bool { | ||
| match (s, o) { | ||
| (x, y) if x == y => true, | ||
| (ProxyType::Any, _) => true, | ||
| (_, ProxyType::Any) => false, | ||
| (ProxyType::Assets, ProxyType::AssetOwner) => true, | ||
| (ProxyType::Assets, ProxyType::AssetManager) => true, | ||
| (ProxyType::NonTransfer, ProxyType::Collator) => true, | ||
| _ => false, | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| /// Proxy commons for Pop runtimes | ||
| use codec::{Decode, Encode, MaxEncodedLen}; | ||
| use frame_support::parameter_types; | ||
| use sp_runtime::RuntimeDebug; | ||
|
|
||
| use crate::{deposit, Balance}; | ||
|
|
||
| parameter_types! { | ||
| // One storage item; key size 32, value size 8; . | ||
| pub const ProxyDepositBase: Balance = deposit(1, 40); | ||
| // Additional storage item size of 33 bytes. | ||
| pub const ProxyDepositFactor: Balance = deposit(0, 33); | ||
| pub const MaxProxies: u16 = 32; | ||
| // One storage item; key size 32, value size 16 | ||
| pub const AnnouncementDepositBase: Balance = deposit(1, 48); | ||
| pub const AnnouncementDepositFactor: Balance = deposit(0, 66); | ||
| pub const MaxPending: u16 = 32; | ||
| } | ||
|
|
||
| /// The type used to represent the kinds of proxying allowed. | ||
| #[derive( | ||
| Copy, | ||
| Clone, | ||
| Eq, | ||
| PartialEq, | ||
| Ord, | ||
| PartialOrd, | ||
| Encode, | ||
| Decode, | ||
| RuntimeDebug, | ||
| MaxEncodedLen, | ||
| scale_info::TypeInfo, | ||
| )] | ||
| pub enum ProxyType { | ||
| /// Fully permissioned proxy. Can execute any call on behalf of _proxied_. | ||
| Any, | ||
| /// Can execute any call that does not transfer funds or assets. | ||
| NonTransfer, | ||
| /// Proxy with the ability to reject time-delay proxy announcements. | ||
| CancelProxy, | ||
| /// Assets proxy. Can execute any call from `assets`, **including asset transfers**. | ||
| Assets, | ||
| /// Owner proxy. Can execute calls related to asset ownership. | ||
| AssetOwner, | ||
| /// Asset manager. Can execute calls related to asset management. | ||
| AssetManager, | ||
| /// Collator selection proxy. Can execute calls related to collator selection mechanism. | ||
| Collator, | ||
| /// Smart contract proxy. Can execute calls related to smart contract management. | ||
| SmartContract, | ||
Daanvdplas marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| impl Default for ProxyType { | ||
| fn default() -> Self { | ||
| Self::Any | ||
| } | ||
| } | ||
|
|
||
| impl ProxyType { | ||
| /// Defines proxies permission hierarchy. | ||
| // Example: A proxy that is not superset of another one won't be able to remove | ||
| // that proxy relationship | ||
| // src: https://github.com/paritytech/polkadot-sdk/blob/4cd07c56378291fddb9fceab3b508cf99034126a/substrate/frame/proxy/src/lib.rs#L802 | ||
| pub fn is_superset(s: &ProxyType, o: &ProxyType) -> bool { | ||
| match (s, o) { | ||
| (x, y) if x == y => true, | ||
| (ProxyType::Any, _) => true, | ||
| (_, ProxyType::Any) => false, | ||
| (ProxyType::Assets, ProxyType::AssetOwner) => true, | ||
| (ProxyType::Assets, ProxyType::AssetManager) => true, | ||
| (ProxyType::NonTransfer, ProxyType::Collator) => true, | ||
| _ => false, | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.