Skip to content

Commit

Permalink
Merge branch 'main' into carlos/update-error-message-total-escrow-mig…
Browse files Browse the repository at this point in the history
…ration
  • Loading branch information
crodriguezvega authored Jun 7, 2023
2 parents 0b9a026 + c5fd97d commit 6958eb1
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .github/compatibility-test-matrices/main/client-chain-a.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"chain-b": ["main", "v7.0.1", "v6.2.0", "v6.1.1", "v5.3.1", "v5.2.1", "v5.0.1", "v4.4.2", "v4.3.1", "v4.2.2", "v4.1.3"],
"entrypoint": ["TestClientTestSuite"],
"test": [
"TestClientUpdateProposal_Succeeds"
"TestClientUpdateProposal_Succeeds",
"TestAllowedClientsParam"
],
"relayer-type": ["rly"],
"chain-binary": ["simd"],
Expand Down
3 changes: 2 additions & 1 deletion .github/compatibility-test-matrices/main/client-chain-b.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"chain-b": ["main"],
"entrypoint": ["TestClientTestSuite"],
"test": [
"TestClientUpdateProposal_Succeeds"
"TestClientUpdateProposal_Succeeds",
"TestAllowedClientsParam"
],
"relayer-type": ["rly"],
"chain-binary": ["simd"],
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-simd-image-from-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
ref: "${{ env.GIT_TAG }}"
fetch-depth: 0
- name: Log in to the Container registry
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-compatibility-unreleased.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
ref: "${{ matrix.release-branch }}"
fetch-depth: 0
- name: Log in to the Container registry
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-compatibility.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
fetch-depth: 0
- name: Log in to the Container registry
if: env.RELEASE_BRANCH == matrix.release-branch
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-test-workflow-call.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
if: ${{ inputs.build-and-push-docker-image }}
- name: Log in to the Container registry
if: ${{ inputs.build-and-push-docker-image }}
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand Down
19 changes: 13 additions & 6 deletions e2e/relayer/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ const (
Rly = "rly"
Hermes = "hermes"

cosmosRelayerRepository = "damiannolan/rly" //"ghcr.io/cosmos/relayer"
cosmosRelayerUser = "100:1000" // docker run -it --rm --entrypoint echo ghcr.io/cosmos/relayer "$(id -u):$(id -g)"
hermesRelayerRepository = "ghcr.io/informalsystems/hermes"
hermesRelayerUser = "1000:1000"
rlyRelayerRepository = "damiannolan/rly" //"ghcr.io/cosmos/relayer"
rlyRelayerUser = "100:1000" // docker run -it --rm --entrypoint echo ghcr.io/cosmos/relayer "$(id -u):$(id -g)"
)

