Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hybrid Inflation Model #1077

Merged
merged 15 commits into from
Nov 17, 2023
33 changes: 26 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +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-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 }
Expand Down
2 changes: 1 addition & 1 deletion bin/collator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "astar-collator"
version = "5.24.0"
PierreOssun marked this conversation as resolved.
Show resolved Hide resolved
version = "5.25.0"
description = "Astar collator implementation in Rust."
build = "build.rs"
default-run = "astar-collator"
Expand Down
6 changes: 3 additions & 3 deletions bin/collator/src/local/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
//! Chain specifications.

use local_runtime::{
wasm_binary_unwrap, AccountId, AuraConfig, AuraId, BalancesConfig, BlockRewardConfig,
wasm_binary_unwrap, AccountId, AuraConfig, AuraId, BalancesConfig, BlockRewardConfig, RewardDistributionConfig,
CouncilConfig, DemocracyConfig, EVMConfig, GenesisConfig, GrandpaConfig, GrandpaId,
Precompiles, Signature, SudoConfig, SystemConfig, TechnicalCommitteeConfig, TreasuryConfig,
VestingConfig,
Expand Down Expand Up @@ -117,8 +117,8 @@ fn testnet_genesis(
},
block_reward: BlockRewardConfig {
// Make sure sum is 100
reward_config: pallet_block_reward::RewardDistributionConfig {
base_treasury_percent: Perbill::from_percent(25),
reward_config: RewardDistributionConfig {
treasury_percent: Perbill::from_percent(25),
base_staker_percent: Perbill::from_percent(30),
dapps_percent: Perbill::from_percent(20),
collators_percent: Perbill::zero(),
Expand Down
6 changes: 3 additions & 3 deletions bin/collator/src/parachain/chain_spec/shibuya.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use cumulus_primitives_core::ParaId;
use sc_service::ChainType;
use shibuya_runtime::{
wasm_binary_unwrap, AccountId, AuraConfig, AuraId, Balance, BalancesConfig, BlockRewardConfig,
wasm_binary_unwrap, AccountId, AuraConfig, AuraId, Balance, BalancesConfig, BlockRewardConfig, RewardDistributionConfig,
CollatorSelectionConfig, CouncilConfig, DemocracyConfig, EVMChainIdConfig, EVMConfig,
GenesisConfig, ParachainInfoConfig, Precompiles, SessionConfig, SessionKeys, Signature,
SudoConfig, SystemConfig, TechnicalCommitteeConfig, TreasuryConfig, VestingConfig, SBY,
Expand Down Expand Up @@ -115,8 +115,8 @@ fn make_genesis(
balances: BalancesConfig { balances },
block_reward: BlockRewardConfig {
// Make sure sum is 100
reward_config: pallet_block_reward::RewardDistributionConfig {
base_treasury_percent: Perbill::from_percent(10),
reward_config: RewardDistributionConfig {
treasury_percent: Perbill::from_percent(10),
base_staker_percent: Perbill::from_percent(20),
dapps_percent: Perbill::from_percent(20),
collators_percent: Perbill::from_percent(5),
Expand Down
51 changes: 51 additions & 0 deletions pallets/block-rewards-hybrid/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
[package]
name = "block-rewards-hybrid"
PierreOssun marked this conversation as resolved.
Show resolved Hide resolved
version = "2.2.2"
PierreOssun marked this conversation as resolved.
Show resolved Hide resolved
license = "Apache-2.0"
description = "FRAME pallet for managing block reward issuance & distribution"
authors.workspace = true
edition.workspace = true
homepage.workspace = true
repository.workspace = true

[dependencies]
parity-scale-codec = { workspace = true }
serde = { workspace = true }

astar-primitives = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
scale-info = { workspace = true }
sp-arithmetic = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }

frame-benchmarking = { workspace = true, optional = true }

[dev-dependencies]
pallet-balances = { workspace = true }
pallet-timestamp = { workspace = true }
sp-core = { workspace = true }

[features]
default = ["std"]
std = [
"parity-scale-codec/std",
"sp-core/std",
"scale-info/std",
"sp-std/std",
"serde/std",
"frame-support/std",
"frame-system/std",
"pallet-timestamp/std",
"pallet-balances/std",
"astar-primitives/std",
]
runtime-benchmarks = [
"frame-benchmarking",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"astar-primitives/runtime-benchmarks",
]
try-runtime = ["frame-support/try-runtime"]
61 changes: 61 additions & 0 deletions pallets/block-rewards-hybrid/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// This file is part of Astar.

// Copyright (C) 2019-2023 Stake Technologies Pte.Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later

// Astar is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Astar is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Astar. If not, see <http://www.gnu.org/licenses/>.

#![cfg(feature = "runtime-benchmarks")]

use super::*;

use frame_benchmarking::v2::*;
use frame_system::{Pallet as System, RawOrigin};

/// Assert that the last event equals the provided one.
fn assert_last_event<T: Config>(generic_event: <T as Config>::RuntimeEvent) {
System::<T>::assert_last_event(generic_event.into());
}

#[benchmarks(where T: Config)]
mod benchmarks {
use super::*;

#[benchmark]
fn set_configuration() {
let reward_config = RewardDistributionConfig::default();
assert!(reward_config.is_consistent());

#[extrinsic_call]
_(RawOrigin::Root, reward_config.clone());

assert_last_event::<T>(Event::<T>::DistributionConfigurationChanged(reward_config).into());
}

impl_benchmark_test_suite!(
Pallet,
crate::benchmarking::tests::new_test_ext(),
crate::mock::TestRuntime,
);
}

#[cfg(test)]
mod tests {
use crate::mock;
use frame_support::sp_io::TestExternalities;

pub fn new_test_ext() -> TestExternalities {
mock::ExternalityBuilder::build()
}
}
Loading
Loading