Skip to content

Restaking Control#1339

Merged
KPrasch merged 11 commits intonucypher:masterfrom
KPrasch:restake
Sep 19, 2019
Merged

Restaking Control#1339
KPrasch merged 11 commits intonucypher:masterfrom
KPrasch:restake

Conversation

@KPrasch
Copy link
Member

@KPrasch KPrasch commented Sep 17, 2019

Co-Author: @cygnusv

Fixes #1269, Includes extracted changes from #1227

New Staker CLI Commands

nucypher stake restake --enable
nucypher stake restake --disable
nucypher stake restake --lock-until <PERIOD>

Example
$ nucypher stake restake --enable
 ____    __            __                      
/\  _`\ /\ \__        /\ \                     
\ \,\L\_\ \ ,_\    __ \ \ \/'\      __   _ __  
 \/_\__ \\ \ \/  /'__`\\ \ , <    /'__`\/\`'__\
   /\ \L\ \ \ \_/\ \L\.\\ \ \\`\ /\  __/\ \ \/ 
   \ `\____\ \__\ \__/.\_\ \_\ \_\ \____\\ \_\ 
    \/_____/\/__/\/__/\/_/\/_/\/_/\/____/ \/_/ 
   
The Holder of Stakes.                                      

======================================= Active Stakes =========================================

| ~ | Staker | Worker | # | Value    | Duration     | Enactment          
|   | ------ | ------ | - | -------- | ------------ | ----------------------------------------- 
| 0 | 0xEc39 | 0x985a | 0 | 45000 NU | 103 periods  | Aug 27 23:47:06 PDT - Dec 08 22:47:06 PST 

Select Stake: 0
Enter password to unlock account 0xEc391142E1007787101F328837C3ffa9eef767A2: 
Confirm enable restaking for staker 0xEc391142E1007787101F328837C3ffa9eef767A2? [y/N]: y
Successfully enabled restaking for 0xEc391142E1007787101F328837C3ffa9eef767A2
OK | 0x279c03b0bade60b0e499d85cce090d35bae2472aaa3f63250291f5b255086476 (31953 gas)
Block #1312292 | 0x7eab515f7a2e9ed98cbdbe6f2d4ff637e07274be1b9fd11bde7d0bbedc14a829
 See https://goerli.etherscan.io/tx/0x279c03b0bade60b0e499d85cce090d35bae2472aaa3f63250291f5b255086476

@KPrasch KPrasch added API CLI This effects the nucypher CLI labels Sep 17, 2019
@codecov
Copy link

codecov bot commented Sep 17, 2019

Codecov Report

Merging #1339 into master will decrease coverage by 0.33%.
The diff coverage is 81.92%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1339      +/-   ##
==========================================
- Coverage   83.16%   82.82%   -0.34%     
==========================================
  Files          72       72              
  Lines       10226    10347     +121     
==========================================
+ Hits         8504     8570      +66     
- Misses       1722     1777      +55
Impacted Files Coverage Δ
nucypher/blockchain/eth/registry.py 76.22% <100%> (ø) ⬆️
nucypher/cli/painting.py 77.43% <42.85%> (-0.87%) ⬇️
nucypher/cli/characters/stake.py 81.18% <80.76%> (-0.19%) ⬇️
nucypher/blockchain/eth/agents.py 87.28% <86.95%> (-1.32%) ⬇️
nucypher/blockchain/eth/actors.py 85.74% <88.46%> (+0.56%) ⬆️
nucypher/policy/collections.py 88.26% <0%> (-3.52%) ⬇️
nucypher/characters/lawful.py 86.24% <0%> (-2.76%) ⬇️
nucypher/network/server.py 82.88% <0%> (-2.71%) ⬇️
nucypher/network/middleware.py 81.3% <0%> (-2.44%) ⬇️
nucypher/crypto/kits.py 85.45% <0%> (-1.82%) ⬇️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 159ab96...3d51918. Read the comment docs.

Copy link
Member

