Skip to content

Commit

Permalink
Remove usage of res.Block.Header, Header interface. (cosmos#5753)
Browse files Browse the repository at this point in the history
Co-authored-by: Carlos Rodriguez <carlos@interchain.io>
  • Loading branch information
DimitrisJim and crodriguezvega committed Jan 30, 2024
1 parent f64de8e commit a1f0dfb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
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 {
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

0 comments on commit a1f0dfb

Please sign in to comment.