Skip to content

Commit

Permalink
Remove migrations and add changelog for devs (#1405)
Browse files Browse the repository at this point in the history
* remove migrations and add changelog for devs

* update copyright
  • Loading branch information
Chralt98 authored Feb 24, 2025
1 parent f322977 commit 36faa40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 67 deletions.
4 changes: 4 additions & 0 deletions docs/changelog_for_devs.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ As of 0.3.9, the changelog's format is based on
components which query the chain's storage, the extrinsics or the runtime
APIs/RPC interface.

## v0.5.7

- Update `AssetId` for `pallet_asset_tx_payment` from `u32` to `MultiLocation`

## v0.5.6

- Increase existential deposit of all non-foreign assets to `BASE`.
Expand Down
70 changes: 3 additions & 67 deletions runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2022-2024 Forecasting Technologies LTD.
// Copyright 2022-2025 Forecasting Technologies LTD.
// Copyright 2021-2022 Zeitgeist PM LLC.
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
//
Expand Down Expand Up @@ -83,79 +83,15 @@ macro_rules! decl_common_types {
use scale_info::TypeInfo;
use sp_core::storage::ChildInfo;
use sp_runtime::{
generic, BoundedBTreeMap, DispatchError, DispatchResult, RuntimeDebug,
SaturatedConversion,
generic, DispatchError, DispatchResult, RuntimeDebug, SaturatedConversion,
};
use zeitgeist_primitives::traits::{DeployPoolApi, DistributeFees, MarketCommonsPalletApi};

pub type Block = generic::Block<Header, UncheckedExtrinsic>;

type Address = sp_runtime::MultiAddress<AccountId, ()>;

type TrieId = BoundedVec<u8, ConstU32<128>>;
type CodeHash = <Runtime as frame_system::Config>::Hash;

// `ContractInfo` struct that we need for `ClearContractsChildTries` but pallet-contracts
// doesn't expose publicly.
#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
pub struct ContractInfo {
pub trie_id: TrieId,
pub code_hash: CodeHash,
pub storage_bytes: u32,
pub storage_items: u32,
pub storage_byte_deposit: Balance,
pub storage_item_deposit: Balance,
pub storage_base_deposit: Balance,
pub delegate_dependencies:
BoundedBTreeMap<CodeHash, Balance, ContractsMaxDelegateDependencies>,
}

struct ClearContractsChildTries;

impl OnRuntimeUpgrade for ClearContractsChildTries {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
log::info!("ClearContractsChildTries: Starting...");
let mut total_reads = 0u64;
let mut total_writes = 0u64;
for (_, contract_info) in storage_key_iter::<AccountId, ContractInfo, Twox64Concat>(
b"Contracts",
b"ContractInfoOf",
) {
let trie_id = contract_info.trie_id;
let inner_trie_id = trie_id.into_inner();
let child_info = ChildInfo::new_default(&inner_trie_id);
let multi_removal_result = child::clear_storage(&child_info, None, None);
let writes = multi_removal_result.loops as u64;
log::info!(
"ClearContractsChildTries: Cleared trie {:?} in {:?} loops",
inner_trie_id,
writes
);
total_reads = total_reads.saturating_add(1);
total_writes = total_writes.saturating_add(writes);
}
log::info!("ClearContractsChildTries: Done!");
<Runtime as frame_system::Config>::DbWeight::get()
.reads_writes(total_reads, total_writes)
}

#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, DispatchError> {
Ok(vec![])
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(_: Vec<u8>) -> Result<(), DispatchError> {
Ok(())
}
}

parameter_types! {
pub const ContractsPalletStr: &'static str = "Contracts";
}
type DeleteContracts = RemovePallet<ContractsPalletStr, RocksDbWeight>;

type Migrations = (ClearContractsChildTries, DeleteContracts);
type Migrations = ();

pub type Executive = frame_executive::Executive<
Runtime,
Expand Down

0 comments on commit 36faa40

Please sign in to comment.