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

List stake distribution and stake pool statistics #713

Closed
Anviking opened this issue Sep 13, 2019 · 9 comments
Closed

List stake distribution and stake pool statistics #713

Anviking opened this issue Sep 13, 2019 · 9 comments
Assignees

Comments

@Anviking
Copy link
Collaborator

Anviking commented Sep 13, 2019

Context

ℹ️ This ticket is now an aggregation of:

#712
#715
#725
#722

Jörmungandr provides an endpoint for this with the following yaml-ified response format:

epoch: 228      # Epoch of last block
stake:
  dangling: 0 # Total value stored in accounts, but assigned to nonexistent pools
  pools:
    - - 5cf03f333f37eb7b987dbc9017b8a928287a3d77d086cd93cd9ad05bcba7e60f # stake pool ID
      - 1000000000000                                                    # staked value
    - - 3815602c096fcbb91072f419c296c3dfe1f730e0f446a9bd2553145688e75615 # stake pool ID
      - 1000000000000                                                    # staked value
  unassigned: 0 # Total value stored in accounts, but not assigned to any pool

Todo: When run with BFT-config, jörmungandr only returns {"epoch":2521}. How do we handle that?

Decision

  • Extend NetworkLayer and JörmungandrLayer to allow fetching this endpoint.

It should have a return-type similar to

(EpochNumber, [(PoolId, Stake)])
where
newtype Stake = Stake { getStakeLovelace :: Natural }
newtype PoolId = PoolVRFPubKey ByteString -- 32 bytes long

Acceptance Criteria

  1. Our Jörmungandr client must be able to fetch stake pool distribution
  2. We must be able to retrieve stake of each pool and the epoch for which the results are valid
  3. We should be able to ignore dangling and unassigned stake
  4. Users must be able to list stake pools via the CLI
  5. It must be possible to eventually get an up-to-date distribution and statistics even with the events of rollbacks
  6. It must be possible to know how many blocks each stake pool in the current epoch has produced
  7. Distribution and pool statistics must be persisted so that it can be restored swiftly between restarts.
  8. Wallet API clients must be able to list stake-pools and get their id, approximate performance and stake.
  9. If API results are unavailable, this must be presented appropriately to the user.
  10. The API response should not be paginated
  11. Swagger.yaml must be updated

Development Plan

PR

Number Base
#? master

QA

@KtorZ KtorZ added this to the List Stake Pool milestone Sep 13, 2019
@Anviking Anviking changed the title Get stake-distribution from Jörmungandr's REST API Get stake-distribution from Jörmungandr's GET /stake Sep 15, 2019
@Anviking
Copy link
Collaborator Author

I'm not sure why jcli rest v0 stake get -h http://127.0.0.1:8080/api doesn't work for me on jcli 0.3.3, but curl-ing works:

curl http://127.0.0.1:8080/api/v0/stake
{"epoch":0,"stake":{"dangling":0,"pools":[],"unassigned":100100000000000}}⏎

@KtorZ
Copy link
Member

KtorZ commented Sep 17, 2019

From @rvl

  • yamlification was a good idea
  • Put in the type signature of the function that will be implemented

@Anviking
Copy link
Collaborator Author

yamlification was a good idea

Not quite sure what this refers to 🤔, but I simply copied the yaml-example from the jörmungandr docs. I wasn't advocating that we should serve yaml (in #715 that would be).

@Anviking Anviking changed the title Get stake-distribution from Jörmungandr's GET /stake Get stake-distribution from Jörmungandr's GET /stake Sep 18, 2019
@Anviking
Copy link
Collaborator Author

About what is included in the total stake: The U/S clearly specifies S as the total stake currently delegated to pools. So we shouldn't have to care about unassigned or dangling.

Running jörmungandr with the following stake distribution:

$ curl http://127.0.0.1:8080/api/v0/stake
{"epoch":252054,"stake":{"dangling":0,"pools":[["7d749ef424507fb80fed0d2289d535a94f6870add0cf8b374cfe6cae078320ec",1]],"unassigned":100100000000000}}⏎

it produces blocks every slot.

Also, if the single pool has 0 stake, it doesn't produce blocks.

@KtorZ
Copy link
Member

KtorZ commented Sep 18, 2019

Also, if the single pool has 0 stake, it doesn't produce blocks.

👍 sounds intuitive.

