-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: cleanup aborted broadcasts (#5301)
* feat: cleanup aborted broadcasts * refactor: use housekeeping migration * refactor: remove stale from perseverance as well * chore: remove left over structs
- Loading branch information
Showing
5 changed files
with
114 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
state-chain/pallets/cf-broadcast/src/migrations/remove_aborted_broadcasts.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use crate::*; | ||
|
||
// Highest stale aborted broadcasts as of 3/10/2024: | ||
// Mainnet | ||
pub const ETHEREUM_MAX_ABORTED_BROADCAST_BERGHAIN: BroadcastId = 11592; | ||
pub const ARBITRUM_MAX_ABORTED_BROADCAST_BERGHAIN: BroadcastId = 426; | ||
// Perseverance testnet | ||
pub const ETHEREUM_MAX_ABORTED_BROADCAST_PERSEVERANCE: BroadcastId = 1609; | ||
pub const ARBITRUM_MAX_ABORTED_BROADCAST_PERSEVERANCE: BroadcastId = 665; | ||
pub const POLKADOT_MAX_ABORTED_BROADCAST_PERSEVERANCE: BroadcastId = 634; | ||
|
||
pub fn remove_stale_and_all_older<T: Config<I>, I: 'static>(latest_stale_broadcast: BroadcastId) { | ||
AbortedBroadcasts::<T, I>::mutate(|aborted| { | ||
aborted.retain(|id| id > &latest_stale_broadcast); | ||
}); | ||
} | ||
|
||
#[cfg(feature = "try-runtime")] | ||
pub fn assert_removed<T: Config<I>, I: 'static>(latest_stale_broadcast: BroadcastId) { | ||
let aborted_broadcasts = AbortedBroadcasts::<T, I>::get(); | ||
if let Some(first) = aborted_broadcasts.first() { | ||
assert!(*first > latest_stale_broadcast, "Aborted broadcast {first} was not removed"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters