diff --git a/Cargo.lock b/Cargo.lock index 78474fb7ae..93da23d547 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2472,6 +2472,35 @@ dependencies = [ "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", ] +[[package]] +name = "pallet-block-rewards" +version = "0.1.0" +dependencies = [ + "cfg-mocks", + "cfg-primitives", + "cfg-traits", + "cfg-types", + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "num-traits", + "orml-tokens", + "orml-traits", + "pallet-balances", + "pallet-collator-selection", + "pallet-restricted-tokens", + "pallet-rewards", + "pallet-session", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-staking", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", +] + [[package]] name = "pallet-bridge" version = "2.0.0" @@ -2510,6 +2539,25 @@ dependencies = [ "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", ] +[[package]] +name = "pallet-collator-selection" +version = "9.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "log", + "pallet-authorship", + "pallet-session", + "parity-scale-codec", + "rand", + "scale-info", + "sp-runtime", + "sp-staking", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", +] + [[package]] name = "pallet-collective" version = "28.0.0" @@ -2583,6 +2631,24 @@ dependencies = [ "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", ] +[[package]] +name = "pallet-liquidity-rewards" +version = "0.1.0" +dependencies = [ + "cfg-mocks", + "cfg-traits", + "frame-benchmarking", + "frame-support", + "frame-system", + "num-traits", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", +] + [[package]] name = "pallet-oracle-collection" version = "1.0.0" @@ -2680,6 +2746,50 @@ dependencies = [ "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", ] +[[package]] +name = "pallet-rewards" +version = "0.1.0" +dependencies = [ + "cfg-traits", + "cfg-types", + "frame-support", + "frame-system", + "lazy_static", + "log", + "num-traits", + "orml-tokens", + "orml-traits", + "parity-scale-codec", + "scale-info", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", +] + +[[package]] +name = "pallet-session" +version = "28.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "frame-support", + "frame-system", + "impl-trait-for-tuples", + "log", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-io", + "sp-runtime", + "sp-session", + "sp-staking", + "sp-state-machine", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", + "sp-trie", +] + [[package]] name = "pallet-swaps" version = "1.0.0" @@ -3953,6 +4063,21 @@ dependencies = [ "syn 2.0.63", ] +[[package]] +name = "sp-session" +version = "27.0.0" +source = "git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2#0d7ca59fd4b4d15f9400971f32bc6a51b2fe837f" +dependencies = [ + "parity-scale-codec", + "scale-info", + "sp-api", + "sp-core", + "sp-keystore", + "sp-runtime", + "sp-staking", + "sp-std 14.0.0 (git+https://github.com/paritytech/polkadot-sdk?branch=release-polkadot-v1.7.2)", +] + [[package]] name = "sp-staking" version = "26.0.0" diff --git a/Cargo.toml b/Cargo.toml index 4c7d4de199..5e57afdc2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ members = [ "libs/utils", "pallets/anchors", "pallets/bridge", - #"pallets/block-rewards", + "pallets/block-rewards", "pallets/collator-allowlist", #"pallets/crowdloan-claim", #"pallets/crowdloan-reward", @@ -25,7 +25,7 @@ members = [ #"pallets/liquidity-pools-gateway", #"pallets/liquidity-pools-gateway/axelar-gateway-precompile", #"pallets/liquidity-pools-gateway/routers", - #"pallets/liquidity-rewards", + "pallets/liquidity-rewards", #"pallets/loans", "pallets/oracle-feed", "pallets/oracle-collection", @@ -36,7 +36,7 @@ members = [ #"pallets/pool-registry", #"pallets/restricted-tokens", #"pallets/restricted-xtokens", - #"pallets/rewards", + "pallets/rewards", "pallets/swaps", #"pallets/token-mux", #"pallets/transfer-allowlist", diff --git a/pallets/block-rewards/src/benchmarking.rs b/pallets/block-rewards/src/benchmarking.rs index a4c0c337fc..08cd1c1467 100644 --- a/pallets/block-rewards/src/benchmarking.rs +++ b/pallets/block-rewards/src/benchmarking.rs @@ -7,7 +7,6 @@ use frame_support::{ }; use frame_system::RawOrigin; use sp_runtime::traits::Zero; -use sp_std::vec; // required for #[benchmarks] use super::*; use crate::{pallet::Config, Pallet as BlockRewards}; diff --git a/pallets/block-rewards/src/migrations.rs b/pallets/block-rewards/src/migrations.rs index c6de5570a9..1e47492de5 100644 --- a/pallets/block-rewards/src/migrations.rs +++ b/pallets/block-rewards/src/migrations.rs @@ -20,7 +20,7 @@ use parity_scale_codec::{Decode, Encode}; use sp_runtime::FixedPointNumber; #[cfg(feature = "try-runtime")] use sp_runtime::TryRuntimeError; -use sp_std::{marker::PhantomData, vec::Vec}; +use sp_std::marker::PhantomData; use crate::{pallet, Config, Pallet, SessionData}; @@ -31,7 +31,7 @@ fn inflation_rate(percent: u32) -> T::Rate { pub mod init { use cfg_traits::rewards::{AccountRewards, CurrencyGroupChange, GroupRewards}; use num_traits::Zero; - use sp_runtime::{BoundedVec, SaturatedConversion}; + use sp_runtime::SaturatedConversion; use super::*; @@ -40,19 +40,6 @@ pub mod init { PhantomData<(T, CollatorReward, AnnualTreasuryInflationPercent)>, ); - fn get_collators() -> Vec { - let candidates = BoundedVec::< - T::AccountId, - ::MaxCandidates, - >::truncate_from( - pallet_collator_selection::Pallet::::candidates() - .into_iter() - .map(|c| c.who) - .collect(), - ); - pallet_collator_selection::Pallet::::assemble_collators(candidates) - } - impl OnRuntimeUpgrade for InitBlockRewards where @@ -63,7 +50,7 @@ pub mod init { { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, TryRuntimeError> { - let collators = get_collators::(); + let collators = pallet_collator_selection::Pallet::::assemble_collators(); assert!(!collators.is_empty()); assert!(!CollatorReward::get().is_zero()); @@ -85,7 +72,7 @@ pub mod init { pallet::ActiveSessionData::::get() != Default::default(); log::info!("{LOG_PREFIX} Getting list of collators"); - let collators = get_collators::(); + let collators = pallet_collator_selection::Pallet::::assemble_collators(); let collators_are_staked = collators.clone().into_iter().all(|c| { log::info!("{LOG_PREFIX} Checking stake of collator {c:?}"); diff --git a/pallets/rewards/src/issuance.rs b/pallets/rewards/src/issuance.rs index 8ea5860297..74abb5b78e 100644 --- a/pallets/rewards/src/issuance.rs +++ b/pallets/rewards/src/issuance.rs @@ -15,6 +15,7 @@ use cfg_traits::rewards::RewardIssuance; use frame_support::traits::{fungibles::Mutate, tokens::Preservation}; use parity_scale_codec::{Decode, Encode}; use sp_runtime::{traits::Get, DispatchResult}; +use sp_std::cmp::Eq; use sp_std::marker::PhantomData; /// Enables rewarding out of thin air, e.g. via minting. @@ -25,7 +26,7 @@ pub struct MintReward( impl RewardIssuance for MintReward where - AccountId: Encode + Decode, + AccountId: Encode + Decode + Eq, Currency: Mutate, { type AccountId = AccountId; @@ -49,7 +50,7 @@ pub struct TransferReward RewardIssuance for TransferReward where - AccountId: Encode + Decode, + AccountId: Encode + Decode + Eq, Currency: Mutate, SourceAddress: Get, {