@paweljakubas paweljakubas self-assigned this Sep 25, 2019
iohk-bors bot added a commit that referenced this issue Oct 1, 2019
763: add jormungandr get stake distribution r=KtorZ a=paweljakubas

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->
#713 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have added GET handle of jormungandr `/stake`
- [x] I have added tests


# Comments

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


764: Update Buildable instances for BlockHeader and Hash r=KtorZ a=Anviking

# Issue Number

#711 


# Overview

- [x] I added an idea for new `BlockHeader` buildable instance where the prevBlockHash comes first, and the blockHeader points towards it.
- [x] I made `Hash tag` `build` to `424c4f43` instead of `424c4f43...c0dd1877`. 
- [x] I implemented `To/FromText` and `Buildable` instances on `Hash tag` in general, instead of having one instance per tag.


# Comments

<!-- Additional comments or screenshots to attach if any -->

```haskell
fmtLn $ build h
-- Old: Block (5.36#1036) -> 424c4f43...434b3033
-- New: 424c4f43 ⬸ [5.36#1036]

fmtLn $ build (prevBlockHash h)
-- Old: 424c4f43...434b3033
-- New: 424c4f43
```

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


770: Foundations for stake-pools integration tests r=KtorZ a=piotr-iohk

# Issue Number

#715

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [ ] I have added simple _foundations_ for future integration tests for stake-pools list


# Comments

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Pawel Jakubas <pawel.jakubas@iohk.io>
Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
Co-authored-by: Piotr Stachyra <piotr.stachyra@iohk.io>
iohk-bors bot added a commit that referenced this issue Oct 1, 2019
763: add jormungandr get stake distribution r=KtorZ a=paweljakubas

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->
#713 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have added GET handle of jormungandr `/stake`
- [x] I have added tests


# Comments

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Pawel Jakubas <pawel.jakubas@iohk.io>
iohk-bors bot added a commit that referenced this issue Oct 17, 2019
842: Add `NetworkLayer.stakeDistribution` and change types of response r=Anviking a=Anviking

# Issue Number

#713

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I simplified the types of JormungandrClient.getStakeDistribution and added NetworkLayer.stakeDistribution since our code currently works well with a large NetworkLayer. This way `StakePool.Metrics` can get the stake distribution without having a JörmungandrClient.
- [ ] *Bonus*: <s>Add Buildable instance for Percentage</s>

# Comments

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
iohk-bors bot added a commit that referenced this issue Oct 17, 2019
842: Add `NetworkLayer.stakeDistribution` and change types of response r=Anviking a=Anviking

# Issue Number

#713

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I simplified the types of JormungandrClient.getStakeDistribution and added NetworkLayer.stakeDistribution since our code currently works well with a large NetworkLayer. This way `StakePool.Metrics` can get the stake distribution without having a JörmungandrClient.
- [ ] *Bonus*: <s>Add Buildable instance for Percentage</s>

# Comments

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
iohk-bors bot added a commit that referenced this issue Oct 17, 2019
856: implement 'withinSameTip' = to retry an action if the tip has changed while executing it r=Anviking a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

#713 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have added a helper function `withinSameTip` to "bracket" an action, retrying it if necessary (i.e. if the tip has changed during the execution of the action). 

# Comments

<!-- Additional comments or screenshots to attach if any -->

example usage:

```hs
withinSameTip defaultPolicy (getNetworkTip nl) $ \tip -> do
    activity <- getStakePoolActivity tip
    distribution  <- getStakeDistribution tip
    pure $ combineMetrics activity distribution
```
<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: KtorZ <matthias.benkort@gmail.com>
iohk-bors bot added a commit that referenced this issue Oct 17, 2019
856: implement 'withinSameTip' = to retry an action if the tip has changed while executing it r=KtorZ a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

#713 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have added a helper function `withinSameTip` to "bracket" an action, retrying it if necessary (i.e. if the tip has changed during the execution of the action). 

# Comments

<!-- Additional comments or screenshots to attach if any -->

example usage:

```hs
withinSameTip defaultPolicy (getNetworkTip nl) $ \tip -> do
    activity <- getStakePoolActivity tip
    distribution  <- getStakeDistribution tip
    pure $ combineMetrics activity distribution
```
<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: KtorZ <matthias.benkort@gmail.com>
iohk-bors bot added a commit that referenced this issue Oct 18, 2019
861: Measure intersection hit rate in chain following tests r=KtorZ a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

