Skip to content

Commit

Permalink
Merge branch 'master' into feat/xcm-benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutoshvarma committed Jan 9, 2024
2 parents 4cf8638 + 21acad9 commit 60c1e93
Show file tree
Hide file tree
Showing 28 changed files with 1,052 additions and 439 deletions.
23 changes: 23 additions & 0 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 @@ -284,6 +284,7 @@ pallet-inflation = { path = "./pallets/inflation", default-features = false }
pallet-dynamic-evm-base-fee = { path = "./pallets/dynamic-evm-base-fee", default-features = false }
pallet-unified-accounts = { path = "./pallets/unified-accounts", default-features = false }
astar-xcm-benchmarks = { path = "./pallets/astar-xcm-benchmarks", default-features = false }
pallet-static-price-provider = { path = "./pallets/static-price-provider", default-features = false }

dapp-staking-v3-runtime-api = { path = "./pallets/dapp-staking-v3/rpc/runtime-api", default-features = false }

Expand Down
3 changes: 2 additions & 1 deletion pallets/dapp-staking-migration/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use sp_runtime::traits::{BlakeTwo256, IdentityLookup};

use astar_primitives::{
dapp_staking::{CycleConfiguration, SmartContract, StakingRewardHandler},
oracle::PriceProvider,
testing::Header,
Balance, BlockNumber,
};
Expand Down Expand Up @@ -108,7 +109,7 @@ impl pallet_balances::Config for Test {
}

pub struct DummyPriceProvider;
impl pallet_dapp_staking_v3::PriceProvider for DummyPriceProvider {
impl PriceProvider for DummyPriceProvider {
fn average_price() -> FixedU64 {
FixedU64::from_rational(1, 10)
}
Expand Down
2 changes: 2 additions & 0 deletions pallets/dapp-staking-v3/rpc/runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
sp-api = { workspace = true }
sp-std = { workspace = true }

astar-primitives = { workspace = true }
pallet-dapp-staking-v3 = { workspace = true }
Expand All @@ -20,6 +21,7 @@ pallet-dapp-staking-v3 = { workspace = true }
default = ["std"]
std = [
"sp-api/std",
"sp-std/std",
"pallet-dapp-staking-v3/std",
"astar-primitives/std",
]
9 changes: 8 additions & 1 deletion pallets/dapp-staking-v3/rpc/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#![cfg_attr(not(feature = "std"), no_std)]

use astar_primitives::BlockNumber;
use pallet_dapp_staking_v3::EraNumber;
use pallet_dapp_staking_v3::{DAppId, EraNumber, PeriodNumber, TierId};
pub use sp_std::collections::btree_map::BTreeMap;

sp_api::decl_runtime_apis! {

Expand All @@ -28,6 +29,9 @@ sp_api::decl_runtime_apis! {
/// Used to provide information otherwise not available via RPC.
pub trait DappStakingApi {

/// How many periods are there in one cycle.
fn periods_per_cycle() -> PeriodNumber;

/// For how many standard era lengths does the voting subperiod last.
fn eras_per_voting_subperiod() -> EraNumber;

Expand All @@ -36,5 +40,8 @@ sp_api::decl_runtime_apis! {

/// How many blocks are there per standard era.
fn blocks_per_era() -> BlockNumber;

/// Get dApp tier assignment for the given dApp.
fn get_dapp_tier_assignment() -> BTreeMap<DAppId, TierId>;
}
}
7 changes: 5 additions & 2 deletions pallets/dapp-staking-v3/src/benchmarking/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -946,8 +946,11 @@ mod benchmarks {

#[block]
{
let (dapp_tiers, _) =
Pallet::<T>::get_dapp_tier_assignment(reward_era, reward_period, reward_pool);
let (dapp_tiers, _) = Pallet::<T>::get_dapp_tier_assignment_and_rewards(
reward_era,
reward_period,
reward_pool,
);
assert_eq!(dapp_tiers.dapps.len(), x as usize);
}
}
Expand Down
Loading

0 comments on commit 60c1e93

Please sign in to comment.