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

Parameterise StakePools API over apiPool type #1738

Merged
merged 1 commit into from
Jun 12, 2020

Conversation

Anviking
Copy link
Member

@Anviking Anviking commented Jun 10, 2020

Issue Number

ADP-311, #1718

Overview

  • I parameterised StakePools API over apiPool
  • I renamed ApiStakePool to ApiJormungandrStakePool, such that we can later introduce a haskell ApiStakePool
  • I made the default Api type use ApiJormungandrStakePool. We should later switch to ApiStakePool, and update the swagger scheme such that it targets haskell, and not jormungandr.
  • I moved StakePoolLayer to the jormungandr package.

Comments

  • I am keeping the Pool DB in core, since I think we still want it. But I have not thought about how it would work with shelley.
  • changelog: this is pure refactoring, but in combination with follow-up PRs this is a new feature.

@Anviking
Copy link
Member Author

bors try

iohk-bors bot added a commit that referenced this pull request Jun 10, 2020

-- | @StakePoolLayer@ is a thin layer ontop of the DB. It is /one/ value that
-- can easily be passed to the API-server, where it can be used in a simple way.
data StakePoolLayer e m = StakePoolLayer
Copy link
Member Author

@Anviking Anviking Jun 10, 2020

Choose a reason for hiding this comment

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

Moved to Cardano.Pool.Jormungandr.Metrics

-> StakePoolLayer e IO
-> IO [PoolId]
-- ^ Known pools
-- We could maybe replace this with a @IO (PoolId -> Bool)@
Copy link
Member Author

@Anviking Anviking Jun 10, 2020

Choose a reason for hiding this comment

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

No need to have a common StakePoolLayer at this point. No need to have a common StakePool type in core either.

We just need to make sure the target packages can provide a Handler (ListStakePool apiPool), for some apiPool, and can provide this IO [PoolId].

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 10, 2020

try

Build failed

@Anviking Anviking force-pushed the anviking/ADP-311/liberate-stakepool-api branch from d5e4b84 to 11d2408 Compare June 10, 2020 09:39
@Anviking Anviking requested review from paweljakubas and KtorZ June 10, 2020 09:40
@Anviking Anviking self-assigned this Jun 10, 2020
@Anviking Anviking force-pushed the anviking/ADP-311/liberate-stakepool-api branch 2 times, most recently from 9fe0e15 to 2d547bd Compare June 10, 2020 10:26
@@ -183,13 +183,16 @@ import Servant.API.Verbs

type ApiV2 n = "v2" :> Api n

-- | The full cardano-wallet API.
--
-- The API used in cardano-wallet-jormungandr may differ from this one.
type Api n =
Copy link
Member

Choose a reason for hiding this comment

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

I assume this one can be fully moved to each target package, alongside the server instantiation.

Copy link
Member Author

Choose a reason for hiding this comment

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

No! Sadly not easily, because we have a swagger spec in core!

My plan is to keep this type, but let jormungandr use a custom Api type.

Copy link
Member

Choose a reason for hiding this comment

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

Hmmm. Well no, we can also declare an "Api" type in the relevant test.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well no, we can also declare an "Api" type in the relevant test

That might make our test meaningless since if it is no longer testing the Api type that is actually used.

I say we keep the haskell API in core as the most important api, and test it, but not the jormungandr one.

…or, we define and test both APIs in core 🤔

…or, maybe one could do something with a ApiStakePool | ApiJormungandrStakePool sum type 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Can sort out later.

Copy link
Member

Choose a reason for hiding this comment

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

…or, maybe one could do something with a ApiStakePool | ApiJormungandrStakePool sum type thinking

Yeah, I thought of it. Since the stake pools are only something the server produces, it might just be okay to go down that path and fairly transparent for clients.


-- | @StakePoolLayer@ is a thin layer ontop of the DB. It is /one/ value that
-- can easily be passed to the API-server, where it can be used in a simple way.
data StakePoolLayer e m = StakePoolLayer
Copy link
Contributor

Choose a reason for hiding this comment

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

don't we want to have StakePoolLayer interface in core? And in jormunagdr and shelley implementations of it?

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe we/you currently only need the knownStakePools :: IO [PoolId] field to check that the pool we're joining actually exists. So I see no point in keeping the entire StakePoolLayer then, since it would just be more work trying to unify the different pool-types under one common interface.

Copy link
Contributor

@paweljakubas paweljakubas Jun 10, 2020

Choose a reason for hiding this comment

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