#713 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have added a `findIntersection` function to the network layer in order to allow client code to find an intersection with the current node's unstable block headers.
- [x] I have measured the "intersection hit rate" (i.e., the number of time we are actually within `k` blocks from the tip before we call `nextBlocks` for the next batch). 
- [x] I have fixed a "small" bug in the http-bridge init cursor which would cause a partial pattern match to be triggered when the wallet is restarted. This gives us some idea of how well our chain following code performs. The main assumption is that our Jörmungandr client is actually much harsher than the reality. Therefore, if our chain follower does good in these scenarios, we might expect it to do rather okay in reality

# Comments

<!-- Additional comments or screenshots to attach if any -->

We were wondering how frequent would we return a "ErrNoSynced"  when fetching the stake pool distribution. We return such error if the our local chain has no intersection with the node's. 

With a small (in front of `k`) batch size, we currently get something like this:

```
      57.425% Intersection hit rate  GREAT (75% - 100%)
      32.235% Intersection hit rate  GOOD  (50% - 75%)
      10.331% Intersection hit rate  POOR  (10% - 50%)
       0.009% Intersection hit rate  BAD   (0%  - 10%)
```

Now, if we increase the batch size to be bigger than k (like an order of magnitude)

```
      84.438% Intersection hit rate GREAT (75% - 100%)
      15.541% Intersection hit rate GOOD  (50% - 75%)
       0.021% Intersection hit rate POOR  (10% - 50%)
```

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: KtorZ <matthias.benkort@gmail.com>
iohk-bors bot added a commit that referenced this issue Oct 18, 2019
868: store 'StakeDistribution' in the database, implement put & read ops  r=KtorZ a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

#713 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have added a StakeDistribution table
- [x] I have added two operations for reading and putting stake distributions to DB
- [x] I have added two basic properties for the operations above.

# Comments

<!-- Additional comments or screenshots to attach if any -->

```
  Sqlite
    Stake Pool properties
      readStakeDistribution . putStakeDistribution == pure
        +++ OK, passed 100 tests (4% Empty distributions).
      readStake . putStake a1 . putStake s0 == pure a1
        +++ OK, passed 100 tests:
         6% b is empty
         4% a is empty
         3% a & b are empty
```

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: KtorZ <matthias.benkort@gmail.com>
iohk-bors bot added a commit that referenced this issue Oct 18, 2019
868: store 'StakeDistribution' in the database, implement put & read ops  r=KtorZ a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

#713 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have added a StakeDistribution table
- [x] I have added two operations for reading and putting stake distributions to DB
- [x] I have added two basic properties for the operations above.

# Comments

<!-- Additional comments or screenshots to attach if any -->

```
  Sqlite
    Stake Pool properties
      readStakeDistribution . putStakeDistribution == pure
        +++ OK, passed 100 tests (4% Empty distributions).
      readStake . putStake a1 . putStake s0 == pure a1
        +++ OK, passed 100 tests:
         6% b is empty
         4% a is empty
         3% a & b are empty
```

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: KtorZ <matthias.benkort@gmail.com>
iohk-bors bot added a commit that referenced this issue Oct 18, 2019
868: store 'StakeDistribution' in the database, implement put & read ops  r=KtorZ a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

#713 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have added a StakeDistribution table
- [x] I have added two operations for reading and putting stake distributions to DB
- [x] I have added two basic properties for the operations above.

# Comments

<!-- Additional comments or screenshots to attach if any -->

```
  Sqlite
    Stake Pool properties
      readStakeDistribution . putStakeDistribution == pure
        +++ OK, passed 100 tests (4% Empty distributions).
      readStake . putStake a1 . putStake s0 == pure a1
        +++ OK, passed 100 tests:
         6% b is empty
         4% a is empty
         3% a & b are empty
```

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: KtorZ <matthias.benkort@gmail.com>
iohk-bors bot added a commit that referenced this issue Oct 18, 2019
868: store 'StakeDistribution' in the database, implement put & read ops  r=KtorZ a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

#713 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have added a StakeDistribution table
- [x] I have added two operations for reading and putting stake distributions to DB
- [x] I have added two basic properties for the operations above.

# Comments

<!-- Additional comments or screenshots to attach if any -->

