Skip to content

Commit 9536303

Browse files
authored
dApp Staking v3 & Tokenomics 2.0 (#990)
* dApp Staking v3 Part1 * Feat/dapp staking v3 phase2 (#991) * Phase2 progress * Adapt for 0.9.43 * Abstract sparse vector type * Further modifications * claim unlocked functionality WIP * claim unlocked tested * Relock unlocking * Check era when adding chunk * Custom error for some types * Additional type tests - WIP * More type tests * Review comments * Additional changes * dApp staking v3 - part 3 (#1036) * dApp staking v3 - PR3 * SingularStakingInfo * SingularStakingInfo tests * Stake work * Stake & lots of tests * TODOs, renaming, improvements * Refactoring & cleanup * More fixes * Rework series * Series tests * Minor adjustment * stake test utils & first test * Stake test * stake extrinsic tests * Era & Period change logic * Update era/period transition in mock & tests * on_init tests & refactoring * Unstake & some minor improvements * Lots of type tests for unstake * More tests * More types test * Testing utils for unstake, some TODOs * Unstake tests * Minor adjustments * Fixes * Additional scenario * Address review comments * Correct unstake amount * Tests * dapp staking v3 - part 4 (#1053) * 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 * Fix for cleanup * dapp staking v3 - part 5 (#1087) * 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 * dApp staking v3 - part 5 * Make check work * Limit map size to improve benchmarks * Fix for cleanup * Minor fixes, more tests * More fixes & test * Minor changes * More tests * More tests, some clippy fixes * Finished with type tests for now * Log, remove some TODOs * Changes * Bug fix for unstake era, more tests * Formatting, extra test * Unregistered unstake, expired cleanup, test utils & tests * Cleanup tests, minor fixes * force tests * Remove TODOs * Tier assignment test WIP * Finish dapp tier assignment test, fix reward calculation bug * Some renaming, test utils for era change WIP * Fix minor issues, propagaste renaming * More checks * Finish on_init tests * Comments, docs, some benchmarks * Benchmark progress * More benchmarks * Even more benchmarks * All extrinsics benchmarked * Expand tests * Comment * Missed error test * Review comments * Pallet inflation (#1091) * Pallet inflation * Hooks * Functionality, mock & benchmarks * Empty commit since it seems last push didn't work properly * Tests, fixes * More tests, minor fixes&changes * Zero divison protection, frontier update * More tests, minor changes * Integration & renaming * Genesis integration, more tests * Final integration * Cleanup deps * Division with zero test * Comments * More minor changes * Improve test coverage * Integrate into pallet-timestamp * Remove timestamp * Fix * review comments * toml format * dApp Staking v3 - part 6 (#1093) * dApp staking v3 part 6 * Minor refactor of benchmarks * Weights integration * Fix * remove orig file * Minor refactoring, more benchmark code * Extract on_init logic * Some renaming * More benchmarks * Full benchmarks integration * Testing primitives * staking primitives * dev fix * Integration part1 * Integration part2 * Reward payout integration * Replace lock functionality with freeze * Cleanup TODOs * More negative tests * Frozen balance test * Zero div * Docs for inflation * Rename is_active & add some more docs * More docs * pallet docs * text * scripts * More tests * Test, docs * Review comment * dApp staking v3 - part 7 (#1099) * dApp staking v3 part 6 * Minor refactor of benchmarks * Weights integration * Fix * remove orig file * Minor refactoring, more benchmark code * Extract on_init logic * Some renaming * More benchmarks * Full benchmarks integration * Testing primitives * staking primitives * dev fix * Integration part1 * Integration part2 * Reward payout integration * Replace lock functionality with freeze * Cleanup TODOs * More negative tests * Frozen balance test * Zero div * Docs for inflation * Rename is_active & add some more docs * More docs * pallet docs * text * scripts * More tests * Test, docs * Review comment * Runtime API * Changes * Change dep * Comment * Formatting * Expired entry cleanup * Cleanup logic test * Remove tier labels * fix * Improve README * Improved cleanup * Review comments * Docs * Formatting * Typo * Fix - bonus reward update ledger (#1102) * Bonus claim reduced contract_stake_count * Extra test * dApp Staking Migration (#1101) * dApp Staking Migration * Events, benchmark prep * benchmarks * Benchmarks & mock * weights * limit * Use extrinsic call * Solved todos, docs, improvements * Maintenance mode, on_runtime_upgrade logic * Tests, refactoring * Finish * More tests * Type cleanup * try-runtime checks * deps * Improve docs * Fixes & try-runtime testing modifications * Fix test * repeated * Minor improvements * Improvements * taplo * Minor rename * Feat/dapp staking v3 precompiles (#1096) * Init commit * All legacy calls covered * v2 interface first definition * Rename * Resolve merge errors * TODO * v2 init implementation * Prepared mock * todo * Migration to v2 utils * More adjustments * Finish adapting implementation to v2 * Mock & fixes * Primitive smart contract * Fix dsv3 test * Prepare impl & mock * Remove redundant code, adjust mock & prepare tests * Tests & utils * Test for legacy getters/view functions * More legacy tests * v1 interface covered with tests * Minor refactor, organization, improvements * v2 tests * Cleanup TODOs * More tests * Updates * docs * Fixes * Address review comments * Adjustments * Audit comments * Fix mock * FMT * Review comments * Fix for incorrect freeze amount (#1111) * dApp Staking v3 - Shibuya integration (#1109) * dApp staking v3 - Shibuya integration * Init * Fix build * Fix find/replace doc mess * Migration & disable * More integration * Progress * Adjusted integration * Finished integration * Additional modifications & cleanup * Move comment * Fixes * Shibuya integration tests fix & proxy * Renaming * Integration test fixes & legacy support * Adjust for benchmarks * Remove chain-extension, small updates * fixes * Partial weights * Minor changes * Benchmark fixes * dApp staking weights * Weights, deps * Remove redundant storage item * Inflation params, resolve TODOs * Optimize lengthy benchmark * Integration test * Sort out more TODOs * Benchmark optimization * Fix seed * Remove spec version bump * Fix integration test * Weights update
1 parent ae668a0 commit 9536303

76 files changed

Lines changed: 21868 additions & 1163 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 106 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ members = [
1515

1616
"primitives",
1717

18-
"chain-extensions/dapps-staking",
1918
"chain-extensions/pallet-assets",
2019
"chain-extensions/xvm",
2120
"chain-extensions/unified-accounts",
@@ -275,12 +274,17 @@ orml-xcm-support = { git = "https://github.com/open-web3-stack/open-runtime-modu
275274
pallet-block-rewards-hybrid = { path = "./pallets/block-rewards-hybrid", default-features = false }
276275
pallet-collator-selection = { path = "./pallets/collator-selection", default-features = false }
277276
pallet-dapps-staking = { path = "./pallets/dapps-staking", default-features = false }
277+
pallet-dapp-staking-v3 = { path = "./pallets/dapp-staking-v3", default-features = false }
278+
pallet-dapp-staking-migration = { path = "./pallets/dapp-staking-migration", default-features = false }
278279
pallet-xc-asset-config = { path = "./pallets/xc-asset-config", default-features = false }
279280
pallet-xvm = { path = "./pallets/xvm", default-features = false }
280281
pallet-ethereum-checked = { path = "./pallets/ethereum-checked", default-features = false }
282+
pallet-inflation = { path = "./pallets/inflation", default-features = false }
281283
pallet-dynamic-evm-base-fee = { path = "./pallets/dynamic-evm-base-fee", default-features = false }
282284
pallet-unified-accounts = { path = "./pallets/unified-accounts", default-features = false }
283285

286+
dapp-staking-v3-runtime-api = { path = "./pallets/dapp-staking-v3/rpc/runtime-api", default-features = false }
287+
284288
astar-primitives = { path = "./primitives", default-features = false }
285289
astar-test-utils = { path = "./tests/utils", default-features = false }
286290

@@ -290,14 +294,13 @@ pallet-evm-precompile-substrate-ecdsa = { path = "./precompiles/substrate-ecdsa"
290294
pallet-evm-precompile-xcm = { path = "./precompiles/xcm", default-features = false }
291295
pallet-evm-precompile-xvm = { path = "./precompiles/xvm", default-features = false }
292296
pallet-evm-precompile-dapps-staking = { path = "./precompiles/dapps-staking", default-features = false }
297+
pallet-evm-precompile-dapp-staking-v3 = { path = "./precompiles/dapp-staking-v3", default-features = false }
293298
pallet-evm-precompile-unified-accounts = { path = "./precompiles/unified-accounts", default-features = false }
294299

295-
pallet-chain-extension-dapps-staking = { path = "./chain-extensions/dapps-staking", default-features = false }
296300
pallet-chain-extension-xvm = { path = "./chain-extensions/xvm", default-features = false }
297301
pallet-chain-extension-assets = { path = "./chain-extensions/pallet-assets", default-features = false }
298302
pallet-chain-extension-unified-accounts = { path = "./chain-extensions/unified-accounts", default-features = false }
299303

300-
dapps-staking-chain-extension-types = { path = "./chain-extensions/types/dapps-staking", default-features = false }
301304
xvm-chain-extension-types = { path = "./chain-extensions/types/xvm", default-features = false }
302305
assets-chain-extension-types = { path = "./chain-extensions/types/assets", default-features = false }
303306
unified-accounts-chain-extension-types = { path = "./chain-extensions/types/unified-accounts", default-features = false }

bin/collator/src/local/chain_spec.rs

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@
2020
2121
use local_runtime::{
2222
wasm_binary_unwrap, AccountId, AuraConfig, AuraId, BalancesConfig, BlockRewardConfig,
23-
CouncilConfig, DemocracyConfig, EVMConfig, GenesisConfig, GrandpaConfig, GrandpaId,
24-
Precompiles, RewardDistributionConfig, Signature, SudoConfig, SystemConfig,
25-
TechnicalCommitteeConfig, TreasuryConfig, VestingConfig,
23+
CouncilConfig, DappStakingConfig, DemocracyConfig, EVMConfig, GenesisConfig, GrandpaConfig,
24+
GrandpaId, InflationConfig, InflationParameters, Precompiles, RewardDistributionConfig,
25+
Signature, SudoConfig, SystemConfig, TechnicalCommitteeConfig, TierThreshold, TreasuryConfig,
26+
VestingConfig, AST,
2627
};
2728
use sc_service::ChainType;
2829
use sp_core::{crypto::Ss58Codec, sr25519, Pair, Public};
2930
use sp_runtime::{
3031
traits::{IdentifyAccount, Verify},
31-
Perbill,
32+
Perbill, Permill,
3233
};
3334

3435
type AccountPublic = <Signature as Verify>::Signer;
@@ -112,7 +113,7 @@ fn testnet_genesis(
112113
balances: endowed_accounts
113114
.iter()
114115
.cloned()
115-
.map(|k| (k, 1_000_000_000_000_000_000_000_000_000))
116+
.map(|k| (k, 1_000_000_000 * AST))
116117
.collect(),
117118
},
118119
block_reward: BlockRewardConfig {
@@ -177,6 +178,39 @@ fn testnet_genesis(
177178
},
178179
democracy: DemocracyConfig::default(),
179180
treasury: TreasuryConfig::default(),
181+
dapp_staking: DappStakingConfig {
182+
reward_portion: vec![
183+
Permill::from_percent(40),
184+
Permill::from_percent(30),
185+
Permill::from_percent(20),
186+
Permill::from_percent(10),
187+
],
188+
slot_distribution: vec![
189+
Permill::from_percent(10),
190+
Permill::from_percent(20),
191+
Permill::from_percent(30),
192+
Permill::from_percent(40),
193+
],
194+
tier_thresholds: vec![
195+
TierThreshold::DynamicTvlAmount {
196+
amount: 100 * AST,
197+
minimum_amount: 80 * AST,
198+
},
199+
TierThreshold::DynamicTvlAmount {
200+
amount: 50 * AST,
201+
minimum_amount: 40 * AST,
202+
},
203+
TierThreshold::DynamicTvlAmount {
204+
amount: 20 * AST,
205+
minimum_amount: 20 * AST,
206+
},
207+
TierThreshold::FixedTvlAmount { amount: 10 * AST },
208+
],
209+
slots_per_tier: vec![10, 20, 30, 40],
210+
},
211+
inflation: InflationConfig {
212+
params: InflationParameters::default(),
213+
},
180214
}
181215
}
182216

0 commit comments

Comments
 (0)