// Config holds configuration values for the relayer used in the tests.
Expand All @@ -35,7 +37,7 @@ func New(t *testing.T, cfg Config, logger *zap.Logger, dockerClient *dockerclien
case Rly:
return newCosmosRelayer(t, cfg.Tag, logger, dockerClient, network)
case Hermes:
return newHermesRelayer()
return newHermesRelayer(t, cfg.Tag, logger, dockerClient, network)
default:
panic(fmt.Sprintf("unknown relayer specified: %s", cfg.Type))
}
Expand All @@ -44,7 +46,7 @@ func New(t *testing.T, cfg Config, logger *zap.Logger, dockerClient *dockerclien
// newCosmosRelayer returns an instance of the go relayer.
// Options are used to allow for relayer version selection and specifying the default processing option.
func newCosmosRelayer(t *testing.T, tag string, logger *zap.Logger, dockerClient *dockerclient.Client, network string) ibc.Relayer {
customImageOption := relayer.CustomDockerImage(cosmosRelayerRepository, tag, cosmosRelayerUser)
customImageOption := relayer.CustomDockerImage(rlyRelayerRepository, tag, rlyRelayerUser)
relayerProcessingOption := relayer.StartupFlags("-p", "events") // relayer processes via events

relayerFactory := interchaintest.NewBuiltinRelayerFactory(ibc.CosmosRly, logger, customImageOption, relayerProcessingOption)
Expand All @@ -55,8 +57,13 @@ func newCosmosRelayer(t *testing.T, tag string, logger *zap.Logger, dockerClient
}

// newHermesRelayer returns an instance of the hermes relayer.
func newHermesRelayer() ibc.Relayer {
panic("hermes relayer not yet implemented for interchaintest")
func newHermesRelayer(t *testing.T, tag string, logger *zap.Logger, dockerClient *dockerclient.Client, network string) ibc.Relayer {
customImageOption := relayer.CustomDockerImage(hermesRelayerRepository, tag, hermesRelayerUser)
relayerFactory := interchaintest.NewBuiltinRelayerFactory(ibc.Hermes, logger, customImageOption)

return relayerFactory.Build(
t, dockerClient, network,
)
}

// RelayerMap is a mapping from test names to a relayer set for that test.
Expand Down
4 changes: 3 additions & 1 deletion e2e/testconfig/testconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ const (
// defaultRlyTag is the tag that will be used if no relayer tag is specified.
// all images are here https://github.com/cosmos/relayer/pkgs/container/relayer/versions
defaultRlyTag = "latest" // "andrew-tendermint_v0.37" // "v2.2.0"
// defaultHermesTag is the tag that will be used if no relayer tag is specified for hermes.
defaultHermesTag = "v1.4.0"
// defaultChainTag is the tag that will be used for the chains if none is specified.
defaultChainTag = "main"
// defaultRelayerType is the default relayer that will be used if none is specified.
Expand Down Expand Up @@ -286,7 +288,7 @@ func getRelayerConfigFromEnv() relayer.Config {
rlyTag = defaultRlyTag
}
if relayerType == relayer.Hermes {
// TODO: set default hermes version
rlyTag = defaultHermesTag
}
}
return relayer.Config{
Expand Down
64 changes: 63 additions & 1 deletion e2e/tests/core/02-client/client_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package e2e
package client

import (
"context"
Expand All @@ -23,6 +23,8 @@ import (

"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"

govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
paramsproposaltypes "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
"github.com/cosmos/ibc-go/e2e/dockerutil"
"github.com/cosmos/ibc-go/e2e/testsuite"
"github.com/cosmos/ibc-go/e2e/testvalues"
Expand Down Expand Up @@ -58,6 +60,15 @@ func (s *ClientTestSuite) Status(ctx context.Context, chain ibc.Chain, clientID
return res.Status, nil
}

// QueryAllowedClients queries the on-chain AllowedClients parameter for 02-client
func (s *ClientTestSuite) QueryAllowedClients(ctx context.Context, chain ibc.Chain) []string {
queryClient := s.GetChainGRCPClients(chain).ClientQueryClient
res, err := queryClient.ClientParams(ctx, &clienttypes.QueryClientParamsRequest{})
s.Require().NoError(err)

return res.Params.AllowedClients
}

func (s *ClientTestSuite) TestClientUpdateProposal_Succeeds() {
t := s.T()
ctx := context.TODO()
Expand Down Expand Up @@ -242,6 +253,57 @@ func (s *ClientTestSuite) TestClient_Update_Misbehaviour() {
})
}

// TestAllowedClientsParam tests changing the AllowedClients parameter using a governance proposal
func (s *ClientTestSuite) TestAllowedClientsParam() {
t := s.T()
ctx := context.TODO()

_, _ = s.SetupChainsRelayerAndChannel(ctx, s.TransferChannelOptions())
chainA, chainB := s.GetChains()
chainAVersion := chainA.Config().Images[0].Version

chainAWallet := s.CreateUserOnChainA(ctx, testvalues.StartingTokenAmount)

s.Require().NoError(test.WaitForBlocks(ctx, 1, chainA, chainB), "failed to wait for blocks")

t.Run("ensure allowed clients are set to the default", func(t *testing.T) {
allowedClients := s.QueryAllowedClients(ctx, chainA)
s.Require().Equal(clienttypes.DefaultAllowedClients, allowedClients)
})

allowedClient := ibcexported.Solomachine
t.Run("change the allowed client to only allow solomachine clients", func(t *testing.T) {
if testvalues.SelfParamsFeatureReleases.IsSupported(chainAVersion) {
authority, err := s.QueryModuleAccountAddress(ctx, govtypes.ModuleName, chainA)
s.Require().NoError(err)
s.Require().NotNil(authority)

msg := clienttypes.NewMsgUpdateParams(authority.String(), clienttypes.NewParams(allowedClient))
s.ExecuteGovProposalV1(ctx, msg, chainA, chainAWallet, 1)
} else {
value, err := tmjson.Marshal([]string{allowedClient})
s.Require().NoError(err)
changes := []paramsproposaltypes.ParamChange{
paramsproposaltypes.NewParamChange(ibcexported.ModuleName, string(clienttypes.KeyAllowedClients), string(value)),
}

proposal := paramsproposaltypes.NewParameterChangeProposal(ibctesting.Title, ibctesting.Description, changes)
s.ExecuteGovProposal(ctx, chainA, chainAWallet, proposal)
}
})

t.Run("validate the param was successfully changed", func(t *testing.T) {
allowedClients := s.QueryAllowedClients(ctx, chainA)
s.Require().Equal([]string{allowedClient}, allowedClients)
})

t.Run("ensure querying non-allowed client's status returns Unauthorized Status", func(t *testing.T) {
status, err := s.QueryClientStatus(ctx, chainA, ibctesting.FirstClientID)
s.Require().NoError(err)
s.Require().Equal(ibcexported.Unauthorized.String(), status)
})
}

// extractChainPrivateKeys returns a slice of tmtypes.PrivValidator which hold the private keys for all validator
// nodes for a given chain.
func (s *ClientTestSuite) extractChainPrivateKeys(ctx context.Context, chain *cosmos.CosmosChain) []tmtypes.PrivValidator {
Expand Down
4 changes: 2 additions & 2 deletions e2e/testsuite/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"context"
"fmt"
"strings"
"time"

dockerclient "github.com/docker/docker/client"
interchaintest "github.com/strangelove-ventures/interchaintest/v7"
"github.com/strangelove-ventures/interchaintest/v7/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v7/ibc"
"github.com/strangelove-ventures/interchaintest/v7/testreporter"
test "github.com/strangelove-ventures/interchaintest/v7/testutil"
"github.com/stretchr/testify/suite"
"go.uber.org/zap"
"go.uber.org/zap/zaptest"
Expand Down Expand Up @@ -128,7 +128,7 @@ func (s *E2ETestSuite) SetupChainsRelayerAndChannel(ctx context.Context, channel
}
})
// wait for relayer to start.
time.Sleep(time.Second * 10)
s.Require().NoError(test.WaitForBlocks(ctx, 10, chainA, chainB), "failed to wait for blocks")
}

s.InitGRPCClients(chainA)
Expand Down
2 changes: 2 additions & 0 deletions modules/apps/transfer/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ func (m Migrator) MigrateTotalEscrowForDenom(ctx sdk.Context) error {
m.keeper.SetTotalEscrowForDenom(ctx, totalEscrow)
}

logger := m.keeper.Logger(ctx)
logger.Info("successfully set total escrow for %d denominations", totalEscrowed.Len())
return nil
}

Expand Down

0 comments on commit 6958eb1

Please sign in to comment.