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

Add in Deposit Map To Cache #9885

Merged
merged 8 commits into from
Nov 16, 2021
Merged

Add in Deposit Map To Cache #9885

merged 8 commits into from
Nov 16, 2021

Conversation

nisdas
Copy link
Member

@nisdas nisdas commented Nov 10, 2021

What type of PR is this?

Bug Fix

What does this PR do? Why is it needed?

  • For our validator rpc methods, a lot of them require knowledge on a particular validator's deposit. If the validator
    isn't active yet we have to perform a large search through all our deposits. Adding a map brings this down to O(1) from O(n) per validator.

  • Fix and add relevant tests.

Which issues(s) does this PR fix?

N.A

Other notes for review

@nisdas nisdas requested a review from a team as a code owner November 10, 2021 11:19
@nisdas nisdas requested review from kasey, rkapka and uncdr November 10, 2021 11:19
@@ -54,6 +53,7 @@ type DepositCache struct {
pendingDeposits []*dbpb.DepositContainer
deposits []*dbpb.DepositContainer
finalizedDeposits *FinalizedDeposits
depositMap map[[48]byte][]*dbpb.DepositContainer
Copy link
Member

Choose a reason for hiding this comment

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

I will argue that if we always only going to return the first deposit, we dont need a list for value. But i think extensibility is nice, maybe we'll need DepositsByPubkey one day

@@ -54,6 +53,7 @@ type DepositCache struct {
pendingDeposits []*dbpb.DepositContainer
deposits []*dbpb.DepositContainer
finalizedDeposits *FinalizedDeposits
depositMap map[[48]byte][]*dbpb.DepositContainer
Copy link
Contributor

Choose a reason for hiding this comment

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

We tend to avoid giving variables names related to their type in Go. This doesn't tell us much about what the keys in the map are, so maybe we can call it depositsByPubKey

@prylabs-bulldozer prylabs-bulldozer bot merged commit 5962363 into develop Nov 16, 2021
@delete-merged-branch delete-merged-branch bot deleted the depositMap branch November 16, 2021 02:07
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.

3 participants