diff --git a/components/restapi/core/accounts.go b/components/restapi/core/accounts.go index d94cef2ab..48f51361e 100644 --- a/components/restapi/core/accounts.go +++ b/components/restapi/core/accounts.go @@ -67,7 +67,7 @@ func validators(c echo.Context) (*api.ValidatorsResponse, error) { } slotRange := uint32(requestedSlot) / restapi.ParamsRestAPI.RequestsMemoryCacheGranularity - return deps.RequestHandler.Validators(slotRange, pageSize, cursorIndex) + return deps.RequestHandler.Validators(slotRange, cursorIndex, pageSize) } func validatorByAccountAddress(c echo.Context) (*api.ValidatorResponse, error) { diff --git a/pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go b/pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go index 4abf4db90..ca6531202 100644 --- a/pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go +++ b/pkg/protocol/sybilprotection/sybilprotectionv1/sybilprotection.go @@ -371,9 +371,14 @@ func (o *SybilProtection) OrderedRegisteredCandidateValidatorsList(epoch iotago. }); err != nil { return nil, ierrors.Wrapf(err, "failed to iterate over eligible validator candidates") } - // sort candidates by stake + + // sort validators by pool stake, then by address sort.Slice(validatorResp, func(i int, j int) bool { - return validatorResp[i].ValidatorStake > validatorResp[j].ValidatorStake + if validatorResp[i].PoolStake == validatorResp[j].PoolStake { + return validatorResp[i].AddressBech32 < validatorResp[j].AddressBech32 + } + + return validatorResp[i].PoolStake > validatorResp[j].PoolStake }) return validatorResp, nil diff --git a/pkg/requesthandler/accounts.go b/pkg/requesthandler/accounts.go index e82aa15ba..1d463cf15 100644 --- a/pkg/requesthandler/accounts.go +++ b/pkg/requesthandler/accounts.go @@ -2,6 +2,7 @@ package requesthandler import ( "fmt" + "sort" "github.com/labstack/echo/v4" @@ -202,6 +203,15 @@ func (r *RequestHandler) SelectedCommittee(epoch iotago.EpochIndex) (*api.Commit return true }) + // sort committee by pool stake, then by address + sort.Slice(committee, func(i, j int) bool { + if committee[i].PoolStake == committee[j].PoolStake { + return committee[i].AddressBech32 < committee[j].AddressBech32 + } + + return committee[i].PoolStake > committee[j].PoolStake + }) + return &api.CommitteeResponse{ Epoch: epoch, Committee: committee,