a ok, got it . so now we will sneak IO [PoolId] instead of StakePoolLayer on wallet level. and just call it (with liftIO). and this will be knownPools type argument...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah (see diff at #1738 (comment))

I was curious about using a IO (PoolId -> Bool) also, but didn't do it.

@Anviking Anviking added the ADDING FEATURE Mark a PR as adding a new feature, for auto-generated CHANGELOG label Jun 10, 2020
@Anviking
Copy link
Member Author

bors r+

iohk-bors bot added a commit that referenced this pull request Jun 10, 2020
1738: Parameterise `StakePools` API over apiPool type r=Anviking a=Anviking

# Issue Number

ADP-311, #1718 


# Overview

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

- [x] I parameterised `StakePools` API over `apiPool`
- [x] I renamed `ApiStakePool` to `ApiJormungandrStakePool`, such that we can later introduce a haskell `ApiStakePool`
- [x] I made the default `Api` type use `ApiJormungandrStakePool`. We should later switch to `ApiStakePool`, and update the swagger scheme such that it targets haskell, and not jormungandr.
- [x] I moved `StakePoolLayer` to the jormungandr package.

# Comments

- I am keeping the Pool DB in core, since I think we still want it. But I have not thought about how it would work with shelley.
- changelog: this is pure refactoring, but in combination with follow-up PRs this is a new feature.

<!-- 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
 ✓ Assign the PR to a corresponding milestone
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <[email protected]>
Co-authored-by: KtorZ <[email protected]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 10, 2020

Build failed

@Anviking
Copy link
Member Author

bors r+

iohk-bors bot added a commit that referenced this pull request Jun 10, 2020
1738: Parameterise `StakePools` API over apiPool type r=Anviking a=Anviking

# Issue Number

ADP-311, #1718 


# Overview

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

- [x] I parameterised `StakePools` API over `apiPool`
- [x] I renamed `ApiStakePool` to `ApiJormungandrStakePool`, such that we can later introduce a haskell `ApiStakePool`
- [x] I made the default `Api` type use `ApiJormungandrStakePool`. We should later switch to `ApiStakePool`, and update the swagger scheme such that it targets haskell, and not jormungandr.
- [x] I moved `StakePoolLayer` to the jormungandr package.

# Comments

- I am keeping the Pool DB in core, since I think we still want it. But I have not thought about how it would work with shelley.
- changelog: this is pure refactoring, but in combination with follow-up PRs this is a new feature.

<!-- 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
 ✓ Assign the PR to a corresponding milestone
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <[email protected]>
Co-authored-by: KtorZ <[email protected]>
@KtorZ
Copy link
Member

KtorZ commented Jun 10, 2020

bors r-

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 10, 2020

Canceled

@KtorZ
Copy link
Member

KtorZ commented Jun 10, 2020

Hydra will cache the previous build and it'll fail all-the-same.

@KtorZ KtorZ force-pushed the anviking/ADP-311/liberate-stakepool-api branch from e240a99 to 08d6c86 Compare June 10, 2020 15:26
@KtorZ
Copy link
Member

KtorZ commented Jun 10, 2020

bors try

iohk-bors bot added a commit that referenced this pull request Jun 10, 2020
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 10, 2020

try

Build failed

@KtorZ
Copy link
Member

KtorZ commented Jun 10, 2020

Twice in a row, the unit tests on Windows aren't passing 🤔

cardano-wallet-core-test-unit-2020.6.5-x86_64-w64-mingw32-check-x86_64-w64-mingw32.drv

@KtorZ
Copy link
Member

KtorZ commented Jun 10, 2020

I don't see anything obviously wrong on Windows in the changes from this PR though...

@Anviking
Copy link
Member Author

bors r+

iohk-bors bot added a commit that referenced this pull request Jun 11, 2020
1738: Parameterise `StakePools` API over apiPool type r=Anviking a=Anviking

# Issue Number

ADP-311, #1718 


# Overview

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

- [x] I parameterised `StakePools` API over `apiPool`
- [x] I renamed `ApiStakePool` to `ApiJormungandrStakePool`, such that we can later introduce a haskell `ApiStakePool`
- [x] I made the default `Api` type use `ApiJormungandrStakePool`. We should later switch to `ApiStakePool`, and update the swagger scheme such that it targets haskell, and not jormungandr.
- [x] I moved `StakePoolLayer` to the jormungandr package.

# Comments

- I am keeping the Pool DB in core, since I think we still want it. But I have not thought about how it would work with shelley.
- changelog: this is pure refactoring, but in combination with follow-up PRs this is a new feature.

<!-- 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
 ✓ Assign the PR to a corresponding milestone
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <[email protected]>
Co-authored-by: KtorZ <[email protected]>
@KtorZ
Copy link
Member

KtorZ commented Jun 11, 2020

bors r-

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 11, 2020

Canceled

@KtorZ KtorZ force-pushed the anviking/ADP-311/liberate-stakepool-api branch from 08d6c86 to 1e27e7e Compare June 11, 2020 14:47
@KtorZ
Copy link
Member

KtorZ commented Jun 11, 2020

bors r+

iohk-bors bot added a commit that referenced this pull request Jun 11, 2020
1738: Parameterise `StakePools` API over apiPool type r=KtorZ a=Anviking

# Issue Number

ADP-311, #1718 


# Overview

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

- [x] I parameterised `StakePools` API over `apiPool`
- [x] I renamed `ApiStakePool` to `ApiJormungandrStakePool`, such that we can later introduce a haskell `ApiStakePool`
- [x] I made the default `Api` type use `ApiJormungandrStakePool`. We should later switch to `ApiStakePool`, and update the swagger scheme such that it targets haskell, and not jormungandr.
- [x] I moved `StakePoolLayer` to the jormungandr package.

# Comments

- I am keeping the Pool DB in core, since I think we still want it. But I have not thought about how it would work with shelley.
- changelog: this is pure refactoring, but in combination with follow-up PRs this is a new feature.

<!-- 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
 ✓ Assign the PR to a corresponding milestone
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <[email protected]>
Co-authored-by: KtorZ <[email protected]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 11, 2020

Build failed

@Anviking
Copy link
Member Author

bors r+

iohk-bors bot added a commit that referenced this pull request Jun 12, 2020
1738: Parameterise `StakePools` API over apiPool type r=Anviking a=Anviking

# Issue Number

ADP-311, #1718 


# Overview

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

- [x] I parameterised `StakePools` API over `apiPool`
- [x] I renamed `ApiStakePool` to `ApiJormungandrStakePool`, such that we can later introduce a haskell `ApiStakePool`
- [x] I made the default `Api` type use `ApiJormungandrStakePool`. We should later switch to `ApiStakePool`, and update the swagger scheme such that it targets haskell, and not jormungandr.
- [x] I moved `StakePoolLayer` to the jormungandr package.

# Comments

- I am keeping the Pool DB in core, since I think we still want it. But I have not thought about how it would work with shelley.
- changelog: this is pure refactoring, but in combination with follow-up PRs this is a new feature.

<!-- 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
 ✓ Assign the PR to a corresponding milestone
 ✓ Acknowledge any changes required to the Wiki
-->


Co-authored-by: Johannes Lund <[email protected]>
Co-authored-by: KtorZ <[email protected]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 12, 2020

Build failed

@Anviking
Copy link
Member Author

This doesn't make sense, because this is not the actual code:

src/Cardano/Wallet/Shelley/Api/Server.hs:23:1: error:
    Could not find module ‘Cardano.Pool’
    Perhaps you meant
      Cardano.Pool.DB (from cardano-wallet-core-2020.6.5)
    Use -v to see a list of the files searched for.
   |
23 | import Cardano.Pool
   | ^^^^^^^^^^^^^^^^^^^...
[2 of 6] Compiling Cardano.Wallet.Shelley.Compatibility ( src/Cardano/Wallet/Shelley/Compatibility.hs, dist/build/Cardano/Wallet/Shelley/Compatibility.o )
[3 of 6] Compiling Cardano.Wallet.Shelley.Network ( src/Cardano/Wallet/Shelley/Network.hs, dist/build/Cardano/Wallet/Shelley/Network.o )
[4 of 6] Compiling Cardano.Wallet.Shelley.Transaction ( src/Cardano/Wallet/Shelley/Transaction.hs, dist/build/Cardano/Wallet/Shelley/Transaction.o )
builder for '/nix/store/q9jxhhslcw0j4f4aqdkn3xpvyyx0y9z6-cardano-wa

The build failure can't be cached, since master has changed?

@Anviking
Copy link
Member Author

Ok, it is because of the merge 🤔

@Anviking Anviking force-pushed the anviking/ADP-311/liberate-stakepool-api branch 2 times, most recently from 8ac875f to 9c249fb Compare June 12, 2020 13:06
…askell

- ApiStakePool -> ApiJormungandrStakePool

- Move StakePoolLayer to the jormungandr package

- add missing JSON golden file 'ApiJormungandrStakePool.json'

- Move jorm listPools handler to server module

- re-generate JSON golden file, in hope (commit from Matthias)

Hoping to see the windows unit test timeout disappear
@Anviking Anviking force-pushed the anviking/ADP-311/liberate-stakepool-api branch from 9c249fb to a42e9ae Compare June 12, 2020 13:08
@Anviking
Copy link
Member Author

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 12, 2020

@iohk-bors iohk-bors bot merged commit 2787bbd into master Jun 12, 2020
@iohk-bors iohk-bors bot deleted the anviking/ADP-311/liberate-stakepool-api branch June 12, 2020 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ADDING FEATURE Mark a PR as adding a new feature, for auto-generated CHANGELOG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants