diff --git a/e2e/go.mod b/e2e/go.mod index e07220575b6..0a597d2d982 100644 --- a/e2e/go.mod +++ b/e2e/go.mod @@ -16,7 +16,7 @@ require ( github.com/stretchr/testify v1.9.0 go.uber.org/zap v1.27.0 golang.org/x/mod v0.17.0 - google.golang.org/grpc v1.63.0 + google.golang.org/grpc v1.63.2 gopkg.in/yaml.v2 v2.4.0 ) diff --git a/e2e/go.sum b/e2e/go.sum index d18041399d0..37c00601b09 100644 --- a/e2e/go.sum +++ b/e2e/go.sum @@ -1731,8 +1731,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8= -google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= +google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= +google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= diff --git a/go.mod b/go.mod index 1f456ff5a94..756e2ad48f1 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,7 @@ require ( github.com/spf13/viper v1.18.2 github.com/stretchr/testify v1.9.0 google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de - google.golang.org/grpc v1.63.0 + google.golang.org/grpc v1.63.2 google.golang.org/protobuf v1.33.0 gopkg.in/yaml.v2 v2.4.0 ) diff --git a/go.sum b/go.sum index 2443adefd66..3ac3b263bdc 100644 --- a/go.sum +++ b/go.sum @@ -1646,8 +1646,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8= -google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= +google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= +google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= diff --git a/modules/apps/callbacks/go.mod b/modules/apps/callbacks/go.mod index 83d0f340ac1..19fb3140b88 100644 --- a/modules/apps/callbacks/go.mod +++ b/modules/apps/callbacks/go.mod @@ -195,7 +195,7 @@ require ( google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect - google.golang.org/grpc v1.63.0 // indirect + google.golang.org/grpc v1.63.2 // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/modules/apps/callbacks/go.sum b/modules/apps/callbacks/go.sum index 2443adefd66..3ac3b263bdc 100644 --- a/modules/apps/callbacks/go.sum +++ b/modules/apps/callbacks/go.sum @@ -1646,8 +1646,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8= -google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= +google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= +google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= diff --git a/modules/core/02-client/keeper/keeper.go b/modules/core/02-client/keeper/keeper.go index 6d33183b72b..4cd70f54287 100644 --- a/modules/core/02-client/keeper/keeper.go +++ b/modules/core/02-client/keeper/keeper.go @@ -83,8 +83,8 @@ func (k Keeper) UpdateLocalhostClient(ctx sdk.Context, clientState exported.Clie return clientModule.UpdateState(ctx, exported.LocalhostClientID, nil) } -// SetSelfConsensusHost sets a custom ConsensusHost for self client state and consensus state validation. -func (k *Keeper) SetSelfConsensusHost(consensusHost types.ConsensusHost) { +// SetConsensusHost sets a custom ConsensusHost for self client state and consensus state validation. +func (k *Keeper) SetConsensusHost(consensusHost types.ConsensusHost) { if consensusHost == nil { panic(fmt.Errorf("cannot set a nil self consensus host")) } diff --git a/modules/core/03-connection/keeper/handshake_test.go b/modules/core/03-connection/keeper/handshake_test.go index 5632e924790..77ce7f3f685 100644 --- a/modules/core/03-connection/keeper/handshake_test.go +++ b/modules/core/03-connection/keeper/handshake_test.go @@ -233,7 +233,7 @@ func (suite *KeeperTestSuite) TestConnOpenTry() { }, } - suite.chainB.App.GetIBCKeeper().ClientKeeper.SetSelfConsensusHost(&mockValidator) + suite.chainB.App.GetIBCKeeper().SetConsensusHost(&mockValidator) }, false}, } diff --git a/modules/core/04-channel/keeper/packet.go b/modules/core/04-channel/keeper/packet.go index c7d12d6dfe7..3a8928a2044 100644 --- a/modules/core/04-channel/keeper/packet.go +++ b/modules/core/04-channel/keeper/packet.go @@ -69,6 +69,10 @@ func (k Keeper) SendPacket( } latestHeight := k.clientKeeper.GetClientLatestHeight(ctx, connectionEnd.ClientId) + if latestHeight.IsZero() { + return 0, errorsmod.Wrapf(clienttypes.ErrInvalidHeight, "cannot send packet using client (%s) with zero height", connectionEnd.ClientId) + } + latestTimestamp, err := k.clientKeeper.GetClientTimestampAtHeight(ctx, connectionEnd.ClientId, latestHeight) if err != nil { return 0, err diff --git a/modules/core/04-channel/keeper/packet_test.go b/modules/core/04-channel/keeper/packet_test.go index 7fe6fe83fca..91cf13337ae 100644 --- a/modules/core/04-channel/keeper/packet_test.go +++ b/modules/core/04-channel/keeper/packet_test.go @@ -145,7 +145,24 @@ func (suite *KeeperTestSuite) TestSendPacket() { channelCap = suite.chainA.GetChannelCapability(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) }, false}, + {"client state zero height", func() { + path.Setup() + sourceChannel = path.EndpointA.ChannelID + + connection := path.EndpointA.GetConnection() + clientState := path.EndpointA.GetClientState() + cs, ok := clientState.(*ibctm.ClientState) + suite.Require().True(ok) + + // force a consensus state into the store at height zero to allow client status check to pass. + consensusState := path.EndpointA.GetConsensusState(cs.LatestHeight) + path.EndpointA.SetConsensusState(consensusState, clienttypes.ZeroHeight()) + + cs.LatestHeight = clienttypes.ZeroHeight() + suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), connection.ClientId, cs) + channelCap = suite.chainA.GetChannelCapability(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID) + }, false}, {"timeout height passed", func() { path.Setup() sourceChannel = path.EndpointA.ChannelID diff --git a/modules/core/keeper/keeper.go b/modules/core/keeper/keeper.go index 093c8313e9b..2c5ffcee2b7 100644 --- a/modules/core/keeper/keeper.go +++ b/modules/core/keeper/keeper.go @@ -2,6 +2,7 @@ package keeper import ( "errors" + "fmt" "reflect" "strings" @@ -80,6 +81,15 @@ func (k Keeper) Codec() codec.BinaryCodec { return k.cdc } +// SetConsensusHost sets a custom ConsensusHost for self client state and consensus state validation. +func (k *Keeper) SetConsensusHost(consensusHost clienttypes.ConsensusHost) { + if consensusHost == nil { + panic(fmt.Errorf("cannot set a nil self consensus host")) + } + + k.ClientKeeper.SetConsensusHost(consensusHost) +} + // SetRouter sets the Router in IBC Keeper and seals it. The method panics if // there is an existing router that's already sealed. func (k *Keeper) SetRouter(rtr *porttypes.Router) { diff --git a/modules/light-clients/07-tendermint/consensus_host_test.go b/modules/light-clients/07-tendermint/consensus_host_test.go index 7c79815ea22..bb2f03d5b1b 100644 --- a/modules/light-clients/07-tendermint/consensus_host_test.go +++ b/modules/light-clients/07-tendermint/consensus_host_test.go @@ -51,7 +51,7 @@ func (suite *TendermintTestSuite) TestGetSelfConsensusState() { return nil, mock.MockApplicationCallbackError }, } - suite.chainA.GetSimApp().GetIBCKeeper().ClientKeeper.SetSelfConsensusHost(consensusHost) + suite.chainA.GetSimApp().GetIBCKeeper().SetConsensusHost(consensusHost) }, expError: mock.MockApplicationCallbackError, }, @@ -63,7 +63,7 @@ func (suite *TendermintTestSuite) TestGetSelfConsensusState() { return &solomachine.ConsensusState{}, nil }, } - suite.chainA.GetSimApp().GetIBCKeeper().ClientKeeper.SetSelfConsensusHost(consensusHost) + suite.chainA.GetSimApp().GetIBCKeeper().SetConsensusHost(consensusHost) }, expError: nil, }, @@ -153,7 +153,7 @@ func (suite *TendermintTestSuite) TestValidateSelfClient() { } // add mock validation logic - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetSelfConsensusHost(smConsensusHost) + suite.chainA.App.GetIBCKeeper().SetConsensusHost(smConsensusHost) }, expError: nil, }, diff --git a/modules/light-clients/08-wasm/go.mod b/modules/light-clients/08-wasm/go.mod index a347d533077..115854731d2 100644 --- a/modules/light-clients/08-wasm/go.mod +++ b/modules/light-clients/08-wasm/go.mod @@ -35,7 +35,7 @@ require ( github.com/spf13/viper v1.18.2 github.com/stretchr/testify v1.9.0 google.golang.org/genproto/googleapis/api v0.0.0-20240227224415-6ceb2ff114de - google.golang.org/grpc v1.63.0 + google.golang.org/grpc v1.63.2 ) require ( diff --git a/modules/light-clients/08-wasm/go.sum b/modules/light-clients/08-wasm/go.sum index 99585381cb7..e01c7231918 100644 --- a/modules/light-clients/08-wasm/go.sum +++ b/modules/light-clients/08-wasm/go.sum @@ -1648,8 +1648,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.63.0 h1:WjKe+dnvABXyPJMD7KDNLxtoGk5tgk+YFWN6cBWjZE8= -google.golang.org/grpc v1.63.0/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= +google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM= +google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= diff --git a/modules/light-clients/08-wasm/types/consensus_host_test.go b/modules/light-clients/08-wasm/types/consensus_host_test.go index f6249f382cf..f190cb2d164 100644 --- a/modules/light-clients/08-wasm/types/consensus_host_test.go +++ b/modules/light-clients/08-wasm/types/consensus_host_test.go @@ -60,9 +60,7 @@ func (suite *TypesTestSuite) TestGetSelfConsensusState() { consensusHost, err = types.NewWasmConsensusHost(suite.chainA.Codec, consensusHost) suite.Require().NoError(err) - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetSelfConsensusHost( - consensusHost, - ) + suite.chainA.App.GetIBCKeeper().SetConsensusHost(consensusHost) cs, err := suite.chainA.App.GetIBCKeeper().ClientKeeper.GetSelfConsensusState(suite.chainA.GetContext(), height) @@ -134,9 +132,7 @@ func (suite *TypesTestSuite) TestValidateSelfClient() { consensusHost, err = types.NewWasmConsensusHost(suite.chainA.Codec, consensusHost) suite.Require().NoError(err) - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetSelfConsensusHost( - consensusHost, - ) + suite.chainA.App.GetIBCKeeper().ClientKeeper.SetConsensusHost(consensusHost) err = suite.chainA.App.GetIBCKeeper().ClientKeeper.ValidateSelfClient(suite.chainA.GetContext(), clientState)