-
Notifications
You must be signed in to change notification settings - Fork 4
fix: align attester light client RPC data #409
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
Open
randygrok
wants to merge
7
commits into
main
Choose a base branch
from
jgimeno/issue-271-attester-consensus-key
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6c085c3
fix: use attester consensus keys for light blocks
randygrok 841363e
fix: align attester light client RPC data
randygrok 5e34142
fix: address attester RPC CI lint
randygrok 04d6e4a
test: cover multi-attester quorum and commits
randygrok 5e0654a
test: cover four-attester IBC quorum
randygrok b98f792
fix: propagate attester signature query errors
randygrok e673bc0
fix: use one attester vote address source
randygrok File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| package keeper | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/cometbft/cometbft/crypto/ed25519" | ||
| codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
| cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" | ||
| sdk "github.com/cosmos/cosmos-sdk/types" | ||
| "github.com/stretchr/testify/require" | ||
| "google.golang.org/grpc/codes" | ||
| "google.golang.org/grpc/status" | ||
|
|
||
| "github.com/evstack/ev-abci/modules/network/types" | ||
| ) | ||
|
|
||
| func TestAttestersQueryReturnsRegisteredAttesterInfo(t *testing.T) { | ||
| newQueryServer := func(t *testing.T) (types.QueryServer, Keeper, sdk.Context) { | ||
| t.Helper() | ||
| sk := NewMockStakingKeeper() | ||
| _, keeper, ctx := newTestServer(t, &sk) | ||
| return NewQueryServer(keeper), keeper, ctx | ||
| } | ||
|
|
||
| t.Run("nil request", func(t *testing.T) { | ||
| queryServer, _, ctx := newQueryServer(t) | ||
|
|
||
| resp, err := queryServer.Attesters(ctx, nil) | ||
|
|
||
| require.Nil(t, resp) | ||
| require.Error(t, err) | ||
| require.Equal(t, codes.InvalidArgument, status.Code(err)) | ||
| }) | ||
|
|
||
| t.Run("empty set", func(t *testing.T) { | ||
| queryServer, _, ctx := newQueryServer(t) | ||
|
|
||
| resp, err := queryServer.Attesters(ctx, &types.QueryAttestersRequest{}) | ||
|
|
||
| require.NoError(t, err) | ||
| require.NotNil(t, resp) | ||
| require.Empty(t, resp.Attesters) | ||
| }) | ||
|
|
||
| t.Run("joined attester with pubkey", func(t *testing.T) { | ||
| queryServer, keeper, ctx := newQueryServer(t) | ||
| pubKeyAny := newAttesterPubKeyAny(t) | ||
| consensusAddress := sdk.ValAddress(ed25519.GenPrivKey().PubKey().Address()).String() | ||
| attesterInfo := &types.AttesterInfo{ | ||
| Authority: sdk.AccAddress("operator").String(), | ||
| Pubkey: pubKeyAny, | ||
| JoinedHeight: ctx.BlockHeight(), | ||
| } | ||
| require.NoError(t, keeper.SetAttesterSetMember(ctx, consensusAddress)) | ||
| require.NoError(t, keeper.SetAttesterInfo(ctx, consensusAddress, attesterInfo)) | ||
|
|
||
| resp, err := queryServer.Attesters(ctx, &types.QueryAttestersRequest{}) | ||
|
|
||
| require.NoError(t, err) | ||
| require.Len(t, resp.Attesters, 1) | ||
| require.Equal(t, consensusAddress, resp.Attesters[0].ValidatorAddress) | ||
| require.Equal(t, attesterInfo.Authority, resp.Attesters[0].AttesterInfo.Authority) | ||
| require.Equal(t, attesterInfo.JoinedHeight, resp.Attesters[0].AttesterInfo.JoinedHeight) | ||
| require.Equal(t, pubKeyAny.TypeUrl, resp.Attesters[0].AttesterInfo.Pubkey.TypeUrl) | ||
| require.Equal(t, pubKeyAny.Value, resp.Attesters[0].AttesterInfo.Pubkey.Value) | ||
| }) | ||
|
|
||
| t.Run("missing attester info", func(t *testing.T) { | ||
| queryServer, keeper, ctx := newQueryServer(t) | ||
| consensusAddress := sdk.ValAddress(ed25519.GenPrivKey().PubKey().Address()).String() | ||
| require.NoError(t, keeper.SetAttesterSetMember(ctx, consensusAddress)) | ||
|
|
||
| resp, err := queryServer.Attesters(ctx, &types.QueryAttestersRequest{}) | ||
|
|
||
| require.Nil(t, resp) | ||
| require.Error(t, err) | ||
| }) | ||
| } | ||
|
|
||
| func newAttesterPubKeyAny(t *testing.T) *codectypes.Any { | ||
| t.Helper() | ||
|
|
||
| sdkPubKey, err := cryptocodec.FromCmtPubKeyInterface(ed25519.GenPrivKey().PubKey()) | ||
| require.NoError(t, err) | ||
|
|
||
| pubKeyAny, err := codectypes.NewAnyWithValue(sdkPubKey) | ||
| require.NoError(t, err) | ||
| return pubKeyAny | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use one keypair for both
validator_addressandattester_info.pubkeyin the success fixture.At Line 47-52, the test builds
pubKeyAnyandconsensusAddressfrom different random keys. That creates internally inconsistent attester data and reduces the value of this contract test.Proposed fix
🤖 Prompt for AI Agents