Skip to content

Commit

Permalink
Merge branch 'main' into charly/denom_traces_migration_handler
Browse files Browse the repository at this point in the history
  • Loading branch information
charleenfei committed Jul 19, 2022
2 parents 35ea75e + 193e414 commit 7660328
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 3 deletions.
10 changes: 9 additions & 1 deletion docs/roadmap/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,20 @@ This roadmap should be read as a high-level guide, rather than a commitment to s

At a high level we will focus on:

### Features

- Releasing [v4.0.0](https://github.com/cosmos/ibc-go/milestone/26), which includes the ICS-29 Fee Middleware module.
- Finishing and releasing the [refactoring of 02-client](https://github.com/cosmos/ibc-go/milestone/16). This refactor will make the development of light clients easier.
- Finishing and releasing the upgrade to Cosmos SDK v0.46.
- Starting the implementation of channel upgradability (see [epic](https://github.com/cosmos/ibc-go/issues/1599) and [alpha milestone](https://github.com/cosmos/ibc-go/milestone/29)) with the goal of cutting an alpha1 pre-release by the end of the quarter. Channel upgradability will allow chains to renegotiate an existing channel to take advantage of new features without having to create a new channel, thus preserving all existing packet state processed on the channel.
- Implementing the new [`ORDERED_ALLOW_TIMEOUT` channel type](https://github.com/cosmos/ibc-go/milestone/31) and hopefully releasing it as well. This new channel type will allow packets on an ordered channel to timeout without causing the closure of the channel.

### Testing and infrastructure

- Adding [automated e2e tests](https://github.com/cosmos/ibc-go/milestone/32) to the repo's CI.

### Documentation and backlog

- Finishing and releasing the upgrade to Cosmos SDK v0.46.
- Writing the [light client implementation guide](https://github.com/cosmos/ibc-go/issues/59).
- Working on [core backlog issues](https://github.com/cosmos/ibc-go/milestone/28).
- Depending on the timeline of the Cosmos SDK, implementing and testing the changes needed to support the [transtion to SMT storage](https://github.com/cosmos/ibc-go/milestone/21).
Expand Down
58 changes: 57 additions & 1 deletion e2e/fee_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@ import (
"context"
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/strangelove-ventures/ibctest/broadcast"
"github.com/strangelove-ventures/ibctest/chain/cosmos"
"github.com/strangelove-ventures/ibctest/ibc"
"github.com/stretchr/testify/suite"

"e2e/testsuite"

feetypes "github.com/cosmos/ibc-go/v4/modules/apps/29-fee/types"
channeltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
)

func TestFeeMiddlewareTestSuite(t *testing.T) {
Expand All @@ -18,13 +24,63 @@ type FeeMiddlewareTestSuite struct {
testsuite.E2ETestSuite
}

// RegisterCounterPartyPayee broadcasts a MsgRegisterCounterpartyPayee message.
func (s *FeeMiddlewareTestSuite) RegisterCounterPartyPayee(ctx context.Context, chain *cosmos.CosmosChain,
user broadcast.User, portID, channelID, relayerAddr, counterpartyPayeeAddr string) (sdk.TxResponse, error) {
msg := feetypes.NewMsgRegisterCounterpartyPayee(portID, channelID, relayerAddr, counterpartyPayeeAddr)
return s.BroadcastMessages(ctx, chain, user, msg)
}

// QueryCounterPartyPayee queries the counterparty payee of the given chain and relayer address on the specified channel.
func (s *FeeMiddlewareTestSuite) QueryCounterPartyPayee(ctx context.Context, chain ibc.Chain, relayerAddress, channelID string) (string, error) {
queryClient := s.GetChainGRCPClients(chain).FeeQueryClient
res, err := queryClient.CounterpartyPayee(ctx, &feetypes.QueryCounterpartyPayeeRequest{
ChannelId: channelID,
Relayer: relayerAddress,
})

if err != nil {
return "", err
}
return res.CounterpartyPayee, nil
}

// PayPacketFeeAsync broadcasts a MsgPayPacketFeeAsync message.
func (s *FeeMiddlewareTestSuite) PayPacketFeeAsync(
ctx context.Context,
chain *cosmos.CosmosChain,
user broadcast.User,
packetID channeltypes.PacketId,
packetFee feetypes.PacketFee,
) (sdk.TxResponse, error) {
msg := feetypes.NewMsgPayPacketFeeAsync(packetID, packetFee)
return s.BroadcastMessages(ctx, chain, user, msg)
}

// QueryIncentivizedPacketsForChannel queries the incentivized packets on the specified channel.
func (s *FeeMiddlewareTestSuite) QueryIncentivizedPacketsForChannel(
ctx context.Context,
chain *cosmos.CosmosChain,
portId,
channelId string,
) ([]*feetypes.IdentifiedPacketFees, error) {
queryClient := s.GetChainGRCPClients(chain).FeeQueryClient
res, err := queryClient.IncentivizedPacketsForChannel(ctx, &feetypes.QueryIncentivizedPacketsForChannelRequest{
PortId: portId,
ChannelId: channelId,
})
if err != nil {
return nil, err
}
return res.IncentivizedPackets, err
}

func (s *FeeMiddlewareTestSuite) TestPlaceholder() {
ctx := context.Background()
r := s.SetupChainsRelayerAndChannel(ctx, feeMiddlewareChannelOptions())
s.T().Run("start relayer", func(t *testing.T) {
s.StartRelayer(r)
})

}

// feeMiddlewareChannelOptions configures both of the chains to have fee middleware enabled.
Expand Down
66 changes: 65 additions & 1 deletion e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,23 @@ import (
"strings"
"time"

"e2e/testconfig"

sdk "github.com/cosmos/cosmos-sdk/types"
dockerclient "github.com/docker/docker/client"
"github.com/strangelove-ventures/ibctest"
"github.com/strangelove-ventures/ibctest/broadcast"
"github.com/strangelove-ventures/ibctest/chain/cosmos"
"github.com/strangelove-ventures/ibctest/ibc"
"github.com/strangelove-ventures/ibctest/test"
"github.com/strangelove-ventures/ibctest/testreporter"
"github.com/stretchr/testify/suite"
"go.uber.org/zap"
"go.uber.org/zap/zaptest"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"e2e/testconfig"
feetypes "github.com/cosmos/ibc-go/v4/modules/apps/29-fee/types"
)

const (
Expand All @@ -29,13 +36,22 @@ const (
// E2ETestSuite has methods and functionality which can be shared among all test suites.
type E2ETestSuite struct {
suite.Suite

grpcClients map[string]GRPCClients
paths map[string]path
logger *zap.Logger
DockerClient *dockerclient.Client
network string
startRelayerFn func(relayer ibc.Relayer)
}

// GRPCClients holds a reference to any GRPC clients that are needed by the tests.
// These should typically be used for query clients only. If we need to make changes, we should
// use E2ETestSuite.BroadcastMessages to broadcast transactions instead.
type GRPCClients struct {
FeeQueryClient feetypes.QueryClient
}

// path is a pairing of two chains which will be used in a test.
type path struct {
chainA, chainB *cosmos.CosmosChain
Expand Down Expand Up @@ -102,6 +118,9 @@ func (s *E2ETestSuite) SetupChainsRelayerAndChannel(ctx context.Context, channel
time.Sleep(time.Second * 10)
}

s.initGRPCClients(chainA)
s.initGRPCClients(chainB)

return r
}

Expand Down Expand Up @@ -129,6 +148,20 @@ func (s *E2ETestSuite) GetChains(chainOpts ...testconfig.ChainOptionConfiguratio
return path.chainA, path.chainB
}

// BroadcastMessages broadcasts the provided messages to the given chain and signs them on behalf of the provided user.
// Once the broadcast response is returned, we wait for a few blocks to be created on both chain A and chain B.
func (s *E2ETestSuite) BroadcastMessages(ctx context.Context, chain *cosmos.CosmosChain, user broadcast.User, msgs ...sdk.Msg) (sdk.TxResponse, error) {
broadcaster := cosmos.NewBroadcaster(s.T(), chain)
resp, err := ibctest.BroadcastTx(ctx, broadcaster, user, msgs...)
if err != nil {
return sdk.TxResponse{}, err
}

chainA, chainB := s.GetChains()
err = test.WaitForBlocks(ctx, 2, chainA, chainB)
return resp, err
}

// GetRelayerWallets returns the relayer wallets associated with the chains.
func (s *E2ETestSuite) GetRelayerWallets(relayer ibc.Relayer) (ibc.RelayerWallet, ibc.RelayerWallet, error) {
chainA, chainB := s.GetChains()
Expand Down Expand Up @@ -196,6 +229,37 @@ func (s *E2ETestSuite) GetChainBNativeBalance(ctx context.Context, user *ibctest
return GetNativeChainBalance(ctx, chainB, user)
}

// GetChainGRCPClients gets the GRPC clients associated with the given chain.
func (s *E2ETestSuite) GetChainGRCPClients(chain ibc.Chain) GRPCClients {
cs, ok := s.grpcClients[chain.Config().ChainID]
s.Require().True(ok, "chain %s does not have GRPC clients", chain.Config().ChainID)
return cs
}

// initGRPCClients establishes GRPC clients with the given chain.
// The created GRPCClients can be retrieved with GetChainGRCPClients.
func (s *E2ETestSuite) initGRPCClients(chain *cosmos.CosmosChain) {
// Create a connection to the gRPC server.
grpcConn, err := grpc.Dial(
chain.GetHostGRPCAddress(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
s.Require().NoError(err)
s.T().Cleanup(func() {
if err := grpcConn.Close(); err != nil {
s.T().Logf("failed closing GRPC connection to chain %s: %s", chain.Config().ChainID, err)
}
})

if s.grpcClients == nil {
s.grpcClients = make(map[string]GRPCClients)
}

s.grpcClients[chain.Config().ChainID] = GRPCClients{
FeeQueryClient: feetypes.NewQueryClient(grpcConn),
}
}

// createCosmosChains creates two separate chains in docker containers.
// test and can be retrieved with GetChains.
func (s *E2ETestSuite) createCosmosChains(chainOptions testconfig.ChainOptions) (*cosmos.CosmosChain, *cosmos.CosmosChain) {
Expand Down

0 comments on commit 7660328

Please sign in to comment.