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

chore: add pagination to queryDelegationsWithStatus #96

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

RafilxTenfen
Copy link
Contributor

@RafilxTenfen RafilxTenfen commented Jan 15, 2025

The query should loop by the max limit set in the config delegationlimit, since the BTC delegations already signed and the ones in which the covenant pub key was not constructed with are being removed by sanitizeDelegations

Closes: #92

@RafilxTenfen RafilxTenfen marked this pull request as ready for review January 16, 2025 15:50
@RafilxTenfen RafilxTenfen requested a review from Lazar955 January 16, 2025 18:33
Copy link
Member

@Lazar955 Lazar955 left a comment

Choose a reason for hiding this comment

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

Nice work! Minor comments

Comment on lines +189 to +198
func (bc *BabylonController) QueryPendingDelegations(limit uint64, filter FilterFn) ([]*types.Delegation, error) {
return bc.queryDelegationsWithStatus(btcstakingtypes.BTCDelegationStatus_PENDING, limit, filter)
}

func (bc *BabylonController) QueryActiveDelegations(limit uint64) ([]*types.Delegation, error) {
return bc.queryDelegationsWithStatus(btcstakingtypes.BTCDelegationStatus_ACTIVE, limit)
return bc.queryDelegationsWithStatus(btcstakingtypes.BTCDelegationStatus_ACTIVE, limit, nil)
}

func (bc *BabylonController) QueryVerifiedDelegations(limit uint64) ([]*types.Delegation, error) {
return bc.queryDelegationsWithStatus(btcstakingtypes.BTCDelegationStatus_VERIFIED, limit)
return bc.queryDelegationsWithStatus(btcstakingtypes.BTCDelegationStatus_VERIFIED, limit, nil)
Copy link
Member

Choose a reason for hiding this comment

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

Feels like this can be one function QueryDelegations(limit uint64, status btcstakingtypes.BTCDelegationStatus, filter FilterFn)

Comment on lines +375 to +400
// amtSatFirst := btcutil.Amount(100)
// amtSatSecond := btcutil.Amount(150)
// amtSatThird := btcutil.Amount(200)
// lastUnsanitizedDels := []*types.Delegation{
// &types.Delegation{
// ParamsVersion: pVersionWithCovenant,
// TotalSat: amtSatFirst,
// },
// delNoCovenant,
// &types.Delegation{
// ParamsVersion: pVersionWithCovenant,
// TotalSat: amtSatSecond,
// },
// delNoCovenant,
// &types.Delegation{
// ParamsVersion: pVersionWithCovenant,
// TotalSat: amtSatThird,
// },
// }

// sanitizedDels, err := covenant.SanitizeDelegations(covKeyPair.PublicKey, paramsGet, lastUnsanitizedDels)
// require.NoError(t, err)
// require.Len(t, sanitizedDels, 3)
// require.Equal(t, amtSatFirst, sanitizedDels[0].TotalSat)
// require.Equal(t, amtSatSecond, sanitizedDels[1].TotalSat)
// require.Equal(t, amtSatThird, sanitizedDels[2].TotalSat)
Copy link
Member

Choose a reason for hiding this comment

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

remove leftover code

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.

Fix query loop in covenant evmulator
3 participants