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

Store delegation reward account balances in the database #1768

Merged
merged 18 commits into from
Jun 30, 2020

Conversation

rvl
Copy link
Contributor

@rvl rvl commented Jun 16, 2020

Issue Number

ADP-302 / #1750 / #1759

Overview

Turns out querying reward account balances can be slow.
This is not good if it's done when listing/getting wallets.
Better to do these queries in a separate thread and cache the results in the database.

  • Add new database table for the latest known wallet reward account balance.
  • Use the database when getting the reward account balance.
  • Add a network layer method to watch the node tip.
  • Update the account balance in each wallet when the node tip changes (asynchronously).
  • Store reward account balance in db as it arrives.
  • Adapt Jörmungandr network layer

@rvl rvl self-assigned this Jun 16, 2020
@rvl rvl force-pushed the rvl/adp-302/db-reward-balance branch from 5e078a6 to fa9ff16 Compare June 18, 2020 05:10
@KtorZ KtorZ added the RESOLVING ISSUE Mark a PR as resolving issues, for auto-generated CHANGELOG label Jun 18, 2020
@rvl rvl force-pushed the rvl/adp-302/db-reward-balance branch 2 times, most recently from 40b5f06 to 6483eb6 Compare June 23, 2020 06:24
lib/core/src/Cardano/Wallet.hs Outdated Show resolved Hide resolved
lib/core/src/Cardano/Wallet.hs Outdated Show resolved Hide resolved
lib/core/src/Cardano/Wallet.hs Show resolved Hide resolved
lib/core/src/Cardano/Wallet.hs Show resolved Hide resolved
lib/core/src/Cardano/Wallet/Api/Server.hs Show resolved Hide resolved
lib/core/src/Cardano/Wallet/DB.hs Show resolved Hide resolved
lib/core/src/Cardano/Wallet/DB/Sqlite.hs Show resolved Hide resolved
lib/shelley/src/Cardano/Wallet/Shelley/Network.hs Outdated Show resolved Hide resolved

setupWatchers
:: Tracer IO (WatcherLog e)
-> TQueue IO v
Copy link
Member

Choose a reason for hiding this comment

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

There's already a lof of concurrent mutable variables down there, since the function only needs an accessor on the tip, I'd actually change this for just a IO v and not even mention the TQueue here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK good idea

lib/shelley/src/Cardano/Wallet/Shelley/Network.hs Outdated Show resolved Hide resolved
@rvl rvl force-pushed the rvl/adp-302/db-reward-balance branch 5 times, most recently from 78f5150 to 8574e98 Compare June 26, 2020 15:11
@KtorZ KtorZ force-pushed the rvl/adp-302/db-reward-balance branch 2 times, most recently from 90c5dba to f42de76 Compare June 27, 2020 12:14
@KtorZ KtorZ marked this pull request as ready for review June 27, 2020 13:07
@KtorZ KtorZ force-pushed the rvl/adp-302/db-reward-balance branch from 7184497 to 5102817 Compare June 27, 2020 16:24
@KtorZ
Copy link
Member

KtorZ commented Jun 27, 2020

bors r+

iohk-bors bot added a commit that referenced this pull request Jun 27, 2020
1768: Store delegation reward account balances in the database r=KtorZ a=rvl

### Issue Number

ADP-302 / #1750 

### Overview

Turns out querying reward account balances can be slow.
This is not good if it's done when listing/getting wallets.
Better to do these queries in a separate thread and cache the results in the database.

- [x] Add new database table for the latest known wallet reward account balance.
- [x] Use the database when getting the reward account balance.
- [x] Add a network layer method to watch the node tip.
- [x] Update the account balance in each wallet when the node tip changes (asynchronously).
- [x] Store reward account balance in db as it arrives.
- [x] Adapt Jörmungandr network layer

### Comments

- [ ] STAKE_POOLS_JOIN_04 test passes


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

iohk-bors bot commented Jun 27, 2020

Build failed

@KtorZ
Copy link
Member

KtorZ commented Jun 27, 2020

bors retry

iohk-bors bot added a commit that referenced this pull request Jun 27, 2020
1768: Store delegation reward account balances in the database r=KtorZ a=rvl

