-
Notifications
You must be signed in to change notification settings - Fork 13
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
(BEDS-1319) split validator addition #1382
base: BEDS-101/pectra
Are you sure you want to change the base?
Conversation
16f644a
to
20f3997
Compare
20f3997
to
39ceca5
Compare
39ceca5
to
c38d76e
Compare
query, args, err := validatorsDs.Prepared(true).ToSQL() | ||
if err != nil { | ||
return nil, fmt.Errorf("error preparing query: %w", err) | ||
} | ||
|
||
var validators []uint64 | ||
err = d.alloyReader.SelectContext(ctx, &validators, query, args...) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
ebsBeforeExit := []struct { | ||
ValidatorIndex uint64 `db:"validator_index"` | ||
EffectiveBalance uint64 `db:"balance_effective_end"` | ||
}{} | ||
err = d.clickhouseReader.SelectContext(ctx, &ebsBeforeExit, query, args...) | ||
if err != nil && err != sql.ErrNoRows { | ||
return validators, nil |
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.
Nitpick: could simply do:
return runQueryRows[[]uint64](ctx, d.alloyReader, validatorsDs)
(same for all other queries)
backend/pkg/api/handlers/public.go
Outdated
} | ||
existingValidatorsMap := utils.SliceToMap(existingValidators) | ||
ebSpaceLeft := ebLimit - totalExistingEb |
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.
Issue: this could overflow if the archiver is slow, should check if totalExistingEb
is smaller than ebLimit
before.
var ebSpaceLeft uint64
if (ebLimit > totalExistingEb){
ebSpaceLeft = ebLimit - totalExistingEb
}
func (d *DataAccessService) GetValidatorDashboardEffectiveBalanceTotal(ctx context.Context, dashboardId t.VDBId, onlyActive bool) (uint64, error) { | ||
// returns the effective balances of the provided validators | ||
// if onlyActive = true: executed from the vdb premium limits pov, i.e. exited validators account for the EB at exit time | ||
func (d *DataAccessService) GetValidatorDashboardEffectiveBalances(ctx context.Context, dashboardId t.VDBId, onlyActive bool) (map[t.VDBValidator]uint64, 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.
Issue: This should not be a dashboard func where you pass the dashboard ID but simply GetValidatorEffectiveBalances
where you pass a list of validators, since in
requestedEbs, err := h.getDataAccessor(ctx).GetValidatorDashboardEffectiveBalances(ctx, types.VDBId{Validators: requestedValidators}, false) |
GetValidatorEffectiveBalances
here existingEBs, err := h.getDataAccessor(ctx).GetValidatorDashboardEffectiveBalances(ctx, types.VDBId{Id: dashboardId}, false) |
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.
Otherwise very nice way of unifying all types of adding validators. IMO it's much clearer what's happening now. 🙌
tackles #1367 (comment) / #1367 (comment)