Skip to content

Commit 69715be

Browse files
committed
Migrate pallet-subtensor's rate limiting to pallet-rate-limiting
1 parent 7705637 commit 69715be

File tree

6 files changed

+751
-1
lines changed

6 files changed

+751
-1
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pallets/rate-limiting/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,18 @@ pub mod pallet {
393393
true
394394
}
395395

396+
/// Inserts or updates the cached usage timestamp for a rate-limited call.
397+
///
398+
/// This is primarily intended for migrations that need to hydrate the new tracking storage
399+
/// from legacy pallets.
400+
pub fn record_last_seen(
401+
identifier: &TransactionIdentifier,
402+
usage_key: Option<<T as Config<I>>::UsageKey>,
403+
block_number: BlockNumberFor<T>,
404+
) {
405+
LastSeen::<T, I>::insert(identifier, usage_key, block_number);
406+
}
407+
396408
/// Migrates a stored rate limit configuration from one scope to another.
397409
///
398410
/// Returns `true` when an entry was moved. Passing identical `from`/`to` scopes simply

pallets/subtensor/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ sha2.workspace = true
5555
rand_chacha.workspace = true
5656
pallet-crowdloan.workspace = true
5757
pallet-subtensor-proxy.workspace = true
58+
pallet-rate-limiting.workspace = true
5859

5960
[dev-dependencies]
6061
pallet-balances = { workspace = true, features = ["std"] }
@@ -112,6 +113,7 @@ std = [
112113
"pallet-crowdloan/std",
113114
"pallet-drand/std",
114115
"pallet-subtensor-proxy/std",
116+
"pallet-rate-limiting/std",
115117
"pallet-subtensor-swap/std",
116118
"subtensor-swap-interface/std",
117119
"pallet-subtensor-utility/std",

runtime/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ sp-inherents.workspace = true
5353
sp-offchain.workspace = true
5454
sp-runtime.workspace = true
5555
sp-session.workspace = true
56+
sp-io.workspace = true
5657
sp-std.workspace = true
5758
sp-transaction-pool.workspace = true
5859
sp-version.workspace = true
@@ -154,7 +155,6 @@ ethereum.workspace = true
154155

155156
[dev-dependencies]
156157
frame-metadata.workspace = true
157-
sp-io.workspace = true
158158
sp-tracing.workspace = true
159159

160160
[build-dependencies]

0 commit comments

Comments
 (0)