### Issue Number

ADP-302 / #1750 

### Overview

Turns out querying reward account balances can be slow.
This is not good if it's done when listing/getting wallets.
Better to do these queries in a separate thread and cache the results in the database.

- [x] Add new database table for the latest known wallet reward account balance.
- [x] Use the database when getting the reward account balance.
- [x] Add a network layer method to watch the node tip.
- [x] Update the account balance in each wallet when the node tip changes (asynchronously).
- [x] Store reward account balance in db as it arrives.
- [x] Adapt Jörmungandr network layer

### Comments

- [ ] STAKE_POOLS_JOIN_04 test passes


Co-authored-by: Rodney Lorrimar <[email protected]>
Co-authored-by: KtorZ <[email protected]>
@KtorZ KtorZ force-pushed the rvl/adp-302/db-reward-balance branch from 5102817 to caf9b46 Compare June 27, 2020 18:09
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 27, 2020

Canceled

@KtorZ
Copy link
Member

KtorZ commented Jun 27, 2020

bors r+

iohk-bors bot added a commit that referenced this pull request Jun 27, 2020
1768: Store delegation reward account balances in the database r=KtorZ a=rvl

### Issue Number

ADP-302 / #1750 

### Overview

Turns out querying reward account balances can be slow.
This is not good if it's done when listing/getting wallets.
Better to do these queries in a separate thread and cache the results in the database.

- [x] Add new database table for the latest known wallet reward account balance.
- [x] Use the database when getting the reward account balance.
- [x] Add a network layer method to watch the node tip.
- [x] Update the account balance in each wallet when the node tip changes (asynchronously).
- [x] Store reward account balance in db as it arrives.
- [x] Adapt Jörmungandr network layer

### Comments

- [ ] STAKE_POOLS_JOIN_04 test passes


Co-authored-by: Rodney Lorrimar <[email protected]>
Co-authored-by: KtorZ <[email protected]>
Co-authored-by: IOHK <[email protected]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 27, 2020

Build failed

@KtorZ
Copy link
Member

KtorZ commented Jun 27, 2020

bors retry

iohk-bors bot added a commit that referenced this pull request Jun 27, 2020
1768: Store delegation reward account balances in the database r=KtorZ a=rvl

### Issue Number

ADP-302 / #1750 

### Overview

Turns out querying reward account balances can be slow.
This is not good if it's done when listing/getting wallets.
Better to do these queries in a separate thread and cache the results in the database.

- [x] Add new database table for the latest known wallet reward account balance.
- [x] Use the database when getting the reward account balance.
- [x] Add a network layer method to watch the node tip.
- [x] Update the account balance in each wallet when the node tip changes (asynchronously).
- [x] Store reward account balance in db as it arrives.
- [x] Adapt Jörmungandr network layer

### Comments

- [ ] STAKE_POOLS_JOIN_04 test passes


Co-authored-by: Rodney Lorrimar <[email protected]>
Co-authored-by: KtorZ <[email protected]>
Co-authored-by: IOHK <[email protected]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 27, 2020

Build failed

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 29, 2020

try

Build failed

@rvl
Copy link
Contributor Author

rvl commented Jun 29, 2020

bors r+

iohk-bors bot added a commit that referenced this pull request Jun 29, 2020
1768: Store delegation reward account balances in the database r=rvl a=rvl

### Issue Number

ADP-302 / #1750 / #1759

### Overview

Turns out querying reward account balances can be slow.
This is not good if it's done when listing/getting wallets.
Better to do these queries in a separate thread and cache the results in the database.

- [x] Add new database table for the latest known wallet reward account balance.
- [x] Use the database when getting the reward account balance.
- [x] Add a network layer method to watch the node tip.
- [x] Update the account balance in each wallet when the node tip changes (asynchronously).
- [x] Store reward account balance in db as it arrives.
- [x] Adapt Jörmungandr network layer


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

KtorZ commented Jun 29, 2020

bors r-

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Jun 29, 2020

Canceled

@KtorZ
Copy link
Member

KtorZ commented Jun 29, 2020

(just have some little changes to push)

