Skip to content

Commit

Permalink
Actually Lower ED (#158)
Browse files Browse the repository at this point in the history
Since #115, chains do
not use their local `constants.rs` values, so
#131 did not have the
desired effect.

Would suggest a special Asset Hub 1.1.1 release to get this deployed as
soon as possible since a lot of applications were planning on it.
  • Loading branch information
joepetrowski authored and ggwpez committed Jan 25, 2024
1 parent 45cb7b4 commit ab047c2
Show file tree
Hide file tree
Showing 22 changed files with 121 additions and 616 deletions.
5 changes: 0 additions & 5 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion system-parachains/asset-hubs/asset-hub-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
hex-literal = { version = "0.4.1" }
log = { version = "0.4.20", default-features = false }
scale-info = { version = "2.9.0", default-features = false, features = ["derive"] }
smallvec = "1.11.0"

# Local
bp-asset-hub-kusama = { path = "./primitives", default-features = false}
Expand Down
106 changes: 0 additions & 106 deletions system-parachains/asset-hubs/asset-hub-kusama/src/constants.rs

This file was deleted.

36 changes: 18 additions & 18 deletions system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ impl pallet_authorship::Config for Runtime {
}

parameter_types! {
pub const ExistentialDeposit: Balance = EXISTENTIAL_DEPOSIT;
// This comes from system_parachains_constants::kusama::currency and is the ED for all system
// parachains. For Asset Hub in particular, we set it to 1/10th of the amount.
pub const ExistentialDeposit: Balance = SYSTEM_PARA_EXISTENTIAL_DEPOSIT / 10;
}

impl pallet_balances::Config for Runtime {
Expand Down Expand Up @@ -249,13 +251,12 @@ impl pallet_transaction_payment::Config for Runtime {

parameter_types! {
pub const AssetDeposit: Balance = UNITS / 10; // 1 / 10 UNITS deposit to create asset
pub const AssetAccountDeposit: Balance = deposit(1, 16);
pub const ApprovalDeposit: Balance = EXISTENTIAL_DEPOSIT;
pub const AssetAccountDeposit: Balance = system_para_deposit(1, 16);
pub const AssetsStringLimit: u32 = 50;
/// Key = 32 bytes, Value = 36 bytes (32+1+1+1+1)
// https://github.com/paritytech/substrate/blob/069917b/frame/assets/src/lib.rs#L257L271
pub const MetadataDepositBase: Balance = deposit(1, 68);
pub const MetadataDepositPerByte: Balance = deposit(0, 1);
pub const MetadataDepositBase: Balance = system_para_deposit(1, 68);
pub const MetadataDepositPerByte: Balance = system_para_deposit(0, 1);
}

/// We allow root to execute privileged asset operations.
Expand All @@ -277,7 +278,7 @@ impl pallet_assets::Config<TrustBackedAssetsInstance> for Runtime {
type AssetDeposit = AssetDeposit;
type MetadataDepositBase = MetadataDepositBase;
type MetadataDepositPerByte = MetadataDepositPerByte;
type ApprovalDeposit = ApprovalDeposit;
type ApprovalDeposit = ExistentialDeposit;
type StringLimit = AssetsStringLimit;
type Freezer = ();
type Extra = ();
Expand Down Expand Up @@ -317,7 +318,7 @@ impl pallet_assets::Config<PoolAssetsInstance> for Runtime {
type AssetAccountDeposit = ConstU128<0>;
type MetadataDepositBase = ConstU128<0>;
type MetadataDepositPerByte = ConstU128<0>;
type ApprovalDeposit = ApprovalDeposit;
type ApprovalDeposit = ExistentialDeposit;
type StringLimit = ConstU32<50>;
type Freezer = ();
type Extra = ();
Expand Down Expand Up @@ -363,7 +364,6 @@ parameter_types! {
// we just reuse the same deposits
pub const ForeignAssetsAssetDeposit: Balance = AssetDeposit::get();
pub const ForeignAssetsAssetAccountDeposit: Balance = AssetAccountDeposit::get();
pub const ForeignAssetsApprovalDeposit: Balance = ApprovalDeposit::get();
pub const ForeignAssetsAssetsStringLimit: u32 = AssetsStringLimit::get();
pub const ForeignAssetsMetadataDepositBase: Balance = MetadataDepositBase::get();
pub const ForeignAssetsMetadataDepositPerByte: Balance = MetadataDepositPerByte::get();
Expand All @@ -389,7 +389,7 @@ impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {
type AssetDeposit = ForeignAssetsAssetDeposit;
type MetadataDepositBase = ForeignAssetsMetadataDepositBase;
type MetadataDepositPerByte = ForeignAssetsMetadataDepositPerByte;
type ApprovalDeposit = ForeignAssetsApprovalDeposit;
type ApprovalDeposit = ExistentialDeposit;
type StringLimit = ForeignAssetsAssetsStringLimit;
type Freezer = ();
type Extra = ();
Expand All @@ -403,9 +403,9 @@ impl pallet_assets::Config<ForeignAssetsInstance> for Runtime {

parameter_types! {
// One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes.
pub const DepositBase: Balance = deposit(1, 88);
pub const DepositBase: Balance = system_para_deposit(1, 88);
// Additional storage item size of 32 bytes.
pub const DepositFactor: Balance = deposit(0, 32);
pub const DepositFactor: Balance = system_para_deposit(0, 32);
pub const MaxSignatories: u32 = 100;
}

Expand All @@ -428,13 +428,13 @@ impl pallet_utility::Config for Runtime {

parameter_types! {
// One storage item; key size 32, value size 8; .
pub const ProxyDepositBase: Balance = deposit(1, 40);
pub const ProxyDepositBase: Balance = system_para_deposit(1, 40);
// Additional storage item size of 33 bytes.
pub const ProxyDepositFactor: Balance = deposit(0, 33);
pub const ProxyDepositFactor: Balance = system_para_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 AnnouncementDepositBase: Balance = system_para_deposit(1, 48);
pub const AnnouncementDepositFactor: Balance = system_para_deposit(0, 66);
pub const MaxPending: u16 = 32;
}

Expand Down Expand Up @@ -744,9 +744,9 @@ impl pallet_asset_conversion_tx_payment::Config for Runtime {
parameter_types! {
pub const UniquesCollectionDeposit: Balance = UNITS / 10; // 1 / 10 UNIT deposit to create a collection
pub const UniquesItemDeposit: Balance = UNITS / 1_000; // 1 / 1000 UNIT deposit to mint an item
pub const UniquesMetadataDepositBase: Balance = deposit(1, 129);
pub const UniquesAttributeDepositBase: Balance = deposit(1, 0);
pub const UniquesDepositPerByte: Balance = deposit(0, 1);
pub const UniquesMetadataDepositBase: Balance = system_para_deposit(1, 129);
pub const UniquesAttributeDepositBase: Balance = system_para_deposit(1, 0);
pub const UniquesDepositPerByte: Balance = system_para_deposit(0, 1);
}

impl pallet_uniques::Config for Runtime {
Expand Down
19 changes: 18 additions & 1 deletion system-parachains/asset-hubs/asset-hub-kusama/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@ fn collator_session_keys() -> CollatorSessionKeys<Runtime> {
)
}

#[test]
fn test_ed_is_one_hundredth_of_relay() {
ExtBuilder::<Runtime>::default()
.with_collators(vec![AccountId::from(ALICE)])
.with_session_keys(vec![(
AccountId::from(ALICE),
AccountId::from(ALICE),
SessionKeys { aura: AuraId::from(sp_core::sr25519::Public::from_raw(ALICE)) },
)])
.build()
.execute_with(|| {
let relay_ed = kusama_runtime_constants::currency::EXISTENTIAL_DEPOSIT;
let asset_hub_ed = ExistentialDeposit::get();
assert_eq!(relay_ed / 100, asset_hub_ed);
});
}

#[test]
fn test_asset_xcm_trader() {
ExtBuilder::<Runtime>::default()
Expand Down Expand Up @@ -257,7 +274,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() {
RuntimeHelper::run_to_block(2, AccountId::from(ALICE));

// We are going to buy small amount
let bought = Weight::from_parts(500_000_000u64, 0);
let bought = Weight::from_parts(50_000_000u64, 0);

let asset_multilocation = AssetIdForTrustBackedAssetsConvert::convert_back(&1).unwrap();

Expand Down
1 change: 0 additions & 1 deletion system-parachains/asset-hubs/asset-hub-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ codec = { package = "parity-scale-codec", version = "3.0.0", default-features =
hex-literal = { version = "0.4.1", optional = true }
log = { version = "0.4.20", default-features = false }
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
smallvec = "1.11.1"

# Local
bp-asset-hub-kusama = { path = "../asset-hub-kusama/primitives", default-features = false}
Expand Down
Loading

0 comments on commit ab047c2

Please sign in to comment.