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

Features needed for reserve-backed stablecoins #7152

Merged
merged 49 commits into from
Dec 4, 2020
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
944c129
Features needed for reserve-backed stablecoins
gavofyork Sep 20, 2020
911795a
Builds & tests.
gavofyork Sep 20, 2020
ddf83eb
Double map for an efficient destroy.
gavofyork Sep 20, 2020
9c79b6d
Update frame/assets/src/lib.rs
gavofyork Sep 21, 2020
b8ef2fb
ED/zombie-count/refs
gavofyork Sep 21, 2020
1888155
Merge remote-tracking branch 'origin/gav-assets-extra' into gav-asset…
gavofyork Sep 21, 2020
8bae97f
Merge remote-tracking branch 'origin/master' into gav-assets-extra
gavofyork Sep 25, 2020
4df1054
Update frame/assets/src/lib.rs
gavofyork Sep 25, 2020
aef1d0c
Update frame/assets/Cargo.toml
gavofyork Sep 25, 2020
e302a0e
Merge remote-tracking branch 'origin/master' into gav-assets-extra
gavofyork Oct 1, 2020
b173c37
Docs
gavofyork Oct 2, 2020
6263beb
Merge remote-tracking branch 'origin/master' into gav-assets-extra
gavofyork Oct 2, 2020
fd75591
Some tests
gavofyork Oct 5, 2020
3d03358
More tests
gavofyork Oct 5, 2020
8aa7cc5
Allow for max_zombies to be adjusted
gavofyork Oct 5, 2020
347f2db
Test for set_max_zombies
gavofyork Oct 5, 2020
2d5f752
Tests and a couple of fixes
gavofyork Oct 5, 2020
760ba44
First few benchmarks
gavofyork Oct 8, 2020
b630906
Benchmarks.
gavofyork Oct 8, 2020
39a54ea
Merge remote-tracking branch 'origin/master' into gav-assets-extra
Oct 15, 2020
4d173bc
Merge branch 'gav-assets-extra' of github.com:paritytech/substrate in…
gavofyork Oct 15, 2020
4664812
Fix error message in test
gavofyork Oct 15, 2020
8954764
Fixes
gavofyork Oct 15, 2020
87f311e
Fixes
gavofyork Oct 15, 2020
d12fe90
Fixes
gavofyork Oct 15, 2020
e29b3fa
cargo run --release --features runtime-benchmarks --manifest-path bin…
Oct 15, 2020
85443d2
Update frame/assets/src/lib.rs
gavofyork Oct 16, 2020
b53c1ba
Fixes
gavofyork Oct 16, 2020
6de272f
Merge branch 'gav-assets-extra' of github.com:paritytech/substrate in…
gavofyork Oct 16, 2020
27353a7
Fixes
gavofyork Oct 16, 2020
bbdce2e
Merge remote-tracking branch 'origin/master' into gav-assets-extra
Oct 16, 2020
0b5fa74
Fixes
gavofyork Oct 16, 2020
89cbf7e
Merge branch 'gav-assets-extra' of gthub.com:paritytech/substrate int…
gavofyork Oct 16, 2020
1eff995
cargo run --release --features runtime-benchmarks --manifest-path bin…
Oct 16, 2020
1fe69b1
Fixes
gavofyork Oct 16, 2020
76f2e40
Merge branch 'gav-assets-extra' of github.com:paritytech/substrate in…
gavofyork Oct 16, 2020
a452393
Update default weight
shawntabrizi Oct 17, 2020
402835d
Merge branch 'master' into gav-assets-extra
shawntabrizi Oct 17, 2020
373f4d7
Add proper verification to benchmarks
shawntabrizi Oct 18, 2020
d8b840a
minor improvements to tests
shawntabrizi Oct 18, 2020
13a0cc0
Merge branch 'gav-assets-extra' of github.com:paritytech/substrate in…
gavofyork Nov 9, 2020
e65a75c
Merge remote-tracking branch 'origin/master' into gav-assets-extra
gavofyork Nov 9, 2020
dc0839d
Update frame/assets/src/benchmarking.rs
gavofyork Nov 9, 2020
d0f1829
Fix
gavofyork Nov 9, 2020
45f3c04
Merge branch 'gav-assets-extra' of github.com:paritytech/substrate in…
gavofyork Nov 9, 2020
0286497
Merge remote-tracking branch 'origin/master' into gav-assets-extra
gavofyork Dec 2, 2020
927bcc6
New weights system
gavofyork Dec 2, 2020
a1c43f9
fix compile
shawntabrizi Dec 3, 2020
82bbd66
cargo run --release --features=runtime-benchmarks --manifest-path=bin…
Dec 3, 2020
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
3 changes: 3 additions & 0 deletions 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 bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ frame-support = { version = "2.0.0", default-features = false, path = "../../../
frame-system = { version = "2.0.0", default-features = false, path = "../../../frame/system" }
frame-system-benchmarking = { version = "2.0.0", default-features = false, path = "../../../frame/system/benchmarking", optional = true }
frame-system-rpc-runtime-api = { version = "2.0.0", default-features = false, path = "../../../frame/system/rpc/runtime-api/" }
pallet-assets = { version = "2.0.0", default-features = false, path = "../../../frame/assets" }
pallet-authority-discovery = { version = "2.0.0", default-features = false, path = "../../../frame/authority-discovery" }
pallet-authorship = { version = "2.0.0", default-features = false, path = "../../../frame/authorship" }
pallet-babe = { version = "2.0.0", default-features = false, path = "../../../frame/babe" }
Expand Down Expand Up @@ -89,6 +90,7 @@ default = ["std"]
with-tracing = [ "frame-executive/with-tracing" ]
std = [
"sp-authority-discovery/std",
"pallet-assets/std",
"pallet-authority-discovery/std",
"pallet-authorship/std",
"sp-consensus-babe/std",
Expand Down Expand Up @@ -147,6 +149,7 @@ runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-babe/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
Expand Down
18 changes: 18 additions & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,22 @@ impl pallet_vesting::Trait for Runtime {
type WeightInfo = pallet_vesting::weights::SubstrateWeight<Runtime>;
}

parameter_types! {
pub const AssetDepositBase: Balance = 100 * DOLLARS;
pub const AssetDepositPerZombie: Balance = 1 * DOLLARS;
}

impl pallet_assets::Trait for Runtime {
type Event = Event;
type Balance = u64;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is incompatible with the standard type Balance = u128 defined in the standard Substrate node and node-template. This should use the Balance type to be compatible.

Copy link
Member Author

@gavofyork gavofyork Nov 9, 2020

Choose a reason for hiding this comment

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

u128 is not a "standard" and there is no reason to think that fungible asset pallet balances should necessarily be the same type as a balance elsewhere in the chain.

Copy link
Contributor

Choose a reason for hiding this comment

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

mmh, I guess I would expect a runtime to follow the convention of only having one type named Balance to avoid confusion. I see your point that they can be different in principle, though.

u128 is not a "standard"

maybe standard was the wrong word, I meant standard as in "default" or "configured" or "example"

Copy link
Contributor

@apopiak apopiak Nov 17, 2020

Choose a reason for hiding this comment

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

u128 is not a "standard" and there is no reason to think that fungible asset pallet balances should necessarily be the same type as a balance elsewhere in the chain.

@JesseAbram and I tried setting a Substrate chain up with u64 as the assets Balance type, but polkadot-js assumes that T::Balance equals Balance (the globally defined type), so in practice we are not able to interact with the chain. (This is a similar issue to the other issue you already addressed.)

We'll get in touch with Jaco about improving polkadot-js on this, but until then we need to configure it to be the same concrete type or change the name.

Edit: never mind, we found the typesAlias stuff.

type AssetId = u32;
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: this should probably be a publicly defined type

Copy link
Member Author

Choose a reason for hiding this comment

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

One extra line for near zero gain. Sounds less like a nit-pick and more like a bikeshed.

Copy link
Contributor

Choose a reason for hiding this comment

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

🤷
These suggestions came out of trying to deploy the pallet and are more quality of life stuff than anything else.

type Currency = Balances;
type ForceOrigin = EnsureRoot<AccountId>;
type AssetDepositBase = AssetDepositBase;
type AssetDepositPerZombie = AssetDepositPerZombie;
type WeightInfo = weights::pallet_assets::WeightInfo<Runtime>;
}

construct_runtime!(
pub enum Runtime where
Block = Block,
Expand Down Expand Up @@ -927,6 +943,7 @@ construct_runtime!(
Scheduler: pallet_scheduler::{Module, Call, Storage, Event<T>},
Proxy: pallet_proxy::{Module, Call, Storage, Event<T>},
Multisig: pallet_multisig::{Module, Call, Storage, Event<T>},
Assets: pallet_assets::{Module, Call, Storage, Event<T>},
}
);

Expand Down Expand Up @@ -1193,6 +1210,7 @@ impl_runtime_apis! {
let mut batches = Vec::<BenchmarkBatch>::new();
let params = (&config, &whitelist);

add_benchmark!(params, batches, pallet_assets, Assets);
add_benchmark!(params, batches, pallet_babe, Babe);
add_benchmark!(params, batches, pallet_balances, Balances);
add_benchmark!(params, batches, pallet_collective, Council);
Expand Down
Empty file.
99 changes: 99 additions & 0 deletions bin/node/runtime/src/weights/pallet_assets.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// This file is part of Substrate.

// Copyright (C) 2020 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! Weights for pallet_assets
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0
//! DATE: 2020-10-16, STEPS: [50], REPEAT: 20, LOW RANGE: [], HIGH RANGE: []

#![allow(unused_parens)]
#![allow(unused_imports)]

use frame_support::{traits::Get, weights::Weight};
use sp_std::marker::PhantomData;

pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Trait> pallet_assets::WeightInfo for WeightInfo<T> {
fn create() -> Weight {
(58_069_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn force_create() -> Weight {
(30_401_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn destroy(z: u32, ) -> Weight {
(0 as Weight)
.saturating_add((1_151_000 as Weight).saturating_mul(z as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(z as Weight)))
}
fn force_destroy(z: u32, ) -> Weight {
(0 as Weight)
.saturating_add((1_151_000 as Weight).saturating_mul(z as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().writes((1 as Weight).saturating_mul(z as Weight)))
}
fn mint() -> Weight {
(44_772_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn burn() -> Weight {
(39_564_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight))
}
fn transfer() -> Weight {
(58_453_000 as Weight)
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn force_transfer() -> Weight {
(58_704_000 as Weight)
.saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight))
}
fn freeze() -> Weight {
(43_141_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn thaw() -> Weight {
(42_965_000 as Weight)
.saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn transfer_ownership() -> Weight {
(30_110_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn set_team() -> Weight {
(30_704_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
fn set_max_zombies() -> Weight {
(56_445_000 as Weight)
.saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
}
}
10 changes: 10 additions & 0 deletions frame/assets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,34 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
serde = { version = "1.0.101", optional = true }
codec = { package = "parity-scale-codec", version = "1.3.4", default-features = false }
sp-std = { version = "2.0.0", default-features = false, path = "../../primitives/std" }
# Needed for various traits. In our case, `OnFinalize`.
sp-runtime = { version = "2.0.0", default-features = false, path = "../../primitives/runtime" }
# Needed for type-safe access to storage DB.
frame-support = { version = "2.0.0", default-features = false, path = "../support" }
# `system` module provides us with all sorts of useful stuff and macros depend on it being around.
frame-system = { version = "2.0.0", default-features = false, path = "../system" }
frame-benchmarking = { version = "2.0.0", default-features = false, path = "../benchmarking", optional = true }

[dev-dependencies]
sp-core = { version = "2.0.0", path = "../../primitives/core" }
sp-std = { version = "2.0.0", path = "../../primitives/std" }
sp-io = { version = "2.0.0", path = "../../primitives/io" }
pallet-balances = { version = "2.0.0", default-features = false, path = "../balances" }

[features]
default = ["std"]
std = [
"serde",
"codec/std",
"sp-std/std",
"sp-runtime/std",
"frame-support/std",
"frame-system/std",
"frame-benchmarking/std",
]
runtime-benchmarks = [
"frame-benchmarking",
"sp-runtime/runtime-benchmarks",
"frame-system/runtime-benchmarks",
]
Loading