-
Notifications
You must be signed in to change notification settings - Fork 61
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
!upgrade: Cosmos SDK to v0.50.x, ibc v8 #1060
Conversation
…g and maybe this is the upgrade branch)
…e/quicksilver into tuan/upgrade-sdk-v0.50.x
hey @tropicaldog -- nice work here -- btw here's the v50 upgrade for lens, which is a dependency of quicksilver: |
@tropicaldog FYI it's become known that comet v0.38.0 - v0.38.4 just plain don't work, so I have bumped those dependencies. If you're looking for some guidance here, basically, I would say that we should try and:
|
hey @tropicaldog -- if you were wondering why nothing you did could fix it, please know that all of the issues you've been facing come from upstream. v0.38.3 was a build of comet fraught with issues and it's now been retracted. |
@faddat do you think it's good idea to postpone the upgrade and wait a little bit until the upstream code is more mature? |
But yes but we should prepare the upgrade anyway. That will actually help us learn a bit more about the maturity of the code base. So basically we can think about the next steps in segments. First of all we have to make it so that the chain runs from the binary that we produce, secondly we need to figure out tests. Thirdly, we need to write the upgrade handler. It's pretty important to us to get this upgrade finished relatively rapidly, and I believe that the problem with comet 38 is actually related to vote extensions. I have been working with the bera chain team about these issues. So to answer your question, yes we definitely want to wait until it's more mature but also no we don't want to wait because then we might wait forever. So let's do our best to get the upgrade prepared and all of us will monitor the upstream situation because you're absolutely not wrong the upstream situation is a little weird. This makes sense to you? |
Well look you got a gift in the form of merge conflicts. Let's try and work through these together |
@faddat yeah these protobuf files will certainly be diverging from the main branch at some point, so not really a big deal I guess. |
Basically we want to always merge from main so that we are working against the latest code from the main branch. |
Overview
Closes #941
This upgrade bumps the project's SDK to version v0.50.3, IBC to v8 but does not supposed to introduce any changes to existing application functionality. This document outlines the major areas of change and their impact.
Current issues
High-level Changes
Bump Cosmos SDK from v0.46.16 to v0.50.3
Bumping IBC from v5 to v8
Refactor modules to match new SDK syntax
Update both quicksilver and third-party proto-file to use newer libraries.
Migrate deprecated methods from older SDK to quicksilver
Detailed Changes
App folder
Basic Module Manager
Remove app.RegisterRoutes
Remove the need to passing encodingConfig to NewQuicksilver, just create both Codec and LegacyAmino inside the function body
quicksilver/app/app.go
Lines 532 to 551 in 0bec6c1
Cmd folder
Refactor based on the change on App folder, see detail on the https://github.com/quicksilver-zone/quicksilver/pull/1060/files#diff-b648a0ba5f73d63678f411584d6e97f8413a398ea4e50232311650b7f6b53ba1
Wasmbinding folder
Use NewMsgSubmitProposal to submit the MsgStoreCode
quicksilver/wasmbinding/test/custom_query_test.go
Lines 116 to 129 in 5393bba
Proto files
Quicksilver protos
Thirdparty protos
Overall, the changes are:
+ Gas datatype: from cosmos-sdktypes.Gas to plain uint64, since SDK50 removed Gas types
+ cosmos-sdktypes Dec and Int are replaced with cosmossdk.io/math LegacyDec and Int
+ fileDescriptor value are changed
Third party protos file(*.pb.go) are updated, generated by cloning the original changes, change their proto to use newer cosmos sdk math and gogoproto libraries to their protos, then generate pb.go files using protocgen.sh scripts. Finally, move the newly generated proto files to Quicksilver repos, and make some required changes.
Utility files
Migrated deprecated SDK46 banktypes method to quicksilver "bankutils" packages
utils/bankutils/bank.go, not sure if it is correct way to handle the deprecated stuffs, I just want to keep the old functionality.
Modules changes
Overview
The Module changes section is for describing the changes in each module
Since we update the SDK version to v0.50, all modules need to follow the change accordingly. So, most of the changes are just replace types.math-> cosmossdk.io/Math, Dec->LegacyDec, cosmos-sdk/stores->seperate stores packages. These changes are pretty trivial, so it won't be discussed in detailed
x/airdrop
Current status: In progress, some tests has not beed fixed/logic not refactored
No notable changes
x/claimsmanager
Current status: In Review
Similar to x/airdrop changes, but no existing bugs remain.
x/interchainquery
Current status: In Review
No notable changes, similar changes to x/airdrop
x/interchainstaking
client folder
Current status: In review
No notable changes
keeper folder
Current status: In review
a major change is introduced. I bring the x/auth txBuilder to the quicksilver repo, in order to construct a valid sdk.Tx from msgs. https://github.com/quicksilver-zone/quicksilver/pull/1060/files#diff-c0cf771f814c0fd6ba394ed186f92fd959d422f61279ec57aba38cc8ef83372b
since sdk.TxDecoder now return sdk.Tx, so isn't able to return tx.Tx anymore
https://github.com/cosmos/cosmos-sdk/blob/7685abb8857773c147b7ba49496e8b9b06d13c0d/x/auth/tx/decoder.go
I constructed the Tx using the new TxBuilder, and the tests seems to work nicely with the tests: https://github.com/quicksilver-zone/quicksilver/blob/tuan/upgrade-sdk-v0.50.x/x/interchainstaking/keeper/receipt_test.go#L146-L155
x/lsmtypes
Status: In review, test passed
No significant changes.
Detail changes: https://github.com/quicksilver-zone/quicksilver/pull/1060/files#diff-ace71f7aadb021f0ed0cabb67986e08b4ba90919b1733d397534760efbb67052
x/mint
Status: In review, test passed
No significant changes
https://github.com/quicksilver-zone/quicksilver/pull/1060/files#diff-97ab51578583f8ac4f726ae9ea3c6f6496483d85b488a0b37546accc310a87aa
x/participantsreward
Status: In review, test passed
using bankutils as replacement of SDK46 banktypes methods
Overall, still just changes similar to above modules.
x/supply
Status: In review, test passed
No significant changes
x/tokenfactory
Status: In review, test passed
No significant changes
Current issues
Wasmbindings
Currently, I am not able to fix some of the tests due to newer wasmtypesUpdate(24 Jan): fixed in 5393bba
Updated changes in the Detailed Changes section
Utilities Files
utils/proofs.go
This line doesn't work anymore, and I haven't figured an alternative method to this
x/airdrop
x/airdrop/claim_handler.go
Currently the way we iterate through proposals:
In SDK 50 they don't support the IterateProposals anymore, docsThey said that the state of gov modules is now managed by the Collection API, but I haven't figured a way to access the collections. cosmos/cosmos-sdk#16171In the gov tests of Cosmos SDK, they access the Proposal field of govKeeper directly, but not sure how we could achieve the same thing, proposal_test.goUpdate(24 Jan): Fixed in e0b669b, need review @joe-bowman @faddat
x/interchainstaking
Not sure why the testchain generated using setupTestZone always has the "-1" at the end, so I need to modify some tests. for example "testchain2" -> "testchain2-1", not sure if it is my fault or some changes in the IBC library
x/interchainstaking/zones_test.go
Now, when the types.Zone is initialize like this
then the RedemptionRate, the LastRedemptionRate and the Tvl value, which is all sdkmath.LegacyDec types, is stored as *big.Int(nil). But when it is stored and retrieved from the store, it is store in a different way.
I resolve this by initialize it in the test
but not sure if this issue would cause any problem in production
icq-relayer
After bumping ibc-go to v8, a problem arise, that the MsgUpdateClient doesn't have Header anymore, and also the
PackHeader
andUnpackHeader
method also been removed from theclienttypes
package. Haven't figured out a way to fix it yethttps://github.com/quicksilver-zone/quicksilver/blob/main/icq-relayer/pkg/runner/run.go#L639-L649
Final thoughts
Most of the bugs I encountered during fixing the code is because the required module isn't properly registered, under new Cosmos SDK. The tests are very helpful to catch these kind of bugs, and also comparing the app initialization code from both https://github.com/CosmWasm/wasmd/blob/main/app/app.go and https://github.com/cosmos/ibc-go/blob/v8.0.0/testing/simapp/app.go prove to be very helpful for my upgrade process