Skip to content

Commit

Permalink
impl rate limit for xtokens (#854)
Browse files Browse the repository at this point in the history
* poc

* add RateLimiter for xtokens

* impl new pallet orml-rate-limit

* add unit tests

* add comment

* add weight

* update

* use explicit call index

* fix features

* update Cargo.toml

---------

Co-authored-by: Bryan Chen <xlchen1291@gmail.com>
Co-authored-by: zjb0807 <zjb0807@qq.com>
  • Loading branch information
3 people authored Mar 5, 2024
1 parent d26b0b1 commit 7e05827
Show file tree
Hide file tree
Showing 15 changed files with 1,758 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Cargo.dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ members = [
"oracle/runtime-api",
"parameters",
"payments",
"rate-limit",
"rewards",
"tokens",
"tokens/runtime-api",
Expand Down Expand Up @@ -47,6 +48,7 @@ pallet-message-queue = { version = "32.0.0", default-features = false }
pallet-preimage = { version = "29.0.0", default-features = false }
pallet-root-testing = { version = "5.0.0", default-features = false }
pallet-scheduler = { version = "30.0.0", default-features = false }
pallet-timestamp = { version = "28.0.0", default-features = false }
pallet-treasury = { version = "28.0.0", default-features = false }
pallet-xcm = { version = "8.0.0", default-features = false }
polkadot-parachain-primitives = { version = "7.0.0", default-features = false }
Expand Down
2 changes: 2 additions & 0 deletions asset-registry/src/mock/para.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ impl orml_xtokens::Config for Runtime {
type UniversalLocation = UniversalLocation;
type MaxAssetsForTransfer = MaxAssetsForTransfer;
type ReserveProvider = RelativeReserveProvider;
type RateLimiter = ();
type RateLimiterId = ();
}

impl orml_xcm::Config for Runtime {
Expand Down
52 changes: 52 additions & 0 deletions rate-limit/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[package]
name = "orml-rate-limit"
description = "Provides way to config rate limiter for limit some operation."
repository = "https://github.com/open-web3-stack/open-runtime-module-library/tree/master/rate-limit"
license = "Apache-2.0"
version = "0.7.0"
authors = ["Laminar Developers <hello@laminar.one>"]
edition = "2021"

[dependencies]
parity-scale-codec = { workspace = true }
scale-info = { workspace = true }
serde = { workspace = true, optional = true }

frame-support = { workspace = true }
frame-system = { workspace = true }
sp-core = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }

orml-traits = { path = "../traits", version = "0.7.0", default-features = false }
orml-utilities = { path = "../utilities", version = "0.7.0", default-features = false }

[dev-dependencies]
pallet-timestamp = { workspace = true, features = ["std"] }

[features]
default = [ "std" ]
std = [
"frame-support/std",
"frame-system/std",
"orml-traits/std",
"orml-utilities/std",
"parity-scale-codec/std",
"scale-info/std",
"serde",
"sp-core/std",
"sp-io/std",
"sp-runtime/std",
"sp-std/std",
]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
]
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"sp-runtime/try-runtime",
]
Loading

0 comments on commit 7e05827

Please sign in to comment.