From 4a13f11f431f03208cce8ce8cf0aa635fedf460e Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Thu, 5 Sep 2024 18:02:18 +0200 Subject: [PATCH 1/3] some improvements --- docs/docs/05-migrations/13-v8-to-v9.md | 79 ++++++++++++++++--- .../core/04-channel/keeper/handshake_test.go | 3 +- testing/endpoint.go | 2 +- 3 files changed, 68 insertions(+), 16 deletions(-) diff --git a/docs/docs/05-migrations/13-v8-to-v9.md b/docs/docs/05-migrations/13-v8-to-v9.md index ad93bcb1e06..32ab4844320 100644 --- a/docs/docs/05-migrations/13-v8-to-v9.md +++ b/docs/docs/05-migrations/13-v8-to-v9.md @@ -91,8 +91,8 @@ func NewKeeper( ### 03-connection -- The [functions `GetState()`, `GetClientID()`, `GetCounterparty()`, `GetVersions()`, and `GetDelayPeriod()`](https://github.com/cosmos/ibc-go/blob/v8.0.0/modules/core/03-connection/types/connection.go#L25-L48) of the `Connection` type have been removed. -- The [functions `GetClientID()`, `GetConnectionID()`, and `GetPrefix()`](https://github.com/cosmos/ibc-go/blob/v8.0.0/modules/core/03-connection/types/connection.go#L79-L92) of the `Counterparty` type have been removed. +- The [functions `GetState()`, `GetClientID()`, `GetCounterparty()`, `GetVersions()`, and `GetDelayPeriod()`](https://github.com/cosmos/ibc-go/blob/v8.0.0/modules/core/03-connection/types/connection.go#L25-L48) of the `Connection` type have been removed. Please access the fields directly. +- The [functions `GetClientID()`, `GetConnectionID()`, and `GetPrefix()`](https://github.com/cosmos/ibc-go/blob/v8.0.0/modules/core/03-connection/types/connection.go#L79-L92) of the `Counterparty` type have been removed. Please access the fields directly. #### Removal of self client and consensus state from connection handshake @@ -133,7 +133,7 @@ func NewMsgConnectionOpenAck( ### 04-channel - The utility function [`QueryLatestConsensusState`](https://github.com/cosmos/ibc-go/blob/v8.0.0/modules/core/04-channel/client/utils/utils.go#L130) of the CLI has been removed. -- The [functions `GetState()`, `GetOrdering()`, `GetCounterparty()`, `GetConnectionHops()`, `GetVersion()`](https://github.com/cosmos/ibc-go/blob/v8.0.0/modules/core/04-channel/types/channel.go#L29-L52) of the `Channel` type have been removed. +- The [functions `GetState()`, `GetOrdering()`, `GetCounterparty()`, `GetConnectionHops()`, `GetVersion()`](https://github.com/cosmos/ibc-go/blob/v8.0.0/modules/core/04-channel/types/channel.go#L29-L52) of the `Channel` type have been removed. Please access the fields directly. - The [functions `IsOpen()` and `IsClosed()`](https://github.com/cosmos/ibc-go/blob/v8.0.0/modules/core/04-channel/types/channel.go#L54-L62) of the `Channel` type have been removed. - The [functions `GetPortID()`, `GetChannelID()`](https://github.com/cosmos/ibc-go/blob/v8.0.0/modules/core/04-channel/types/channel.go#L92-L100) of the `CounterpartyChannel` type have been removed. - Functions [`ChanCloseConfirmWithCounterpartyUpgradeSequence`](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/handshake.go#L446) and [`TimeoutOnCloseWithCounterpartyUpgradeSequence`](https://github.com/cosmos/ibc-go/blob/v8.1.0/modules/core/04-channel/keeper/timeout.go#L226) have been removed. Please use `ChanCloseConfirm` and `TimeoutOnClose` with the updated signature that takes the counterparty upgrade sequence as extra argument: @@ -146,7 +146,7 @@ func (k *Keeper) ChanCloseConfirm( chanCap *capabilitytypes.Capability, initProof []byte, proofHeight exported.Height, -+ counterpartyUpgradeSequence uint64, ++ counterpartyUpgradeSequence uint64, ) func (k *Keeper) TimeoutOnClose( @@ -157,7 +157,7 @@ func (k *Keeper) TimeoutOnClose( closedProof []byte, proofHeight exported.Height, nextSequenceRecv uint64, -+ counterpartyUpgradeSequence uint64, ++ counterpartyUpgradeSequence uint64, ) ``` @@ -392,6 +392,51 @@ type ContractKeeper interface { ### IBC testing package +- In the `TestChain` struct the field [`LastHeader`](https://github.com/cosmos/ibc-go/blob/v8.0.0/testing/chain.go#L59) has been renamed to `LatestCommittedHeader`, the field [`CurrentHeader`](https://github.com/cosmos/ibc-go/blob/v8.0.0/testing/chain.go#L60) has been renamed to `ProposedHeader` and the [`QueryServer` interface](https://github.com/cosmos/ibc-go/blob/v8.0.0/testing/chain.go#L61) has been removed. + +```diff +type TestChain struct { + testing.TB + + Coordinator *Coordinator + App TestingApp + ChainID string +- LastHeader *ibctm.Header // header for last block height committed ++ LatestCommittedHeader *ibctm.Header // header for last block height committed +- CurrentHeader cmtproto.Header // header for current block height ++ ProposedHeader cmtproto.Header // proposed (uncommitted) header for current block height +- QueryServer types.QueryServer + TxConfig client.TxConfig + Codec codec.Codec + + Vals *cmttypes.ValidatorSet + NextVals *cmttypes.ValidatorSet + + // Signers is a map from validator address to the PrivValidator + // The map is converted into an array that is the same order as the validators right before signing commit + // This ensures that signers will always be in correct order even as validator powers change. + // If a test adds a new validator after chain creation, then the signer map must be updated to include + // the new PrivValidator entry. + Signers map[string]cmttypes.PrivValidator + + // autogenerated sender private key + SenderPrivKey cryptotypes.PrivKey + SenderAccount sdk.AccountI + + SenderAccounts []SenderAccount + + // Short-term solution to override the logic of the standard SendMsgs function. + // See issue https://github.com/cosmos/ibc-go/issues/3123 for more information. + SendMsgsOverride func(msgs ...sdk.Msg) (*abci.ExecTxResult, error) +} +``` + +Submodule query servers can be constructed directly by passing their associated keeper to the appropriate constructor function. For example: + +```golang +clientQueryServer := clientkeeper.NewQueryServer(app.IBCKeeper.ClientKeeper) +``` + - The `mock.PV` type has been removed in favour of [`cmttypes.MockPV`](https://github.com/cometbft/cometbft/blob/v0.38.5/types/priv_validator.go#L50) in [#5709](https://github.com/cosmos/ibc-go/pull/5709). - [Functions `ConstructUpdateTMClientHeader` and `ConstructUpdateTMClientHeaderWithTrustedHeight`](https://github.com/cosmos/ibc-go/blob/v8.0.0/testing/chain.go#L446-L481) of `TestChain` type have been replaced with `IBCClientHeader` function. This function will construct a 07-tendermint header to update the light client on the counterparty chain. The trusted height must be passed in as a non-zero height. - [`GetValsAtHeight`](https://github.com/cosmos/ibc-go/blob/v8.0.0/testing/chain.go#L401) has been renamed to [`GetTrustedValidators`](https://github.com/cosmos/ibc-go/blob/release/v9.0.x/testing/chain.go#L403). @@ -412,12 +457,6 @@ func AssertEvents( ) ``` -- The [`QueryServer` interface has been removed from the `TestChain` struct](https://github.com/cosmos/ibc-go/blob/v8.0.0/testing/chain.go#L61). Submodule query servers can be constructed directly by passing their associated keeper to the appropriate constructor function. For example: - -```golang -clientQueryServer := clientkeeper.NewQueryServer(app.IBCKeeper.ClientKeeper) -``` - - The signature of the function `QueryConnectionHandshakeProof` has changed, since the validation of self client and consensus state has been remove from the connection handshake: ```diff @@ -431,9 +470,10 @@ func (endpoint *Endpoint) QueryConnectionHandshakeProof() ( - The functions [`GenerateClientStateProof` and `GenerateConsensusStateProof`](https://github.com/cosmos/ibc-go/blob/v8.0.0/testing/solomachine.go#L513-L547) have been removed. -### API deprecation notice +#### API deprecation notice -- The testing package functions `Setup`, `SetupClients`, `SetupConnections`, `CreateConnections`, and `CreateChannels` of the `Coordinator` type have been deprecated and will be removed in v10. Please use the new functions `Setup`, `SetupClients`, `SetupConnections`, `CreateConnections`, `CreateChannels` of the `Path` type. +- The functions `Setup`, `SetupClients`, `SetupConnections`, `CreateConnections`, and `CreateChannels` of the `Coordinator` type have been deprecated and will be removed in v11. Please use the new functions `Setup`, `SetupClients`, `SetupConnections`, `CreateConnections`, `CreateChannels` of the `Path` type. +- The function `SetChannelState` of the `Path` type has been deprecated and will be removed in v11. Please use the new function `UpdateChannel` of the `Path` type. ## Relayers @@ -441,6 +481,19 @@ have been removed. #### 02-client +- The function `CreateClient` of the keeper expects now a string for the client type (e.g. `07-tendermint`) and two `[]byte` for the Protobuf-serialized client and consensus states: + +```diff +func (k *Keeper) CreateClient( + ctx sdk.Context, ++ clientType string, +- clientState exported.ClientState, +- consensusState exported.ConsensusState, ++ clientState []byte, ++ consensusState []byte, +) (string, error) +``` + - The [`header` attribute](https://github.com/cosmos/ibc-go/blob/v8.0.0/modules/core/02-client/keeper/events.go#L60) has been removed from the `update_client` event in [\#5110](https://github.com/cosmos/ibc-go/pull/5110). #### 04-channel diff --git a/modules/core/04-channel/keeper/handshake_test.go b/modules/core/04-channel/keeper/handshake_test.go index 96b0bb74ded..4ed5b5abbd6 100644 --- a/modules/core/04-channel/keeper/handshake_test.go +++ b/modules/core/04-channel/keeper/handshake_test.go @@ -572,8 +572,7 @@ func (suite *KeeperTestSuite) TestChanCloseConfirm() { {"success with upgrade info", func() { path.Setup() - err := path.EndpointA.SetChannelState(types.CLOSED) - suite.Require().NoError(err) + path.EndpointA.UpdateChannel(func(channel *types.Channel) { channel.State = types.CLOSED }) // add mock upgrade info to simulate that the channel is closing during // an upgrade and verify that the upgrade information is deleted diff --git a/testing/endpoint.go b/testing/endpoint.go index 1426a386261..5e71de994a1 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -776,7 +776,7 @@ func (endpoint *Endpoint) ChanUpgradeCancel() error { return endpoint.Chain.sendMsgs(msg) } -// Deprecated: usage of this function should be replaced by `UpdateChannelState` +// Deprecated: usage of this function should be replaced by `UpdateChannel` // SetChannelState sets a channel state func (endpoint *Endpoint) SetChannelState(state channeltypes.State) error { channel := endpoint.GetChannel() From a13b9d99c5c30a9bbf8f985f04db89549192d175 Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Thu, 5 Sep 2024 18:05:20 +0200 Subject: [PATCH 2/3] alignment --- docs/docs/05-migrations/13-v8-to-v9.md | 40 +++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/docs/docs/05-migrations/13-v8-to-v9.md b/docs/docs/05-migrations/13-v8-to-v9.md index 32ab4844320..61f3aa0e0fe 100644 --- a/docs/docs/05-migrations/13-v8-to-v9.md +++ b/docs/docs/05-migrations/13-v8-to-v9.md @@ -396,38 +396,38 @@ type ContractKeeper interface { ```diff type TestChain struct { - testing.TB + testing.TB - Coordinator *Coordinator - App TestingApp - ChainID string + Coordinator *Coordinator + App TestingApp + ChainID string - LastHeader *ibctm.Header // header for last block height committed + LatestCommittedHeader *ibctm.Header // header for last block height committed - CurrentHeader cmtproto.Header // header for current block height + ProposedHeader cmtproto.Header // proposed (uncommitted) header for current block height - QueryServer types.QueryServer - TxConfig client.TxConfig - Codec codec.Codec + TxConfig client.TxConfig + Codec codec.Codec - Vals *cmttypes.ValidatorSet - NextVals *cmttypes.ValidatorSet + Vals *cmttypes.ValidatorSet + NextVals *cmttypes.ValidatorSet // Signers is a map from validator address to the PrivValidator - // The map is converted into an array that is the same order as the validators right before signing commit - // This ensures that signers will always be in correct order even as validator powers change. - // If a test adds a new validator after chain creation, then the signer map must be updated to include - // the new PrivValidator entry. - Signers map[string]cmttypes.PrivValidator + // The map is converted into an array that is the same order as the validators right before signing commit + // This ensures that signers will always be in correct order even as validator powers change. + // If a test adds a new validator after chain creation, then the signer map must be updated to include + // the new PrivValidator entry. + Signers map[string]cmttypes.PrivValidator - // autogenerated sender private key - SenderPrivKey cryptotypes.PrivKey - SenderAccount sdk.AccountI + // autogenerated sender private key + SenderPrivKey cryptotypes.PrivKey + SenderAccount sdk.AccountI - SenderAccounts []SenderAccount + SenderAccounts []SenderAccount - // Short-term solution to override the logic of the standard SendMsgs function. - // See issue https://github.com/cosmos/ibc-go/issues/3123 for more information. - SendMsgsOverride func(msgs ...sdk.Msg) (*abci.ExecTxResult, error) + // Short-term solution to override the logic of the standard SendMsgs function. + // See issue https://github.com/cosmos/ibc-go/issues/3123 for more information. + SendMsgsOverride func(msgs ...sdk.Msg) (*abci.ExecTxResult, error) } ``` From 984e964633f959c8d8ca3bf376e5c4747497086e Mon Sep 17 00:00:00 2001 From: Carlos Rodriguez Date: Thu, 5 Sep 2024 18:10:38 +0200 Subject: [PATCH 3/3] more alignment --- docs/docs/05-migrations/13-v8-to-v9.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/05-migrations/13-v8-to-v9.md b/docs/docs/05-migrations/13-v8-to-v9.md index 61f3aa0e0fe..7b1dc0399db 100644 --- a/docs/docs/05-migrations/13-v8-to-v9.md +++ b/docs/docs/05-migrations/13-v8-to-v9.md @@ -401,11 +401,11 @@ type TestChain struct { Coordinator *Coordinator App TestingApp ChainID string -- LastHeader *ibctm.Header // header for last block height committed +- LastHeader *ibctm.Header // header for last block height committed + LatestCommittedHeader *ibctm.Header // header for last block height committed - CurrentHeader cmtproto.Header // header for current block height + ProposedHeader cmtproto.Header // proposed (uncommitted) header for current block height -- QueryServer types.QueryServer +- QueryServer types.QueryServer TxConfig client.TxConfig Codec codec.Codec