contracts_mbm/
lib.rs

1// This file is part of Astar.
2
3// Copyright (C) Stake Technologies Pte.Ltd.
4// SPDX-License-Identifier: GPL-3.0-or-later
5
6// Astar is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10
11// Astar is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License
17// along with Astar. If not, see <http://www.gnu.org/licenses/>.
18
19//! # Contracts MBM
20//!
21//! Multi block migrations decommissioning `pallet-contracts` (ink!/Wasm smart contracts) from the
22//! Astar, Shiden & Shibuya runtimes. Staged over two runtime upgrades:
23//!
24//! 1. *(shipped)* `ReleaseContractsDeposits` - settled every balance the pallet still held. It had
25//!    to complete before the pallet index was dropped, otherwise those holds would have become
26//!    undecodable and the funds frozen for good. Removed here, along with the pallet: without the
27//!    `RuntimeHoldReason::Contracts` variant there is nothing left for it to match on.
28//! 2. [`PurgeContractsChildTries`] then [`RemovePalletStepped`] - purge the contract child tries
29//!    and the leftover pallet prefixes, in that order.
30//!
31//! Both are size aware: every value is measured before it is deleted and charged through
32//! benchmarked, size dependent weights, so a run of large values (`Contracts::PristineCode` blobs,
33//! up to 123 KiB each) cannot produce a PoV oversized block.
34
35#![cfg_attr(not(feature = "std"), no_std)]
36
37#[cfg(feature = "runtime-benchmarks")]
38mod benchmarks;
39#[cfg(test)]
40mod mock;
41#[cfg(test)]
42mod tests;
43
44mod purge;
45pub use purge::{
46    MaxKeyLen, PurgeContractsChildTries, RemovePalletStepped, TrieId, CONTRACT_INFO_OF,
47    DELETION_QUEUE, MAX_KEYS_PER_STEP, TRIE_ID_LEN,
48};
49
50pub mod weights;
51pub use weights::WeightInfo;
52
53pub use pallet::*;
54
55pub(crate) const LOG_TARGET: &str = "mbm::contracts";
56
57#[frame_support::pallet]
58pub mod pallet {
59    /// Carries no storage and no calls. It exists only so that the migrations in this crate can
60    /// be benchmarked through the standard `benchmark pallet` tooling, and is therefore added to
61    /// the runtimes under `runtime-benchmarks` only.
62    #[pallet::pallet]
63    #[pallet::without_storage_info]
64    pub struct Pallet<T>(_);
65
66    #[pallet::config]
67    pub trait Config: frame_system::Config {}
68}