Currently, the wallet maintainer uses the FindPendingRedemptions function to determine a list of wallets that have pending redemptions. Then, it submits redemption proposals for that wallets.
Within FindPendingRedemptions, the list of wallets is taken based on past NewWalletRegistered events:
// Take all wallets.
events, err := chain.PastNewWalletRegisteredEvents(nil)
if err != nil {
return nil, fmt.Errorf(
"failed to get new wallet registered wallets: [%w]",
err,
)
}
// Sort the wallets list from the oldest to the newest.
sort.SliceStable(events, func(i, j int) bool {
return events[i].BlockNumber < events[j].BlockNumber
})
As a result, the function obtains a list of all wallets ever created, sorted from the oldest one to the newest one. Then, if the WalletsLimit filter is set, the wallets list is limited to WalletsLimit oldest wallets:
// Apply the wallets number limit if needed.
if limit := int(filter.WalletsLimit); limit > 0 && len(walletPublicKeyHashes) > limit {
walletPublicKeyHashes = walletPublicKeyHashes[:limit]
logger.Infof(
"limited the initial wallets list to [%v] wallets",
len(walletPublicKeyHashes),
)
}
After that, those wallets are checked for pending redemptions. This logic is wrong as, if the WalletsLimit filter is on, always the same wallets will be taken into account so redemption requests targeting newer wallets can be missed by the wallet maintainer.
We should fix that and apply the WalletsLimit filter at a later stage.
Currently, the wallet maintainer uses the
FindPendingRedemptions
function to determine a list of wallets that have pending redemptions. Then, it submits redemption proposals for that wallets.Within
FindPendingRedemptions
, the list of wallets is taken based on pastNewWalletRegistered
events:As a result, the function obtains a list of all wallets ever created, sorted from the oldest one to the newest one. Then, if the
WalletsLimit
filter is set, the wallets list is limited toWalletsLimit
oldest wallets:After that, those wallets are checked for pending redemptions. This logic is wrong as, if the
WalletsLimit
filter is on, always the same wallets will be taken into account so redemption requests targeting newer wallets can be missed by the wallet maintainer.We should fix that and apply the
WalletsLimit
filter at a later stage.