Skip to content
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

Merged
merged 5 commits into from Oct 21, 2020

Conversation

vzotova
Copy link
Member

@vzotova vzotova commented Oct 18, 2020

No description provided.

@vzotova vzotova added ETH Contracts CLI This effects the nucypher CLI labels Oct 18, 2020
@vzotova vzotova added this to the Mainnet Second-tier (previously "Mainnet Month 1") milestone Oct 18, 2020
@vzotova vzotova self-assigned this Oct 18, 2020
@vzotova vzotova marked this pull request as ready for review October 19, 2020 17:54
@vzotova vzotova changed the title [WIP] Method to remove unused sub-stakes in StakingEscrow Method to remove unused sub-stakes in StakingEscrow Oct 19, 2020
nucypher/cli/commands/stake.py Outdated Show resolved Hide resolved
nucypher/cli/literature.py Outdated Show resolved Hide resolved
nucypher/cli/commands/stake.py Outdated Show resolved Hide resolved
docs/source/guides/network_node/staking_guide.rst Outdated Show resolved Hide resolved
vzotova added a commit to vzotova/nucypher that referenced this pull request Oct 19, 2020
Co-authored-by: Derek Pierre <derek.pierre@gmail.com>
Copy link
Member

@derekpierre derekpierre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎸

Copy link
Member

@arjunhassard arjunhassard left a 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Member Author

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

Copy link
Member

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.

Copy link
Member Author

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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To remove unused sub-stake:
To remove unused sub-stakes:

Copy link
Member Author

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

nucypher/cli/literature.py Outdated Show resolved Hide resolved
subStake.periods = lastSubStake.periods;
subStake.lockedValue = lastSubStake.lockedValue;
}
info.subStakes.pop();
Copy link
Member

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

Copy link
Member Author

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

vzotova added a commit to vzotova/nucypher that referenced this pull request Oct 20, 2020
Co-authored-by: Derek Pierre <derek.pierre@gmail.com>
Co-authored-by: Arjun Hassard <arjunhassard@gmail.com>
vzotova added a commit to vzotova/nucypher that referenced this pull request Oct 20, 2020
Co-authored-by: Derek Pierre <derek.pierre@gmail.com>
Co-authored-by: Arjun Hassard <arjunhassard@gmail.com>
Remove unused sub-stake
***********************

Combining or editing sub-stakes can lead to 'unused', inactive sub-stakes remaining on-chain.
Copy link
Member

@KPrasch KPrasch Oct 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. What guidance can you offer as to who and when this operation needs to be performed, after every stake editing operation?
  2. Usage of the word "combine" here makes me want to rename "merge".

Copy link
Member Author

@vzotova vzotova Oct 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 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)
  2. ✔️

@@ -271,6 +271,10 @@

SUCCESSFUL_STAKES_MERGE = 'Successfully Merged Stakes'

CONFIRM_REMOVE = "Publish removal of {stake_index} stake?"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CONFIRM_REMOVE = "Publish removal of {stake_index} stake?"
CONFIRM_REMOVE_SUBSTAKE = "Publish removal of {stake_index} stake?"

Copy link
Member Author

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):
Copy link
Member

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?

Copy link
Member Author

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>
@KPrasch KPrasch merged commit e531035 into nucypher:main Oct 21, 2020
@vzotova vzotova deleted the remove-sub-stakes branch December 7, 2020 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI This effects the nucypher CLI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants