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

Remove usage of res.Block.Header, Header interface. #5753

Merged
merged 7 commits into from
Jan 30, 2024
4 changes: 2 additions & 2 deletions e2e/tests/core/02-client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ func (s *ClientTestSuite) TestClient_Update_Misbehaviour() {
trustedHeight clienttypes.Height
latestHeight clienttypes.Height
clientState ibcexported.ClientState
header testsuite.Header
header *cmtservice.Header
signers []cmttypes.PrivValidator
validatorSet []*cmttypes.Validator
maliciousHeader *ibctm.Header
Expand Down Expand Up @@ -527,7 +527,7 @@ func (s *ClientTestSuite) extractChainPrivateKeys(ctx context.Context, chain ibc
}

// createMaliciousTMHeader creates a header with the provided trusted height with an invalid app hash.
func createMaliciousTMHeader(chainID string, blockHeight int64, trustedHeight clienttypes.Height, timestamp time.Time, tmValSet, tmTrustedVals *cmttypes.ValidatorSet, signers []cmttypes.PrivValidator, oldHeader testsuite.Header) (*ibctm.Header, error) {
func createMaliciousTMHeader(chainID string, blockHeight int64, trustedHeight clienttypes.Height, timestamp time.Time, tmValSet, tmTrustedVals *cmttypes.ValidatorSet, signers []cmttypes.PrivValidator, oldHeader *cmtservice.Header) (*ibctm.Header, error) {
tmHeader := cmttypes.Header{
Version: cmtprotoversion.Consensus{Block: cmtversion.BlockProtocol, App: 2},
ChainID: chainID,
Expand Down
18 changes: 2 additions & 16 deletions e2e/testsuite/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"sort"
"time"

"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
Expand Down Expand Up @@ -106,13 +105,6 @@ func (s *E2ETestSuite) InitGRPCClients(chain ibc.Chain) {
}
}

// Header defines an interface which is implemented by both the sdk block header and the cometbft Block Header.
// this interfaces allows us to use the same function to fetch the block header for both chains.
type Header interface {
crodriguezvega marked this conversation as resolved.
Show resolved Hide resolved
GetTime() time.Time
GetLastCommitHash() []byte
}

// QueryClientState queries the client state on the given chain for the provided clientID.
func (s *E2ETestSuite) QueryClientState(ctx context.Context, chain ibc.Chain, clientID string) (ibcexported.ClientState, error) {
queryClient := s.GetChainGRCPClients(chain).ClientQueryClient
Expand Down Expand Up @@ -351,7 +343,7 @@ func (s *E2ETestSuite) QueryProposalV1(ctx context.Context, chain ibc.Chain, pro
}

// GetBlockHeaderByHeight fetches the block header at a given height.
func (s *E2ETestSuite) GetBlockHeaderByHeight(ctx context.Context, chain ibc.Chain, height uint64) (Header, error) {
func (s *E2ETestSuite) GetBlockHeaderByHeight(ctx context.Context, chain ibc.Chain, height uint64) (*cmtservice.Header, error) {
consensusService := s.GetChainGRCPClients(chain).ConsensusServiceClient
res, err := consensusService.GetBlockByHeight(ctx, &cmtservice.GetBlockByHeightRequest{
Height: int64(height),
Expand All @@ -360,13 +352,7 @@ func (s *E2ETestSuite) GetBlockHeaderByHeight(ctx context.Context, chain ibc.Cha
return nil, err
}

// Clean up when v4 is not supported, see: https://github.com/cosmos/ibc-go/issues/3540
// versions newer than 0.46 SDK use the SdkBlock field while versions older
// than 0.46 SDK, which do not have the SdkBlock field, use the Block field.
if res.SdkBlock != nil {
return &res.SdkBlock.Header, nil
}
return &res.Block.Header, nil // needed for v4 (uses SDK v0.45)
return &res.SdkBlock.Header, nil
}

// GetValidatorSetByHeight returns the validators of the given chain at the specified height. The returned validators
Expand Down
Loading