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

Commit

Permalink
Features needed for reserve-backed stablecoins (#7152)
Browse files Browse the repository at this point in the history
* Features needed for reserve-backed stablecoins

* Builds & tests.

* Double map for an efficient destroy.

* Update frame/assets/src/lib.rs

Co-authored-by: Nikolay Volf <[email protected]>

* ED/zombie-count/refs

Feature: ED/minimum balance enforcement
Feature: enforce zombie count
Feature: allow system-alive accounts to exist, but add reference

* Update frame/assets/src/lib.rs

Co-authored-by: Nikolay Volf <[email protected]>

* Update frame/assets/Cargo.toml

Co-authored-by: Niklas Adolfsson <[email protected]>

* Docs

* Some tests

* More tests

* Allow for max_zombies to be adjusted

* Test for set_max_zombies

* Tests and a couple of fixes

* First few benchmarks

* Benchmarks.

* Fix error message in test

* Fixes

* Fixes

* Fixes

* cargo run --release --features runtime-benchmarks --manifest-path bin/node/cli/Cargo.toml -- benchmark --chain dev --steps 50 --repeat 20 --extrinsic * --execution=wasm --wasm-execution=compiled --output ./bin/node/runtime/src/weights --header ./HEADER --pallet pallet_assets

* Update frame/assets/src/lib.rs

Co-authored-by: Guillaume Thiolliere <[email protected]>

* Fixes

* Fixes

* Fixes

* cargo run --release --features runtime-benchmarks --manifest-path bin/node/cli/Cargo.toml -- benchmark --chain dev --steps 50 --repeat 20 --extrinsic * --execution=wasm --wasm-execution=compiled --output ./bin/node/runtime/src/weights --header ./HEADER --pallet pallet_assets

* Fixes

* Update default weight

* Add proper verification to benchmarks

* minor improvements to tests

* Update frame/assets/src/benchmarking.rs

Co-authored-by: Kian Paimani <[email protected]>

* Fix

* New weights system

* fix compile

* cargo run --release --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark --chain=dev --steps=50 --repeat=20 --pallet=pallet_assets --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/assets/src/weights.rs --template=./.maintain/frame-weight-template.hbs

Co-authored-by: Nikolay Volf <[email protected]>
Co-authored-by: Niklas Adolfsson <[email protected]>
Co-authored-by: Parity Benchmarking Bot <[email protected]>
Co-authored-by: Guillaume Thiolliere <[email protected]>
Co-authored-by: Shawn Tabrizi <[email protected]>
Co-authored-by: Kian Paimani <[email protected]>
  • Loading branch information
7 people authored Dec 4, 2020
1 parent f73ac5e commit 1802283
Show file tree
Hide file tree
Showing 10 changed files with 1,612 additions and 179 deletions.
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 @@ -892,6 +892,22 @@ impl pallet_vesting::Config 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::Config for Runtime {
type Event = Event;
type Balance = u64;
type AssetId = u32;
type Currency = Balances;
type ForceOrigin = EnsureRoot<AccountId>;
type AssetDepositBase = AssetDepositBase;
type AssetDepositPerZombie = AssetDepositPerZombie;
type WeightInfo = pallet_assets::weights::SubstrateWeight<Runtime>;
}

construct_runtime!(
pub enum Runtime where
Block = Block,
Expand Down Expand Up @@ -929,6 +945,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 @@ -1195,6 +1212,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
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

0 comments on commit 1802283

Please sign in to comment.