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
Method to remove unused sub-stakes in StakingEscrow #2384
Conversation
Co-authored-by: Derek Pierre <derek.pierre@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎸
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💹
Remove unused sub-stake | ||
*********************** | ||
|
||
Unused sub-stakes still cost some amount of gas during operations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused sub-stakes still cost some amount of gas during operations. | |
Combining or editing sub-stakes can lead to 'unused', inactive sub-stakes remaining on-chain. These unused sub-stakes add unnecessary gas costs to daily operations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technicaly this is wrong, because merging stakes will produce two sub-stakes and sometimes both of them will be active at least one period (when node is online at least 2 periods), also inactive sub-stakes will be shown if special flag will be specified. Anyway I'd prefer not to have here info about merge stake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had another go! But no pressure to make this change, I just think some context is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️(changed one word)
*********************** | ||
|
||
Unused sub-stakes still cost some amount of gas during operations. | ||
To remove unused sub-stake: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To remove unused sub-stake: | |
To remove unused sub-stakes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Command removes only one sub-stake by each tx
subStake.periods = lastSubStake.periods; | ||
subStake.lockedValue = lastSubStake.lockedValue; | ||
} | ||
info.subStakes.pop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does using pop
mean that the function can only remove one unused sub-stake at a time? Unless I'm mistaken this just deletes one element from the end of an array.
If so, how does one keep track of their removal of multiple sub-stakes? It doesn't show you unused sub-stakes when you check via nucypher stake list
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right - this deletes last element in array but before this - copies last element to place of removed unused sub-stake.
To show inactive sub-stakes you can use option --all
for nucypher stake list
or interactive mode for nucypher stake remove-unused
Co-authored-by: Derek Pierre <derek.pierre@gmail.com> Co-authored-by: Arjun Hassard <arjunhassard@gmail.com>
9348a53
to
fc08be8
Compare
Co-authored-by: Derek Pierre <derek.pierre@gmail.com> Co-authored-by: Arjun Hassard <arjunhassard@gmail.com>
fc08be8
to
e38594b
Compare
Remove unused sub-stake | ||
*********************** | ||
|
||
Combining or editing sub-stakes can lead to 'unused', inactive sub-stakes remaining on-chain. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- What guidance can you offer as to who and when this operation needs to be performed, after every stake editing operation?
- Usage of the word "combine" here makes me want to rename "merge".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Remove all inactive (shown using by
nucypher stake list --all
) allways if you want pay less as possible for gas,
unlock, increase, merge, slashing could create temporary sub-stakes (which will be inactive soon) or make some sub-stakes inactive, so ideally do some operations and only after all of them - check inactive and potentially inactive sub-stakes (last period active) - ✔️
nucypher/cli/literature.py
Outdated
@@ -271,6 +271,10 @@ | |||
|
|||
SUCCESSFUL_STAKES_MERGE = 'Successfully Merged Stakes' | |||
|
|||
CONFIRM_REMOVE = "Publish removal of {stake_index} stake?" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CONFIRM_REMOVE = "Publish removal of {stake_index} stake?" | |
CONFIRM_REMOVE_SUBSTAKE = "Publish removal of {stake_index} stake?" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️
@@ -264,16 +263,6 @@ def test_deposit_and_increase(agency, testerchain, test_registry, token_economic | |||
assert staking_agent.get_locked_tokens(staker_account, 1) == locked_tokens + amount | |||
|
|||
|
|||
def test_disable_restaking(agency, testerchain, test_registry): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this test get relocated somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few lines below - same method with the same name and this one was already disabled
Co-authored-by: Derek Pierre <derek.pierre@gmail.com> Co-authored-by: Arjun Hassard <arjunhassard@gmail.com> Co-authored-by: Kieran Prasch <kieran@nucypher.com>
e38594b
to
8c80b03
Compare
No description provided.