add is frozen client state check to send packet (#7957)
Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
parent
e93b18e60e
commit
0647d897f5
@ -67,6 +67,11 @@ func (k Keeper) SendPacket(
|
||||
return clienttypes.ErrConsensusStateNotFound
|
||||
}
|
||||
|
||||
// prevent accidental sends with clients that cannot be updated
|
||||
if clientState.IsFrozen() {
|
||||
return sdkerrors.Wrapf(clienttypes.ErrClientFrozen, "cannot send packet on a frozen client with ID %s", connectionEnd.GetClientID())
|
||||
}
|
||||
|
||||
// check if packet timeouted on the receiving chain
|
||||
latestHeight := clientState.GetLatestHeight()
|
||||
timeoutHeight := packet.GetTimeoutHeight()
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/core/04-channel/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/core/exported"
|
||||
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/07-tendermint/types"
|
||||
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
|
||||
ibcmock "github.com/cosmos/cosmos-sdk/x/ibc/testing/mock"
|
||||
)
|
||||
@ -111,6 +112,22 @@ func (suite *KeeperTestSuite) TestSendPacket() {
|
||||
packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp)
|
||||
channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID)
|
||||
}, false},
|
||||
{"client state is frozen", func() {
|
||||
_, _, connA, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
|
||||
|
||||
connection := suite.chainA.GetConnection(connA)
|
||||
clientState := suite.chainA.GetClientState(connection.ClientId)
|
||||
cs, ok := clientState.(*ibctmtypes.ClientState)
|
||||
suite.Require().True(ok)
|
||||
|
||||
// freeze client
|
||||
cs.FrozenHeight = clienttypes.NewHeight(0, 1)
|
||||
suite.chainA.App.IBCKeeper.ClientKeeper.SetClientState(suite.chainA.GetContext(), connection.ClientId, cs)
|
||||
|
||||
packet = types.NewPacket(validPacketData, 1, channelA.PortID, channelA.ID, channelB.PortID, channelB.ID, timeoutHeight, disabledTimeoutTimestamp)
|
||||
channelCap = suite.chainA.GetChannelCapability(channelA.PortID, channelA.ID)
|
||||
}, false},
|
||||
|
||||
{"timeout height passed", func() {
|
||||
clientA, _, _, _, channelA, channelB := suite.coordinator.Setup(suite.chainA, suite.chainB, types.UNORDERED)
|
||||
// use client state latest height for timeout
|
||||
|
||||
Loading…
Reference in New Issue
Block a user