@KtorZ KtorZ force-pushed the rvl/adp-302/db-reward-balance branch from 7532fab to c869327 Compare June 29, 2020 14:53
@KtorZ
Copy link
Member

KtorZ commented Jun 29, 2020

bors r+

iohk-bors bot added a commit that referenced this pull request Jun 29, 2020
1768: Store delegation reward account balances in the database r=KtorZ a=rvl

### Issue Number

ADP-302 / #1750 / #1759

### Overview

Turns out querying reward account balances can be slow.
This is not good if it's done when listing/getting wallets.
Better to do these queries in a separate thread and cache the results in the database.

- [x] Add new database table for the latest known wallet reward account balance.
- [x] Use the database when getting the reward account balance.
- [x] Add a network layer method to watch the node tip.
- [x] Update the account balance in each wallet when the node tip changes (asynchronously).
- [x] Store reward account balance in db as it arrives.
- [x] Adapt Jörmungandr network layer


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

iohk-bors bot commented Jun 29, 2020

Canceled

@KtorZ
Copy link
Member

KtorZ commented Jun 29, 2020

bors r+

iohk-bors bot added a commit that referenced this pull request Jun 29, 2020
1768: Store delegation reward account balances in the database r=KtorZ a=rvl

### Issue Number

ADP-302 / #1750 / #1759

### Overview

Turns out querying reward account balances can be slow.
This is not good if it's done when listing/getting wallets.
Better to do these queries in a separate thread and cache the results in the database.

- [x] Add new database table for the latest known wallet reward account balance.
- [x] Use the database when getting the reward account balance.
- [x] Add a network layer method to watch the node tip.
- [x] Update the account balance in each wallet when the node tip changes (asynchronously).
- [x] Store reward account balance in db as it arrives.
- [x] Adapt Jörmungandr network layer


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

iohk-bors bot commented Jun 29, 2020

Build failed

@KtorZ
Copy link
Member

KtorZ commented Jun 29, 2020

bors retry

iohk-bors bot added a commit that referenced this pull request Jun 29, 2020
1768: Store delegation reward account balances in the database r=KtorZ a=rvl

### Issue Number

ADP-302 / #1750 / #1759

### Overview

Turns out querying reward account balances can be slow.
This is not good if it's done when listing/getting wallets.
Better to do these queries in a separate thread and cache the results in the database.

- [x] Add new database table for the latest known wallet reward account balance.
- [x] Use the database when getting the reward account balance.
- [x] Add a network layer method to watch the node tip.
- [x] Update the account balance in each wallet when the node tip changes (asynchronously).
- [x] Store reward account balance in db as it arrives.
- [x] Adapt Jörmungandr network layer


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

iohk-bors bot commented Jun 29, 2020

Build failed

@rvl
Copy link
Contributor Author

rvl commented Jun 30, 2020

Integration test failure seems to be due to a rolled back transaction ⇒ ADP-93. Retrying.

bors r+

iohk-bors bot added a commit that referenced this pull request Jun 30, 2020
1768: Store delegation reward account balances in the database r=rvl a=rvl

### Issue Number

ADP-302 / #1750 / #1759

### Overview

Turns out querying reward account balances can be slow.
This is not good if it's done when listing/getting wallets.
Better to do these queries in a separate thread and cache the results in the database.

- [x] Add new database table for the latest known wallet reward account balance.
- [x] Use the database when getting the reward account balance.
- [x] Add a network layer method to watch the node tip.
- [x] Update the account balance in each wallet when the node tip changes (asynchronously).
- [x] Store reward account balance in db as it arrives.
- [x] Adapt Jörmungandr network layer


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

iohk-bors bot commented Jun 30, 2020

Build failed

@KtorZ KtorZ merged commit bfc9408 into master Jun 30, 2020
@KtorZ KtorZ deleted the rvl/adp-302/db-reward-balance branch June 30, 2020 09:36
@KtorZ
Copy link
Member

KtorZ commented Jun 30, 2020

Merging, the failure above seems related to something else: #1831

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RESOLVING ISSUE Mark a PR as resolving issues, for auto-generated CHANGELOG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants