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

(BEDS-1319) split validator addition #1382

Open
wants to merge 3 commits into
base: BEDS-101/pectra
Choose a base branch
from

Conversation

remoterami
Copy link
Contributor

@remoterami remoterami commented Mar 6, 2025

@remoterami remoterami force-pushed the BEDS-1319/split-validator-addition branch from 16f644a to 20f3997 Compare March 6, 2025 11:32
@remoterami remoterami changed the base branch from staging to BEDS-101/pectra March 6, 2025 11:34
@remoterami remoterami force-pushed the BEDS-1319/split-validator-addition branch from 20f3997 to 39ceca5 Compare March 6, 2025 12:00
@remoterami remoterami force-pushed the BEDS-1319/split-validator-addition branch from 39ceca5 to c38d76e Compare March 6, 2025 12:20
@LuccaBitfly
Copy link
Contributor

image
👏

Comment on lines 36 to 47
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
Copy link
Contributor

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)

}
existingValidatorsMap := utils.SliceToMap(existingValidators)
ebSpaceLeft := ebLimit - totalExistingEb
Copy link
Contributor

@LuccaBitfly LuccaBitfly Mar 6, 2025

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) {
Copy link
Contributor

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)
you're "abusing" it as exactly that. Looking inside the func, if an actual dashboard ID is passed, the code simply fetches all validators in the dashboard and proceeds with the whole validator set, so there's no real performance gain here. Rather, the handler should fetch all existing dashboard validators and pass it to a GetValidatorEffectiveBalances here
existingEBs, err := h.getDataAccessor(ctx).GetValidatorDashboardEffectiveBalances(ctx, types.VDBId{Id: dashboardId}, false)

Copy link
Contributor

@LuccaBitfly LuccaBitfly Mar 6, 2025

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. 🙌

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