From 33c4750600f616f9b436904167fcb928c22e86ca Mon Sep 17 00:00:00 2001 From: bear Date: Fri, 19 Aug 2022 11:21:07 +0800 Subject: [PATCH] Delete the staled order (#1407) Co-authored-by: Xavier Lau --- node/runtime/pangolin/src/migrations.rs | 24 ++++++++++++++++++++++-- node/runtime/pangoro/src/migrations.rs | 24 ++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/node/runtime/pangolin/src/migrations.rs b/node/runtime/pangolin/src/migrations.rs index ece5346e12..2e09a94a2d 100644 --- a/node/runtime/pangolin/src/migrations.rs +++ b/node/runtime/pangolin/src/migrations.rs @@ -23,6 +23,26 @@ impl OnRuntimeUpgrade for CustomOnRuntimeUpgrade { } fn migrate() -> Weight { - 0 - // RuntimeBlockWeights::get().max_block + // --- paritytech --- + use frame_support::{migration::storage_key_iter, Blake2_128Concat}; + // --- darwinia-network --- + use bp_messages::{LaneId, MessageNonce}; + use pallet_fee_market::{types::Order, Orders}; + + let module: &[u8] = b"PangoroFeeMarket"; + let item: &[u8] = b"Orders"; + for ((lane_id, nonce), order) in storage_key_iter::< + (LaneId, MessageNonce), + Order, + Blake2_128Concat, + >(module, item) + .drain() + { + if lane_id != [0, 0, 0, 0] || lane_id != [0, 0, 0, 1] { + Orders::::insert((lane_id, nonce), order); + } + } + + // 0 + RuntimeBlockWeights::get().max_block } diff --git a/node/runtime/pangoro/src/migrations.rs b/node/runtime/pangoro/src/migrations.rs index ece5346e12..241451329b 100644 --- a/node/runtime/pangoro/src/migrations.rs +++ b/node/runtime/pangoro/src/migrations.rs @@ -23,6 +23,26 @@ impl OnRuntimeUpgrade for CustomOnRuntimeUpgrade { } fn migrate() -> Weight { - 0 - // RuntimeBlockWeights::get().max_block + // --- paritytech --- + use frame_support::{migration::storage_key_iter, Blake2_128Concat}; + // --- darwinia-network --- + use bp_messages::{LaneId, MessageNonce}; + use pallet_fee_market::{types::Order, Orders}; + + let module: &[u8] = b"PangolinFeeMarket"; + let item: &[u8] = b"Orders"; + for ((lane_id, nonce), order) in storage_key_iter::< + (LaneId, MessageNonce), + Order, + Blake2_128Concat, + >(module, item) + .drain() + { + if lane_id != [0, 0, 0, 0] || lane_id != [0, 0, 0, 1] { + Orders::::insert((lane_id, nonce), order); + } + } + + // 0 + RuntimeBlockWeights::get().max_block }