```
  Sqlite
    Stake Pool properties
      readStakeDistribution . putStakeDistribution == pure
        +++ OK, passed 100 tests (4% Empty distributions).
      readStake . putStake a1 . putStake s0 == pure a1
        +++ OK, passed 100 tests:
         6% b is empty
         4% a is empty
         3% a & b are empty
```

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: KtorZ <matthias.benkort@gmail.com>
iohk-bors bot added a commit that referenced this issue Oct 23, 2019
881: Connect Pool DB with Api r=KtorZ a=Anviking

# Issue Number

#713 

# Overview

- [x] I have implemented a `GET /stake-pool` that reads and combines metrics from `Pool.DB`
- [x] TODO: Figure out when we are unsynced
- [ ] TODO: Look for things to test if possible in this PR

# Comments

### Self-node with a very short epoch-length (results are unavailable across epoch boundaries)
![self-node-short-epochs](https://user-images.githubusercontent.com/304423/67398367-d0edc680-f5aa-11e9-86da-ac13337e2a63.gif)

### Testnet syncing which is interrupted and resumed
![testnet-2](https://user-images.githubusercontent.com/304423/67399072-f7f8c800-f5ab-11e9-9fb1-38e8886aeba4.gif)


<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
iohk-bors bot added a commit that referenced this issue Oct 23, 2019
881: Connect Pool DB with Api r=Anviking a=Anviking

# Issue Number

#713 

# Overview

- [x] I have implemented a `GET /stake-pool` that reads and combines metrics from `Pool.DB`
- [x] TODO: Figure out when we are unsynced
- [ ] TODO: Look for things to test if possible in this PR

# Comments

### Self-node with a very short epoch-length (results are unavailable across epoch boundaries)
![self-node-short-epochs](https://user-images.githubusercontent.com/304423/67398367-d0edc680-f5aa-11e9-86da-ac13337e2a63.gif)

### Testnet syncing which is interrupted and resumed
![testnet-2](https://user-images.githubusercontent.com/304423/67399072-f7f8c800-f5ab-11e9-9fb1-38e8886aeba4.gif)


<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
iohk-bors bot added a commit that referenced this issue Oct 23, 2019
881: Connect Pool DB with Api r=Anviking a=Anviking

# Issue Number

#713 

# Overview

- [x] I have implemented a `GET /stake-pool` that reads and combines metrics from `Pool.DB`
- [x] TODO: Figure out when we are unsynced
- [ ] TODO: Look for things to test if possible in this PR

# Comments

### Self-node with a very short epoch-length (results are unavailable across epoch boundaries)
![self-node-short-epochs](https://user-images.githubusercontent.com/304423/67398367-d0edc680-f5aa-11e9-86da-ac13337e2a63.gif)

### Testnet syncing which is interrupted and resumed
![testnet-2](https://user-images.githubusercontent.com/304423/67399072-f7f8c800-f5ab-11e9-9fb1-38e8886aeba4.gif)


<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
iohk-bors bot added a commit that referenced this issue Oct 24, 2019
881: Connect Pool DB with Api r=KtorZ a=Anviking

# Issue Number

#713 

# Overview

- [x] I have implemented a `GET /stake-pool` that reads and combines metrics from `Pool.DB`
- [x] TODO: Figure out when we are unsynced
- [ ] TODO: Look for things to test if possible in this PR

# Comments

### Self-node with a very short epoch-length (results are unavailable across epoch boundaries)
![self-node-short-epochs](https://user-images.githubusercontent.com/304423/67398367-d0edc680-f5aa-11e9-86da-ac13337e2a63.gif)

### Testnet syncing which is interrupted and resumed
![testnet-2](https://user-images.githubusercontent.com/304423/67399072-f7f8c800-f5ab-11e9-9fb1-38e8886aeba4.gif)


<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
iohk-bors bot added a commit that referenced this issue Oct 24, 2019
881: Connect Pool DB with Api r=KtorZ a=Anviking

# Issue Number

#713 

# Overview

- [x] I have implemented a `GET /stake-pool` that reads and combines metrics from `Pool.DB`
- [x] TODO: Figure out when we are unsynced
- [ ] TODO: Look for things to test if possible in this PR

# Comments

### Self-node with a very short epoch-length (results are unavailable across epoch boundaries)
![self-node-short-epochs](https://user-images.githubusercontent.com/304423/67398367-d0edc680-f5aa-11e9-86da-ac13337e2a63.gif)

### Testnet syncing which is interrupted and resumed
![testnet-2](https://user-images.githubusercontent.com/304423/67399072-f7f8c800-f5ab-11e9-9fb1-38e8886aeba4.gif)


<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
iohk-bors bot added a commit that referenced this issue Oct 24, 2019
910: Review stake pool worker creation r=Anviking a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

#713 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have slightly re-organized the code around the declaration of the stake pool layer
- [x] I have namespaced the stake pool worker
- [x] I have mounted some simple error handling on the stake pool worker thread

# Comments

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: KtorZ <matthias.benkort@gmail.com>
iohk-bors bot added a commit that referenced this issue Oct 24, 2019
910: Review stake pool worker creation r=Anviking a=KtorZ

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

#713 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] I have slightly re-organized the code around the declaration of the stake pool layer
- [x] I have namespaced the stake pool worker
- [x] I have mounted some simple error handling on the stake pool worker thread

# Comments

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: KtorZ <matthias.benkort@gmail.com>
iohk-bors bot added a commit that referenced this issue Oct 26, 2019
919: Test stake-pool metrics on extremely short epochs r=Anviking a=Anviking

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

#713 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] ⚠️ I have changed the epoch length to 3, and slotDuration to 1, in the genesis block of the integration tests.
- [x] I have extended the expectation that we `eventually get 200`, to `eventually get 200 >> eventually get 503`, as the stake-pool metrics become unsynced when the node enters a new epoch.
- [x] I have added guarantees on the returned list of stake-pools based on our specific testing setup. 

# Comments

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
iohk-bors bot added a commit that referenced this issue Oct 28, 2019
919: Test stake-pool metrics on extremely short epochs r=Anviking a=Anviking

# Issue Number

<!-- Put here a reference to the issue this PR relates to and which requirements it tackles -->

#713 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] ⚠️ I have changed the epoch length to 3, and slotDuration to 1, in the genesis block of the integration tests.
- [x] I have extended the expectation that we `eventually get 200`, to `eventually get 200 >> eventually get 503`, as the stake-pool metrics become unsynced when the node enters a new epoch.
- [x] I have added guarantees on the returned list of stake-pools based on our specific testing setup. 

# Comments

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
iohk-bors bot added a commit that referenced this issue Oct 29, 2019
928: Test that monitorStakePools resumes correctly after being killed r=Anviking a=Anviking

# Issue Number

#713 

# Overview

- [x] I added an integration test, testing `monitorStakePools` and `Pool.DB, making sure that if a worker is killed and restarted, it is the same as if it had never been killed.

# Comments


<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
iohk-bors bot added a commit that referenced this issue Oct 31, 2019
940: Add more stake-pools in the CI setup r=Anviking a=Anviking

# Issue Number

#713 


# Overview

- [x] I have added more stake-pools to the CI setup. We launch 1 pool, and have 2 inactive ones.


# Comments

- I don't really understand the effect on `consensus_genesis_praos_active_slot_coeff` on the block-production / slot, I'm checking with the rust folks.
- As of currently this PR keeps `consensus_genesis_praos_active_slot_coeff : 1` and results in 100% of the slots being produced by the first pool, despite having 33% of the stake.

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
iohk-bors bot added a commit that referenced this issue Nov 1, 2019
940: Add more stake-pools in the CI setup r=Anviking a=Anviking

# Issue Number

#713 


# Overview

- [x] I have added more stake-pools to the CI setup. We launch 1 pool, and have 2 inactive ones.


# Comments

- I don't really understand the effect on `consensus_genesis_praos_active_slot_coeff` on the block-production / slot, I'm checking with the rust folks.
- As of currently this PR keeps `consensus_genesis_praos_active_slot_coeff : 1` and results in 100% of the slots being produced by the first pool, despite having 33% of the stake.

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
iohk-bors bot added a commit that referenced this issue Nov 1, 2019
924: Prototype implementation of approximate pool performance r=KtorZ a=Anviking

# Issue Number

#713 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] Very quick prototype implementation of approximate performance (`AP`).
- [x] Performance is included in the stake-pool-metrics served by the api.

# Comments

<!-- Additional comments or screenshots to attach if any -->

- Should make sure corner-cases are handled correctly (numbers may be 0)
- On the jormungandr testnet one pool has a performance of 53, while the others have 0 🤔 . (There is only one pool that is actually producing blocks.)

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
iohk-bors bot added a commit that referenced this issue Nov 1, 2019
924: Prototype implementation of approximate pool performance r=KtorZ a=Anviking

# Issue Number

#713 

# Overview

<!-- Detail in a few bullet points the work accomplished in this PR -->

- [x] Very quick prototype implementation of approximate performance (`AP`).
- [x] Performance is included in the stake-pool-metrics served by the api.

# Comments

<!-- Additional comments or screenshots to attach if any -->

- Should make sure corner-cases are handled correctly (numbers may be 0)
- On the jormungandr testnet one pool has a performance of 53, while the others have 0 🤔 . (There is only one pool that is actually producing blocks.)

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
iohk-bors bot added a commit that referenced this issue Nov 9, 2019
979: Support atomic and isolated executions of the database layers r=KtorZ a=Anviking

# Issue Number

#713 

# Overview

- [x] I have made sure that `putPoolProduction` and `putStakeDistribution` happens in a single Sqlite transaction. If the wallet were to crash, either none of them or both of them succeed.
- [x] Existing tests verify that this works for large batches `~ 100`. I tried writing 2000 pool-productions atomically, and it also worked, but slowed down tests, so I didn't commit it.

# Comments

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
iohk-bors bot added a commit that referenced this issue Nov 9, 2019
979: Support atomic and isolated executions of the database layers r=KtorZ a=Anviking

# Issue Number

#713 

# Overview

- [x] I have made sure that `putPoolProduction` and `putStakeDistribution` happens in a single Sqlite transaction. If the wallet were to crash, either none of them or both of them succeed.
- [x] Existing tests verify that this works for large batches `~ 100`. I tried writing 2000 pool-productions atomically, and it also worked, but slowed down tests, so I didn't commit it.

# Comments

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
iohk-bors bot added a commit that referenced this issue Nov 9, 2019
979: Support atomic and isolated executions of the database layers r=KtorZ a=Anviking

# Issue Number

#713 

# Overview

- [x] I have made sure that `putPoolProduction` and `putStakeDistribution` happens in a single Sqlite transaction. If the wallet were to crash, either none of them or both of them succeed.
- [x] Existing tests verify that this works for large batches `~ 100`. I tried writing 2000 pool-productions atomically, and it also worked, but slowed down tests, so I didn't commit it.

# Comments

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
iohk-bors bot added a commit that referenced this issue Nov 9, 2019
979: Support atomic and isolated executions of the database layers r=KtorZ a=Anviking

# Issue Number

#713 

# Overview

- [x] I have made sure that `putPoolProduction` and `putStakeDistribution` happens in a single Sqlite transaction. If the wallet were to crash, either none of them or both of them succeed.
- [x] Existing tests verify that this works for large batches `~ 100`. I tried writing 2000 pool-productions atomically, and it also worked, but slowed down tests, so I didn't commit it.

# Comments

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
iohk-bors bot added a commit that referenced this issue Nov 9, 2019
979: Support atomic and isolated executions of the database layers r=KtorZ a=Anviking

# Issue Number

#713 

# Overview

- [x] I have made sure that `putPoolProduction` and `putStakeDistribution` happens in a single Sqlite transaction. If the wallet were to crash, either none of them or both of them succeed.
- [x] Existing tests verify that this works for large batches `~ 100`. I tried writing 2000 pool-productions atomically, and it also worked, but slowed down tests, so I didn't commit it.

# Comments

<!-- Additional comments or screenshots to attach if any -->

<!-- 
Don't forget to:

 ✓ Self-review your changes to make sure nothing unexpected slipped through
 ✓ Assign yourself to the PR
 ✓ Assign one or several reviewer(s)
 ✓ Once created, link this PR to its corresponding ticket
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <johannes.lund@iohk.io>
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
@KtorZ
Copy link
Member

KtorZ commented Nov 20, 2019

Shall we close that one 😶 ?

@piotr-iohk
Copy link
Contributor

Yes I think so, I was just keeping it here while doing some exploratory testing on different testnets (which discovered few issues)...

@Anviking
Copy link
Collaborator Author

It might be worth attempting to generalise the performance calculation (to e.g. support exponential moving averages) and at the same time extending the tests.

@KtorZ
Copy link
Member

KtorZ commented Nov 21, 2019

to generalise the performance calculation

To cover what business requirement exactly 🤔 ?

at the same time extending the tests.

I think we already had 50 days for that :) ... Any more work on this would go in a new story, in a new ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants