Skip to content

Commit

Permalink
dapp staking v3 - part 4 (#1053)
Browse files Browse the repository at this point in the history
* EraRewardSpan

* Initial version of claim_staker_reward

* Tests

* Test utils for claim-staker

* Bug fixes, improvements

* Claim improvements & some tests

* Refactoring in progress

* Refactoring continued

* Refactoring progress

* Refactoring finished

* Bonus rewards

* Docs & some minor changes

* Comments, tests, improved coverage

* Tier params & config init solution

* Tier reward calculation WIP

* Tier assignemnt

* Minor cleanup

* Claim dapp rewards

* Claim dapp reward tests

* unstake from unregistered call

* Extra traits

* fixes

* Extra calls

* Refactoring

* More refactoring, improvements, TODO solving

* Local integration

* Genesis config

* Add forcing call

* try runtime build fix

* Minor changes

* Minor

* Formatting

* Benchmarks INIT

* Compiling benchmarks

* Fix

* dapp tier calculation benchmark

* Measured tier assignment

* Decending rewards in benchmarks

* Series refactoring & partial tests

* Comments, minor changes

* Tests, improvements

* More tests, some minor refactoring

* Formatting

* More benchmarks & experiments, refactoring

* Readme, docs

* Minor renaming, docs

* More docs

* More docs

* Minor addition

* Review comment fixes & changes

* Minor change

* Review comments

* Update frontier to make CI pass
  • Loading branch information
Dinonard authored Nov 14, 2023
1 parent 655c280 commit 9b5f988
Show file tree
Hide file tree
Showing 17 changed files with 4,487 additions and 1,969 deletions.
52 changes: 28 additions & 24 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 @@ -274,6 +274,7 @@ pallet-block-reward = { path = "./pallets/block-reward", default-features = fals
pallet-collator-selection = { path = "./pallets/collator-selection", default-features = false }
pallet-custom-signatures = { path = "./pallets/custom-signatures", default-features = false }
pallet-dapps-staking = { path = "./pallets/dapps-staking", default-features = false }
pallet-dapp-staking-v3 = { path = "./pallets/dapp-staking-v3", default-features = false }
pallet-xc-asset-config = { path = "./pallets/xc-asset-config", default-features = false }
pallet-xvm = { path = "./pallets/xvm", default-features = false }
pallet-xcm = { path = "./pallets/pallet-xcm", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions bin/collator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ shiden-runtime = { workspace = true, features = ["std"] }
# astar pallets dependencies
astar-primitives = { workspace = true }
pallet-block-reward = { workspace = true }
pallet-dapp-staking-v3 = { workspace = true }

# frame dependencies
frame-system = { workspace = true, features = ["std"] }
Expand Down
42 changes: 37 additions & 5 deletions bin/collator/src/local/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@
use local_runtime::{
wasm_binary_unwrap, AccountId, AuraConfig, AuraId, BalancesConfig, BaseFeeConfig,
BlockRewardConfig, CouncilConfig, DemocracyConfig, EVMConfig, GenesisConfig, GrandpaConfig,
GrandpaId, Precompiles, Signature, SudoConfig, SystemConfig, TechnicalCommitteeConfig,
TreasuryConfig, VestingConfig,
BlockRewardConfig, CouncilConfig, DappStakingConfig, DemocracyConfig, EVMConfig, GenesisConfig,
GrandpaConfig, GrandpaId, Precompiles, Signature, SudoConfig, SystemConfig,
TechnicalCommitteeConfig, TreasuryConfig, VestingConfig, AST,
};
use sc_service::ChainType;
use sp_core::{crypto::Ss58Codec, sr25519, Pair, Public};
use sp_runtime::{
traits::{IdentifyAccount, Verify},
Perbill,
Perbill, Permill,
};

use pallet_dapp_staking_v3::TierThreshold;

type AccountPublic = <Signature as Verify>::Signer;

/// Specialized `ChainSpec` for Shiden Network.
Expand Down Expand Up @@ -112,7 +114,7 @@ fn testnet_genesis(
balances: endowed_accounts
.iter()
.cloned()
.map(|k| (k, 1_000_000_000_000_000_000_000_000_000))
.map(|k| (k, 1_000_000_000 * AST))
.collect(),
},
block_reward: BlockRewardConfig {
Expand Down Expand Up @@ -181,6 +183,36 @@ fn testnet_genesis(
},
democracy: DemocracyConfig::default(),
treasury: TreasuryConfig::default(),
dapp_staking: DappStakingConfig {
reward_portion: vec![
Permill::from_percent(40),
Permill::from_percent(30),
Permill::from_percent(20),
Permill::from_percent(10),
],
slot_distribution: vec![
Permill::from_percent(10),
Permill::from_percent(20),
Permill::from_percent(30),
Permill::from_percent(40),
],
tier_thresholds: vec![
TierThreshold::DynamicTvlAmount {
amount: 100 * AST,
minimum_amount: 80 * AST,
},
TierThreshold::DynamicTvlAmount {
amount: 50 * AST,
minimum_amount: 40 * AST,
},
TierThreshold::DynamicTvlAmount {
amount: 20 * AST,
minimum_amount: 20 * AST,
},
TierThreshold::FixedTvlAmount { amount: 10 * AST },
],
slots_per_tier: vec![10, 20, 30, 40],
},
}
}

Expand Down
11 changes: 11 additions & 0 deletions pallets/dapp-staking-v3/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ sp-std = { workspace = true }

astar-primitives = { workspace = true }

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

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

Expand All @@ -42,4 +44,13 @@ std = [
"frame-system/std",
"pallet-balances/std",
"astar-primitives/std",
"frame-benchmarking/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"]
Loading

0 comments on commit 9b5f988

Please sign in to comment.