-
Notifications
You must be signed in to change notification settings - Fork 33
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 validator data retention by pubkey #102
Add validator data retention by pubkey #102
Conversation
a542bf3
to
a3194a7
Compare
a3194a7
to
728083b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this PR. In general it looks good, there are a few items to address.
One question: have you analyzed the runtime of the DELETE
with and without USING
? If it is significantly longer in the latter case due to the join then it may make sense to rewrite the query builder so that it only includes USING
if there are pubkeys to retain.
@@ -518,7 +518,7 @@ WHERE f_validator_index = $1 | |||
} | |||
|
|||
// PruneValidatorEpochSummaries prunes validator epoch summaries up to (but not including) the given point. | |||
func (s *Service) PruneValidatorEpochSummaries(ctx context.Context, to phase0.Epoch, retain []phase0.ValidatorIndex) error { | |||
func (s *Service) PruneValidatorEpochSummaries(ctx context.Context, to phase0.Epoch, retainPubkeys []phase0.BLSPubKey) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can keep this value as retain
given that its type is BLSPubKey
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated !
pubkeyBytes := make([]byte, len(pubkey)) | ||
copy(pubkeyBytes, pubkey[:]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this required? Could it be replaced by just pubKey[:]
to reduce allocations and copying?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacing by pubKey[:]
would work with 1.22 go for loops.
It does not work with 1.21 go (project use 1.20 go, and i did not want to change version)
See example here: https://go.dev/play/p/K5u3iVSeWe_e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should be able to avoid that by only using the loop variable:
for i := range retain {
pubkeysBytes = append(pubkeysBytes, retain[i][:])
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's better ! Thanks.
@@ -716,7 +716,7 @@ func validatorBalanceFromRow(rows pgx.Rows) (*chaindb.ValidatorBalance, error) { | |||
} | |||
|
|||
// PruneValidatorBalances prunes validator balances up to (but not including) the given epoch. | |||
func (s *Service) PruneValidatorBalances(ctx context.Context, to phase0.Epoch, retain []phase0.ValidatorIndex) error { | |||
func (s *Service) PruneValidatorBalances(ctx context.Context, to phase0.Epoch, retainPubkeys []phase0.BLSPubKey) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above on variable name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated !
retainPubkeysBytes := make([][]byte, 0, len(retainPubkeys)) | ||
|
||
for _, pubkey := range retainPubkeys { | ||
pubkeyBytes := make([]byte, len(pubkey)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above on variable creation.
@@ -104,6 +108,25 @@ func WithValidatorSummaries(enabled bool) Parameter { | |||
}) | |||
} | |||
|
|||
// WithvalidatorRetainPubkeys states if the module should retain balance and epoch summaries for a subset of validator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update comment to match the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated !
@@ -104,6 +108,25 @@ func WithValidatorSummaries(enabled bool) Parameter { | |||
}) | |||
} | |||
|
|||
// WithvalidatorRetainPubkeys states if the module should retain balance and epoch summaries for a subset of validator. | |||
func WithvalidatorRetainPubkeys(validatorRetainPubkeys []string) Parameter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have a capital "v".
Also, the pubkeys should not be passed in as a string slice. This function should accept []BLSPubKey
to allow for catching and reporting errors in the input.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated !
1c26370
to
6c4633e
Compare
I did not notice any changes in deletion time. (my bottleneck is io) But, in any way I've updated so that it only add |
Thanks for making the changes. I think that the SQL is now broken in the case that there are no items in |
534c4ed
to
a8633bf
Compare
It should be okay now. I've tested it with and without retain values. |
Thanks for your work on this. |
Hello,
I needed to retain data indefinitly for certain pubkeys and saw you already had a
retain []phase0.ValidatorIndex
parameter in pruning methodsPruneValidatorEpochSummaries
andPruneValidatorBalances
.I've made the choice to change validator index to pubkey since I know ahead of time which pubkey are going to be my validator, but not the indices. So i can set all my pubkeys even if my deposits are not yet made. Could do a quick adaptation to handle both index and pubkeys.
Thanks,
Sylvain