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

listStakePools - Include metadata in API responses #1159

Merged
merged 18 commits into from
Dec 12, 2019

Conversation

rvl
Copy link
Contributor

@rvl rvl commented Dec 11, 2019

Relates to #1065.

Overview

  • Modified Api.Server.listPools and StakePoolLayer listStakePools to include metadata.
  • Made it possible to use an environment variable for the registry url.
  • Handles the case where different stake pool owners register different metadata by logging and then ignoring all inconsistent data.

Comments

  • This is a draft.

@rvl rvl self-assigned this Dec 11, 2019
getRegistryZipUrl :: IO String
getRegistryZipUrl = fromMaybe cardanoFoundationRegistryZip <$> lookupEnv var
where
var = "CARDANO_WALLET_STAKE_POOL_REGISTRY_URL"
Copy link
Member

Choose a reason for hiding this comment

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

👍

newStakePoolLayer db@DBLayer{..} nl tr = StakePoolLayer
{ listStakePools = do
lift $ logTrace tr MsgListStakePoolsBegin
stakePools <- rankKnownPools
Copy link
Member

Choose a reason for hiding this comment

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

[remark]

You have used to forbidden word (i.e. rank) 😱
It makes things clearer though 👍

@rvl rvl force-pushed the rvl/1065/list-stake-pools-meta branch from 82cb177 to c6b2edc Compare December 11, 2019 12:19
@KtorZ KtorZ force-pushed the rvl/1065/list-stake-pools-meta branch from c6b2edc to 4de52ca Compare December 11, 2019 14:08
(Map.fromList [(pid, [owner])])
[(owner, Just md)]

res `shouldBe` [(MsgMetadataUsing pid owner md, Just md)]
Copy link
Member

Choose a reason for hiding this comment

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

👍

(Map.fromList [(PoolId "1", [PoolOwner "a"])])
[(PoolOwner "a", Nothing)]

res `shouldBe` [(MsgMetadataMissing (PoolId "1"), Nothing)]
Copy link
Member

Choose a reason for hiding this comment

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

👍

md `shouldSatisfy` sameStakePoolMetadata mdb
_ -> fail $ "wrong log message " ++ show msg

fmap (sameStakePoolMetadata mda) res `shouldBe` Just True
Copy link
Member

Choose a reason for hiding this comment

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

👍

@KtorZ KtorZ marked this pull request as ready for review December 11, 2019 14:40
@KtorZ KtorZ force-pushed the rvl/1065/list-stake-pools-meta branch from 02fa548 to baddeec Compare December 11, 2019 20:25
@@ -170,6 +183,30 @@ spec = do
expectResponseCode @IO HTTP.status405 r
expectErrorMessage errMsg405 r

it "STAKE_POOLS_LIST_04 - Discovers new pools when they are registered" $ \ctx -> do
Copy link
Member

Choose a reason for hiding this comment

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

@rvl I added a rather extensive integration test. The setup behind registerStakePool is a bit complex because we have to do everything with jcli and use accounts to pay for the registration certificate! I got to the end of it and.. nicely caught a small bug in the "zipping logic" from the listStakePools endpoint (cf my last commit).
Please have another round of review / fixes and let's get this merged!

Some outstanding points remaining after that:

  • Maybe do some caching? I expect this endpoint to be quite heavily hammered by clients like Daedalus. The registry won't change very often. Renewing a cache every hour or so should also mitigate the concern.
  • Currently the handler for joinStakePool relies on listStakePool to get a list of known stake pool... that's kinda lame because listStakePool is a very heavy operation and, all stake pools ids can be known by simply making a database call. So we should fix that.
  • Apparent performance could be wrong for brief times (because of multiple sources of truth) #1158

@KtorZ
Copy link
Member

KtorZ commented Dec 11, 2019

bors try

iohk-bors bot added a commit that referenced this pull request Dec 11, 2019
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Dec 11, 2019

try

Build failed

@rvl
Copy link
Contributor Author

rvl commented Dec 12, 2019

bors r+

iohk-bors bot added a commit that referenced this pull request Dec 12, 2019
1159: listStakePools - Include metadata in API responses r=rvl a=rvl

Relates to #1065.

# Overview

- Modified Api.Server.listPools and StakePoolLayer listStakePools to include metadata.
- Made it possible to use an environment variable for the registry url.
- Handles the case where different stake pool owners register different metadata by logging and then ignoring all inconsistent data.

# Comments

- This is a draft.


Co-authored-by: Rodney Lorrimar <rodney.lorrimar@iohk.io>
Co-authored-by: KtorZ <matthias.benkort@gmail.com>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Dec 12, 2019

Build succeeded

@iohk-bors iohk-bors bot merged commit 2f976d4 into master Dec 12, 2019
@rvl rvl deleted the rvl/1065/list-stake-pools-meta branch December 12, 2019 05:47
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.

2 participants