Skip to content

Commit f4f3183

Browse files
Drop the echoed height from GigaRouter.Validators (#4590)
`GigaRouter.Validators` returned the global height it was called with as a second result. Every success path echoed that argument, and `Environment.Validators` already resolves an omitted or zero height to the app tip or `InitialHeight` before the call, then wrote the echo back over the same value. The method now returns only the validator set and an error. `/validators` still reports the height it resolved. A road index is not part of `ResultValidators`, so there is nothing for a second return to carry. No consensus, state, or wire change. Checked with `TestGigaRouterCommon_ValidatorsAtGlobalHeight` and `TestValidators` under `-race`. Made with [Cursor](https://cursor.com) Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent d704c77 commit f4f3183

4 files changed

Lines changed: 12 additions & 17 deletions

File tree

‎sei-tendermint/internal/p2p/giga_router.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,6 @@ type GigaRouter interface {
8282
// EvmProxyEnabled reports whether EvmProxy can return Some for any sender.
8383
EvmProxyEnabled() bool
8484
Mempool() utils.Option[*producer.State]
85-
Validators(n atypes.GlobalBlockNumber) ([]*types.Validator, atypes.GlobalBlockNumber, error)
85+
Validators(n atypes.GlobalBlockNumber) ([]*types.Validator, error)
8686
fillInboundHandshake(spec handshakeSpec) (handshakeSpec, utils.Option[handshakeOffer])
8787
}

‎sei-tendermint/internal/p2p/giga_router_common.go‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -850,23 +850,22 @@ func (r *gigaRouterCommon) runInboundMux(
850850

851851
// Validators returns the Autobahn validator set that certified global height n.
852852
// Before the first CommitQC, FirstBlock resolves to the genesis committee.
853-
func (r *gigaRouterCommon) Validators(n atypes.GlobalBlockNumber) ([]*types.Validator, atypes.GlobalBlockNumber, error) {
853+
func (r *gigaRouterCommon) Validators(n atypes.GlobalBlockNumber) ([]*types.Validator, error) {
854854
first := r.data.Registry().FirstBlock()
855855
qc, err := r.data.TryQC(n)
856856
var epochIndex atypes.EpochIndex
857857
if errors.Is(err, atypes.ErrNotFound) && n == first {
858858
epochIndex = 0
859859
} else if err != nil {
860-
return nil, 0, heightLookupError(n, err)
860+
return nil, heightLookupError(n, err)
861861
} else {
862862
epochIndex = qc.QC().Proposal().EpochIndex()
863863
}
864864
ep, err := r.data.Registry().EpochByIndex(epochIndex)
865865
if err != nil {
866-
return nil, 0, heightLookupError(n, err)
866+
return nil, heightLookupError(n, err)
867867
}
868-
vs, err := committeeValidators(ep.Committee())
869-
return vs, n, err
868+
return committeeValidators(ep.Committee())
870869
}
871870

872871
// heightLookupError returns the RPC error for a data lookup at global height n.

‎sei-tendermint/internal/p2p/giga_router_common_test.go‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,15 @@ func TestGigaRouterCommon_ValidatorsAtGlobalHeight(t *testing.T) {
176176
})
177177
first := router.data.Registry().FirstBlock()
178178

179-
got, h, err := router.Validators(first)
179+
got, err := router.Validators(first)
180180
require.NoError(t, err)
181-
require.Equal(t, first, h)
182181
require.Len(t, got, 3)
183182
require.Equal(t, []int64{1, 1, 1}, []int64{got[0].VotingPower, got[1].VotingPower, got[2].VotingPower})
184183

185-
_, _, err = router.Validators(0)
184+
_, err = router.Validators(0)
186185
require.ErrorIs(t, err, coretypes.ErrHeightNotAvailable)
187186

188-
_, _, err = router.Validators(first + 100)
187+
_, err = router.Validators(first + 100)
189188
require.ErrorIs(t, err, coretypes.ErrHeightExceedsChainHead)
190189

191190
weights := map[atypes.PublicKey]uint64{
@@ -196,15 +195,13 @@ func TestGigaRouterCommon_ValidatorsAtGlobalHeight(t *testing.T) {
196195
require.NoError(t, router.data.Registry().StageAndActivate(0, weights))
197196
fakeNext := utils.NewAtomicSend(router.data.Registry().MustEpoch(2))
198197
router.nextCommitEpoch = fakeNext.Subscribe()
199-
got, h, err = router.Validators(first)
198+
got, err = router.Validators(first)
200199
require.NoError(t, err)
201-
require.Equal(t, first, h)
202200
require.Equal(t, []int64{1, 1, 1}, []int64{got[0].VotingPower, got[1].VotingPower, got[2].VotingPower})
203201

204202
n := pushQCAtRoad(t, router, keys, router.data.Registry().MustEpoch(2), epoch.FirstRoad(2))
205-
got, h, err = router.Validators(n)
203+
got, err = router.Validators(n)
206204
require.NoError(t, err)
207-
require.Equal(t, n, h)
208205
require.Equal(t, []int64{10, 5, 1}, []int64{got[0].VotingPower, got[1].VotingPower, got[2].VotingPower})
209206
require.Equal(t, high.Public().Bytes(), got[0].PubKey.Bytes())
210207
require.Equal(t, mid.Public().Bytes(), got[1].PubKey.Bytes())
@@ -213,7 +210,7 @@ func TestGigaRouterCommon_ValidatorsAtGlobalHeight(t *testing.T) {
213210
require.NoError(t, router.data.Registry().StageAndActivate(1, weights))
214211
require.NoError(t, router.data.Registry().StageAndActivate(2, weights))
215212
require.NoError(t, router.data.Registry().PruneBefore(4))
216-
_, _, err = router.Validators(n)
213+
_, err = router.Validators(n)
217214
require.ErrorIs(t, err, coretypes.ErrHeightNotAvailable)
218215
}
219216

‎sei-tendermint/internal/rpc/core/consensus.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ func (env *Environment) Validators(ctx context.Context, req *coretypes.RequestVa
3737
if !ok {
3838
return nil, fmt.Errorf("invalid height %d", height)
3939
}
40-
vs, resolved, err := giga.Validators(gbn)
40+
vs, err := giga.Validators(gbn)
4141
if err != nil {
4242
return nil, err
4343
}
44-
height = utils.Clamp[int64](resolved)
4544
totalCount := len(vs)
4645
perPage := env.validatePerPage(req.PerPage.IntPtr())
4746
page, err := validatePage(req.Page.IntPtr(), perPage, totalCount)

0 commit comments

Comments
 (0)