@cygnusv cygnusv left a comment

Choose a reason for hiding this comment

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

Just some minor comments wrt to docs.


As your Ursula performs work, you can optionally enable the automatic addition of
all rewards to your existing stake to optimize earnings. By default this feature is disabled,
to enable it run:
Copy link
Member

Choose a reason for hiding this comment

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

I think we talked about leaving re-stake on by default, since that would be the most profitable and common scenario for stakers. Also, use "re-stake" with hyphen in the section title and in the next lines.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah right

Copy link
Member Author

@KPrasch KPrasch Sep 19, 2019

Choose a reason for hiding this comment

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

Yeah - I agree that it makes sense to have restaking enabled by default - just documenting the current behavior.

Do we want to control this default at the contract-level? If not we can add a re-stake enable transaction to the nucypher stake create command. Is this something we want to introduce in this PR?

Copy link
Member

Choose a reason for hiding this comment

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

We can just leave this as an open issue, because it does make sense to do it at the contract level. What do you think @szotov ?

Copy link
Member

@vzotova vzotova Sep 19, 2019

Choose a reason for hiding this comment

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

unfortunately no such thing like default value in contract, because all values are zero in the beginning and only can be set in functions. So we can set value in first deposit if we want, but I'm not sure is it good decision to do it implicitly

Copy link
Contributor

Choose a reason for hiding this comment

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

The value can be set when initializing the contract though?

Copy link
Member

@vzotova vzotova Sep 19, 2019

Choose a reason for hiding this comment

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

Not really, because it's individual structure for each staker
I can do a trick - use something like notReStake field. But also issue here: to keep upgradability this should be a new field and old reStake wil be as a garbage.
So I prefer to set reStake on the first call of deposit

Copy link
Contributor

Choose a reason for hiding this comment

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

Or, perhaps, we can have it explicitly set as a required parameter when we start staking (and then the default can be set in Python)

Copy link
Member

@cygnusv cygnusv left a comment

Choose a reason for hiding this comment

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

Oh, another commend wrt to the commands: if --lock and --release-period are always used together, why not just using one? I always envisioned something like --lock-until PERIOD.

@KPrasch
Copy link
Member Author

KPrasch commented Sep 18, 2019

Why past tense? :-)

@KPrasch KPrasch marked this pull request as ready for review September 18, 2019 16:22
@KPrasch KPrasch changed the title [WIP] Restaking Control Restaking Control Sep 18, 2019
KPrasch added a commit to KPrasch/nucypher that referenced this pull request Sep 19, 2019
Copy link
Member

@cygnusv cygnusv left a comment

Choose a reason for hiding this comment

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

Good stuff. My only major requested change is to remove one of the duplicated methods of StakingEscrowAgent

KPrasch added a commit to KPrasch/nucypher that referenced this pull request Sep 19, 2019
KPrasch added a commit to KPrasch/nucypher that referenced this pull request Sep 19, 2019
…ods, Docs touchups; ContractAgency, restaing agency layer assertions.
KPrasch added a commit to KPrasch/nucypher that referenced this pull request Sep 19, 2019
…ods, Docs touchups; ContractAgency, restaing agency layer assertions.
…ods, Docs touchups; ContractAgency, restaing agency layer assertions.
@KPrasch
Copy link
Member Author

KPrasch commented Sep 19, 2019

Only outstanding question I have here (perhaps best addressed in a follow-up PR) - Do we want to perform a re-staking enable transaction as part of stake initialization?

@michwill
Copy link
Contributor

@KPrasch yeah, my vote on that is to, ideally, have a _restake argument to the restaking transaction, so that the defaults are decided in Python

@KPrasch
Copy link
Member Author

KPrasch commented Sep 19, 2019

Follow-up #1349

@KPrasch KPrasch merged commit 314ab27 into nucypher:master Sep 19, 2019
@KPrasch KPrasch deleted the restake branch March 22, 2021 18:41
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.

Restake workflow with CLI

6 participants