Add staker info tools to nucypher status#1259
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1259 +/- ##
==========================================
- Coverage 81.19% 79.55% -1.65%
==========================================
Files 72 72
Lines 10018 10269 +251
==========================================
+ Hits 8134 8169 +35
- Misses 1884 2100 +216
Continue to review full report at Codecov.
|
5f10d15 to
52790ac
Compare
nucypher status
|
I very much wish there was an |
|
|
||
| MAX_ROWS = 30 | ||
| period_range = list(range(1, periods + 1)) | ||
| token_counter = Counter({day: agent.get_all_locked_tokens(day) for day in period_range}) |
There was a problem hiding this comment.
Just a reminder - this will print using only "active" workers/stakers
There was a problem hiding this comment.
How can we get the non active stakers too?
There was a problem hiding this comment.
It's not trivial question. Because if you want to print period by period all stakes for all stakers - this will be not fast, because should do this manualy (calculate next period, get next staker, get locked tokens, sum or get next staker, get all sub stakes and then do all others summarization)
Also possible other solution if only current/next periods will be enough
There was a problem hiding this comment.
Can this be derived by listing all the stakers that have ever connected to the network, then removing the currently active stakers?
michwill
left a comment
There was a problem hiding this comment.
Omg, this is insanely awesome!
nucypher/cli/painting.py
Outdated
| Actively Staked Tokens ... {NU.from_nunits(staking_agent.get_global_locked_tokens())} | ||
| Published Stakes ......... {staking_agent.get_staker_population()} | ||
| Gas Price ................ {Web3.fromWei(blockchain.client.gas_price, 'gwei')} Gwei | ||
| Active Staking Ursulas ... {staking_agent.get_staker_population()} |
There was a problem hiding this comment.
This prints the same thing as the line before ('Published Stakes')? Rebase issue perhaps...?
There was a problem hiding this comment.
Yes, I think published stakes doesn't make much sense here, since there's a 1 to 1 relation between stake and stakers. I also changed the Active Staking Ursulas part since "Staking Ursulas" is not correct, and also get_staker_population() gives you all stakers, both active and inactive. Instead, I added a new functionality to get stakers partitioned by different confirmation status.
derekpierre
left a comment
There was a problem hiding this comment.
Left a prior comment about a problematic line in painting.py
KPrasch
left a comment
There was a problem hiding this comment.
Awesome Work! Giving eyes to the network.... Approved with pending rebase over master. I'd love to see a follow-up PR that allows for JSON output generation, perhaps via composition on Moe.
derekpierre
left a comment
There was a problem hiding this comment.
Great stuff @cygnusv !! A couple comments about the units used for token balance output.
…> 'network'. Support status via registry filepath.
…n `nucypher status network`
…uff here and there.
There was a problem hiding this comment.
Tools like this really level the playing field between large and small stakers! @cygnusv
|
|
||
| stake = agent.owned_tokens(staker) | ||
| last_confirmed_period = agent.get_last_active_period(staker) | ||
| worker = agent.get_worker_from_staker(staker) |
There was a problem hiding this comment.
Can this function retrieve the addresses of multiple workers associated with the same staker/stake? Re: #1302
def get_worker_from_staker(self, staker_address: str) -> str:
worker = self.contract.functions.getWorkerFromStaker(staker_address).call()
return to_checksum_address(worker)
There was a problem hiding this comment.
Our current model assumes a 1-to-1 relation between Workers and Stakers.
| bucket_end = bucket[-1] | ||
|
|
||
| bucket_max = max([token_counter[period] for period in bucket]) | ||
| bucket_min = min([token_counter[period] for period in bucket]) |
There was a problem hiding this comment.
Visuals showing min, max and total tokens locked for each set of periods are great. Maybe a note explaining what min and max mean wouldn't go amiss?
|
|
||
| MAX_ROWS = 30 | ||
| period_range = list(range(1, periods + 1)) | ||
| token_counter = Counter({day: agent.get_all_locked_tokens(day) for day in period_range}) |
There was a problem hiding this comment.
Can this be derived by listing all the stakers that have ever connected to the network, then removing the currently active stakers?
If you have ideas to improve these commands (or new commands), don't be shy! Maybe I can add them.
Usage:
To see evolution of overall locked tokens of the network for next

Ndays (default is 90):nucypher status locked-tokens --provider <GETH> --poa [--periods N]To see all stakers info (optionally a staking address can be supplied):

nucypher status stakers --provider <GETH> --poa [--staking-address 0xfoobar]