diff --git a/pallets/moonbeam-lazy-migrations/src/benchmarks.rs b/pallets/moonbeam-lazy-migrations/src/benchmarks.rs
deleted file mode 100644
index 9bdcd2d63c..0000000000
--- a/pallets/moonbeam-lazy-migrations/src/benchmarks.rs
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright 2024 Moonbeam foundation
-// This file is part of Moonbeam.
-
-// Moonbeam is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-
-// Moonbeam is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License
-// along with Moonbeam. If not, see .
-
-#![cfg(feature = "runtime-benchmarks")]
-
-use crate::{Call, Config, GetArrayLimit, Pallet};
-use core::cmp::max;
-use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite};
-use frame_support::BoundedVec;
-use frame_system::RawOrigin;
-use sp_core::{H160, H256};
-
-benchmarks! {
- clear_suicided_storage {
- let caller = account("caller", 1, 100);
- // a is the number of addresses
- let a in 1 .. 100;
- // l is the limit of the number of storage entries to be deleted
- let l in 1 .. 1000;
-
- // Create the addresses to be used in the test
- let mut addresses = BoundedVec::::new();
-
- // Create the storage entries to be deleted
- for i in 0..a {
- let address = account("address", i, i);
- addresses.try_push(address).expect("Cannot add more addresses to address list");
- let n = max(1, l/a);
- for j in 0..n {
- pallet_evm::AccountStorages::::insert(
- address,
- H256::from_low_u64_be(j as u64),
- H256::from_low_u64_be(j as u64),
- );
- }
- }
- }:_(
- RawOrigin::Signed(caller),
- addresses,
- l
- )
- verify {
- }
-}
-
-#[cfg(test)]
-mod tests {
- use crate::mock::Test;
- use sp_io::TestExternalities;
- use sp_runtime::BuildStorage;
-
- pub fn new_test_ext() -> TestExternalities {
- let t = frame_system::GenesisConfig::::default()
- .build_storage()
- .unwrap();
- TestExternalities::new(t)
- }
-}
-
-impl_benchmark_test_suite!(
- Pallet,
- crate::benchmarks::tests::new_test_ext(),
- crate::mock::Test
-);
diff --git a/pallets/moonbeam-lazy-migrations/src/lib.rs b/pallets/moonbeam-lazy-migrations/src/lib.rs
index 58875eefee..aa76963ff6 100644
--- a/pallets/moonbeam-lazy-migrations/src/lib.rs
+++ b/pallets/moonbeam-lazy-migrations/src/lib.rs
@@ -19,8 +19,6 @@
#![allow(non_camel_case_types)]
#![cfg_attr(not(feature = "std"), no_std)]
-#[cfg(any(test, feature = "runtime-benchmarks"))]
-mod benchmarks;
#[cfg(test)]
mod mock;
#[cfg(test)]
@@ -50,10 +48,6 @@ pub mod pallet {
#[pallet::pallet]
pub struct Pallet(PhantomData);
- #[pallet::storage]
- /// The total number of suicided contracts that were removed
- pub(crate) type SuicidedContractsRemoved = StorageValue<_, u32, ValueQuery>;
-
#[pallet::storage]
pub(crate) type StateMigrationStatusValue =
StorageValue<_, (StateMigrationStatus, u64), ValueQuery>;
@@ -82,12 +76,6 @@ pub mod pallet {
#[pallet::error]
pub enum Error {
- /// The limit cannot be zero
- LimitCannotBeZero,
- /// There must be at least one address
- AddressesLengthCannotBeZero,
- /// The contract is not corrupted (Still exist or properly suicided)
- ContractNotCorrupted,
/// The contract already have metadata
ContractMetadataAlreadySet,
/// Contract not exist
@@ -323,61 +311,6 @@ pub mod pallet {
#[pallet::call]
impl Pallet {
- // TODO(rodrigo): This extrinsic should be removed once the storage of destroyed contracts
- // has been removed
- #[pallet::call_index(1)]
- #[pallet::weight({
- let addresses_len = addresses.len() as u32;
- ::WeightInfo::clear_suicided_storage(addresses_len, *limit)
- })]
- pub fn clear_suicided_storage(
- origin: OriginFor,
- addresses: BoundedVec,
- limit: u32,
- ) -> DispatchResultWithPostInfo {
- ensure_signed(origin)?;
-
- ensure!(limit != 0, Error::::LimitCannotBeZero);
- ensure!(
- addresses.len() != 0,
- Error::::AddressesLengthCannotBeZero
- );
-
- let mut limit = limit as usize;
-
- for address in &addresses {
- // Ensure that the contract is corrupted by checking
- // that it has no code and at least one storage entry.
- let suicided = pallet_evm::Suicided::::contains_key(&address);
- let has_code = pallet_evm::AccountCodes::::contains_key(&address);
- ensure!(
- !suicided
- && !has_code && pallet_evm::AccountStorages::::iter_key_prefix(&address)
- .next()
- .is_some(),
- Error::::ContractNotCorrupted
- );
-
- let deleted = pallet_evm::AccountStorages::::drain_prefix(*address)
- .take(limit)
- .count();
-
- // Check if the storage of this contract has been completly removed
- if pallet_evm::AccountStorages::::iter_key_prefix(&address)
- .next()
- .is_none()
- {
- // All entries got removed, lets count this address as migrated
- SuicidedContractsRemoved::::mutate(|x| *x = x.saturating_add(1));
- }
-
- limit = limit.saturating_sub(deleted);
- if limit == 0 {
- return Ok(Pays::No.into());
- }
- }
- Ok(Pays::No.into())
- }
#[pallet::call_index(2)]
#[pallet::weight(Pallet::::create_contract_metadata_weight(MAX_CONTRACT_CODE_SIZE))]
pub fn create_contract_metadata(
diff --git a/pallets/moonbeam-lazy-migrations/src/mock.rs b/pallets/moonbeam-lazy-migrations/src/mock.rs
index 8d9b074408..b9868cdefc 100644
--- a/pallets/moonbeam-lazy-migrations/src/mock.rs
+++ b/pallets/moonbeam-lazy-migrations/src/mock.rs
@@ -19,13 +19,12 @@
use super::*;
use crate as pallet_moonbeam_lazy_migrations;
use frame_support::{
- construct_runtime, ord_parameter_types, parameter_types,
- traits::{EqualPrivilegeOnly, Everything, SortedMembers},
+ construct_runtime, parameter_types,
+ traits::Everything,
weights::{RuntimeDbWeight, Weight},
};
-use frame_system::EnsureRoot;
use pallet_evm::{AddressMapping, EnsureAddressTruncated};
-use sp_core::{ConstU32, H160, H256, U256};
+use sp_core::{H160, H256, U256};
use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup},
AccountId32, BuildStorage, Perbill,
@@ -43,7 +42,6 @@ construct_runtime!(
Timestamp: pallet_timestamp,
EVM: pallet_evm,
LazyMigrations: pallet_moonbeam_lazy_migrations::{Pallet, Call},
- Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event},
}
);
@@ -113,36 +111,6 @@ impl pallet_balances::Config for Test {
type RuntimeFreezeReason = ();
}
-impl pallet_scheduler::Config for Test {
- type RuntimeEvent = RuntimeEvent;
- type RuntimeOrigin = RuntimeOrigin;
- type PalletsOrigin = OriginCaller;
- type RuntimeCall = RuntimeCall;
- type MaximumWeight = ();
- type ScheduleOrigin = EnsureRoot;
- type MaxScheduledPerBlock = ConstU32<100>;
- type WeightInfo = ();
- type OriginPrivilegeCmp = EqualPrivilegeOnly;
- type Preimages = ();
-}
-
-ord_parameter_types! {
- pub const One: u64 = 1;
- pub const Two: u64 = 2;
- pub const Three: u64 = 3;
- pub const Four: u64 = 4;
- pub const Five: u64 = 5;
- pub const Six: u64 = 6;
-}
-pub struct OneToFive;
-impl SortedMembers for OneToFive {
- fn sorted_members() -> Vec {
- vec![1, 2, 3, 4, 5]
- }
- #[cfg(feature = "runtime-benchmarks")]
- fn add(_m: &u64) {}
-}
-
parameter_types! {
pub const MinimumPeriod: u64 = 6000 / 2;
}
diff --git a/pallets/moonbeam-lazy-migrations/src/tests.rs b/pallets/moonbeam-lazy-migrations/src/tests.rs
index ff460d1fa1..49a457ed34 100644
--- a/pallets/moonbeam-lazy-migrations/src/tests.rs
+++ b/pallets/moonbeam-lazy-migrations/src/tests.rs
@@ -72,206 +72,6 @@ fn create_dummy_contract_without_metadata(seed: u8) -> H160 {
address
}
-#[test]
-fn test_clear_suicided_contract_succesfull() {
- ExtBuilder::default().build().execute_with(|| {
- let contract_address = mock_contract_with_entries(1, 1, 10);
-
- // No addresses have been migrated yet
- assert_eq!(crate::pallet::SuicidedContractsRemoved::::get(), 0);
-
- // The account has some storage entries
- assert_eq!(
- pallet_evm::AccountStorages::::iter_prefix(contract_address).count(),
- 10
- );
-
- // Call the extrinsic to delete the storage entries
- let _ = LazyMigrations::clear_suicided_storage(
- RuntimeOrigin::signed(AccountId32::from([45; 32])),
- vec![contract_address].try_into().unwrap(),
- 1000,
- );
-
- // One address has been migrated
- assert_eq!(crate::pallet::SuicidedContractsRemoved::::get(), 1);
- // All the account storage should have been removed
- assert_eq!(
- pallet_evm::AccountStorages::::iter_prefix(contract_address).count(),
- 0
- );
- })
-}
-
-// Test that the extrinsic fails if the contract is not suicided
-#[test]
-fn test_clear_suicided_contract_failed() {
- ExtBuilder::default().build().execute_with(|| {
- let contract1_address = mock_contract_with_entries(1, 1, 10);
- let contract2_address = mock_contract_with_entries(2, 1, 10);
-
- // The contracts have not been self-destructed.
- pallet_evm::AccountCodes::::insert(contract1_address, vec![1, 2, 3]);
- pallet_evm::Suicided::::insert(contract2_address, ());
-
- assert_noop!(
- LazyMigrations::clear_suicided_storage(
- RuntimeOrigin::signed(AccountId32::from([45; 32])),
- vec![contract1_address].try_into().unwrap(),
- 1000
- ),
- Error::::ContractNotCorrupted
- );
-
- assert_noop!(
- LazyMigrations::clear_suicided_storage(
- RuntimeOrigin::signed(AccountId32::from([45; 32])),
- vec![contract2_address].try_into().unwrap(),
- 1000
- ),
- Error::::ContractNotCorrupted
- );
-
- // Check that no storage has been removed
-
- assert_eq!(
- pallet_evm::AccountStorages::::iter_prefix(contract1_address).count(),
- 10
- );
- assert_eq!(
- pallet_evm::AccountStorages::::iter_prefix(contract2_address).count(),
- 10
- );
- })
-}
-
-// Test that the extrinsic can handle an empty input
-#[test]
-fn test_clear_suicided_empty_input() {
- ExtBuilder::default().build().execute_with(|| {
- let contract_address = mock_contract_with_entries(1, 1, 10);
-
- let _ = LazyMigrations::clear_suicided_storage(
- RuntimeOrigin::signed(AccountId32::from([45; 32])),
- vec![].try_into().unwrap(),
- 1000,
- );
-
- assert_eq!(
- pallet_evm::AccountStorages::::iter_prefix(contract_address).count(),
- 10
- );
- })
-}
-
-// Test with multiple deleted contracts ensuring that the extrinsic can handle
-// multiple addresses at once.
-#[test]
-fn test_clear_suicided_contract_multiple_addresses() {
- ExtBuilder::default().build().execute_with(|| {
- let contract_address1 = mock_contract_with_entries(1, 1, 10);
- let contract_address2 = mock_contract_with_entries(2, 1, 20);
- let contract_address3 = mock_contract_with_entries(3, 1, 30);
-
- // Call the extrinsic to delete the storage entries
- let _ = LazyMigrations::clear_suicided_storage(
- RuntimeOrigin::signed(AccountId32::from([45; 32])),
- vec![contract_address1, contract_address2, contract_address3]
- .try_into()
- .unwrap(),
- 1000,
- )
- .unwrap();
-
- assert_eq!(
- pallet_evm::AccountStorages::::iter_prefix(contract_address1).count(),
- 0
- );
- assert_eq!(
- pallet_evm::AccountStorages::::iter_prefix(contract_address2).count(),
- 0
- );
- assert_eq!(
- pallet_evm::AccountStorages::::iter_prefix(contract_address3).count(),
- 0
- );
- })
-}
-
-// Test that the limit of entries to be deleted is respected
-#[test]
-fn test_clear_suicided_entry_limit() {
- ExtBuilder::default().build().execute_with(|| {
- let contract_address1 = mock_contract_with_entries(1, 1, 2000);
- let contract_address2 = mock_contract_with_entries(2, 1, 1);
-
- let _ = LazyMigrations::clear_suicided_storage(
- RuntimeOrigin::signed(AccountId32::from([45; 32])),
- vec![contract_address1, contract_address2]
- .try_into()
- .unwrap(),
- 1000,
- )
- .unwrap();
- assert_eq!(
- pallet_evm::AccountStorages::::iter_prefix(contract_address1).count(),
- 1000
- );
-
- assert_eq!(
- pallet_evm::AccountStorages::::iter_prefix(contract_address2).count(),
- 1
- );
- })
-}
-
-// Test a combination of Suicided and non-suicided contracts
-#[test]
-fn test_clear_suicided_mixed_suicided_and_non_suicided() {
- ExtBuilder::default().build().execute_with(|| {
- let contract_address1 = mock_contract_with_entries(1, 1, 10);
- let contract_address2 = mock_contract_with_entries(2, 1, 10);
- let contract_address3 = mock_contract_with_entries(3, 1, 10);
- let contract_address4 = mock_contract_with_entries(4, 1, 10);
-
- // Contract has not been self-destructed.
- pallet_evm::AccountCodes::::insert(contract_address3, vec![1, 2, 3]);
-
- assert_noop!(
- LazyMigrations::clear_suicided_storage(
- RuntimeOrigin::signed(AccountId32::from([45; 32])),
- vec![
- contract_address1,
- contract_address2,
- contract_address3,
- contract_address4
- ]
- .try_into()
- .unwrap(),
- 1000
- ),
- Error::::ContractNotCorrupted
- );
-
- assert_eq!(
- pallet_evm::AccountStorages::::iter_prefix(contract_address1).count(),
- 10
- );
- assert_eq!(
- pallet_evm::AccountStorages::::iter_prefix(contract_address2).count(),
- 10
- );
- assert_eq!(
- pallet_evm::AccountStorages::::iter_prefix(contract_address3).count(),
- 10
- );
- assert_eq!(
- pallet_evm::AccountStorages::::iter_prefix(contract_address4).count(),
- 10
- );
- })
-}
-
#[test]
fn test_create_contract_metadata_contract_not_exist() {
ExtBuilder::default().build().execute_with(|| {
diff --git a/pallets/moonbeam-lazy-migrations/src/weights.rs b/pallets/moonbeam-lazy-migrations/src/weights.rs
index 72ba0396e6..46b9fc6509 100644
--- a/pallets/moonbeam-lazy-migrations/src/weights.rs
+++ b/pallets/moonbeam-lazy-migrations/src/weights.rs
@@ -23,58 +23,13 @@ use sp_std::marker::PhantomData;
/// Weight functions needed for pallet_moonbeam_lazy_migrations.
pub trait WeightInfo {
- fn clear_suicided_storage(a: u32, l: u32, ) -> Weight;
}
/// Weights for pallet_moonbeam_lazy_migrations using the Substrate node and recommended hardware.
pub struct SubstrateWeight(PhantomData);
impl WeightInfo for SubstrateWeight {
- /// Storage: `EVM::AccountCodes` (r:1000 w:0)
- /// Proof: `EVM::AccountCodes` (`max_values`: None, `max_size`: None, mode: `Measured`)
- /// Storage: `EVM::AccountStorages` (r:33000 w:32000)
- /// Proof: `EVM::AccountStorages` (`max_values`: None, `max_size`: None, mode: `Measured`)
- /// The range of component `a` is `[0, 1000]`.
- /// The range of component `l` is `[0, 32500]`.
- fn clear_suicided_storage(a: u32, l: u32, ) -> Weight {
- // Proof Size summary in bytes:
- // Measured: `0 + a * (2 ±0) + l * (87 ±0)`
- // Estimated: `7953 + a * (2352 ±14) + l * (2564 ±0)`
- // Minimum execution time: 1_850_000 picoseconds.
- Weight::from_parts(1_900_000, 7953)
- // Standard Error: 1_276_197
- .saturating_add(Weight::from_parts(18_091_220, 0).saturating_mul(a.into()))
- // Standard Error: 39_260
- .saturating_add(Weight::from_parts(5_558_165, 0).saturating_mul(l.into()))
- .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(a.into())))
- .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(l.into())))
- .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(l.into())))
- .saturating_add(Weight::from_parts(0, 2352).saturating_mul(a.into()))
- .saturating_add(Weight::from_parts(0, 2564).saturating_mul(l.into()))
- }
}
// For backwards compatibility and tests
impl WeightInfo for () {
- /// Storage: `EVM::AccountCodes` (r:1000 w:0)
- /// Proof: `EVM::AccountCodes` (`max_values`: None, `max_size`: None, mode: `Measured`)
- /// Storage: `EVM::AccountStorages` (r:33000 w:32000)
- /// Proof: `EVM::AccountStorages` (`max_values`: None, `max_size`: None, mode: `Measured`)
- /// The range of component `a` is `[0, 1000]`.
- /// The range of component `l` is `[0, 32500]`.
- fn clear_suicided_storage(a: u32, l: u32, ) -> Weight {
- // Proof Size summary in bytes:
- // Measured: `0 + a * (2 ±0) + l * (87 ±0)`
- // Estimated: `7953 + a * (2352 ±14) + l * (2564 ±0)`
- // Minimum execution time: 1_850_000 picoseconds.
- Weight::from_parts(1_900_000, 7953)
- // Standard Error: 1_276_197
- .saturating_add(Weight::from_parts(18_091_220, 0).saturating_mul(a.into()))
- // Standard Error: 39_260
- .saturating_add(Weight::from_parts(5_558_165, 0).saturating_mul(l.into()))
- .saturating_add(RocksDbWeight::get().reads((2_u64).saturating_mul(a.into())))
- .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(l.into())))
- .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(l.into())))
- .saturating_add(Weight::from_parts(0, 2352).saturating_mul(a.into()))
- .saturating_add(Weight::from_parts(0, 2564).saturating_mul(l.into()))
- }
}
\ No newline at end of file
diff --git a/runtime/common/src/weights/pallet_moonbeam_lazy_migrations.rs b/runtime/common/src/weights/pallet_moonbeam_lazy_migrations.rs
index 5b16b958b0..bd0b11f47d 100644
--- a/runtime/common/src/weights/pallet_moonbeam_lazy_migrations.rs
+++ b/runtime/common/src/weights/pallet_moonbeam_lazy_migrations.rs
@@ -46,32 +46,4 @@ use sp_std::marker::PhantomData;
/// Weights for `pallet_moonbeam_lazy_migrations`.
pub struct WeightInfo(PhantomData);
impl pallet_moonbeam_lazy_migrations::WeightInfo for WeightInfo {
- /// Storage: `EVM::Suicided` (r:100 w:0)
- /// Proof: `EVM::Suicided` (`max_values`: None, `max_size`: None, mode: `Measured`)
- /// Storage: `EVM::AccountCodes` (r:100 w:0)
- /// Proof: `EVM::AccountCodes` (`max_values`: None, `max_size`: None, mode: `Measured`)
- /// Storage: `EVM::AccountStorages` (r:1000 w:900)
- /// Proof: `EVM::AccountStorages` (`max_values`: None, `max_size`: None, mode: `Measured`)
- /// Storage: `MoonbeamLazyMigrations::SuicidedContractsRemoved` (r:1 w:1)
- /// Proof: `MoonbeamLazyMigrations::SuicidedContractsRemoved` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`)
- /// The range of component `a` is `[1, 100]`.
- /// The range of component `l` is `[1, 1000]`.
- fn clear_suicided_storage(a: u32, l: u32, ) -> Weight {
- // Proof Size summary in bytes:
- // Measured: `4251 + a * (12 ±0) + l * (84 ±0)`
- // Estimated: `37759 + a * (2229 ±74) + l * (2536 ±7)`
- // Minimum execution time: 49_196_000 picoseconds.
- Weight::from_parts(50_354_000, 37759)
- // Standard Error: 2_593_683
- .saturating_add(Weight::from_parts(42_870_661, 0).saturating_mul(a.into()))
- // Standard Error: 259_091
- .saturating_add(Weight::from_parts(27_114_710, 0).saturating_mul(l.into()))
- .saturating_add(T::DbWeight::get().reads(5_u64))
- .saturating_add(T::DbWeight::get().reads((2_u64).saturating_mul(a.into())))
- .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(l.into())))
- .saturating_add(T::DbWeight::get().writes(41_u64))
- .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(l.into())))
- .saturating_add(Weight::from_parts(0, 2229).saturating_mul(a.into()))
- .saturating_add(Weight::from_parts(0, 2536).saturating_mul(l.into()))
- }
}
diff --git a/runtime/moonbase/src/lib.rs b/runtime/moonbase/src/lib.rs
index 7c699860f6..40eae5cd7f 100644
--- a/runtime/moonbase/src/lib.rs
+++ b/runtime/moonbase/src/lib.rs
@@ -1538,7 +1538,6 @@ mod benches {
[pallet_multisig, Multisig]
[pallet_relay_storage_roots, RelayStorageRoots]
[pallet_precompile_benchmarks, PrecompileBenchmarks]
- [pallet_moonbeam_lazy_migrations, MoonbeamLazyMigrations]
[pallet_parameters, Parameters]
[pallet_xcm_weight_trader, XcmWeightTrader]
);
diff --git a/runtime/moonbeam/src/lib.rs b/runtime/moonbeam/src/lib.rs
index 91635966c5..1aa6d177e0 100644
--- a/runtime/moonbeam/src/lib.rs
+++ b/runtime/moonbeam/src/lib.rs
@@ -1525,7 +1525,6 @@ mod benches {
[pallet_preimage, Preimage]
[pallet_whitelist, Whitelist]
[pallet_multisig, Multisig]
- [pallet_moonbeam_lazy_migrations, MoonbeamLazyMigrations]
[pallet_relay_storage_roots, RelayStorageRoots]
);
}
diff --git a/runtime/moonriver/src/lib.rs b/runtime/moonriver/src/lib.rs
index bd9776892e..d1d7f970cd 100644
--- a/runtime/moonriver/src/lib.rs
+++ b/runtime/moonriver/src/lib.rs
@@ -1526,7 +1526,6 @@ mod benches {
[pallet_preimage, Preimage]
[pallet_whitelist, Whitelist]
[pallet_multisig, Multisig]
- [pallet_moonbeam_lazy_migrations, MoonbeamLazyMigrations]
[pallet_relay_storage_roots, RelayStorageRoots]
);
}
diff --git a/test/suites/dev/moonbase/test-moonbeam-lazy-migrations/test-clear-suicided-contracts.ts b/test/suites/dev/moonbase/test-moonbeam-lazy-migrations/test-clear-suicided-contracts.ts
deleted file mode 100644
index 48d328b57b..0000000000
--- a/test/suites/dev/moonbase/test-moonbeam-lazy-migrations/test-clear-suicided-contracts.ts
+++ /dev/null
@@ -1,73 +0,0 @@
-import {
- describeSuite,
- expect,
- deployCreateCompiledContract,
- fetchCompiledContract,
- beforeAll,
-} from "@moonwall/cli";
-import { createEthersTransaction } from "@moonwall/util";
-import { encodeFunctionData } from "viem";
-import { expectOk } from "../../../../helpers";
-import { ApiPromise } from "@polkadot/api";
-
-describeSuite({
- id: "D012201",
- title: "Lazy Migrations Pallet - Clear Suicided Storage",
- foundationMethods: "dev",
- testCases: ({ context, it }) => {
- let api: ApiPromise;
-
- beforeAll(async () => {
- api = context.polkadotJs();
- });
-
- it({
- id: "T01",
- title:
- "Should clear storage entries of multiple suicided contracts within the deletion limit.",
- test: async function () {
- const { abi } = fetchCompiledContract("Storage");
-
- for (let i = 0; i < 3; i++) {
- const { contractAddress } = await deployCreateCompiledContract(context, "Storage");
-
- // Create storage entries for the contract
- const rawSigned = await createEthersTransaction(context, {
- to: contractAddress,
- data: encodeFunctionData({
- abi,
- args: [0, 200],
- functionName: "store",
- }),
- gasLimit: 13_000_000,
- });
- await expectOk(context.createBlock(rawSigned));
-
- await context.createBlock();
-
- // Call the extrinsic to delete the storage entries
- const tx = await context.createBlock(
- api.tx.moonbeamLazyMigrations.clearSuicidedStorage([contractAddress], 199)
- );
- await expect(!tx.result?.successful, "The contract storage cannot be removed");
-
- // Remove The contract code to make it corrupted
- await context.createBlock(
- api.tx.sudo.sudo(
- api.tx.system.killStorage([api.query.evm.accountCodes.key(contractAddress)])
- )
- );
-
- // Now, the storage can be removed
- await expectOk(
- context.createBlock(
- context
- .polkadotJs()
- .tx.moonbeamLazyMigrations.clearSuicidedStorage([contractAddress], 199)
- )
- );
- }
- },
- });
- },
-});