-
Notifications
You must be signed in to change notification settings - Fork 616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: add UpgradeChain and UpgradeClient endpoint test functions #1169
Conversation
add UpgradeChain to upgrade a testing chain to a new revision number add UpgradeClient to submit a MsgUpgradeClient to the client associated with an endpoint
testing/endpoint.go
Outdated
@@ -492,6 +493,85 @@ func (endpoint *Endpoint) TimeoutOnClose(packet channeltypes.Packet) error { | |||
return endpoint.Chain.sendMsgs(timeoutOnCloseMsg) | |||
} | |||
|
|||
// UpgradeChain performs a IBC client upgrade using the provided client state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mega nit: an IBC
testing/endpoint.go
Outdated
if endpoint.Counterparty.ClientID != "" { | ||
|
||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops, forgot to add endpoint.UpgradeClient
call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Super useful, just left one question :)
testing/endpoint.go
Outdated
endpoint.Chain.GetSimApp().UpgradeKeeper.SetUpgradedClient(endpoint.Chain.GetContext(), endpoint.Chain.GetContext().BlockHeight(), bz) | ||
|
||
// set upgraded consensus state | ||
consensusState := &ibctmtypes.ConsensusState{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to include a root/app hash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, the consensus state is set for the next block to be produced under the new chain id so the root hash cannot be known before hand
testing/endpoint.go
Outdated
// UpgradeChain performs a IBC client upgrade using the provided client state. | ||
// The chainID within the client state will have its revision number incremented by 1. | ||
// The counterparty client will be upgraded if it exists. | ||
func (endpoint *Endpoint) UpgradeChain(clientState *ibctmtypes.ClientState) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be useful to pass revision number as a parameter rather than incrementing 🤔
@@ -44,6 +44,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ | |||
|
|||
### Improvements | |||
|
|||
* (testing) [\#1169](https://github.com/cosmos/ibc-go/pull/1169) Add `UpgradeChain` and `UpgradeClient` helper functions to the testing `Endpoint` structure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo, update changelog entry
…s/ibc-go into colin/upgrade-testing-helper-funcs
It took me a while, but I mostly understand the issue here. It is very nuanced. ref https://github.com/cosmos/cosmos-sdk/pull/8187/files#discussion_r545757275 Note: So tendermint process is:
the testing package does things out of order
in most situations it doesn't matter because we never verify functionality between Normally I'd fix this issue in my specific instance by actually doing tm process for the upgrade
The problem is In other words, the testing package in order to be useful needs to be able to modify state during block execution (beginblock must be called). We could be more explicit with checktx vs delivertx usage for context (all queries use checktx) Quickly modifying my code to do this, I still run into
Edit: I got the tests to pass |
I fixed the tests, but it currently requires a few hacks:
I think it might be best to change the testing package to more elegantly mock the TM process before merging these changes, but I think this pr is very useful in understanding how things work. In the short term, on the 02-client-refactor branch we can add a testing helper function which simply sets the lastest client/consensus state to be after the upgrade (bypassing the actual verification of such an upgrade) |
Description
Adds:
UpgradeChain
is a helper function to test upgrading a chain to a different revision number. It will change the testing chain's revision number and set the associated client/consensus states in state. It does not use upgrade plan's, though we can modify this behaviour in the futureUpgradeClient
submits aMsgUpgradeClient
using the upgraded client and consensus states set on the counterparty chaincloses: #XXXX
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes