diff --git a/Cargo.lock b/Cargo.lock index 3b3eed91e9..a025dd9990 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -770,7 +770,7 @@ dependencies = [ "cumulus-primitives-aura", "cumulus-primitives-core", "cumulus-primitives-utility", - "dapp-staking-v3-runtime-api", + "dapp-staking-runtime-api", "fp-rpc", "fp-self-contained", "frame-benchmarking", @@ -797,14 +797,14 @@ dependencies = [ "pallet-chain-extension-assets", "pallet-collator-selection 3.3.2", "pallet-contracts", - "pallet-dapp-staking-v3", + "pallet-dapp-staking", "pallet-dynamic-evm-base-fee", "pallet-ethereum", "pallet-evm", "pallet-evm-precompile-assets-erc20", "pallet-evm-precompile-blake2", "pallet-evm-precompile-bn128", - "pallet-evm-precompile-dapp-staking-v3", + "pallet-evm-precompile-dapp-staking", "pallet-evm-precompile-dispatch", "pallet-evm-precompile-dispatch-lockdrop", "pallet-evm-precompile-ed25519", @@ -2941,7 +2941,7 @@ dependencies = [ ] [[package]] -name = "dapp-staking-v3-runtime-api" +name = "dapp-staking-runtime-api" version = "0.1.0" dependencies = [ "astar-primitives", @@ -5565,7 +5565,7 @@ dependencies = [ "pallet-collective-proxy", "pallet-contracts", "pallet-contracts-uapi", - "pallet-dapp-staking-v3", + "pallet-dapp-staking", "pallet-democracy", "pallet-ethereum", "pallet-ethereum-checked", @@ -6546,7 +6546,7 @@ version = "5.43.1" dependencies = [ "array-bytes 6.2.3", "astar-primitives", - "dapp-staking-v3-runtime-api", + "dapp-staking-runtime-api", "fp-rpc", "fp-self-contained", "frame-benchmarking", @@ -6570,7 +6570,7 @@ dependencies = [ "pallet-collective", "pallet-collective-proxy", "pallet-contracts", - "pallet-dapp-staking-v3", + "pallet-dapp-staking", "pallet-democracy", "pallet-dynamic-evm-base-fee", "pallet-ethereum", @@ -6579,7 +6579,7 @@ dependencies = [ "pallet-evm-precompile-assets-erc20", "pallet-evm-precompile-blake2", "pallet-evm-precompile-bn128", - "pallet-evm-precompile-dapp-staking-v3", + "pallet-evm-precompile-dapp-staking", "pallet-evm-precompile-dispatch", "pallet-evm-precompile-dispatch-lockdrop", "pallet-evm-precompile-ed25519", @@ -8469,7 +8469,7 @@ dependencies = [ ] [[package]] -name = "pallet-dapp-staking-v3" +name = "pallet-dapp-staking" version = "0.1.0" dependencies = [ "assert_matches", @@ -8712,7 +8712,7 @@ dependencies = [ ] [[package]] -name = "pallet-evm-precompile-dapp-staking-v3" +name = "pallet-evm-precompile-dapp-staking" version = "0.1.0" dependencies = [ "assert_matches", @@ -8724,7 +8724,7 @@ dependencies = [ "log", "num_enum 0.5.11", "pallet-balances", - "pallet-dapp-staking-v3", + "pallet-dapp-staking", "pallet-evm", "pallet-timestamp", "parity-scale-codec", @@ -14372,7 +14372,7 @@ dependencies = [ "cumulus-primitives-aura", "cumulus-primitives-core", "cumulus-primitives-utility", - "dapp-staking-v3-runtime-api", + "dapp-staking-runtime-api", "fp-rpc", "fp-self-contained", "frame-benchmarking", @@ -14402,7 +14402,7 @@ dependencies = [ "pallet-collective", "pallet-collective-proxy", "pallet-contracts", - "pallet-dapp-staking-v3", + "pallet-dapp-staking", "pallet-democracy", "pallet-dynamic-evm-base-fee", "pallet-ethereum", @@ -14412,7 +14412,7 @@ dependencies = [ "pallet-evm-precompile-assets-erc20", "pallet-evm-precompile-blake2", "pallet-evm-precompile-bn128", - "pallet-evm-precompile-dapp-staking-v3", + "pallet-evm-precompile-dapp-staking", "pallet-evm-precompile-dispatch", "pallet-evm-precompile-dispatch-lockdrop", "pallet-evm-precompile-ed25519", @@ -14491,7 +14491,7 @@ dependencies = [ "cumulus-primitives-aura", "cumulus-primitives-core", "cumulus-primitives-utility", - "dapp-staking-v3-runtime-api", + "dapp-staking-runtime-api", "fp-rpc", "fp-self-contained", "frame-benchmarking", @@ -14518,14 +14518,14 @@ dependencies = [ "pallet-chain-extension-assets", "pallet-collator-selection 3.3.2", "pallet-contracts", - "pallet-dapp-staking-v3", + "pallet-dapp-staking", "pallet-dynamic-evm-base-fee", "pallet-ethereum", "pallet-evm", "pallet-evm-precompile-assets-erc20", "pallet-evm-precompile-blake2", "pallet-evm-precompile-bn128", - "pallet-evm-precompile-dapp-staking-v3", + "pallet-evm-precompile-dapp-staking", "pallet-evm-precompile-dispatch", "pallet-evm-precompile-dispatch-lockdrop", "pallet-evm-precompile-ed25519", @@ -18106,7 +18106,7 @@ dependencies = [ "pallet-assets", "pallet-balances", "pallet-contracts", - "pallet-dapp-staking-v3", + "pallet-dapp-staking", "pallet-insecure-randomness-collective-flip", "pallet-message-queue", "pallet-proxy", diff --git a/Cargo.toml b/Cargo.toml index 08c448043a..66c30a9647 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -287,7 +287,7 @@ orml-oracle = { git = "https://github.com/AstarNetwork/open-runtime-module-libra # Astar pallets & modules # (wasm) pallet-collator-selection = { path = "./pallets/collator-selection", default-features = false } -pallet-dapp-staking-v3 = { path = "./pallets/dapp-staking-v3", default-features = false } +pallet-dapp-staking = { path = "./pallets/dapp-staking", default-features = false } pallet-xc-asset-config = { path = "./pallets/xc-asset-config", default-features = false } pallet-ethereum-checked = { path = "./pallets/ethereum-checked", default-features = false } pallet-inflation = { path = "./pallets/inflation", default-features = false } @@ -298,7 +298,7 @@ pallet-static-price-provider = { path = "./pallets/static-price-provider", defau pallet-price-aggregator = { path = "./pallets/price-aggregator", default-features = false } pallet-collective-proxy = { path = "./pallets/collective-proxy", default-features = false } -dapp-staking-v3-runtime-api = { path = "./pallets/dapp-staking-v3/rpc/runtime-api", default-features = false } +dapp-staking-runtime-api = { path = "./pallets/dapp-staking/rpc/runtime-api", default-features = false } astar-primitives = { path = "./primitives", default-features = false } astar-test-utils = { path = "./tests/utils", default-features = false } @@ -307,7 +307,7 @@ pallet-evm-precompile-assets-erc20 = { path = "./precompiles/assets-erc20", defa pallet-evm-precompile-sr25519 = { path = "./precompiles/sr25519", default-features = false } pallet-evm-precompile-substrate-ecdsa = { path = "./precompiles/substrate-ecdsa", default-features = false } pallet-evm-precompile-xcm = { path = "./precompiles/xcm", default-features = false } -pallet-evm-precompile-dapp-staking-v3 = { path = "./precompiles/dapp-staking-v3", default-features = false } +pallet-evm-precompile-dapp-staking = { path = "./precompiles/dapp-staking", default-features = false } pallet-evm-precompile-unified-accounts = { path = "./precompiles/unified-accounts", default-features = false } pallet-evm-precompile-dispatch-lockdrop = { path = "./precompiles/dispatch-lockdrop", default-features = false } diff --git a/pallets/dapp-staking-v3/Cargo.toml b/pallets/dapp-staking/Cargo.toml similarity index 97% rename from pallets/dapp-staking-v3/Cargo.toml rename to pallets/dapp-staking/Cargo.toml index 68c6ff468a..61d9ff225d 100644 --- a/pallets/dapp-staking-v3/Cargo.toml +++ b/pallets/dapp-staking/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "pallet-dapp-staking-v3" +name = "pallet-dapp-staking" version = "0.1.0" description = "Pallet for dApp staking v3 protocol" authors.workspace = true diff --git a/pallets/dapp-staking-v3/README.md b/pallets/dapp-staking/README.md similarity index 100% rename from pallets/dapp-staking-v3/README.md rename to pallets/dapp-staking/README.md diff --git a/pallets/dapp-staking-v3/rpc/runtime-api/Cargo.toml b/pallets/dapp-staking/rpc/runtime-api/Cargo.toml similarity index 92% rename from pallets/dapp-staking-v3/rpc/runtime-api/Cargo.toml rename to pallets/dapp-staking/rpc/runtime-api/Cargo.toml index 37b20002ab..637ce49e50 100644 --- a/pallets/dapp-staking-v3/rpc/runtime-api/Cargo.toml +++ b/pallets/dapp-staking/rpc/runtime-api/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "dapp-staking-v3-runtime-api" +name = "dapp-staking-runtime-api" version = "0.1.0" description = "dApp Staking v3 runtime API" authors.workspace = true diff --git a/pallets/dapp-staking-v3/rpc/runtime-api/src/lib.rs b/pallets/dapp-staking/rpc/runtime-api/src/lib.rs similarity index 100% rename from pallets/dapp-staking-v3/rpc/runtime-api/src/lib.rs rename to pallets/dapp-staking/rpc/runtime-api/src/lib.rs diff --git a/pallets/dapp-staking-v3/src/benchmarking/mod.rs b/pallets/dapp-staking/src/benchmarking/mod.rs similarity index 100% rename from pallets/dapp-staking-v3/src/benchmarking/mod.rs rename to pallets/dapp-staking/src/benchmarking/mod.rs diff --git a/pallets/dapp-staking-v3/src/benchmarking/utils.rs b/pallets/dapp-staking/src/benchmarking/utils.rs similarity index 100% rename from pallets/dapp-staking-v3/src/benchmarking/utils.rs rename to pallets/dapp-staking/src/benchmarking/utils.rs diff --git a/pallets/dapp-staking-v3/src/lib.rs b/pallets/dapp-staking/src/lib.rs similarity index 100% rename from pallets/dapp-staking-v3/src/lib.rs rename to pallets/dapp-staking/src/lib.rs diff --git a/pallets/dapp-staking-v3/src/migration.rs b/pallets/dapp-staking/src/migration.rs similarity index 93% rename from pallets/dapp-staking-v3/src/migration.rs rename to pallets/dapp-staking/src/migration.rs index b2e81c3a38..35e27ccfba 100644 --- a/pallets/dapp-staking-v3/src/migration.rs +++ b/pallets/dapp-staking/src/migration.rs @@ -161,7 +161,7 @@ mod v8 { let old_config = v7::TierConfig::::get().ok_or_else(|| { TryRuntimeError::Other( - "dapp-staking-v3::migration::v8: No old configuration found for TierConfig", + "dapp-staking::migration::v8: No old configuration found for TierConfig", ) })?; Ok((old_config.number_of_slots, old_config.tier_thresholds).encode()) @@ -169,9 +169,13 @@ mod v8 { #[cfg(feature = "try-runtime")] fn post_upgrade(data: Vec) -> Result<(), TryRuntimeError> { - let (old_number_of_slots, old_tier_thresholds): (u16, BoundedVec) = - Decode::decode(&mut &data[..]).map_err(|_| { - TryRuntimeError::Other("dapp-staking-v3::migration::v8: Failed to decode old v7 version of tier config") + let (old_number_of_slots, old_tier_thresholds): ( + u16, + BoundedVec, + ) = Decode::decode(&mut &data[..]).map_err(|_| { + TryRuntimeError::Other( + "dapp-staking::migration::v8: Failed to decode old v7 version of tier config", + ) })?; // 0. Prerequisites @@ -180,7 +184,7 @@ mod v8 { ensure!( Pallet::::on_chain_storage_version() >= 8, - "dapp-staking-v3::migration::v8: Wrong storage version." + "dapp-staking::migration::v8: Wrong storage version." ); // 1. Ensure the number of slots is preserved @@ -190,7 +194,7 @@ mod v8 { assert!( within_tolerance.contains(&actual_number_of_slots), - "dapp-staking-v3::migration::v8: New TiersConfiguration format not set correctly, number of slots has diverged. Old: {}. Actual: {}.", + "dapp-staking::migration::v8: New TiersConfiguration format not set correctly, number of slots has diverged. Old: {}. Actual: {}.", old_number_of_slots, actual_number_of_slots ); @@ -203,7 +207,7 @@ mod v8 { BoundedVec::try_from(TierThresholds::get().to_vec()); ensure!( expected_tier_thresholds.is_ok(), - "dapp-staking-v3::migration::v8: Failed to convert expected tier thresholds." + "dapp-staking::migration::v8: Failed to convert expected tier thresholds." ); let actual_tier_thresholds = actual_tier_params.clone().tier_thresholds; assert_eq!(expected_tier_thresholds.unwrap(), actual_tier_thresholds); @@ -222,7 +226,7 @@ mod v8 { ensure!( old_threshold_amounts.is_ok(), - "dapp-staking-v3::migration::v8: Failed to convert old v7 version tier thresholds to balance amounts." + "dapp-staking::migration::v8: Failed to convert old v7 version tier thresholds to balance amounts." ); let old_threshold_amounts = old_threshold_amounts.unwrap(); let expected_new_threshold_amounts = actual_config @@ -242,7 +246,7 @@ mod v8 { assert!( (lower_bound..=upper_bound).contains(&actual_amount), - "dapp-staking-v3::migration::v8: New tier threshold amounts diverged to much from old values, consider adjusting static tier parameters. Old: {}. Actual: {}.", + "dapp-staking::migration::v8: New tier threshold amounts diverged to much from old values, consider adjusting static tier parameters. Old: {}. Actual: {}.", old_amount, actual_amount ); @@ -379,7 +383,7 @@ mod v7 { fn post_upgrade(_data: Vec) -> Result<(), TryRuntimeError> { ensure!( Pallet::::on_chain_storage_version() >= 7, - "dapp-staking-v3::migration::v7: wrong storage version" + "dapp-staking::migration::v7: wrong storage version" ); Ok(()) } diff --git a/pallets/dapp-staking-v3/src/test/mock.rs b/pallets/dapp-staking/src/test/mock.rs similarity index 100% rename from pallets/dapp-staking-v3/src/test/mock.rs rename to pallets/dapp-staking/src/test/mock.rs diff --git a/pallets/dapp-staking-v3/src/test/mod.rs b/pallets/dapp-staking/src/test/mod.rs similarity index 100% rename from pallets/dapp-staking-v3/src/test/mod.rs rename to pallets/dapp-staking/src/test/mod.rs diff --git a/pallets/dapp-staking-v3/src/test/testing_utils.rs b/pallets/dapp-staking/src/test/testing_utils.rs similarity index 100% rename from pallets/dapp-staking-v3/src/test/testing_utils.rs rename to pallets/dapp-staking/src/test/testing_utils.rs diff --git a/pallets/dapp-staking-v3/src/test/tests.rs b/pallets/dapp-staking/src/test/tests.rs similarity index 100% rename from pallets/dapp-staking-v3/src/test/tests.rs rename to pallets/dapp-staking/src/test/tests.rs diff --git a/pallets/dapp-staking-v3/src/test/tests_types.rs b/pallets/dapp-staking/src/test/tests_types.rs similarity index 100% rename from pallets/dapp-staking-v3/src/test/tests_types.rs rename to pallets/dapp-staking/src/test/tests_types.rs diff --git a/pallets/dapp-staking-v3/src/types.rs b/pallets/dapp-staking/src/types.rs similarity index 100% rename from pallets/dapp-staking-v3/src/types.rs rename to pallets/dapp-staking/src/types.rs diff --git a/pallets/dapp-staking-v3/src/weights.rs b/pallets/dapp-staking/src/weights.rs similarity index 99% rename from pallets/dapp-staking-v3/src/weights.rs rename to pallets/dapp-staking/src/weights.rs index fabcfbeb5b..f7c46df534 100644 --- a/pallets/dapp-staking-v3/src/weights.rs +++ b/pallets/dapp-staking/src/weights.rs @@ -17,7 +17,7 @@ // You should have received a copy of the GNU General Public License // along with Astar. If not, see . -//! Autogenerated weights for pallet_dapp_staking_v3 +//! Autogenerated weights for pallet_dapp_staking //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2024-02-06, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` @@ -32,12 +32,12 @@ // --chain=shiden-dev // --steps=50 // --repeat=20 -// --pallet=pallet_dapp_staking_v3 +// --pallet=pallet_dapp_staking // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./benchmark-results/shiden-dev/dapp_staking_v3_weights.rs +// --output=./benchmark-results/shiden-dev/dapp_staking_weights.rs // --template=./scripts/templates/weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -47,7 +47,7 @@ use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use core::marker::PhantomData; -/// Weight functions needed for pallet_dapp_staking_v3. +/// Weight functions needed for pallet_dapp_staking. pub trait WeightInfo { fn maintenance_mode() -> Weight; fn register() -> Weight; @@ -75,7 +75,7 @@ pub trait WeightInfo { fn on_idle_cleanup() -> Weight; } -/// Weights for pallet_dapp_staking_v3 using the Substrate node and recommended hardware. +/// Weights for pallet_dapp_staking using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn maintenance_mode() -> Weight { diff --git a/precompiles/dapp-staking-v3/Cargo.toml b/precompiles/dapp-staking/Cargo.toml similarity index 90% rename from precompiles/dapp-staking-v3/Cargo.toml rename to precompiles/dapp-staking/Cargo.toml index 00a9828666..c72023cb10 100644 --- a/precompiles/dapp-staking-v3/Cargo.toml +++ b/precompiles/dapp-staking/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "pallet-evm-precompile-dapp-staking-v3" +name = "pallet-evm-precompile-dapp-staking" version = "0.1.0" license = "GPL-3.0-or-later" description = "dApp Staking EVM precompiles" @@ -23,7 +23,7 @@ sp-std = { workspace = true } # Astar astar-primitives = { workspace = true } -pallet-dapp-staking-v3 = { workspace = true } +pallet-dapp-staking = { workspace = true } precompile-utils = { workspace = true, default-features = false } # Frontier @@ -53,7 +53,7 @@ std = [ "fp-evm/std", "frame-support/std", "frame-system/std", - "pallet-dapp-staking-v3/std", + "pallet-dapp-staking/std", "pallet-evm/std", "precompile-utils/std", "pallet-balances/std", @@ -62,7 +62,7 @@ std = [ "num_enum/std", ] runtime-benchmarks = [ - "pallet-dapp-staking-v3/runtime-benchmarks", + "pallet-dapp-staking/runtime-benchmarks", "astar-primitives/runtime-benchmarks", "frame-support/runtime-benchmarks", "frame-system/runtime-benchmarks", diff --git a/precompiles/dapp-staking-v3/DappsStakingV2.sol b/precompiles/dapp-staking/DappsStakingV2.sol similarity index 100% rename from precompiles/dapp-staking-v3/DappsStakingV2.sol rename to precompiles/dapp-staking/DappsStakingV2.sol diff --git a/precompiles/dapp-staking-v3/DappsStakingV3.sol b/precompiles/dapp-staking/DappsStakingV3.sol similarity index 99% rename from precompiles/dapp-staking-v3/DappsStakingV3.sol rename to precompiles/dapp-staking/DappsStakingV3.sol index 40c55af6c4..941d00de76 100644 --- a/precompiles/dapp-staking-v3/DappsStakingV3.sol +++ b/precompiles/dapp-staking/DappsStakingV3.sol @@ -5,7 +5,7 @@ pragma solidity >=0.8.0; /// Predeployed at the address 0x0000000000000000000000000000000000005001 /// For better understanding check the source code: /// repo: https://github.com/AstarNetwork/Astar -/// code: pallets/dapp-staking-v3 +/// code: pallets/dapp-staking interface DAppStaking { // Types diff --git a/precompiles/dapp-staking-v3/README.md b/precompiles/dapp-staking/README.md similarity index 100% rename from precompiles/dapp-staking-v3/README.md rename to precompiles/dapp-staking/README.md diff --git a/precompiles/dapp-staking-v3/src/lib.rs b/precompiles/dapp-staking/src/lib.rs similarity index 90% rename from precompiles/dapp-staking-v3/src/lib.rs rename to precompiles/dapp-staking/src/lib.rs index 0b102c7fd7..c1750f2237 100644 --- a/precompiles/dapp-staking-v3/src/lib.rs +++ b/precompiles/dapp-staking/src/lib.rs @@ -45,7 +45,7 @@ use sp_std::{marker::PhantomData, prelude::*}; extern crate alloc; use astar_primitives::{dapp_staking::SmartContractHandle, AccountId, Balance, BlockNumber}; -use pallet_dapp_staking_v3::{ +use pallet_dapp_staking::{ AccountLedgerFor, ActiveProtocolState, ContractStake, ContractStakeAmount, CurrentEraInfo, DAppInfoFor, EraInfo, EraRewardSpanFor, EraRewards, IntegratedDApps, Ledger, Pallet as DAppStaking, ProtocolState, SingularStakingInfo, StakerInfo, Subperiod, @@ -116,12 +116,12 @@ pub struct DappStakingV3Precompile(PhantomData); impl DappStakingV3Precompile where R: pallet_evm::Config - + pallet_dapp_staking_v3::Config + + pallet_dapp_staking::Config + frame_system::Config, BlockNumberFor: IsType, ::RuntimeOrigin: From>, R::RuntimeCall: Dispatchable + GetDispatchInfo, - R::RuntimeCall: From>, + R::RuntimeCall: From>, { // v1 functions @@ -144,7 +144,7 @@ where #[precompile::view] fn read_unbonding_period(_: &mut impl PrecompileHandle) -> EvmResult { // constant, no DB read - Ok(::UnlockingPeriod::get().into()) + Ok(::UnlockingPeriod::get().into()) } /// Read the total assigned reward pool for the given era. @@ -237,7 +237,7 @@ where handle.record_db_read::( 24 + AccountLedgerFor::::max_encoded_len() + ProtocolState::max_encoded_len() - + ::SmartContract::max_encoded_len(), + + ::SmartContract::max_encoded_len(), )?; let staker = Self::parse_input_address(staker.into())?; @@ -267,12 +267,12 @@ where // Blake2_128Concat(16 + SmartContract::max_encoded_len) + SingularStakingInfo::max_encoded_len handle.record_db_read::( 24 + ProtocolState::max_encoded_len() - + ::SmartContract::max_encoded_len() + + ::SmartContract::max_encoded_len() + SingularStakingInfo::max_encoded_len(), )?; let smart_contract = - ::SmartContract::evm(contract_h160.into()); + ::SmartContract::evm(contract_h160.into()); // parse the staker account let staker = Self::parse_input_address(staker.into())?; @@ -307,13 +307,13 @@ where // Twox64Concat(8) + EraIndex(4) + ContractStakeAmount::max_encoded_len handle.record_db_read::( 36 + ProtocolState::max_encoded_len() - + ::SmartContract::max_encoded_len() + + ::SmartContract::max_encoded_len() + DAppInfoFor::::max_encoded_len() + ContractStakeAmount::max_encoded_len(), )?; let smart_contract = - ::SmartContract::evm(contract_h160.into()); + ::SmartContract::evm(contract_h160.into()); let current_period_number = ActiveProtocolState::::get().period_number(); let dapp_info = match IntegratedDApps::::get(&smart_contract) { @@ -356,11 +356,11 @@ where handle.record_db_read::( 24 + AccountLedgerFor::::max_encoded_len() + ProtocolState::max_encoded_len() - + ::SmartContract::max_encoded_len(), + + ::SmartContract::max_encoded_len(), )?; let smart_contract = - ::SmartContract::evm(contract_h160.into()); + ::SmartContract::evm(contract_h160.into()); log::trace!(target: "ds-precompile", "bond_and_stake {:?}, {:?}", smart_contract, amount); // Read total locked & staked amounts @@ -375,12 +375,12 @@ where if stakeable_amount < amount { let delta = amount.saturating_sub(stakeable_amount); - let lock_call = pallet_dapp_staking_v3::Call::::lock { amount: delta }; + let lock_call = pallet_dapp_staking::Call::::lock { amount: delta }; RuntimeHelper::::try_dispatch(handle, Some(origin.clone()).into(), lock_call)?; } // Now, with best effort, we can try & stake the given `value`. - let stake_call = pallet_dapp_staking_v3::Call::::stake { + let stake_call = pallet_dapp_staking::Call::::stake { smart_contract, amount, }; @@ -403,12 +403,12 @@ where // Blake2_128Concat(16 + SmartContract::max_encoded_len) + SingularStakingInfo::max_encoded_len handle.record_db_read::( 24 + ProtocolState::max_encoded_len() - + ::SmartContract::max_encoded_len() + + ::SmartContract::max_encoded_len() + SingularStakingInfo::max_encoded_len(), )?; let smart_contract = - ::SmartContract::evm(contract_h160.into()); + ::SmartContract::evm(contract_h160.into()); let origin = R::AddressMapping::into_account_id(handle.context().caller); log::trace!(target: "ds-precompile", "unbond_and_unstake {:?}, {:?}", smart_contract, amount); @@ -418,7 +418,7 @@ where // If there is, we need to unstake it before calling `unlock` if staker_info.period_number() == protocol_state.period_number() { - let unstake_call = pallet_dapp_staking_v3::Call::::unstake { + let unstake_call = pallet_dapp_staking::Call::::unstake { smart_contract, amount, }; @@ -426,7 +426,7 @@ where } // Now we can try and `unlock` the given `amount` - let unlock_call = pallet_dapp_staking_v3::Call::::unlock { amount }; + let unlock_call = pallet_dapp_staking::Call::::unlock { amount }; RuntimeHelper::::try_dispatch(handle, Some(origin).into(), unlock_call)?; Ok(true) @@ -436,7 +436,7 @@ where #[precompile::public("withdraw_unbonded()")] fn withdraw_unbonded(handle: &mut impl PrecompileHandle) -> EvmResult { let origin = R::AddressMapping::into_account_id(handle.context().caller); - let call = pallet_dapp_staking_v3::Call::::claim_unlocked {}; + let call = pallet_dapp_staking::Call::::claim_unlocked {}; RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; @@ -451,7 +451,7 @@ where era: u128, ) -> EvmResult { let smart_contract = - ::SmartContract::evm(contract_h160.into()); + ::SmartContract::evm(contract_h160.into()); // parse era let era = era @@ -462,7 +462,7 @@ where log::trace!(target: "ds-precompile", "claim_dapp {:?}, era {:?}", smart_contract, era); let origin = R::AddressMapping::into_account_id(handle.context().caller); - let call = pallet_dapp_staking_v3::Call::::claim_dapp_reward { + let call = pallet_dapp_staking::Call::::claim_dapp_reward { smart_contract, era, }; @@ -481,7 +481,7 @@ where _contract_h160: Address, ) -> EvmResult { let origin = R::AddressMapping::into_account_id(handle.context().caller); - let call = pallet_dapp_staking_v3::Call::::claim_staker_rewards {}; + let call = pallet_dapp_staking::Call::::claim_staker_rewards {}; RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; @@ -503,11 +503,11 @@ where contract_h160: Address, ) -> EvmResult { let smart_contract = - ::SmartContract::evm(contract_h160.into()); + ::SmartContract::evm(contract_h160.into()); log::trace!(target: "ds-precompile", "withdraw_from_unregistered {:?}", smart_contract); let origin = R::AddressMapping::into_account_id(handle.context().caller); - let call = pallet_dapp_staking_v3::Call::::unstake_from_unregistered { smart_contract }; + let call = pallet_dapp_staking::Call::::unstake_from_unregistered { smart_contract }; RuntimeHelper::::try_dispatch(handle, Some(origin).into(), call)?; @@ -528,14 +528,14 @@ where // Storage item: StakerInfo: // Blake2_128Concat(16 + SmartContract::max_encoded_len) + SingularStakingInfo::max_encoded_len handle.record_db_read::( - 16 + ::SmartContract::max_encoded_len() + 16 + ::SmartContract::max_encoded_len() + SingularStakingInfo::max_encoded_len(), )?; let origin_smart_contract = - ::SmartContract::evm(origin_contract_h160.into()); + ::SmartContract::evm(origin_contract_h160.into()); let target_smart_contract = - ::SmartContract::evm(target_contract_h160.into()); + ::SmartContract::evm(target_contract_h160.into()); log::trace!(target: "ds-precompile", "nomination_transfer {:?} {:?} {:?}", origin_smart_contract, amount, target_smart_contract); // Find out how much staker has staked on the origin contract @@ -546,7 +546,7 @@ where // if value comes from the past period. let staked_amount = staker_info.total_staked_amount(); let minimum_allowed_stake_amount = - ::MinimumStakeAmount::get(); + ::MinimumStakeAmount::get(); // In case the remaining staked amount on the origin contract is less than the minimum allowed stake amount, // everything will be unstaked. To keep in line with legacy `nomination_transfer` behavior, we should transfer @@ -562,14 +562,14 @@ where }; // First call unstake from the origin smart contract - let unstake_call = pallet_dapp_staking_v3::Call::::unstake { + let unstake_call = pallet_dapp_staking::Call::::unstake { smart_contract: origin_smart_contract, amount, }; RuntimeHelper::::try_dispatch(handle, Some(origin.clone()).into(), unstake_call)?; // Then call stake on the target smart contract - let stake_call = pallet_dapp_staking_v3::Call::::stake { + let stake_call = pallet_dapp_staking::Call::::stake { smart_contract: target_smart_contract, amount: stake_amount, }; @@ -611,7 +611,7 @@ where fn lock(handle: &mut impl PrecompileHandle, amount: u128) -> EvmResult { // Prepare call & dispatch it let origin = R::AddressMapping::into_account_id(handle.context().caller); - let lock_call = pallet_dapp_staking_v3::Call::::lock { amount }; + let lock_call = pallet_dapp_staking::Call::::lock { amount }; RuntimeHelper::::try_dispatch(handle, Some(origin).into(), lock_call)?; Ok(true) @@ -622,7 +622,7 @@ where fn unlock(handle: &mut impl PrecompileHandle, amount: u128) -> EvmResult { // Prepare call & dispatch it let origin = R::AddressMapping::into_account_id(handle.context().caller); - let unlock_call = pallet_dapp_staking_v3::Call::::unlock { amount }; + let unlock_call = pallet_dapp_staking::Call::::unlock { amount }; RuntimeHelper::::try_dispatch(handle, Some(origin).into(), unlock_call)?; Ok(true) @@ -633,7 +633,7 @@ where fn claim_unlocked(handle: &mut impl PrecompileHandle) -> EvmResult { // Prepare call & dispatch it let origin = R::AddressMapping::into_account_id(handle.context().caller); - let claim_unlocked_call = pallet_dapp_staking_v3::Call::::claim_unlocked {}; + let claim_unlocked_call = pallet_dapp_staking::Call::::claim_unlocked {}; RuntimeHelper::::try_dispatch(handle, Some(origin).into(), claim_unlocked_call)?; Ok(true) @@ -650,7 +650,7 @@ where // Prepare call & dispatch it let origin = R::AddressMapping::into_account_id(handle.context().caller); - let stake_call = pallet_dapp_staking_v3::Call::::stake { + let stake_call = pallet_dapp_staking::Call::::stake { smart_contract, amount, }; @@ -670,7 +670,7 @@ where // Prepare call & dispatch it let origin = R::AddressMapping::into_account_id(handle.context().caller); - let unstake_call = pallet_dapp_staking_v3::Call::::unstake { + let unstake_call = pallet_dapp_staking::Call::::unstake { smart_contract, amount, }; @@ -684,7 +684,7 @@ where fn claim_staker_rewards(handle: &mut impl PrecompileHandle) -> EvmResult { // Prepare call & dispatch it let origin = R::AddressMapping::into_account_id(handle.context().caller); - let claim_staker_rewards_call = pallet_dapp_staking_v3::Call::::claim_staker_rewards {}; + let claim_staker_rewards_call = pallet_dapp_staking::Call::::claim_staker_rewards {}; RuntimeHelper::::try_dispatch(handle, Some(origin).into(), claim_staker_rewards_call)?; Ok(true) @@ -701,7 +701,7 @@ where // Prepare call & dispatch it let origin = R::AddressMapping::into_account_id(handle.context().caller); let claim_bonus_reward_call = - pallet_dapp_staking_v3::Call::::claim_bonus_reward { smart_contract }; + pallet_dapp_staking::Call::::claim_bonus_reward { smart_contract }; RuntimeHelper::::try_dispatch(handle, Some(origin).into(), claim_bonus_reward_call)?; Ok(true) @@ -722,7 +722,7 @@ where // Prepare call & dispatch it let origin = R::AddressMapping::into_account_id(handle.context().caller); - let claim_dapp_reward_call = pallet_dapp_staking_v3::Call::::claim_dapp_reward { + let claim_dapp_reward_call = pallet_dapp_staking::Call::::claim_dapp_reward { smart_contract, era, }; @@ -742,7 +742,7 @@ where // Prepare call & dispatch it let origin = R::AddressMapping::into_account_id(handle.context().caller); let unstake_from_unregistered_call = - pallet_dapp_staking_v3::Call::::unstake_from_unregistered { smart_contract }; + pallet_dapp_staking::Call::::unstake_from_unregistered { smart_contract }; RuntimeHelper::::try_dispatch( handle, Some(origin).into(), @@ -758,7 +758,7 @@ where // Prepare call & dispatch it let origin = R::AddressMapping::into_account_id(handle.context().caller); let cleanup_expired_entries_call = - pallet_dapp_staking_v3::Call::::cleanup_expired_entries {}; + pallet_dapp_staking::Call::::cleanup_expired_entries {}; RuntimeHelper::::try_dispatch( handle, Some(origin).into(), @@ -773,7 +773,7 @@ where /// Helper method to decode smart contract struct for v2 calls pub(crate) fn decode_smart_contract( smart_contract: SmartContractV2, - ) -> EvmResult<::SmartContract> { + ) -> EvmResult<::SmartContract> { let smart_contract = match smart_contract.contract_type { SmartContractTypes::Evm => { ensure!( @@ -781,7 +781,7 @@ where revert("Invalid address length for Astar EVM smart contract.") ); let h160_address = H160::from_slice(smart_contract.address.as_bytes()); - ::SmartContract::evm(h160_address) + ::SmartContract::evm(h160_address) } SmartContractTypes::Wasm => { ensure!( @@ -791,7 +791,7 @@ where let mut staker_bytes = [0_u8; 32]; staker_bytes[..].clone_from_slice(&smart_contract.address.as_bytes()); - ::SmartContract::wasm(staker_bytes.into()) + ::SmartContract::wasm(staker_bytes.into()) } }; diff --git a/precompiles/dapp-staking-v3/src/test/mock.rs b/precompiles/dapp-staking/src/test/mock.rs similarity index 95% rename from precompiles/dapp-staking-v3/src/test/mock.rs rename to precompiles/dapp-staking/src/test/mock.rs index a59b456124..bc0ad4e1dc 100644 --- a/precompiles/dapp-staking-v3/src/test/mock.rs +++ b/precompiles/dapp-staking/src/test/mock.rs @@ -48,7 +48,7 @@ use astar_primitives::{ oracle::PriceProvider, AccountId, Balance, BlockNumber, }; -use pallet_dapp_staking_v3::TierThreshold; +use pallet_dapp_staking::TierThreshold; type Block = frame_system::mocking::MockBlockU32; @@ -240,7 +240,7 @@ impl CycleConfiguration for DummyCycleConfiguration { #[cfg(feature = "runtime-benchmarks")] pub struct BenchmarkHelper(sp_std::marker::PhantomData<(SC, ACC)>); #[cfg(feature = "runtime-benchmarks")] -impl pallet_dapp_staking_v3::BenchmarkHelper +impl pallet_dapp_staking::BenchmarkHelper for BenchmarkHelper { fn get_smart_contract(id: u32) -> MockSmartContract { @@ -254,7 +254,7 @@ parameter_types! { pub const BaseNativeCurrencyPrice: FixedU128 = FixedU128::from_rational(5, 100); } -impl pallet_dapp_staking_v3::Config for Test { +impl pallet_dapp_staking::Config for Test { type RuntimeEvent = RuntimeEvent; type RuntimeFreezeReason = RuntimeFreezeReason; type Currency = Balances; @@ -279,7 +279,7 @@ impl pallet_dapp_staking_v3::Config for Test { type MinimumStakeAmount = ConstU128<3>; type NumberOfTiers = ConstU32<4>; type RankingEnabled = ConstBool; - type WeightInfo = pallet_dapp_staking_v3::weights::SubstrateWeight; + type WeightInfo = pallet_dapp_staking::weights::SubstrateWeight; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = BenchmarkHelper; } @@ -290,7 +290,7 @@ construct_runtime!( Balances: pallet_balances, Evm: pallet_evm, Timestamp: pallet_timestamp, - DappStaking: pallet_dapp_staking_v3, + DappStaking: pallet_dapp_staking, } ); @@ -301,8 +301,8 @@ impl ExternalityBuilder { .build_storage() .unwrap(); - pallet_dapp_staking_v3::GenesisConfig::::assimilate_storage( - &pallet_dapp_staking_v3::GenesisConfig:: { + pallet_dapp_staking::GenesisConfig::::assimilate_storage( + &pallet_dapp_staking::GenesisConfig:: { reward_portion: vec![ Permill::from_percent(40), Permill::from_percent(30), @@ -343,7 +343,7 @@ impl ExternalityBuilder { let alice_native = AddressMapper::into_account_id(ALICE); assert_ok!( - ::Currency::write_balance( + ::Currency::write_balance( &alice_native, 1000_000_000_000_000_000_000 as Balance, ) @@ -364,7 +364,7 @@ pub const ALICE: H160 = H160::repeat_byte(0xAA); /// Used to register a smart contract, and stake some funds on it. pub fn register_and_stake( account: H160, - smart_contract: ::SmartContract, + smart_contract: ::SmartContract, amount: Balance, ) { let alice_native = AddressMapper::into_account_id(account); @@ -466,12 +466,12 @@ pub(crate) fn advance_to_next_period() { } // Return all dApp staking events from the event buffer. -pub fn dapp_staking_events() -> Vec> { +pub fn dapp_staking_events() -> Vec> { System::events() .into_iter() .map(|r| r.event) .filter_map(|e| { - ::RuntimeEvent::from(e) + ::RuntimeEvent::from(e) .try_into() .ok() }) diff --git a/precompiles/dapp-staking-v3/src/test/mod.rs b/precompiles/dapp-staking/src/test/mod.rs similarity index 100% rename from precompiles/dapp-staking-v3/src/test/mod.rs rename to precompiles/dapp-staking/src/test/mod.rs diff --git a/precompiles/dapp-staking-v3/src/test/tests_v2.rs b/precompiles/dapp-staking/src/test/tests_v2.rs similarity index 91% rename from precompiles/dapp-staking-v3/src/test/tests_v2.rs rename to precompiles/dapp-staking/src/test/tests_v2.rs index f53ecf2968..df47e7b3f4 100644 --- a/precompiles/dapp-staking-v3/src/test/tests_v2.rs +++ b/precompiles/dapp-staking/src/test/tests_v2.rs @@ -27,7 +27,7 @@ use sp_runtime::traits::Zero; use assert_matches::assert_matches; use astar_primitives::dapp_staking::EraNumber; -use pallet_dapp_staking_v3::{ActiveProtocolState, EraRewards}; +use pallet_dapp_staking::{ActiveProtocolState, EraRewards}; #[test] fn read_current_era_is_ok() { @@ -62,7 +62,7 @@ fn read_unbonding_period_is_ok() { initialize(); let unlocking_period_in_eras: EraNumber = - ::UnlockingPeriod::get(); + ::UnlockingPeriod::get(); precompiles() .prepare_test( @@ -122,7 +122,7 @@ fn read_era_staked_is_ok() { let staker_h160 = ALICE; let smart_contract_address = H160::repeat_byte(0xFA); let smart_contract = - ::SmartContract::evm(smart_contract_address); + ::SmartContract::evm(smart_contract_address); let amount = 1_000_000_000_000; register_and_stake(staker_h160, smart_contract.clone(), amount); let anchor_era = ActiveProtocolState::::get().era; @@ -200,7 +200,7 @@ fn read_staked_amount_is_ok() { // 2. Stake some amount and check again let smart_contract_address = H160::repeat_byte(0xFA); let smart_contract = - ::SmartContract::evm(smart_contract_address); + ::SmartContract::evm(smart_contract_address); let amount = 1_000_000_000_000; register_and_stake(staker_h160, smart_contract.clone(), amount); for staker in &dynamic_addresses { @@ -241,7 +241,7 @@ fn read_staked_amount_on_contract_is_ok() { let staker_h160 = ALICE; let smart_contract_address = H160::repeat_byte(0xFA); let smart_contract = - ::SmartContract::evm(smart_contract_address); + ::SmartContract::evm(smart_contract_address); let dynamic_addresses = into_dynamic_addresses(staker_h160); // 1. Sanity checks - must be zero before anything is staked. @@ -316,7 +316,7 @@ fn read_contract_stake_is_ok() { // 2. Stake some amount and check again let smart_contract = - ::SmartContract::evm(smart_contract_address); + ::SmartContract::evm(smart_contract_address); let amount = 1_000_000_000_000; register_and_stake(staker_h160, smart_contract.clone(), amount); @@ -391,7 +391,7 @@ fn bond_and_stake_with_two_calls_is_ok() { let staker_h160 = ALICE; let smart_contract_address = H160::repeat_byte(0xFA); let smart_contract = - ::SmartContract::evm(smart_contract_address); + ::SmartContract::evm(smart_contract_address); assert_ok!(DappStaking::register( RawOrigin::Root.into(), AddressMapper::into_account_id(staker_h160), @@ -425,14 +425,14 @@ fn bond_and_stake_with_two_calls_is_ok() { let additional_lock_amount = stake_amount - pre_lock_amount; assert_matches!( events[0].clone(), - pallet_dapp_staking_v3::Event::Locked { + pallet_dapp_staking::Event::Locked { amount, .. } if amount == additional_lock_amount ); assert_matches!( events[1].clone(), - pallet_dapp_staking_v3::Event::Stake { + pallet_dapp_staking::Event::Stake { smart_contract, amount, .. @@ -450,7 +450,7 @@ fn bond_and_stake_with_single_call_is_ok() { let staker_h160 = ALICE; let smart_contract_address = H160::repeat_byte(0xFA); let smart_contract = - ::SmartContract::evm(smart_contract_address); + ::SmartContract::evm(smart_contract_address); assert_ok!(DappStaking::register( RawOrigin::Root.into(), AddressMapper::into_account_id(staker_h160), @@ -482,7 +482,7 @@ fn bond_and_stake_with_single_call_is_ok() { assert_eq!(events.len(), 1); assert_matches!( events[0].clone(), - pallet_dapp_staking_v3::Event::Stake { + pallet_dapp_staking::Event::Stake { smart_contract, amount, .. @@ -500,7 +500,7 @@ fn unbond_and_unstake_with_two_calls_is_ok() { let staker_h160 = ALICE; let smart_contract_address = H160::repeat_byte(0xFA); let smart_contract = - ::SmartContract::evm(smart_contract_address); + ::SmartContract::evm(smart_contract_address); let amount = 1_000_000_000_000; register_and_stake(staker_h160, smart_contract.clone(), amount); @@ -522,7 +522,7 @@ fn unbond_and_unstake_with_two_calls_is_ok() { assert_eq!(events.len(), 2); assert_matches!( events[0].clone(), - pallet_dapp_staking_v3::Event::Unstake { + pallet_dapp_staking::Event::Unstake { smart_contract, amount, .. @@ -530,7 +530,7 @@ fn unbond_and_unstake_with_two_calls_is_ok() { ); assert_matches!( events[1].clone(), - pallet_dapp_staking_v3::Event::Unlocking { amount, .. } if amount == amount + pallet_dapp_staking::Event::Unlocking { amount, .. } if amount == amount ); }); } @@ -544,7 +544,7 @@ fn unbond_and_unstake_with_single_calls_is_ok() { let staker_h160 = ALICE; let smart_contract_address = H160::repeat_byte(0xFA); let smart_contract = - ::SmartContract::evm(smart_contract_address); + ::SmartContract::evm(smart_contract_address); let amount = 1_000_000_000_000; register_and_stake(staker_h160, smart_contract.clone(), amount); @@ -573,7 +573,7 @@ fn unbond_and_unstake_with_single_calls_is_ok() { assert_eq!(events.len(), 1); assert_matches!( events[0].clone(), - pallet_dapp_staking_v3::Event::Unlocking { amount, .. } if amount == amount + pallet_dapp_staking::Event::Unlocking { amount, .. } if amount == amount ); }); } @@ -588,7 +588,7 @@ fn withdraw_unbonded_is_ok() { let staker_native = AddressMapper::into_account_id(staker_h160); let smart_contract_address = H160::repeat_byte(0xFA); let smart_contract = - ::SmartContract::evm(smart_contract_address); + ::SmartContract::evm(smart_contract_address); let amount = 1_000_000_000_000; register_and_stake(staker_h160, smart_contract.clone(), amount); @@ -623,7 +623,7 @@ fn withdraw_unbonded_is_ok() { assert_eq!(events.len(), 1); assert_matches!( events[0].clone(), - pallet_dapp_staking_v3::Event::ClaimedUnlocked { + pallet_dapp_staking::Event::ClaimedUnlocked { amount, .. } if amount == unlock_amount @@ -640,7 +640,7 @@ fn claim_dapp_is_ok() { let staker_h160 = ALICE; let smart_contract_address = H160::repeat_byte(0xFA); let smart_contract = - ::SmartContract::evm(smart_contract_address); + ::SmartContract::evm(smart_contract_address); let amount = 1_000_000_000_000; register_and_stake(staker_h160, smart_contract.clone(), amount); @@ -666,7 +666,7 @@ fn claim_dapp_is_ok() { assert_eq!(events.len(), 1); assert_matches!( events[0].clone(), - pallet_dapp_staking_v3::Event::DAppReward { + pallet_dapp_staking::Event::DAppReward { era, smart_contract, .. @@ -684,7 +684,7 @@ fn claim_staker_is_ok() { let staker_h160 = ALICE; let smart_contract_address = H160::repeat_byte(0xFA); let smart_contract = - ::SmartContract::evm(smart_contract_address); + ::SmartContract::evm(smart_contract_address); let amount = 1_000_000_000_000; register_and_stake(staker_h160, smart_contract.clone(), amount); @@ -712,7 +712,7 @@ fn claim_staker_is_ok() { for era in 2..target_era { assert_matches!( events[era as usize - 2].clone(), - pallet_dapp_staking_v3::Event::Reward { era, .. } if era == era + pallet_dapp_staking::Event::Reward { era, .. } if era == era ); } }); @@ -727,7 +727,7 @@ fn withdraw_from_unregistered_is_ok() { let staker_h160 = ALICE; let smart_contract_address = H160::repeat_byte(0xFA); let smart_contract = - ::SmartContract::evm(smart_contract_address); + ::SmartContract::evm(smart_contract_address); let amount = 1_000_000_000_000; register_and_stake(staker_h160, smart_contract.clone(), amount); @@ -754,7 +754,7 @@ fn withdraw_from_unregistered_is_ok() { assert_eq!(events.len(), 1); assert_matches!( events[0].clone(), - pallet_dapp_staking_v3::Event::UnstakeFromUnregistered { + pallet_dapp_staking::Event::UnstakeFromUnregistered { smart_contract, amount, .. @@ -773,14 +773,14 @@ fn nomination_transfer_is_ok() { let staker_native = AddressMapper::into_account_id(staker_h160); let smart_contract_address_1 = H160::repeat_byte(0xFA); let smart_contract_1 = - ::SmartContract::evm(smart_contract_address_1); + ::SmartContract::evm(smart_contract_address_1); let amount = 1_000_000_000_000; register_and_stake(staker_h160, smart_contract_1.clone(), amount); // Register the second dApp. let smart_contract_address_2 = H160::repeat_byte(0xBF); let smart_contract_2 = - ::SmartContract::evm(smart_contract_address_2); + ::SmartContract::evm(smart_contract_address_2); assert_ok!(DappStaking::register( RawOrigin::Root.into(), staker_native.clone(), @@ -790,7 +790,7 @@ fn nomination_transfer_is_ok() { // 1st scenario - transfer enough amount from the first to second dApp to cover the stake, // but not enough for full unstake. let minimum_stake_amount: Balance = - ::MinimumStakeAmount::get(); + ::MinimumStakeAmount::get(); System::reset_events(); precompiles() @@ -811,7 +811,7 @@ fn nomination_transfer_is_ok() { assert_eq!(events.len(), 2); assert_matches!( events[0].clone(), - pallet_dapp_staking_v3::Event::Unstake { + pallet_dapp_staking::Event::Unstake { smart_contract, amount, .. @@ -819,7 +819,7 @@ fn nomination_transfer_is_ok() { ); assert_matches!( events[1].clone(), - pallet_dapp_staking_v3::Event::Stake { + pallet_dapp_staking::Event::Stake { smart_contract, amount, .. @@ -850,7 +850,7 @@ fn nomination_transfer_is_ok() { assert_eq!(events.len(), 2); assert_matches!( events[0].clone(), - pallet_dapp_staking_v3::Event::Unstake { + pallet_dapp_staking::Event::Unstake { smart_contract, amount, .. @@ -858,7 +858,7 @@ fn nomination_transfer_is_ok() { ); assert_matches!( events[1].clone(), - pallet_dapp_staking_v3::Event::Stake { + pallet_dapp_staking::Event::Stake { smart_contract, amount, .. diff --git a/precompiles/dapp-staking-v3/src/test/tests_v3.rs b/precompiles/dapp-staking/src/test/tests_v3.rs similarity index 89% rename from precompiles/dapp-staking-v3/src/test/tests_v3.rs rename to precompiles/dapp-staking/src/test/tests_v3.rs index af5c6a6587..522f1fb764 100644 --- a/precompiles/dapp-staking-v3/src/test/tests_v3.rs +++ b/precompiles/dapp-staking/src/test/tests_v3.rs @@ -29,7 +29,7 @@ use astar_primitives::{ dapp_staking::{CycleConfiguration, EraNumber}, BlockNumber, }; -use pallet_dapp_staking_v3::ActiveProtocolState; +use pallet_dapp_staking::ActiveProtocolState; #[test] fn protocol_state_is_ok() { @@ -65,9 +65,9 @@ fn unlocking_period_is_ok() { initialize(); let unlocking_period_in_eras: EraNumber = - ::UnlockingPeriod::get(); + ::UnlockingPeriod::get(); let era_length: BlockNumber = - ::CycleConfiguration::blocks_per_era(); + ::CycleConfiguration::blocks_per_era(); let expected_outcome = era_length * unlocking_period_in_eras; @@ -99,7 +99,7 @@ fn lock_is_ok() { assert_eq!(events.len(), 1); assert_matches!( events[0].clone(), - pallet_dapp_staking_v3::Event::Locked { + pallet_dapp_staking::Event::Locked { amount, .. } if amount == amount @@ -136,7 +136,7 @@ fn unlock_is_ok() { assert_eq!(events.len(), 1); assert_matches!( events[0].clone(), - pallet_dapp_staking_v3::Event::Unlocking { + pallet_dapp_staking::Event::Unlocking { amount, .. } if amount == unlock_amount @@ -180,7 +180,7 @@ fn claim_unlocked_is_ok() { assert_eq!(events.len(), 1); assert_matches!( events[0].clone(), - pallet_dapp_staking_v3::Event::ClaimedUnlocked { + pallet_dapp_staking::Event::ClaimedUnlocked { amount, .. } if amount == amount @@ -197,7 +197,7 @@ fn stake_is_ok() { let staker_h160 = ALICE; let smart_contract_h160 = H160::repeat_byte(0xFA); let smart_contract = - ::SmartContract::evm(smart_contract_h160); + ::SmartContract::evm(smart_contract_h160); assert_ok!(DappStaking::register( RawOrigin::Root.into(), AddressMapper::into_account_id(staker_h160), @@ -234,7 +234,7 @@ fn stake_is_ok() { assert_eq!(events.len(), 1); assert_matches!( events[0].clone(), - pallet_dapp_staking_v3::Event::Stake { + pallet_dapp_staking::Event::Stake { smart_contract, amount, .. @@ -251,7 +251,7 @@ fn unstake_is_ok() { // Register a dApp for staking let staker_h160 = ALICE; let smart_contract_address = [0xAF; 32]; - let smart_contract = ::SmartContract::wasm( + let smart_contract = ::SmartContract::wasm( smart_contract_address.into(), ); assert_ok!(DappStaking::register( @@ -295,7 +295,7 @@ fn unstake_is_ok() { assert_eq!(events.len(), 1); assert_matches!( events[0].clone(), - pallet_dapp_staking_v3::Event::Unstake { + pallet_dapp_staking::Event::Unstake { smart_contract, amount, .. @@ -312,7 +312,7 @@ fn claim_staker_rewards_is_ok() { // Register a dApp and stake on it let staker_h160 = ALICE; let smart_contract_address = [0xAF; 32]; - let smart_contract = ::SmartContract::wasm( + let smart_contract = ::SmartContract::wasm( smart_contract_address.into(), ); let amount = 1234; @@ -340,7 +340,7 @@ fn claim_staker_rewards_is_ok() { for era in 2..target_era { assert_matches!( events[era as usize - 2].clone(), - pallet_dapp_staking_v3::Event::Reward { era, .. } if era == era + pallet_dapp_staking::Event::Reward { era, .. } if era == era ); } }); @@ -354,7 +354,7 @@ fn claim_bonus_reward_is_ok() { // Register a dApp and stake on it, loyally let staker_h160 = ALICE; let smart_contract_address = [0xAF; 32]; - let smart_contract = ::SmartContract::wasm( + let smart_contract = ::SmartContract::wasm( smart_contract_address.into(), ); let amount = 1234; @@ -385,7 +385,7 @@ fn claim_bonus_reward_is_ok() { assert_eq!(events.len(), 1); assert_matches!( events[0].clone(), - pallet_dapp_staking_v3::Event::BonusReward { smart_contract, .. } if smart_contract == smart_contract + pallet_dapp_staking::Event::BonusReward { smart_contract, .. } if smart_contract == smart_contract ); }); } @@ -398,7 +398,7 @@ fn claim_dapp_reward_is_ok() { // Register a dApp and stake on it let staker_h160 = ALICE; let smart_contract_address = [0xAF; 32]; - let smart_contract = ::SmartContract::wasm( + let smart_contract = ::SmartContract::wasm( smart_contract_address.into(), ); let amount = 1234; @@ -431,7 +431,7 @@ fn claim_dapp_reward_is_ok() { assert_eq!(events.len(), 1); assert_matches!( events[0].clone(), - pallet_dapp_staking_v3::Event::DAppReward { era, smart_contract, .. } if era == claim_era && smart_contract == smart_contract + pallet_dapp_staking::Event::DAppReward { era, smart_contract, .. } if era == claim_era && smart_contract == smart_contract ); }); } @@ -444,7 +444,7 @@ fn unstake_from_unregistered_is_ok() { // Register a dApp and stake on it let staker_h160 = ALICE; let smart_contract_address = [0xAF; 32]; - let smart_contract = ::SmartContract::wasm( + let smart_contract = ::SmartContract::wasm( smart_contract_address.into(), ); let amount = 1234; @@ -478,7 +478,7 @@ fn unstake_from_unregistered_is_ok() { assert_eq!(events.len(), 1); assert_matches!( events[0].clone(), - pallet_dapp_staking_v3::Event::UnstakeFromUnregistered { smart_contract, amount, .. } if smart_contract == smart_contract && amount == amount + pallet_dapp_staking::Event::UnstakeFromUnregistered { smart_contract, amount, .. } if smart_contract == smart_contract && amount == amount ); }); } @@ -499,7 +499,7 @@ fn cleanup_expired_entries_is_ok() { // Register a dApp and stake on it let staker_h160 = ALICE; let smart_contract_address = [0xAF; 32]; - let smart_contract = ::SmartContract::wasm( + let smart_contract = ::SmartContract::wasm( smart_contract_address.into(), ); let amount = 1234; @@ -523,7 +523,7 @@ fn cleanup_expired_entries_is_ok() { assert_eq!(events.len(), 1); assert_matches!( events[0].clone(), - pallet_dapp_staking_v3::Event::ExpiredEntriesRemoved { count, .. } if count == 1 + pallet_dapp_staking::Event::ExpiredEntriesRemoved { count, .. } if count == 1 ); }); } diff --git a/precompiles/dapp-staking-v3/src/test/types.rs b/precompiles/dapp-staking/src/test/types.rs similarity index 94% rename from precompiles/dapp-staking-v3/src/test/types.rs rename to precompiles/dapp-staking/src/test/types.rs index c691ef7a6c..7ad523c1f7 100644 --- a/precompiles/dapp-staking-v3/src/test/types.rs +++ b/precompiles/dapp-staking/src/test/types.rs @@ -57,7 +57,9 @@ fn decode_smart_contract_is_ok() { }; assert_eq!( - Ok(::SmartContract::evm(address)), + Ok(::SmartContract::evm( + address + )), DappStakingV3Precompile::::decode_smart_contract(smart_contract_v2) ); } @@ -71,7 +73,9 @@ fn decode_smart_contract_is_ok() { }; assert_eq!( - Ok(::SmartContract::wasm(address.into())), + Ok(::SmartContract::wasm( + address.into() + )), DappStakingV3Precompile::::decode_smart_contract(smart_contract_v2) ); } diff --git a/runtime/astar/Cargo.toml b/runtime/astar/Cargo.toml index ae2a36cd8c..1c375c4270 100644 --- a/runtime/astar/Cargo.toml +++ b/runtime/astar/Cargo.toml @@ -108,9 +108,9 @@ frame-try-runtime = { workspace = true, optional = true } astar-primitives = { workspace = true } astar-xcm-benchmarks = { workspace = true, optional = true } pallet-collator-selection = { workspace = true } -pallet-dapp-staking-v3 = { workspace = true } +pallet-dapp-staking = { workspace = true } pallet-evm-precompile-assets-erc20 = { workspace = true } -pallet-evm-precompile-dapp-staking-v3 = { workspace = true } +pallet-evm-precompile-dapp-staking = { workspace = true } pallet-evm-precompile-dispatch-lockdrop = { workspace = true } pallet-evm-precompile-sr25519 = { workspace = true } pallet-evm-precompile-substrate-ecdsa = { workspace = true } @@ -120,7 +120,7 @@ pallet-price-aggregator = { workspace = true } pallet-xc-asset-config = { workspace = true } pallet-xcm = { workspace = true } -dapp-staking-v3-runtime-api = { workspace = true } +dapp-staking-runtime-api = { workspace = true } # Moonbeam tracing moonbeam-evm-tracer = { workspace = true, optional = true } @@ -167,11 +167,11 @@ std = [ "pallet-aura/std", "pallet-balances/std", "pallet-proxy/std", - "pallet-dapp-staking-v3/std", + "pallet-dapp-staking/std", "xcm-fee-payment-runtime-api/std", - "dapp-staking-v3-runtime-api/std", + "dapp-staking-runtime-api/std", "pallet-inflation/std", - "pallet-evm-precompile-dapp-staking-v3/std", + "pallet-evm-precompile-dapp-staking/std", "pallet-evm-precompile-sr25519/std", "pallet-evm-precompile-assets-erc20/std", "pallet-evm-precompile-substrate-ecdsa/std", @@ -246,7 +246,7 @@ runtime-benchmarks = [ "pallet-proxy/runtime-benchmarks", 'pallet-timestamp/runtime-benchmarks', "pallet-ethereum/runtime-benchmarks", - "pallet-dapp-staking-v3/runtime-benchmarks", + "pallet-dapp-staking/runtime-benchmarks", "pallet-price-aggregator/runtime-benchmarks", "pallet-inflation/runtime-benchmarks", "pallet-membership/runtime-benchmarks", @@ -269,7 +269,7 @@ runtime-benchmarks = [ "pallet-contracts/runtime-benchmarks", "pallet-evm/runtime-benchmarks", "pallet-evm-precompile-assets-erc20/runtime-benchmarks", - "pallet-evm-precompile-dapp-staking-v3/runtime-benchmarks", + "pallet-evm-precompile-dapp-staking/runtime-benchmarks", "pallet-evm-precompile-xcm/runtime-benchmarks", "pallet-identity/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", @@ -295,7 +295,7 @@ try-runtime = [ "pallet-aura/try-runtime", "pallet-balances/try-runtime", "pallet-proxy/try-runtime", - "pallet-dapp-staking-v3/try-runtime", + "pallet-dapp-staking/try-runtime", "pallet-inflation/try-runtime", "pallet-sudo/try-runtime", "pallet-timestamp/try-runtime", diff --git a/runtime/astar/src/lib.rs b/runtime/astar/src/lib.rs index 248f93e636..07b98fd20a 100644 --- a/runtime/astar/src/lib.rs +++ b/runtime/astar/src/lib.rs @@ -86,7 +86,7 @@ use astar_primitives::{ }; pub use astar_primitives::{governance::OracleMembershipInst, AccountId, Balance, Signature}; -pub use pallet_dapp_staking_v3::TierThreshold; +pub use pallet_dapp_staking::TierThreshold; pub use pallet_inflation::InflationParameters; pub use crate::precompiles::WhitelistedCalls; @@ -362,7 +362,7 @@ parameter_types! { #[cfg(feature = "runtime-benchmarks")] pub struct DAppStakingBenchmarkHelper(sp_std::marker::PhantomData<(SC, ACC)>); #[cfg(feature = "runtime-benchmarks")] -impl pallet_dapp_staking_v3::BenchmarkHelper, AccountId> +impl pallet_dapp_staking::BenchmarkHelper, AccountId> for DAppStakingBenchmarkHelper, AccountId> { fn get_smart_contract(id: u32) -> SmartContract { @@ -387,7 +387,7 @@ impl DappStakingAccountCheck for AccountCheck { } } -impl pallet_dapp_staking_v3::Config for Runtime { +impl pallet_dapp_staking::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeFreezeReason = RuntimeFreezeReason; type Currency = Balances; @@ -412,7 +412,7 @@ impl pallet_dapp_staking_v3::Config for Runtime { type MinimumStakeAmount = MinimumStakingAmount; type NumberOfTiers = ConstU32<4>; type RankingEnabled = ConstBool; - type WeightInfo = weights::pallet_dapp_staking_v3::SubstrateWeight; + type WeightInfo = weights::pallet_dapp_staking::SubstrateWeight; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = DAppStakingBenchmarkHelper, AccountId>; } @@ -1056,7 +1056,7 @@ impl InstanceFilter for ProxyType { matches!( c, RuntimeCall::DappStaking( - pallet_dapp_staking_v3::Call::claim_staker_rewards { .. } + pallet_dapp_staking::Call::claim_staker_rewards { .. } ) ) } @@ -1229,7 +1229,7 @@ construct_runtime!( // logic is executed. // TODO: Address this later. It would be best if Inflation was first pallet. Inflation: pallet_inflation = 33, - DappStaking: pallet_dapp_staking_v3 = 34, + DappStaking: pallet_dapp_staking = 34, Assets: pallet_assets = 36, PriceAggregator: pallet_price_aggregator = 37, Oracle: orml_oracle = 38, @@ -1331,7 +1331,7 @@ pub type Migrations = (Unreleased, Permanent); /// Unreleased migrations. Add new ones here: pub type Unreleased = ( // dApp-staking dyn tier threshold migrations - pallet_dapp_staking_v3::migration::versioned_migrations::V7ToV8< + pallet_dapp_staking::migration::versioned_migrations::V7ToV8< Runtime, TierThresholds, ThresholdVariationPercentage, @@ -1421,7 +1421,7 @@ mod benches { [pallet_assets, pallet_assets::Pallet::] [pallet_balances, Balances] [pallet_timestamp, Timestamp] - [pallet_dapp_staking_v3, DappStaking] + [pallet_dapp_staking, DappStaking] [pallet_inflation, Inflation] [pallet_migrations, MultiBlockMigrations] [pallet_xc_asset_config, XcAssetConfig] @@ -1897,7 +1897,7 @@ impl_runtime_apis! { } } - impl dapp_staking_v3_runtime_api::DappStakingApi for Runtime { + impl dapp_staking_runtime_api::DappStakingApi for Runtime { fn periods_per_cycle() -> PeriodNumber { InflationCycleConfig::periods_per_cycle() } diff --git a/runtime/astar/src/precompiles.rs b/runtime/astar/src/precompiles.rs index 28b6feea82..c2d85d0010 100644 --- a/runtime/astar/src/precompiles.rs +++ b/runtime/astar/src/precompiles.rs @@ -24,7 +24,7 @@ use frame_support::{parameter_types, traits::Contains}; use pallet_evm_precompile_assets_erc20::Erc20AssetsPrecompileSet; use pallet_evm_precompile_blake2::Blake2F; use pallet_evm_precompile_bn128::{Bn128Add, Bn128Mul, Bn128Pairing}; -use pallet_evm_precompile_dapp_staking_v3::DappStakingV3Precompile; +use pallet_evm_precompile_dapp_staking::DappStakingV3Precompile; use pallet_evm_precompile_dispatch::Dispatch; use pallet_evm_precompile_dispatch_lockdrop::DispatchLockdrop; use pallet_evm_precompile_ed25519::Ed25519Verify; @@ -78,12 +78,8 @@ impl Contains for WhitelistedLockdropCalls { | RuntimeCall::Utility(pallet_utility::Call::batch_all { calls }) => calls .iter() .all(|call| WhitelistedLockdropCalls::contains(call)), - RuntimeCall::DappStaking(pallet_dapp_staking_v3::Call::unbond_and_unstake { - .. - }) => true, - RuntimeCall::DappStaking(pallet_dapp_staking_v3::Call::withdraw_unbonded { - .. - }) => true, + RuntimeCall::DappStaking(pallet_dapp_staking::Call::unbond_and_unstake { .. }) => true, + RuntimeCall::DappStaking(pallet_dapp_staking::Call::withdraw_unbonded { .. }) => true, RuntimeCall::Balances(pallet_balances::Call::transfer_all { .. }) => true, RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive { .. }) => true, RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { .. }) => true, diff --git a/runtime/astar/src/weights/mod.rs b/runtime/astar/src/weights/mod.rs index 0b665ae16e..476c43da5b 100644 --- a/runtime/astar/src/weights/mod.rs +++ b/runtime/astar/src/weights/mod.rs @@ -18,7 +18,7 @@ pub mod orml_oracle; pub mod pallet_assets; -pub mod pallet_dapp_staking_v3; +pub mod pallet_dapp_staking; pub mod pallet_inflation; pub mod pallet_xcm; pub mod xcm; diff --git a/runtime/astar/src/weights/pallet_dapp_staking_v3.rs b/runtime/astar/src/weights/pallet_dapp_staking.rs similarity index 98% rename from runtime/astar/src/weights/pallet_dapp_staking_v3.rs rename to runtime/astar/src/weights/pallet_dapp_staking.rs index d7e546f98c..6bb3456bb5 100644 --- a/runtime/astar/src/weights/pallet_dapp_staking_v3.rs +++ b/runtime/astar/src/weights/pallet_dapp_staking.rs @@ -17,7 +17,7 @@ // You should have received a copy of the GNU General Public License // along with Astar. If not, see . -//! Autogenerated weights for pallet_dapp_staking_v3 +//! Autogenerated weights for pallet_dapp_staking //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2024-04-30, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` @@ -32,12 +32,12 @@ // --chain=astar-dev // --steps=50 // --repeat=20 -// --pallet=pallet_dapp_staking_v3 +// --pallet=pallet_dapp_staking // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./benchmark-results/astar-dev/dapp_staking_v3_weights.rs +// --output=./benchmark-results/astar-dev/dapp_staking_weights.rs // --template=./scripts/templates/weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -46,9 +46,9 @@ use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use core::marker::PhantomData; -use pallet_dapp_staking_v3::WeightInfo; +use pallet_dapp_staking::WeightInfo; -// Weights for pallet_dapp_staking_v3 using the Substrate node and recommended hardware. +// Weights for pallet_dapp_staking using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn maintenance_mode() -> Weight { diff --git a/runtime/local/Cargo.toml b/runtime/local/Cargo.toml index 80134dc292..d232ae9510 100644 --- a/runtime/local/Cargo.toml +++ b/runtime/local/Cargo.toml @@ -71,10 +71,10 @@ pallet-transaction-payment-rpc-runtime-api = { workspace = true } astar-primitives = { workspace = true } pallet-chain-extension-unified-accounts = { workspace = true } pallet-collective-proxy = { workspace = true } -pallet-dapp-staking-v3 = { workspace = true } +pallet-dapp-staking = { workspace = true } pallet-dynamic-evm-base-fee = { workspace = true } pallet-evm-precompile-assets-erc20 = { workspace = true } -pallet-evm-precompile-dapp-staking-v3 = { workspace = true } +pallet-evm-precompile-dapp-staking = { workspace = true } pallet-evm-precompile-dispatch-lockdrop = { workspace = true } pallet-evm-precompile-sr25519 = { workspace = true } pallet-evm-precompile-substrate-ecdsa = { workspace = true } @@ -83,7 +83,7 @@ pallet-inflation = { workspace = true } pallet-static-price-provider = { workspace = true } pallet-unified-accounts = { workspace = true } -dapp-staking-v3-runtime-api = { workspace = true } +dapp-staking-runtime-api = { workspace = true } precompile-utils = { workspace = true } @@ -123,8 +123,8 @@ std = [ "pallet-balances/std", "pallet-contracts/std", "pallet-chain-extension-unified-accounts/std", - "pallet-dapp-staking-v3/std", - "dapp-staking-v3-runtime-api/std", + "pallet-dapp-staking/std", + "dapp-staking-runtime-api/std", "pallet-inflation/std", "pallet-static-price-provider/std", "pallet-dynamic-evm-base-fee/std", @@ -138,7 +138,7 @@ std = [ "pallet-evm-precompile-ed25519/std", "pallet-evm-precompile-modexp/std", "pallet-evm-precompile-sha3fips/std", - "pallet-evm-precompile-dapp-staking-v3/std", + "pallet-evm-precompile-dapp-staking/std", "pallet-evm-precompile-sr25519/std", "pallet-evm-precompile-substrate-ecdsa/std", "pallet-evm-precompile-unified-accounts/std", @@ -206,7 +206,7 @@ runtime-benchmarks = [ "pallet-unified-accounts/runtime-benchmarks", "astar-primitives/runtime-benchmarks", "pallet-assets/runtime-benchmarks", - "pallet-dapp-staking-v3/runtime-benchmarks", + "pallet-dapp-staking/runtime-benchmarks", "pallet-inflation/runtime-benchmarks", "pallet-membership/runtime-benchmarks", "pallet-dynamic-evm-base-fee/runtime-benchmarks", @@ -215,7 +215,7 @@ runtime-benchmarks = [ "pallet-contracts/runtime-benchmarks", "pallet-evm/runtime-benchmarks", "pallet-evm-precompile-assets-erc20/runtime-benchmarks", - "pallet-evm-precompile-dapp-staking-v3/runtime-benchmarks", + "pallet-evm-precompile-dapp-staking/runtime-benchmarks", "pallet-grandpa/runtime-benchmarks", "pallet-proxy/runtime-benchmarks", "pallet-scheduler/runtime-benchmarks", @@ -235,7 +235,7 @@ try-runtime = [ "pallet-balances/try-runtime", "pallet-contracts/try-runtime", "pallet-collective-proxy/try-runtime", - "pallet-dapp-staking-v3/try-runtime", + "pallet-dapp-staking/try-runtime", "pallet-treasury/try-runtime", "pallet-inflation/try-runtime", "pallet-membership/try-runtime", diff --git a/runtime/local/src/lib.rs b/runtime/local/src/lib.rs index cc262965bb..b610fe5329 100644 --- a/runtime/local/src/lib.rs +++ b/runtime/local/src/lib.rs @@ -83,7 +83,7 @@ use astar_primitives::{ }; pub use astar_primitives::{AccountId, Signature}; -pub use pallet_dapp_staking_v3::TierThreshold; +pub use pallet_dapp_staking::TierThreshold; pub use crate::precompiles::WhitelistedCalls; #[cfg(feature = "std")] @@ -444,7 +444,7 @@ impl pallet_static_price_provider::Config for Runtime { #[cfg(feature = "runtime-benchmarks")] pub struct BenchmarkHelper(sp_std::marker::PhantomData<(SC, ACC)>); #[cfg(feature = "runtime-benchmarks")] -impl pallet_dapp_staking_v3::BenchmarkHelper, AccountId> +impl pallet_dapp_staking::BenchmarkHelper, AccountId> for BenchmarkHelper, AccountId> { fn get_smart_contract(id: u32) -> SmartContract { @@ -462,7 +462,7 @@ parameter_types! { pub const BaseNativeCurrencyPrice: FixedU128 = FixedU128::from_rational(5, 100); } -impl pallet_dapp_staking_v3::Config for Runtime { +impl pallet_dapp_staking::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeFreezeReason = RuntimeFreezeReason; type Currency = Balances; @@ -487,7 +487,7 @@ impl pallet_dapp_staking_v3::Config for Runtime { type MinimumStakeAmount = ConstU128; type NumberOfTiers = ConstU32<4>; type RankingEnabled = ConstBool; - type WeightInfo = pallet_dapp_staking_v3::weights::SubstrateWeight; + type WeightInfo = pallet_dapp_staking::weights::SubstrateWeight; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = BenchmarkHelper, AccountId>; } @@ -845,7 +845,7 @@ impl InstanceFilter for ProxyType { matches!( c, RuntimeCall::DappStaking( - pallet_dapp_staking_v3::Call::claim_staker_rewards { .. } + pallet_dapp_staking::Call::claim_staker_rewards { .. } ) ) } @@ -1137,7 +1137,7 @@ construct_runtime!( TransactionPayment: pallet_transaction_payment = 30, Balances: pallet_balances = 31, Vesting: pallet_vesting = 32, - DappStaking: pallet_dapp_staking_v3 = 34, + DappStaking: pallet_dapp_staking = 34, Inflation: pallet_inflation = 35, Assets: pallet_assets = 36, StaticPriceProvider: pallet_static_price_provider = 37, @@ -1285,7 +1285,7 @@ mod benches { [pallet_balances, Balances] [pallet_timestamp, Timestamp] [pallet_ethereum_checked, EthereumChecked] - [pallet_dapp_staking_v3, DappStaking] + [pallet_dapp_staking, DappStaking] [pallet_inflation, Inflation] [pallet_dynamic_evm_base_fee, DynamicEvmBaseFee] ); @@ -1775,7 +1775,7 @@ impl_runtime_apis! { } } - impl dapp_staking_v3_runtime_api::DappStakingApi for Runtime { + impl dapp_staking_runtime_api::DappStakingApi for Runtime { fn periods_per_cycle() -> PeriodNumber { InflationCycleConfig::periods_per_cycle() } diff --git a/runtime/local/src/precompiles.rs b/runtime/local/src/precompiles.rs index 662d56cf14..0daf444b5f 100644 --- a/runtime/local/src/precompiles.rs +++ b/runtime/local/src/precompiles.rs @@ -25,7 +25,7 @@ use frame_support::{parameter_types, traits::Contains}; use pallet_evm_precompile_assets_erc20::Erc20AssetsPrecompileSet; use pallet_evm_precompile_blake2::Blake2F; use pallet_evm_precompile_bn128::{Bn128Add, Bn128Mul, Bn128Pairing}; -use pallet_evm_precompile_dapp_staking_v3::DappStakingV3Precompile; +use pallet_evm_precompile_dapp_staking::DappStakingV3Precompile; use pallet_evm_precompile_dispatch::Dispatch; use pallet_evm_precompile_dispatch_lockdrop::DispatchLockdrop; use pallet_evm_precompile_ed25519::Ed25519Verify; @@ -76,12 +76,8 @@ impl Contains for WhitelistedLockdropCalls { | RuntimeCall::Utility(pallet_utility::Call::batch_all { calls }) => calls .iter() .all(|call| WhitelistedLockdropCalls::contains(call)), - RuntimeCall::DappStaking(pallet_dapp_staking_v3::Call::unbond_and_unstake { - .. - }) => true, - RuntimeCall::DappStaking(pallet_dapp_staking_v3::Call::withdraw_unbonded { - .. - }) => true, + RuntimeCall::DappStaking(pallet_dapp_staking::Call::unbond_and_unstake { .. }) => true, + RuntimeCall::DappStaking(pallet_dapp_staking::Call::withdraw_unbonded { .. }) => true, RuntimeCall::Balances(pallet_balances::Call::transfer_all { .. }) => true, RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive { .. }) => true, RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { .. }) => true, diff --git a/runtime/shibuya/Cargo.toml b/runtime/shibuya/Cargo.toml index 1890be8eb9..5697b8756b 100644 --- a/runtime/shibuya/Cargo.toml +++ b/runtime/shibuya/Cargo.toml @@ -107,11 +107,11 @@ astar-primitives = { workspace = true } astar-xcm-benchmarks = { workspace = true, optional = true } pallet-chain-extension-unified-accounts = { workspace = true } pallet-collator-selection = { workspace = true } -pallet-dapp-staking-v3 = { workspace = true } +pallet-dapp-staking = { workspace = true } pallet-dynamic-evm-base-fee = { workspace = true } pallet-ethereum-checked = { workspace = true } pallet-evm-precompile-assets-erc20 = { workspace = true } -pallet-evm-precompile-dapp-staking-v3 = { workspace = true } +pallet-evm-precompile-dapp-staking = { workspace = true } pallet-evm-precompile-dispatch-lockdrop = { workspace = true } pallet-evm-precompile-sr25519 = { workspace = true } pallet-evm-precompile-substrate-ecdsa = { workspace = true } @@ -124,7 +124,7 @@ pallet-xc-asset-config = { workspace = true } pallet-xcm = { workspace = true } pallet-xcm-benchmarks = { workspace = true, optional = true } -dapp-staking-v3-runtime-api = { workspace = true } +dapp-staking-runtime-api = { workspace = true } precompile-utils = { workspace = true } @@ -194,7 +194,7 @@ std = [ "pallet-evm-precompile-ed25519/std", "pallet-evm-precompile-modexp/std", "pallet-evm-precompile-sha3fips/std", - "pallet-evm-precompile-dapp-staking-v3/std", + "pallet-evm-precompile-dapp-staking/std", "pallet-evm-precompile-sr25519/std", "pallet-evm-precompile-substrate-ecdsa/std", "pallet-evm-precompile-assets-erc20/std", @@ -202,9 +202,9 @@ std = [ "pallet-evm-precompile-unified-accounts/std", "xcm-fee-payment-runtime-api/std", "pallet-evm-precompile-dispatch-lockdrop/std", - "pallet-dapp-staking-v3/std", + "pallet-dapp-staking/std", "orml-oracle/std", - "dapp-staking-v3-runtime-api/std", + "dapp-staking-runtime-api/std", "pallet-inflation/std", "pallet-price-aggregator/std", "pallet-identity/std", @@ -273,7 +273,7 @@ runtime-benchmarks = [ "frame-system-benchmarking/runtime-benchmarks", "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", - "pallet-dapp-staking-v3/runtime-benchmarks", + "pallet-dapp-staking/runtime-benchmarks", "pallet-inflation/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-membership/runtime-benchmarks", @@ -300,7 +300,7 @@ runtime-benchmarks = [ "pallet-contracts/runtime-benchmarks", "pallet-evm/runtime-benchmarks", "pallet-evm-precompile-assets-erc20/runtime-benchmarks", - "pallet-evm-precompile-dapp-staking-v3/runtime-benchmarks", + "pallet-evm-precompile-dapp-staking/runtime-benchmarks", "pallet-evm-precompile-xcm/runtime-benchmarks", "pallet-identity/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", @@ -327,7 +327,7 @@ try-runtime = [ "frame-system/try-runtime", "pallet-aura/try-runtime", "pallet-balances/try-runtime", - "pallet-dapp-staking-v3/try-runtime", + "pallet-dapp-staking/try-runtime", "pallet-inflation/try-runtime", "pallet-sudo/try-runtime", "pallet-timestamp/try-runtime", diff --git a/runtime/shibuya/src/lib.rs b/runtime/shibuya/src/lib.rs index f875902e90..b9741072fc 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -96,7 +96,7 @@ use astar_primitives::{ }; pub use astar_primitives::{AccountId, Balance, Signature}; -pub use pallet_dapp_staking_v3::TierThreshold; +pub use pallet_dapp_staking::TierThreshold; pub use pallet_inflation::InflationParameters; pub use crate::precompiles::WhitelistedCalls; @@ -432,7 +432,7 @@ impl pallet_preimage::Config for Runtime { #[cfg(feature = "runtime-benchmarks")] pub struct DAppStakingBenchmarkHelper(sp_std::marker::PhantomData<(SC, ACC)>); #[cfg(feature = "runtime-benchmarks")] -impl pallet_dapp_staking_v3::BenchmarkHelper, AccountId> +impl pallet_dapp_staking::BenchmarkHelper, AccountId> for DAppStakingBenchmarkHelper, AccountId> { fn get_smart_contract(id: u32) -> SmartContract { @@ -462,7 +462,7 @@ parameter_types! { pub const BaseNativeCurrencyPrice: FixedU128 = FixedU128::from_rational(5, 100); } -impl pallet_dapp_staking_v3::Config for Runtime { +impl pallet_dapp_staking::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeFreezeReason = RuntimeFreezeReason; type Currency = Balances; @@ -487,7 +487,7 @@ impl pallet_dapp_staking_v3::Config for Runtime { type MinimumStakeAmount = MinimumStakingAmount; type NumberOfTiers = ConstU32<4>; type RankingEnabled = ConstBool; - type WeightInfo = weights::pallet_dapp_staking_v3::SubstrateWeight; + type WeightInfo = weights::pallet_dapp_staking::SubstrateWeight; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = DAppStakingBenchmarkHelper, AccountId>; } @@ -1094,7 +1094,7 @@ impl InstanceFilter for ProxyType { matches!( c, RuntimeCall::DappStaking( - pallet_dapp_staking_v3::Call::claim_staker_rewards { .. } + pallet_dapp_staking::Call::claim_staker_rewards { .. } ) ) } @@ -1551,7 +1551,7 @@ construct_runtime!( TransactionPayment: pallet_transaction_payment = 30, Balances: pallet_balances = 31, Vesting: pallet_vesting = 32, - DappStaking: pallet_dapp_staking_v3 = 34, + DappStaking: pallet_dapp_staking = 34, Inflation: pallet_inflation = 35, Assets: pallet_assets = 36, PriceAggregator: pallet_price_aggregator = 37, @@ -1672,7 +1672,7 @@ pub type Migrations = (Unreleased, Permanent); /// Unreleased migrations. Add new ones here: pub type Unreleased = ( // dApp-staking dyn tier threshold migrations - pallet_dapp_staking_v3::migration::versioned_migrations::V7ToV8< + pallet_dapp_staking::migration::versioned_migrations::V7ToV8< Runtime, TierThresholds, ThresholdVariationPercentage, @@ -1762,7 +1762,7 @@ mod benches { [pallet_assets, pallet_assets::Pallet::] [pallet_balances, Balances] [pallet_timestamp, Timestamp] - [pallet_dapp_staking_v3, DappStaking] + [pallet_dapp_staking, DappStaking] [pallet_inflation, Inflation] [pallet_migrations, MultiBlockMigrations] [pallet_xc_asset_config, XcAssetConfig] @@ -2242,7 +2242,7 @@ impl_runtime_apis! { } } - impl dapp_staking_v3_runtime_api::DappStakingApi for Runtime { + impl dapp_staking_runtime_api::DappStakingApi for Runtime { fn periods_per_cycle() -> PeriodNumber { InflationCycleConfig::periods_per_cycle() } diff --git a/runtime/shibuya/src/precompiles.rs b/runtime/shibuya/src/precompiles.rs index 5fb0d3e256..642e7e491c 100644 --- a/runtime/shibuya/src/precompiles.rs +++ b/runtime/shibuya/src/precompiles.rs @@ -25,7 +25,7 @@ use frame_support::{parameter_types, traits::Contains}; use pallet_evm_precompile_assets_erc20::Erc20AssetsPrecompileSet; use pallet_evm_precompile_blake2::Blake2F; use pallet_evm_precompile_bn128::{Bn128Add, Bn128Mul, Bn128Pairing}; -use pallet_evm_precompile_dapp_staking_v3::DappStakingV3Precompile; +use pallet_evm_precompile_dapp_staking::DappStakingV3Precompile; use pallet_evm_precompile_dispatch::Dispatch; use pallet_evm_precompile_dispatch_lockdrop::DispatchLockdrop; use pallet_evm_precompile_ed25519::Ed25519Verify; @@ -79,12 +79,8 @@ impl Contains for WhitelistedLockdropCalls { | RuntimeCall::Utility(pallet_utility::Call::batch_all { calls }) => calls .iter() .all(|call| WhitelistedLockdropCalls::contains(call)), - RuntimeCall::DappStaking(pallet_dapp_staking_v3::Call::unbond_and_unstake { - .. - }) => true, - RuntimeCall::DappStaking(pallet_dapp_staking_v3::Call::withdraw_unbonded { - .. - }) => true, + RuntimeCall::DappStaking(pallet_dapp_staking::Call::unbond_and_unstake { .. }) => true, + RuntimeCall::DappStaking(pallet_dapp_staking::Call::withdraw_unbonded { .. }) => true, RuntimeCall::Balances(pallet_balances::Call::transfer_all { .. }) => true, RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive { .. }) => true, RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { .. }) => true, diff --git a/runtime/shibuya/src/weights/mod.rs b/runtime/shibuya/src/weights/mod.rs index 91d43f0856..93a7d79b6f 100644 --- a/runtime/shibuya/src/weights/mod.rs +++ b/runtime/shibuya/src/weights/mod.rs @@ -19,7 +19,7 @@ pub mod orml_oracle; pub mod pallet_assets; pub mod pallet_balances; -pub mod pallet_dapp_staking_v3; +pub mod pallet_dapp_staking; pub mod pallet_inflation; pub mod pallet_xcm; pub mod xcm; diff --git a/runtime/shibuya/src/weights/pallet_dapp_staking_v3.rs b/runtime/shibuya/src/weights/pallet_dapp_staking.rs similarity index 98% rename from runtime/shibuya/src/weights/pallet_dapp_staking_v3.rs rename to runtime/shibuya/src/weights/pallet_dapp_staking.rs index 10d37c5590..1b2808c35b 100644 --- a/runtime/shibuya/src/weights/pallet_dapp_staking_v3.rs +++ b/runtime/shibuya/src/weights/pallet_dapp_staking.rs @@ -17,7 +17,7 @@ // You should have received a copy of the GNU General Public License // along with Astar. If not, see . -//! Autogenerated weights for pallet_dapp_staking_v3 +//! Autogenerated weights for pallet_dapp_staking //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2024-04-30, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` @@ -32,12 +32,12 @@ // --chain=shibuya-dev // --steps=50 // --repeat=20 -// --pallet=pallet_dapp_staking_v3 +// --pallet=pallet_dapp_staking // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./benchmark-results/shibuya-dev/dapp_staking_v3_weights.rs +// --output=./benchmark-results/shibuya-dev/dapp_staking_weights.rs // --template=./scripts/templates/weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -46,9 +46,9 @@ use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use core::marker::PhantomData; -use pallet_dapp_staking_v3::WeightInfo; +use pallet_dapp_staking::WeightInfo; -/// Weights for pallet_dapp_staking_v3 using the Substrate node and recommended hardware. +/// Weights for pallet_dapp_staking using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn maintenance_mode() -> Weight { diff --git a/runtime/shiden/Cargo.toml b/runtime/shiden/Cargo.toml index c6a01c5704..6bcad447cd 100644 --- a/runtime/shiden/Cargo.toml +++ b/runtime/shiden/Cargo.toml @@ -110,9 +110,9 @@ frame-try-runtime = { workspace = true, optional = true } astar-primitives = { workspace = true } astar-xcm-benchmarks = { workspace = true, optional = true } pallet-collator-selection = { workspace = true } -pallet-dapp-staking-v3 = { workspace = true } +pallet-dapp-staking = { workspace = true } pallet-evm-precompile-assets-erc20 = { workspace = true } -pallet-evm-precompile-dapp-staking-v3 = { workspace = true } +pallet-evm-precompile-dapp-staking = { workspace = true } pallet-evm-precompile-dispatch-lockdrop = { workspace = true } pallet-evm-precompile-sr25519 = { workspace = true } pallet-evm-precompile-substrate-ecdsa = { workspace = true } @@ -122,7 +122,7 @@ pallet-price-aggregator = { workspace = true } pallet-xc-asset-config = { workspace = true } pallet-xcm = { workspace = true } -dapp-staking-v3-runtime-api = { workspace = true } +dapp-staking-runtime-api = { workspace = true } precompile-utils = { workspace = true } @@ -178,10 +178,10 @@ std = [ "pallet-evm-precompile-modexp/std", "xcm-fee-payment-runtime-api/std", "pallet-evm-precompile-sha3fips/std", - "pallet-dapp-staking-v3/std", - "dapp-staking-v3-runtime-api/std", + "pallet-dapp-staking/std", + "dapp-staking-runtime-api/std", "pallet-inflation/std", - "pallet-evm-precompile-dapp-staking-v3/std", + "pallet-evm-precompile-dapp-staking/std", "pallet-evm-precompile-sr25519/std", "pallet-evm-precompile-assets-erc20/std", "pallet-evm-precompile-substrate-ecdsa/std", @@ -247,7 +247,7 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "pallet-balances/runtime-benchmarks", - "pallet-dapp-staking-v3/runtime-benchmarks", + "pallet-dapp-staking/runtime-benchmarks", "pallet-inflation/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-ethereum/runtime-benchmarks", @@ -271,7 +271,7 @@ runtime-benchmarks = [ "pallet-contracts/runtime-benchmarks", "pallet-evm/runtime-benchmarks", "pallet-evm-precompile-assets-erc20/runtime-benchmarks", - "pallet-evm-precompile-dapp-staking-v3/runtime-benchmarks", + "pallet-evm-precompile-dapp-staking/runtime-benchmarks", "pallet-evm-precompile-xcm/runtime-benchmarks", "pallet-identity/runtime-benchmarks", "pallet-multisig/runtime-benchmarks", @@ -302,7 +302,7 @@ try-runtime = [ "orml-oracle/try-runtime", "pallet-price-aggregator/try-runtime", "pallet-membership/try-runtime", - "pallet-dapp-staking-v3/try-runtime", + "pallet-dapp-staking/try-runtime", "pallet-inflation/try-runtime", "pallet-sudo/try-runtime", "pallet-timestamp/try-runtime", diff --git a/runtime/shiden/src/lib.rs b/runtime/shiden/src/lib.rs index a37cbef95b..f2db7762a4 100644 --- a/runtime/shiden/src/lib.rs +++ b/runtime/shiden/src/lib.rs @@ -86,7 +86,7 @@ use astar_primitives::{ }; pub use astar_primitives::{AccountId, Balance, Signature}; -pub use pallet_dapp_staking_v3::TierThreshold; +pub use pallet_dapp_staking::TierThreshold; pub use pallet_inflation::InflationParameters; pub use crate::precompiles::WhitelistedCalls; @@ -388,7 +388,7 @@ impl pallet_multisig::Config for Runtime { #[cfg(feature = "runtime-benchmarks")] pub struct DAppStakingBenchmarkHelper(sp_std::marker::PhantomData<(SC, ACC)>); #[cfg(feature = "runtime-benchmarks")] -impl pallet_dapp_staking_v3::BenchmarkHelper, AccountId> +impl pallet_dapp_staking::BenchmarkHelper, AccountId> for DAppStakingBenchmarkHelper, AccountId> { fn get_smart_contract(id: u32) -> SmartContract { @@ -427,7 +427,7 @@ parameter_types! { pub const BaseNativeCurrencyPrice: FixedU128 = FixedU128::from_rational(5, 100); } -impl pallet_dapp_staking_v3::Config for Runtime { +impl pallet_dapp_staking::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeFreezeReason = RuntimeFreezeReason; type Currency = Balances; @@ -452,7 +452,7 @@ impl pallet_dapp_staking_v3::Config for Runtime { type MinimumStakeAmount = MinimumStakingAmount; type NumberOfTiers = ConstU32<4>; type RankingEnabled = ConstBool; - type WeightInfo = weights::pallet_dapp_staking_v3::SubstrateWeight; + type WeightInfo = weights::pallet_dapp_staking::SubstrateWeight; #[cfg(feature = "runtime-benchmarks")] type BenchmarkHelper = DAppStakingBenchmarkHelper, AccountId>; } @@ -1055,7 +1055,7 @@ impl InstanceFilter for ProxyType { matches!( c, RuntimeCall::DappStaking( - pallet_dapp_staking_v3::Call::claim_staker_rewards { .. } + pallet_dapp_staking::Call::claim_staker_rewards { .. } ) ) } @@ -1228,7 +1228,7 @@ construct_runtime!( // logic is executed. // TODO: Address this later. It would be best if Inflation was first pallet. Inflation: pallet_inflation = 33, - DappStaking: pallet_dapp_staking_v3 = 34, + DappStaking: pallet_dapp_staking = 34, Assets: pallet_assets = 36, PriceAggregator: pallet_price_aggregator = 37, Oracle: orml_oracle = 38, @@ -1331,7 +1331,7 @@ pub type Migrations = (Unreleased, Permanent); /// Unreleased migrations. Add new ones here: pub type Unreleased = ( // dApp-staking dyn tier threshold migrations - pallet_dapp_staking_v3::migration::versioned_migrations::V7ToV8< + pallet_dapp_staking::migration::versioned_migrations::V7ToV8< Runtime, TierThresholds, ThresholdVariationPercentage, @@ -1421,7 +1421,7 @@ mod benches { [pallet_assets, pallet_assets::Pallet::] [pallet_balances, Balances] [pallet_timestamp, Timestamp] - [pallet_dapp_staking_v3, DappStaking] + [pallet_dapp_staking, DappStaking] [pallet_inflation, Inflation] [pallet_migrations, MultiBlockMigrations] [pallet_xc_asset_config, XcAssetConfig] @@ -1898,7 +1898,7 @@ impl_runtime_apis! { } } - impl dapp_staking_v3_runtime_api::DappStakingApi for Runtime { + impl dapp_staking_runtime_api::DappStakingApi for Runtime { fn periods_per_cycle() -> PeriodNumber { InflationCycleConfig::periods_per_cycle() } diff --git a/runtime/shiden/src/precompiles.rs b/runtime/shiden/src/precompiles.rs index 34a6290215..d5821340eb 100644 --- a/runtime/shiden/src/precompiles.rs +++ b/runtime/shiden/src/precompiles.rs @@ -25,7 +25,7 @@ use frame_support::{parameter_types, traits::Contains}; use pallet_evm_precompile_assets_erc20::Erc20AssetsPrecompileSet; use pallet_evm_precompile_blake2::Blake2F; use pallet_evm_precompile_bn128::{Bn128Add, Bn128Mul, Bn128Pairing}; -use pallet_evm_precompile_dapp_staking_v3::DappStakingV3Precompile; +use pallet_evm_precompile_dapp_staking::DappStakingV3Precompile; use pallet_evm_precompile_dispatch::Dispatch; use pallet_evm_precompile_dispatch_lockdrop::DispatchLockdrop; use pallet_evm_precompile_ed25519::Ed25519Verify; @@ -77,12 +77,8 @@ impl Contains for WhitelistedLockdropCalls { | RuntimeCall::Utility(pallet_utility::Call::batch_all { calls }) => calls .iter() .all(|call| WhitelistedLockdropCalls::contains(call)), - RuntimeCall::DappStaking(pallet_dapp_staking_v3::Call::unbond_and_unstake { - .. - }) => true, - RuntimeCall::DappStaking(pallet_dapp_staking_v3::Call::withdraw_unbonded { - .. - }) => true, + RuntimeCall::DappStaking(pallet_dapp_staking::Call::unbond_and_unstake { .. }) => true, + RuntimeCall::DappStaking(pallet_dapp_staking::Call::withdraw_unbonded { .. }) => true, RuntimeCall::Balances(pallet_balances::Call::transfer_all { .. }) => true, RuntimeCall::Balances(pallet_balances::Call::transfer_keep_alive { .. }) => true, RuntimeCall::Balances(pallet_balances::Call::transfer_allow_death { .. }) => true, diff --git a/runtime/shiden/src/weights/mod.rs b/runtime/shiden/src/weights/mod.rs index 0b665ae16e..476c43da5b 100644 --- a/runtime/shiden/src/weights/mod.rs +++ b/runtime/shiden/src/weights/mod.rs @@ -18,7 +18,7 @@ pub mod orml_oracle; pub mod pallet_assets; -pub mod pallet_dapp_staking_v3; +pub mod pallet_dapp_staking; pub mod pallet_inflation; pub mod pallet_xcm; pub mod xcm; diff --git a/runtime/shiden/src/weights/pallet_dapp_staking_v3.rs b/runtime/shiden/src/weights/pallet_dapp_staking.rs similarity index 98% rename from runtime/shiden/src/weights/pallet_dapp_staking_v3.rs rename to runtime/shiden/src/weights/pallet_dapp_staking.rs index c6f7c4f9c7..9ccd24fabb 100644 --- a/runtime/shiden/src/weights/pallet_dapp_staking_v3.rs +++ b/runtime/shiden/src/weights/pallet_dapp_staking.rs @@ -17,7 +17,7 @@ // You should have received a copy of the GNU General Public License // along with Astar. If not, see . -//! Autogenerated weights for pallet_dapp_staking_v3 +//! Autogenerated weights for pallet_dapp_staking //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2024-05-01, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` @@ -32,12 +32,12 @@ // --chain=shiden-dev // --steps=50 // --repeat=20 -// --pallet=pallet_dapp_staking_v3 +// --pallet=pallet_dapp_staking // --extrinsic=* // --execution=wasm // --wasm-execution=compiled // --heap-pages=4096 -// --output=./benchmark-results/shiden-dev/dapp_staking_v3_weights.rs +// --output=./benchmark-results/shiden-dev/dapp_staking_weights.rs // --template=./scripts/templates/weight-template.hbs #![cfg_attr(rustfmt, rustfmt_skip)] @@ -46,9 +46,9 @@ use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use core::marker::PhantomData; -use pallet_dapp_staking_v3::WeightInfo; +use pallet_dapp_staking::WeightInfo; -/// Weights for pallet_dapp_staking_v3 using the Substrate node and recommended hardware. +/// Weights for pallet_dapp_staking using the Substrate node and recommended hardware. pub struct SubstrateWeight(PhantomData); impl WeightInfo for SubstrateWeight { fn maintenance_mode() -> Weight { diff --git a/tests/integration/Cargo.toml b/tests/integration/Cargo.toml index daeb2402e8..19e075fc54 100644 --- a/tests/integration/Cargo.toml +++ b/tests/integration/Cargo.toml @@ -47,7 +47,7 @@ xcm-fee-payment-runtime-api = { workspace = true } assets-chain-extension-types = { workspace = true } pallet-collator-selection = { workspace = true } pallet-collective-proxy = { workspace = true } -pallet-dapp-staking-v3 = { workspace = true } +pallet-dapp-staking = { workspace = true } pallet-ethereum-checked = { workspace = true } pallet-evm-precompile-assets-erc20 = { workspace = true } pallet-evm-precompile-dispatch = { workspace = true } @@ -98,7 +98,7 @@ std = [ "cumulus-pallet-parachain-system/std", "pallet-democracy/std", "pallet-timestamp/std", - "pallet-dapp-staking-v3/std", + "pallet-dapp-staking/std", "pallet-ethereum?/std", "pallet-ethereum-checked/std", "pallet-evm/std", diff --git a/tests/integration/src/dapp_staking_v3.rs b/tests/integration/src/dapp_staking.rs similarity index 94% rename from tests/integration/src/dapp_staking_v3.rs rename to tests/integration/src/dapp_staking.rs index 3737c16d8e..bff9c14ced 100644 --- a/tests/integration/src/dapp_staking_v3.rs +++ b/tests/integration/src/dapp_staking.rs @@ -21,7 +21,7 @@ use crate::setup::*; use pallet_collator_selection::{CandidateInfo, Candidates}; -use pallet_dapp_staking_v3::*; +use pallet_dapp_staking::*; #[test] fn dapp_staking_triggers_inflation_recalculation() { @@ -93,10 +93,10 @@ fn lock_not_possible_for_collator_candidate_account() { // Now try to participate in dApp staking with Alice and expect an error let minimum_lock_amount = - ::MinimumLockedAmount::get(); + ::MinimumLockedAmount::get(); assert_noop!( DappStaking::lock(RuntimeOrigin::signed(ALICE.clone()), minimum_lock_amount,), - pallet_dapp_staking_v3::Error::::AccountNotAvailableForDappStaking + pallet_dapp_staking::Error::::AccountNotAvailableForDappStaking ); }); } @@ -107,7 +107,7 @@ fn collator_selection_candidacy_not_possible_for_dapp_staking_participant() { new_test_ext().execute_with(|| { // Lock some amount with Alice let minimum_lock_amount = - ::MinimumLockedAmount::get(); + ::MinimumLockedAmount::get(); assert_ok!(DappStaking::lock( RuntimeOrigin::signed(ALICE.clone()), minimum_lock_amount, diff --git a/tests/integration/src/governance.rs b/tests/integration/src/governance.rs index 01087cea5d..ac8667b5fe 100644 --- a/tests/integration/src/governance.rs +++ b/tests/integration/src/governance.rs @@ -126,7 +126,7 @@ fn community_council_can_execute_dapp_staking_calls() { Balances::make_free_balance_be(&proxy_account, lock_amount); // Prepare the wrapped dApp staking lock call - let lock_call = RuntimeCall::DappStaking(pallet_dapp_staking_v3::Call::lock { + let lock_call = RuntimeCall::DappStaking(pallet_dapp_staking::Call::lock { amount: lock_amount, }); let collective_proxy_call = @@ -162,7 +162,7 @@ fn community_council_can_execute_dapp_staking_calls() { // Check that the lock was successful assert_eq!( - pallet_dapp_staking_v3::Ledger::::get(&proxy_account).locked, + pallet_dapp_staking::Ledger::::get(&proxy_account).locked, lock_amount ); }) diff --git a/tests/integration/src/lib.rs b/tests/integration/src/lib.rs index 1196eaa092..a46917f7d0 100644 --- a/tests/integration/src/lib.rs +++ b/tests/integration/src/lib.rs @@ -36,7 +36,7 @@ mod dispatch_precompile_filter; mod unified_accounts; #[cfg(any(feature = "shibuya", feature = "shiden", feature = "astar"))] -mod dapp_staking_v3; +mod dapp_staking; #[cfg(any(feature = "shibuya", feature = "shiden", feature = "astar"))] mod assets_chain_extensions; diff --git a/tests/integration/src/proxy.rs b/tests/integration/src/proxy.rs index 177e6f73f3..533e106175 100644 --- a/tests/integration/src/proxy.rs +++ b/tests/integration/src/proxy.rs @@ -18,7 +18,7 @@ use crate::setup::*; use astar_primitives::dapp_staking::SmartContractHandle; -use pallet_dapp_staking_v3::ForcingType; +use pallet_dapp_staking::ForcingType; #[test] fn test_utility_call_pass_for_any() { @@ -180,9 +180,8 @@ fn test_staker_reward_claim_proxy_works() { 0 )); - let contract = ::SmartContract::evm( - H160::repeat_byte(0x01), - ); + let contract = + ::SmartContract::evm(H160::repeat_byte(0x01)); let staker_reward_claim_call = RuntimeCall::DappStaking(DappStakingCall::Call::claim_staker_rewards {}); let call = Box::new(staker_reward_claim_call); diff --git a/tests/integration/src/setup.rs b/tests/integration/src/setup.rs index 5235da21bb..8b555ae235 100644 --- a/tests/integration/src/setup.rs +++ b/tests/integration/src/setup.rs @@ -106,7 +106,7 @@ pub const INIT_PRICE: Price = Price::from_rational(1, 10); pub type SystemError = frame_system::Error; pub use pallet_balances::Call as BalancesCall; -pub use pallet_dapp_staking_v3 as DappStakingCall; +pub use pallet_dapp_staking as DappStakingCall; pub use pallet_proxy::Event as ProxyEvent; pub use pallet_utility::{Call as UtilityCall, Event as UtilityEvent}; use parity_scale_codec::Decode; @@ -195,21 +195,21 @@ impl ExtBuilder { ext.execute_with(|| { System::set_block_number(1); - let era_length = ::CycleConfiguration::blocks_per_era(); + let era_length = ::CycleConfiguration::blocks_per_era(); let voting_period_length_in_eras = - ::CycleConfiguration::eras_per_voting_subperiod(); + ::CycleConfiguration::eras_per_voting_subperiod(); - pallet_dapp_staking_v3::ActiveProtocolState::::put(pallet_dapp_staking_v3::ProtocolState { + pallet_dapp_staking::ActiveProtocolState::::put(pallet_dapp_staking::ProtocolState { era: 1, next_era_start: era_length.saturating_mul(voting_period_length_in_eras.into()) + 1, - period_info: pallet_dapp_staking_v3::PeriodInfo { + period_info: pallet_dapp_staking::PeriodInfo { number: 1, - subperiod: pallet_dapp_staking_v3::Subperiod::Voting, + subperiod: pallet_dapp_staking::Subperiod::Voting, next_subperiod_start_era: 2, }, maintenance: false, }); - pallet_dapp_staking_v3::Safeguard::::put(false); + pallet_dapp_staking::Safeguard::::put(false); // Ensure the initial state is set for the first block AllPalletsWithSystem::on_initialize(1); diff --git a/tests/xcm-simulator/Cargo.toml b/tests/xcm-simulator/Cargo.toml index e76a38a443..904c27d23f 100644 --- a/tests/xcm-simulator/Cargo.toml +++ b/tests/xcm-simulator/Cargo.toml @@ -33,7 +33,7 @@ sp-tracing = { workspace = true } # Custom Astar inclusions astar-primitives = { workspace = true } astar-test-utils = { workspace = true } -pallet-dapp-staking-v3 = { workspace = true } +pallet-dapp-staking = { workspace = true } pallet-xc-asset-config = { workspace = true } # polkadot deps @@ -81,7 +81,7 @@ std = [ "orml-xtokens/std", "orml-traits/std", "orml-xcm-support/std", - "pallet-dapp-staking-v3/std", + "pallet-dapp-staking/std", ] runtime-benchmarks = [ "frame-system/runtime-benchmarks", @@ -97,5 +97,5 @@ runtime-benchmarks = [ "orml-xtokens/runtime-benchmarks", "astar-primitives/runtime-benchmarks", "pallet-message-queue/runtime-benchmarks", - "pallet-dapp-staking-v3/runtime-benchmarks", + "pallet-dapp-staking/runtime-benchmarks", ] diff --git a/tests/xcm-simulator/src/mocks/parachain.rs b/tests/xcm-simulator/src/mocks/parachain.rs index 9346305cc2..22ce689034 100644 --- a/tests/xcm-simulator/src/mocks/parachain.rs +++ b/tests/xcm-simulator/src/mocks/parachain.rs @@ -320,7 +320,7 @@ impl InstanceFilter for ProxyType { matches!( c, RuntimeCall::DappStaking( - pallet_dapp_staking_v3::Call::claim_staker_rewards { .. } + pallet_dapp_staking::Call::claim_staker_rewards { .. } ) | RuntimeCall::Utility(..) ) } @@ -684,7 +684,7 @@ pub(crate) type MockSmartContract = SmartContract; #[cfg(feature = "runtime-benchmarks")] pub struct BenchmarkHelper(sp_std::marker::PhantomData<(SC, ACC)>); #[cfg(feature = "runtime-benchmarks")] -impl pallet_dapp_staking_v3::BenchmarkHelper +impl pallet_dapp_staking::BenchmarkHelper for BenchmarkHelper { fn get_smart_contract(id: u32) -> MockSmartContract { @@ -702,7 +702,7 @@ parameter_types! { pub const BaseNativeCurrencyPrice: FixedU128 = FixedU128::from_rational(5, 100); } -impl pallet_dapp_staking_v3::Config for Runtime { +impl pallet_dapp_staking::Config for Runtime { type RuntimeEvent = RuntimeEvent; type RuntimeFreezeReason = RuntimeFreezeReason; type Currency = Balances; @@ -743,7 +743,7 @@ construct_runtime!( Assets: pallet_assets, XcAssetConfig: pallet_xc_asset_config, CumulusXcm: cumulus_pallet_xcm, - DappStaking: pallet_dapp_staking_v3, + DappStaking: pallet_dapp_staking, Proxy: pallet_proxy, Utility: pallet_utility, Randomness: pallet_insecure_randomness_collective_flip, diff --git a/tests/xcm-simulator/src/tests/general.rs b/tests/xcm-simulator/src/tests/general.rs index cf67a27527..6c1f3253ce 100644 --- a/tests/xcm-simulator/src/tests/general.rs +++ b/tests/xcm-simulator/src/tests/general.rs @@ -220,7 +220,7 @@ fn remote_dapps_staking_staker_claim() { )); // advance enough blocks so we at least get to era 5 - this gives us era 2, 3 and 4 for claiming - while pallet_dapp_staking_v3::ActiveProtocolState::::get().era < 5 { + while pallet_dapp_staking::ActiveProtocolState::::get().era < 5 { advance_parachain_block_to(parachain::System::block_number() + 1); } // Ensure it's not first block so event storage is clear @@ -235,7 +235,7 @@ fn remote_dapps_staking_staker_claim() { )); }); - let claim_staker_call = parachain::RuntimeCall::DappStaking(pallet_dapp_staking_v3::Call::< + let claim_staker_call = parachain::RuntimeCall::DappStaking(pallet_dapp_staking::Call::< parachain::Runtime, >::claim_staker_rewards {}); @@ -276,16 +276,16 @@ fn remote_dapps_staking_staker_claim() { .into_iter() .map(|r| r.event) .filter_map(|e| { - ::RuntimeEvent::from(e) + ::RuntimeEvent::from(e) .try_into() .ok() }) - .collect::>>(); + .collect::>>(); assert_eq!(dapp_staking_events.len(), 1); assert_matches::assert_matches!( dapp_staking_events[0].clone(), - pallet_dapp_staking_v3::Event::Reward { account, .. } + pallet_dapp_staking::Event::Reward { account, .. } if account == ALICE ); @@ -336,9 +336,7 @@ fn remote_dapps_staking_staker_claim() { .iter() .filter(|r| matches!( r.event, - parachain::RuntimeEvent::DappStaking( - pallet_dapp_staking_v3::Event::Reward { .. } - ) + parachain::RuntimeEvent::DappStaking(pallet_dapp_staking::Event::Reward { .. }) )) .count(), 2