Skip to content

Commit

Permalink
Merge branch 'main' into dang/host-connection-id
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Rodriguez authored Mar 12, 2024
2 parents 59fdf13 + 9aa7151 commit d7cfafd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
8 changes: 8 additions & 0 deletions modules/core/02-client/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ func (k Keeper) VerifyMembership(c context.Context, req *types.QueryVerifyMember
}

ctx := sdk.UnwrapSDKContext(c)

// cache the context to ensure clientState.VerifyMembership does not change state
cachedCtx, _ := ctx.CacheContext()

Expand All @@ -386,6 +387,13 @@ func (k Keeper) VerifyMembership(c context.Context, req *types.QueryVerifyMember
return nil, status.Error(codes.FailedPrecondition, errorsmod.Wrapf(types.ErrClientNotActive, "cannot verify membership using client (%s) with status %s", req.ClientId, clientStatus).Error())
}

// consume flat gas fee for proof verification queries.
// NOTE: consuming gas prior to method invocation also provides protection against recursive calls reaching stack overflow
ctx.GasMeter().ConsumeGas(
3*ctx.KVGasConfig().ReadCostPerByte*uint64(len(req.Proof)),
"verify membership query",
)

if err := clientState.VerifyMembership(cachedCtx, k.ClientStore(cachedCtx, req.ClientId), k.cdc, req.ProofHeight, req.TimeDelay, req.BlockDelay, req.Proof, req.MerklePath, req.Value); err != nil {
k.Logger(ctx).Debug("proof verification failed", "key", req.MerklePath, "error", err)
return &types.QueryVerifyMembershipResponse{
Expand Down
10 changes: 5 additions & 5 deletions modules/core/02-client/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func (suite *KeeperTestSuite) TestValidateSelfClient() {
}
}

func (suite KeeperTestSuite) TestGetAllGenesisClients() { //nolint:govet // this is a test, we are okay with copying locks
func (suite *KeeperTestSuite) TestGetAllGenesisClients() {
clientIDs := []string{
exported.LocalhostClientID, testClientID2, testClientID3, testClientID,
}
Expand All @@ -252,7 +252,7 @@ func (suite KeeperTestSuite) TestGetAllGenesisClients() { //nolint:govet // this
suite.Require().Equal(expGenClients.Sort(), genClients)
}

func (suite KeeperTestSuite) TestGetAllGenesisMetadata() { //nolint:govet // this is a test, we are okay with copying locks
func (suite *KeeperTestSuite) TestGetAllGenesisMetadata() {
clientA, clientB := "07-tendermint-1", "clientB"

// create some starting state
Expand Down Expand Up @@ -308,7 +308,7 @@ func (suite KeeperTestSuite) TestGetAllGenesisMetadata() { //nolint:govet // thi
})
}

func (suite KeeperTestSuite) TestGetConsensusState() { //nolint:govet // this is a test, we are okay with copying locks
func (suite *KeeperTestSuite) TestGetConsensusState() {
suite.ctx = suite.ctx.WithBlockHeight(10)
cases := []struct {
name string
Expand Down Expand Up @@ -336,7 +336,7 @@ func (suite KeeperTestSuite) TestGetConsensusState() { //nolint:govet // this is

// 2 clients in total are created on chainA. The first client is updated so it contains an initial consensus state
// and a consensus state at the update height.
func (suite KeeperTestSuite) TestGetAllConsensusStates() { //nolint:govet // this is a test, we are okay with copying locks
func (suite *KeeperTestSuite) TestGetAllConsensusStates() {
path := ibctesting.NewPath(suite.chainA, suite.chainB)
path.SetupClients()

Expand Down Expand Up @@ -385,7 +385,7 @@ func (suite KeeperTestSuite) TestGetAllConsensusStates() { //nolint:govet // thi
suite.Require().Equal(expConsensusStates, consStates, "%s \n\n%s", expConsensusStates, consStates)
}

func (suite KeeperTestSuite) TestIterateClientStates() { //nolint:govet // this is a test, we are okay with copying locks
func (suite *KeeperTestSuite) TestIterateClientStates() {
paths := []*ibctesting.Path{
ibctesting.NewPath(suite.chainA, suite.chainB),
ibctesting.NewPath(suite.chainA, suite.chainB),
Expand Down
4 changes: 2 additions & 2 deletions modules/core/03-connection/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (suite *KeeperTestSuite) TestSetAndGetClientConnectionPaths() {
}

// create 2 connections: A0 - B0, A1 - B1
func (suite KeeperTestSuite) TestGetAllConnections() { //nolint:govet // this is a test, we are okay with copying locks
func (suite *KeeperTestSuite) TestGetAllConnections() {
path1 := ibctesting.NewPath(suite.chainA, suite.chainB)
path1.SetupConnections()

Expand Down Expand Up @@ -93,7 +93,7 @@ func (suite KeeperTestSuite) TestGetAllConnections() { //nolint:govet // this is

// the test creates 2 clients path.EndpointA.ClientID0 and path.EndpointA.ClientID1. path.EndpointA.ClientID0 has a single
// connection and path.EndpointA.ClientID1 has 2 connections.
func (suite KeeperTestSuite) TestGetAllClientConnectionPaths() { //nolint:govet // this is a test, we are okay with copying locks
func (suite *KeeperTestSuite) TestGetAllClientConnectionPaths() {
path1 := ibctesting.NewPath(suite.chainA, suite.chainB)
path2 := ibctesting.NewPath(suite.chainA, suite.chainB)
path1.SetupConnections()
Expand Down
6 changes: 3 additions & 3 deletions modules/core/04-channel/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func containsAll(expected, actual []types.IdentifiedChannel) bool {

// TestGetAllChannels creates multiple channels on chain A through various connections
// and tests their retrieval. 2 channels are on connA0 and 1 channel is on connA1
func (suite KeeperTestSuite) TestGetAllChannels() { //nolint:govet // this is a test, we are okay with copying locks
func (suite *KeeperTestSuite) TestGetAllChannels() {
path := ibctesting.NewPath(suite.chainA, suite.chainB)
path.Setup()
// channel0 on first connection on chainA
Expand Down Expand Up @@ -234,7 +234,7 @@ func (suite KeeperTestSuite) TestGetAllChannels() { //nolint:govet // this is a

// TestGetAllSequences sets all packet sequences for two different channels on chain A and
// tests their retrieval.
func (suite KeeperTestSuite) TestGetAllSequences() { //nolint:govet // this is a test, we are okay with copying locks
func (suite *KeeperTestSuite) TestGetAllSequences() {
path := ibctesting.NewPath(suite.chainA, suite.chainB)
path.Setup()

Expand Down Expand Up @@ -276,7 +276,7 @@ func (suite KeeperTestSuite) TestGetAllSequences() { //nolint:govet // this is a

// TestGetAllPacketState creates a set of acks, packet commitments, and receipts on two different
// channels on chain A and tests their retrieval.
func (suite KeeperTestSuite) TestGetAllPacketState() { //nolint:govet // this is a test, we are okay with copying locks
func (suite *KeeperTestSuite) TestGetAllPacketState() {
path := ibctesting.NewPath(suite.chainA, suite.chainB)
path.Setup()

Expand Down

0 comments on commit d7cfafd

Please sign in to comment.