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

Connect Pool DB with Api #881

Merged
merged 12 commits into from
Oct 24, 2019
Merged

Connect Pool DB with Api #881

merged 12 commits into from
Oct 24, 2019

Conversation

Anviking
Copy link
Collaborator

@Anviking Anviking commented Oct 22, 2019

Issue Number

#713

Overview

  • I have implemented a GET /stake-pool that reads and combines metrics from Pool.DB
  • 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

Testnet syncing which is interrupted and resumed

testnet-2

@Anviking Anviking self-assigned this Oct 22, 2019
@Anviking Anviking force-pushed the anviking/713/connect-db-with-api branch 4 times, most recently from 1337b43 to 6c15d00 Compare October 22, 2019 14:07
@Anviking Anviking force-pushed the anviking/713/connect-db-with-api branch from 6c15d00 to fd70b03 Compare October 22, 2019 14:52
@Anviking Anviking changed the base branch from master to anviking/713/worker October 22, 2019 14:52
@Anviking Anviking force-pushed the anviking/713/connect-db-with-api branch from 6a961e5 to 2b98247 Compare October 22, 2019 15:04
@Anviking Anviking changed the base branch from anviking/713/worker to master October 22, 2019 15:06

-- StakePool
PoolSqlite.withDBLayer cfg tr (poolDBPath databaseDir) $
\splDB -> do
Copy link
Member

Choose a reason for hiding this comment

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

why the line-break here 😬 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because we have a rule saying lines must be 80 characters or less 😬 This one would have been 81.

Maybe importing Cardano.Pool.DB.Sqlite as Pool instead of PoolSqlite would actually be nice though…

Copy link
Member

Choose a reason for hiding this comment

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

Hmm. Yes. But the guidelines are... Guidelines. When it makes sense, we can break them and we sometimes do.

@Anviking Anviking force-pushed the anviking/713/connect-db-with-api branch 6 times, most recently from 5294f42 to 91fcdaa Compare October 23, 2019 10:58
lib/core/src/Cardano/Pool/Metrics.hs Outdated Show resolved Hide resolved
lib/core/src/Cardano/Pool/Metrics.hs Outdated Show resolved Hide resolved
_ -> return Nothing

progress :: BlockHeader -> BlockHeader -> Percentage
progress tip target =
Copy link
Member

Choose a reason for hiding this comment

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

Why not use the progress calculation from the primitive types?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  1. This blockHeight-calculation would return 100% when we are at the node tip. I.e. when the stake-pool list results become available. syncProgress compare to the current time. If the node tip is behind the current time, the progress might then jump from 50% to, show results.
  2. This blockHeight approach is simple and gives us (seemingly) perfectly linear increase in progress.
  3. syncProgress returns SyncProgress = Ready | Restoring, which we don't want.
  4. syncProgress has a tolerance which we don't want. Here we know that we are not in sync, and want to show the exact progress to the user. Even if that would happen to be 99% or 100%.

PoolSqlite.withDBLayer cfg tr (poolDBPath databaseDir) $
\splDB -> do

-- TODO: I believe @KTorZ wants us to use @WorkerRegistry@
Copy link
Member

Choose a reason for hiding this comment

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

Not WorkerRegistry. There's no need for this. But newWorker would be good. With void $ forkIO, we are just firing a thread in the wild and we have no control over it..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Separate PR? And can we talk about it first or maybe you want to do do that?

lib/jormungandr/test/data/jormungandr/genesis.yaml Outdated Show resolved Hide resolved
@Anviking Anviking force-pushed the anviking/713/connect-db-with-api branch 3 times, most recently from 1d524da to 44741c3 Compare October 23, 2019 13:18
@Anviking Anviking force-pushed the anviking/713/connect-db-with-api branch from f3136c4 to a5e657f Compare October 23, 2019 22:49
@Anviking
Copy link
Collaborator Author

bors r+

iohk-bors bot added a commit that referenced this pull request 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
Copy link
Contributor

iohk-bors bot commented Oct 23, 2019

Build failed

@KtorZ KtorZ force-pushed the anviking/713/connect-db-with-api branch from 4540a00 to 247270c Compare October 24, 2019 09:13
@KtorZ
Copy link
Member

KtorZ commented Oct 24, 2019

bors r+

iohk-bors bot added a commit that referenced this pull request 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
Copy link
Contributor

iohk-bors bot commented Oct 24, 2019

Build failed

Anviking and others added 12 commits October 24, 2019 13:52
fixup: use minBound :: Percentage

fixup: convert -> count

fixup whitespace spl

Add more detailed TODOs for detecting if we are unsynced

Fixup: accidental diff

Other approach
fixup: f -> mkApiStakePool

fixup: error in bridge listStakePools

fixup: use withDBLayer

Other approach
…assertions

NOTE: 4xx code are for CLIENTS errors. Not being able to answer because we aren't synced is not a client error.
@KtorZ KtorZ force-pushed the anviking/713/connect-db-with-api branch from 247270c to 3adffb1 Compare October 24, 2019 12:40
@KtorZ
Copy link
Member

KtorZ commented Oct 24, 2019

bors r+

iohk-bors bot added a commit that referenced this pull request 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>
Copy link
Contributor

@paweljakubas paweljakubas left a comment

Choose a reason for hiding this comment

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

Nice work!

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Oct 24, 2019

Build succeeded

@iohk-bors iohk-bors bot merged commit 3adffb1 into master Oct 24, 2019
@KtorZ KtorZ deleted the anviking/713/connect-db-with-api branch October 24, 2019 13:22
\situation. Here's some information about what happened: \n"
o `shouldBe` mempty
c `shouldBe` ExitFailure 1
eventually $ do
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

😱 I was wondering if there was something as simple as eventually

Copy link
Member

Choose a reason for hiding this comment

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

:man-shrugging:

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

Successfully merging this pull request may close these issues.

None yet

3 participants