-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Introduces: Delegated Staking Pallet #3904
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
114 commits
Select commit
Hold shift + click to select a range
dda12d4
add ability to super bond to staking
Ank4n 802784c
some comments
Ank4n d2b680e
fix tests
Ank4n 646c7f4
tests
Ank4n bc92a19
fix naming
Ank4n 2528da7
fmt
Ank4n 4ddcb77
Merge branch 'master' into ankan/01-prep-staking-for-delegation
Ank4n 0cbec7d
delegated staking without pool tests
Ank4n e6152ed
fix clippy errors
Ank4n a91a417
remove pool dependency
Ank4n d6069a4
fix imports
Ank4n 3e37916
taplo fmt toml files
Ank4n 79c4a86
taplo refmt
Ank4n 35c5e80
remove calls
Ank4n c5a5d32
fix docs
Ank4n f82b349
rename storage Delegatees to Agents
Ank4n b550031
rename all delegatee to agent
Ank4n b87fc08
remove fixme
Ank4n bfd3434
Make delegation interface independent
Ank4n 7104faf
move reward account check to caller
Ank4n aed693c
virtual staker cannot bond again
Ank4n 989bc50
release all becomes migrate_to_virtual_staker
Ank4n 731f5a1
Merge branch 'ankan/01-prep-staking-for-delegation' into ankan/02-pal…
Ank4n 4226b9b
fix function call
Ank4n 6f05a52
add test
Ank4n 3d0e0ba
Merge branch 'ankan/01-prep-staking-for-delegation' into ankan/02-pal…
Ank4n 4d00b04
remove benchmarking file
Ank4n 264f71a
small refactors
Ank4n f9a52f1
fmt
Ank4n 1d58711
Merge branch 'ankan/01-prep-staking-for-delegation' into ankan/02-pal…
Ank4n 7bf4d34
remove mod bench
Ank4n 40a5132
add pool migration function to Delegation Interface
Ank4n e8e498c
add migrate delegation to delegation interface
Ank4n 5ece9c7
dec provider if agent is killed
Ank4n 23c65c4
doc updates
Ank4n 4f441d5
doc updates
Ank4n 58b50c9
test for bonders cannot virtual bond
Ank4n b946c4a
virtual nominators receive rewards
Ank4n 0aa9006
virtual nominator slashing test
Ank4n d242356
fmt
Ank4n 4fcafd0
Merge branch 'ankan/01-prep-staking-for-delegation' into ankan/02-pal…
Ank4n 6bd5e2c
fmt
Ank4n 2fb04c5
found a bug while unbonding
Ank4n 7962aac
test for unclaimed withdrawals
Ank4n 8bd3bc3
fix clippy error
Ank4n 11da089
Merge branch 'ankan/01-prep-staking-for-delegation' into ankan/02-pal…
Ank4n 15a9fc6
fix clippy
Ank4n 1a34d28
fix compile
Ank4n 2a75dc5
fix defensive trigger
Ank4n 0bf4dba
pool does not have to transfer ed to proxy delegator
Ank4n 7800446
don't check for min balance when delegating to agent. pool should che…
Ank4n 84fb918
don't check for min balance
Ank4n e55cea3
fix imports
Ank4n fbccd0f
Merge branch 'master' into ankan/01-prep-staking-for-delegation
Ank4n 0c83496
Merge branch 'ankan/01-prep-staking-for-delegation' into ankan/02-pal…
Ank4n 765278a
prdoc
Ank4n e46b01b
prdoc
Ank4n 0e41b01
Merge branch 'master' into ankan/01-prep-staking-for-delegation
Ank4n 67a541c
Merge branch 'ankan/01-prep-staking-for-delegation' into ankan/02-pal…
Ank4n 444dc76
add migrate to direct staker for testing
Ank4n 9e5bdfa
Merge branch 'ankan/01-prep-staking-for-delegation' into ankan/02-pal…
Ank4n b1312d7
minor refactor
Ank4n 9079d82
add migrate to direct staker for testing
Ank4n 616dfa7
doc comment
Ank4n 6bcf0ab
Merge branch 'ankan/01-prep-staking-for-delegation' into ankan/02-pal…
Ank4n afe8c87
pr feedback
Ank4n e7d65e2
add try state checks for virtual ledger
Ank4n 474c1de
fmt
Ank4n 6a019d6
Update substrate/frame/delegated-staking/src/lib.rs
kianenigma 8d481a6
Apply suggestions from code review
Ank4n 6940f88
Merge branch 'master' into ankan/01-prep-staking-for-delegation
Ank4n a884846
safe maths
Ank4n d4633c2
fix docs based on feedback
Ank4n c013cde
rename StakingUnsafe to StakingUnchecked
Ank4n b2588a5
Merge branch 'ankan/01-prep-staking-for-delegation' into ankan/02-pal…
Ank4n ac3cadf
use static mutate
Ank4n 8cee25c
Merge branch 'ankan/01-prep-staking-for-delegation' into ankan/02-pal…
Ank4n 0537e9c
Rename StakingUnsafe to StakingUnchecked
Ank4n fb5d64c
pr feedbacks
Ank4n bb93c8c
pr feedbacks
Ank4n cba250e
feedbacks
Ank4n 9897437
feedback
Ank4n 09d3359
Merge branch 'master' into ankan/01-prep-staking-for-delegation
Ank4n e75c2e6
Merge branch 'ankan/01-prep-staking-for-delegation' into ankan/02-pal…
Ank4n e31866e
inline locking
Ank4n 078cf5f
optimize stash kill
Ank4n 3790a40
Merge branch 'master' into ankan/01-prep-staking-for-delegation
Ank4n 796c848
Merge branch 'ankan/01-prep-staking-for-delegation' into ankan/02-pal…
Ank4n 666be52
Merge branch 'master' into ankan/02-pallet-delegated-staking
Ank4n be76a6b
pr feedbacks
Ank4n c6070d8
check stash is killed before cleaning up agent
Ank4n 886a1a7
Merge branch 'master' into ankan/02-pallet-delegated-staking
Ank4n a69d620
Merge branch 'master' into ankan/02-pallet-delegated-staking
Ank4n 4b2daa2
withdraw delegation requires num slashing spans
Ank4n 0e17037
separate trait for migration
Ank4n 4e3b8cd
add a separate slash reward fraction for agent slashing
Ank4n b1b1e1d
better docs pr feedback
Ank4n 1e6cdad
rename claim delegation to migrate delegation
Ank4n 3cef018
Merge branch 'master' into ankan/02-pallet-delegated-staking
Ank4n 24d05ad
fix docs
Ank4n bd56eb3
Merge branch 'master' into ankan/02-pallet-delegated-staking
Ank4n d4ef271
Merge branch 'master' into ankan/02-pallet-delegated-staking
Ank4n fe0b657
fix migration, move free funds as well when migrating a nominator to …
Ank4n 464cea0
Merge branch 'master' into ankan/02-pallet-delegated-staking
Ank4n 7782cab
pr feedbacks
Ank4n 6e3045f
use system events for pallet
Ank4n 159d1bf
run try state for staking
Ank4n 52ae957
fmt
Ank4n 77eb34c
Merge branch 'master' into ankan/02-pallet-delegated-staking
Ank4n 9e035ba
Merge branch 'master' into ankan/02-pallet-delegated-staking
Ank4n 78fac9e
initial release version for delegate staking pallet
Ank4n 3264782
initial version set to 1.0.0 and bump as patch
Ank4n cd5eb94
add other pallets affected in prdoc
Ank4n 8314177
Merge branch 'master' into ankan/02-pallet-delegated-staking
Ank4n File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feedbacks
- Loading branch information
commit cba250e032567c6a9be1e6037cb4b2cc6fea6af0
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ use super::*; | |
| use crate::mock::*; | ||
| use frame_support::{assert_noop, assert_ok, traits::fungible::InspectHold}; | ||
| use pallet_staking::Error as StakingError; | ||
| use sp_staking::DelegationInterface; | ||
|
|
||
| #[test] | ||
| fn create_a_agent_with_first_delegator() { | ||
Ank4n marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
@@ -195,7 +196,6 @@ fn agent_restrictions() { | |
| }); | ||
| } | ||
|
|
||
| use sp_staking::DelegationInterface; | ||
| #[test] | ||
| fn apply_pending_slash() { | ||
| ExtBuilder::default().build_and_execute(|| { | ||
|
|
@@ -239,7 +239,7 @@ fn apply_pending_slash() { | |
| // balance before slash | ||
| let initial_pending_slash = get_agent(&agent).ledger.pending_slash; | ||
| assert!(initial_pending_slash > 0); | ||
| let unslashed_balance = held_balance(&i); | ||
| let unslashed_balance = DelegatedStaking::held_balance_of(&i); | ||
| let slash = unslashed_balance / 2; | ||
| // slash half of delegator's delegation. | ||
| assert_ok!(<DelegatedStaking as DelegationInterface>::delegator_slash( | ||
|
|
@@ -250,7 +250,7 @@ fn apply_pending_slash() { | |
| )); | ||
|
|
||
| // balance after slash. | ||
| assert_eq!(held_balance(&i), unslashed_balance - slash); | ||
| assert_eq!(DelegatedStaking::held_balance_of(&i), unslashed_balance - slash); | ||
| // pending slash is reduced by the amount slashed. | ||
| assert_eq!(get_agent(&agent).ledger.pending_slash, initial_pending_slash - slash); | ||
| // reporter get 10% of the slash amount. | ||
|
|
@@ -341,15 +341,16 @@ mod staking_integration { | |
| DelegatedStaking::release_delegation(RawOrigin::Signed(agent).into(), 301, 50, 0), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the question. :D |
||
| Error::<T>::NotEnoughFunds | ||
| ); | ||
| // assert_noop!(DelegatedStaking::release_delegation(RawOrigin::Signed(agent).into(), | ||
| // 200, 50, 0), Error::<T>::NotAllowed); active and total stake remains same | ||
|
|
||
| assert!(eq_stake(agent, total_staked, total_staked)); | ||
|
|
||
| // 305 wants to unbond 50 in era 2, withdrawable in era 5. | ||
| assert_ok!(Staking::unbond(RawOrigin::Signed(agent).into(), 50)); | ||
|
|
||
| // 310 wants to unbond 100 in era 3, withdrawable in era 6. | ||
Ank4n marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| start_era(3); | ||
| assert_ok!(Staking::unbond(RawOrigin::Signed(agent).into(), 100)); | ||
Ank4n marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // 320 wants to unbond 200 in era 4, withdrawable in era 7. | ||
| start_era(4); | ||
kianenigma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| assert_ok!(Staking::unbond(RawOrigin::Signed(agent).into(), 200)); | ||
|
|
@@ -485,7 +486,7 @@ mod staking_integration { | |
| 0 | ||
| )); | ||
|
|
||
| assert_eq!(held_balance(&300), 100 - 80); | ||
| assert_eq!(DelegatedStaking::held_balance_of(&300), 100 - 80); | ||
| }); | ||
| } | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.