From 6b22734e83dedf6ff70c4f6894e782f91c41bf53 Mon Sep 17 00:00:00 2001 From: PierreOssun Date: Thu, 16 Nov 2023 11:39:50 +0100 Subject: [PATCH] PR comments --- Cargo.lock | 42 ++++++++++++------------- Cargo.toml | 2 +- pallets/block-rewards-hybrid/Cargo.toml | 2 +- pallets/block-rewards-hybrid/src/lib.rs | 3 +- runtime/local/Cargo.toml | 8 ++--- runtime/local/src/lib.rs | 12 +++---- runtime/shibuya/Cargo.toml | 8 ++--- runtime/shibuya/src/lib.rs | 24 +++++++------- 8 files changed, 51 insertions(+), 50 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b105880df2..206e451ab5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1006,25 +1006,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae" -[[package]] -name = "block-rewards-hybrid" -version = "0.1.0" -dependencies = [ - "astar-primitives", - "frame-benchmarking", - "frame-support", - "frame-system", - "pallet-balances", - "pallet-timestamp", - "parity-scale-codec", - "scale-info", - "serde", - "sp-arithmetic", - "sp-core", - "sp-runtime", - "sp-std", -] - [[package]] name = "bounded-collections" version = "0.1.8" @@ -6028,7 +6009,6 @@ version = "5.24.0" dependencies = [ "array-bytes 6.1.0", "astar-primitives", - "block-rewards-hybrid", "fp-rpc", "fp-self-contained", "frame-benchmarking", @@ -6045,6 +6025,7 @@ dependencies = [ "pallet-assets", "pallet-aura", "pallet-balances", + "pallet-block-rewards-hybrid", "pallet-chain-extension-assets", "pallet-chain-extension-dapps-staking", "pallet-chain-extension-unified-accounts", @@ -7473,6 +7454,25 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-block-rewards-hybrid" +version = "0.1.0" +dependencies = [ + "astar-primitives", + "frame-benchmarking", + "frame-support", + "frame-system", + "pallet-balances", + "pallet-timestamp", + "parity-scale-codec", + "scale-info", + "serde", + "sp-arithmetic", + "sp-core", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-bounties" version = "4.0.0-dev" @@ -13122,7 +13122,6 @@ version = "5.24.0" dependencies = [ "array-bytes 6.1.0", "astar-primitives", - "block-rewards-hybrid", "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", "cumulus-pallet-parachain-system", @@ -13151,6 +13150,7 @@ dependencies = [ "pallet-aura", "pallet-authorship", "pallet-balances", + "pallet-block-rewards-hybrid", "pallet-chain-extension-assets", "pallet-chain-extension-dapps-staking", "pallet-chain-extension-unified-accounts", diff --git a/Cargo.toml b/Cargo.toml index e091952f4b..e451b03095 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -273,7 +273,7 @@ orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-modu # Astar pallets & modules # (wasm) pallet-block-reward = { path = "./pallets/block-reward", default-features = false } -block-rewards-hybrid = { path = "./pallets/block-rewards-hybrid", default-features = false } +pallet-block-rewards-hybrid = { path = "./pallets/block-rewards-hybrid", default-features = false } pallet-collator-selection = { path = "./pallets/collator-selection", default-features = false } pallet-dapps-staking = { path = "./pallets/dapps-staking", default-features = false } pallet-xc-asset-config = { path = "./pallets/xc-asset-config", default-features = false } diff --git a/pallets/block-rewards-hybrid/Cargo.toml b/pallets/block-rewards-hybrid/Cargo.toml index 52180ebfec..b5b6486d18 100644 --- a/pallets/block-rewards-hybrid/Cargo.toml +++ b/pallets/block-rewards-hybrid/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "block-rewards-hybrid" +name = "pallet-block-rewards-hybrid" version = "0.1.0" license = "Apache-2.0" description = "FRAME pallet for managing block reward issuance & distribution" diff --git a/pallets/block-rewards-hybrid/src/lib.rs b/pallets/block-rewards-hybrid/src/lib.rs index dc7b5ef2bc..e6695f89c5 100644 --- a/pallets/block-rewards-hybrid/src/lib.rs +++ b/pallets/block-rewards-hybrid/src/lib.rs @@ -70,7 +70,8 @@ //! } //! } //! ``` -//! 4. Set `RewardAmount` to desired block reward value in native currency. +//! 4. Set `MaxBlockRewardAmount` to the max reward amount distributed per block. +//! Max amount will be reached if `ideal_dapps_staking_tvl` is reached. //! #![cfg_attr(not(feature = "std"), no_std)] diff --git a/runtime/local/Cargo.toml b/runtime/local/Cargo.toml index d62037112e..dfb5ab155a 100644 --- a/runtime/local/Cargo.toml +++ b/runtime/local/Cargo.toml @@ -65,7 +65,7 @@ pallet-transaction-payment-rpc-runtime-api = { workspace = true } # Astar pallets astar-primitives = { workspace = true } -block-rewards-hybrid = { workspace = true } +pallet-block-rewards-hybrid = { workspace = true } pallet-chain-extension-dapps-staking = { workspace = true } pallet-chain-extension-unified-accounts = { workspace = true } pallet-chain-extension-xvm = { workspace = true } @@ -111,7 +111,7 @@ std = [ "pallet-assets/std", "pallet-aura/std", "pallet-balances/std", - "block-rewards-hybrid/std", + "pallet-block-rewards-hybrid/std", "pallet-contracts/std", "pallet-contracts-primitives/std", "pallet-chain-extension-dapps-staking/std", @@ -177,7 +177,7 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "pallet-dapps-staking/runtime-benchmarks", - "block-rewards-hybrid/runtime-benchmarks", + "pallet-block-rewards-hybrid/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-ethereum/runtime-benchmarks", @@ -198,7 +198,7 @@ try-runtime = [ "frame-system/try-runtime", "pallet-aura/try-runtime", "pallet-balances/try-runtime", - "block-rewards-hybrid/try-runtime", + "pallet-block-rewards-hybrid/try-runtime", "pallet-contracts/try-runtime", "pallet-dapps-staking/try-runtime", "pallet-grandpa/try-runtime", diff --git a/runtime/local/src/lib.rs b/runtime/local/src/lib.rs index d04014ddb7..f267be3e8f 100644 --- a/runtime/local/src/lib.rs +++ b/runtime/local/src/lib.rs @@ -65,7 +65,7 @@ pub use astar_primitives::{ evm::EvmRevertCodeHandler, AccountId, Address, AssetId, Balance, BlockNumber, Hash, Header, Index, Signature, }; -pub use block_rewards_hybrid::RewardDistributionConfig; +pub use pallet_block_rewards_hybrid::RewardDistributionConfig; pub use crate::precompiles::WhitelistedCalls; #[cfg(feature = "std")] @@ -424,7 +424,7 @@ impl Get for DappsStakingTvlProvider { } pub struct BeneficiaryPayout(); -impl block_rewards_hybrid::BeneficiaryPayout for BeneficiaryPayout { +impl pallet_block_rewards_hybrid::BeneficiaryPayout for BeneficiaryPayout { fn treasury(reward: NegativeImbalance) { Balances::resolve_creating(&TreasuryPalletId::get().into_account_truncating(), reward); } @@ -442,13 +442,13 @@ parameter_types! { pub const MaxBlockRewardAmount: Balance = 230_718 * MILLIAST; } -impl block_rewards_hybrid::Config for Runtime { +impl pallet_block_rewards_hybrid::Config for Runtime { type Currency = Balances; type DappsStakingTvlProvider = DappsStakingTvlProvider; type BeneficiaryPayout = BeneficiaryPayout; type MaxBlockRewardAmount = MaxBlockRewardAmount; type RuntimeEvent = RuntimeEvent; - type WeightInfo = block_rewards_hybrid::weights::SubstrateWeight; + type WeightInfo = pallet_block_rewards_hybrid::weights::SubstrateWeight; } parameter_types! { @@ -1028,7 +1028,7 @@ construct_runtime!( Balances: pallet_balances, Vesting: pallet_vesting, DappsStaking: pallet_dapps_staking, - BlockReward: block_rewards_hybrid, + BlockReward: pallet_block_rewards_hybrid, TransactionPayment: pallet_transaction_payment, EVM: pallet_evm, Ethereum: pallet_ethereum, @@ -1158,7 +1158,7 @@ mod benches { [pallet_balances, Balances] [pallet_timestamp, Timestamp] [pallet_dapps_staking, DappsStaking] - [block_rewards_hybrid, BlockReward] + [pallet_block_rewards_hybrid, BlockReward] [pallet_ethereum_checked, EthereumChecked] [pallet_dynamic_evm_base_fee, DynamicEvmBaseFee] ); diff --git a/runtime/shibuya/Cargo.toml b/runtime/shibuya/Cargo.toml index e75ca525c7..2912090981 100644 --- a/runtime/shibuya/Cargo.toml +++ b/runtime/shibuya/Cargo.toml @@ -95,7 +95,7 @@ orml-xtokens = { workspace = true } # Astar pallets astar-primitives = { workspace = true } -block-rewards-hybrid = { workspace = true } +pallet-block-rewards-hybrid = { workspace = true } pallet-chain-extension-dapps-staking = { workspace = true } pallet-chain-extension-unified-accounts = { workspace = true } pallet-chain-extension-xvm = { workspace = true } @@ -158,7 +158,7 @@ std = [ "pallet-aura/std", "pallet-assets/std", "pallet-balances/std", - "block-rewards-hybrid/std", + "pallet-block-rewards-hybrid/std", "pallet-contracts/std", "pallet-contracts-primitives/std", "pallet-chain-extension-dapps-staking/std", @@ -239,7 +239,7 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "sp-runtime/runtime-benchmarks", "pallet-dapps-staking/runtime-benchmarks", - "block-rewards-hybrid/runtime-benchmarks", + "pallet-block-rewards-hybrid/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-collective/runtime-benchmarks", @@ -266,7 +266,7 @@ try-runtime = [ "frame-system/try-runtime", "pallet-aura/try-runtime", "pallet-balances/try-runtime", - "block-rewards-hybrid/try-runtime", + "pallet-block-rewards-hybrid/try-runtime", "pallet-dapps-staking/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 64e899b6d4..3b9725bd23 100644 --- a/runtime/shibuya/src/lib.rs +++ b/runtime/shibuya/src/lib.rs @@ -72,7 +72,7 @@ pub use astar_primitives::{ xcm::AssetLocationIdConverter, AccountId, Address, AssetId, Balance, BlockNumber, Hash, Header, Index, Signature, }; -pub use block_rewards_hybrid::RewardDistributionConfig; +pub use pallet_block_rewards_hybrid::RewardDistributionConfig; pub use crate::precompiles::WhitelistedCalls; @@ -538,7 +538,7 @@ impl Get for DappsStakingTvlProvider { } pub struct BeneficiaryPayout(); -impl block_rewards_hybrid::BeneficiaryPayout for BeneficiaryPayout { +impl pallet_block_rewards_hybrid::BeneficiaryPayout for BeneficiaryPayout { fn treasury(reward: NegativeImbalance) { Balances::resolve_creating(&TreasuryPalletId::get().into_account_truncating(), reward); } @@ -556,13 +556,13 @@ parameter_types! { pub const MaxBlockRewardAmount: Balance = 230_718 * MILLISBY; } -impl block_rewards_hybrid::Config for Runtime { +impl pallet_block_rewards_hybrid::Config for Runtime { type Currency = Balances; type DappsStakingTvlProvider = DappsStakingTvlProvider; type BeneficiaryPayout = BeneficiaryPayout; type MaxBlockRewardAmount = MaxBlockRewardAmount; type RuntimeEvent = RuntimeEvent; - type WeightInfo = block_rewards_hybrid::weights::SubstrateWeight; + type WeightInfo = pallet_block_rewards_hybrid::weights::SubstrateWeight; } parameter_types! { @@ -1241,7 +1241,7 @@ construct_runtime!( Balances: pallet_balances = 31, Vesting: pallet_vesting = 32, DappsStaking: pallet_dapps_staking = 34, - BlockReward: block_rewards_hybrid = 35, + BlockReward: pallet_block_rewards_hybrid = 35, Assets: pallet_assets = 36, Authorship: pallet_authorship = 40, @@ -1316,17 +1316,17 @@ pub use frame_support::traits::{OnRuntimeUpgrade, StorageVersion}; pub struct HybridInflationModelMigration; impl OnRuntimeUpgrade for HybridInflationModelMigration { fn on_runtime_upgrade() -> Weight { - let mut reward_config = block_rewards_hybrid::RewardDistributionConfig { + let mut reward_config = pallet_block_rewards_hybrid::RewardDistributionConfig { // 4.66% - treasury_percent: Perbill::from_rational(4663701u32, 100000000u32), + treasury_percent: Perbill::from_rational(4_663_701u32, 100_000_000u32), // 23.09% - base_staker_percent: Perbill::from_rational(2309024u32, 10000000u32), + base_staker_percent: Perbill::from_rational(2_309_024u32, 10_000_000u32), // 17.31% - dapps_percent: Perbill::from_rational(173094531u32, 1000000000u32), + dapps_percent: Perbill::from_rational(173_094_531u32, 1_000_000_000u32), // 2.99% - collators_percent: Perbill::from_rational(29863296u32, 1000000000u32), + collators_percent: Perbill::from_rational(29_863_296u32, 1_000_000_000u32), // 51.95% - adjustable_percent: Perbill::from_rational(519502763u32, 1000000000u32), + adjustable_percent: Perbill::from_rational(519_502_763u32, 1_000_000_000u32), // 60.00% ideal_dapps_staking_tvl: Perbill::from_percent(60), }; @@ -1340,7 +1340,7 @@ impl OnRuntimeUpgrade for HybridInflationModelMigration { reward_config = Default::default(); } - block_rewards_hybrid::RewardDistributionConfigStorage::::put(reward_config); + pallet_block_rewards_hybrid::RewardDistributionConfigStorage::::put(reward_config); ::DbWeight::get().writes(1) }