Skip to content
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

[CORE-538] Upgrade to Cosmos 0.50.1 and CometBFT 0.38 #867

Merged
merged 20 commits into from
Jan 4, 2024
Merged

Conversation

lcwik
Copy link
Contributor

@lcwik lcwik commented Dec 8, 2023

Changelist

Update to Cosmos 0.50.1 and CometBFT 0.38

Test Plan

Updated existing tests, some tests have been skipped or partially disabled with TODO tags added.

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Copy link
Contributor

coderabbitai bot commented Dec 8, 2023

Important

Auto Review Skipped

More than 25% of the files skipped due to max files limit. Skipping review to prevent low quality review.

214 files out of 296 files are above the max files limit of 75.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit's AI:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid.
    • @coderabbitai read the files in the src/scheduler package and generate README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@lcwik lcwik changed the title Lukecore538 [CORE-538] Upgrade to Cosmos 0.50 and CometBFT 0.38 Dec 8, 2023
Copy link

linear bot commented Dec 8, 2023

@github-actions github-actions bot added the proto label Dec 13, 2023
@lcwik lcwik force-pushed the lukecore538 branch 11 times, most recently from 657e07a to 9c1980a Compare December 15, 2023 22:41
)

// Verify all signatures for a tx and return an error if any are invalid. Note,
// SigVerificationDecorator verifies all signatures for a tx and return an error if any are invalid. Note,
Copy link
Contributor Author

@lcwik lcwik Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was updated with the copy from Cosmo 0.50 with the SkipSequenceValidation changes ported over.

@@ -21,6 +29,28 @@ import (

func TestSigVerification(t *testing.T) {
Copy link
Contributor Author

@lcwik lcwik Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -48,6 +48,8 @@ var (
"/cosmos.distribution.v1beta1.CommunityPoolSpendProposal": {},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please double check that I grouped the new messages into the appropriate categories.

@@ -262,10 +261,22 @@
"threshold": "0.500000000000000000",
"veto_threshold": "0.334000000000000000",
"min_initial_deposit_ratio": "0.000000000000000000",
"proposal_cancel_ratio": "0.500000000000000000",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check and decide on new parameters, specifically governance.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should get product (Corey) and potentially research team involved if we are writing migration logic for this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To match the suggested staging/prod value, can you use the following?

Suggested change
"proposal_cancel_ratio": "0.500000000000000000",
"proposal_cancel_ratio": "1.0"
"proposal_cancel_dest": "",
"expedited_voting_period": "86400s",
"expedited_threshold": "0.75",
"expedited_min_deposit": [
{
"denom": "stake",
"amount": "50000000"
}
],
"burn_vote_quorum": false,
"burn_proposal_deposit_prevote": false,
"burn_vote_veto": true,
"min_deposit_ratio": "0.20"
},
"constitution": ""
},

@@ -64,7 +64,6 @@ func initAppConfig() (string, *DydxAppConfig) {

// GRPC.
appConfig.GRPC.Address = "0.0.0.0:9090"
appConfig.GRPCWeb.Address = "0.0.0.0:9091"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now runs under GRPC address with Cosmos 0.50

@@ -84,7 +83,6 @@ func initTendermintConfig() *tmcfg.Config {
cfg.RPC.CORSAllowedOrigins = []string{"*"}

// Mempool config.
cfg.Mempool.Version = "v1"
Copy link
Contributor Author

@lcwik lcwik Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mempool v1 is now gone, TTL changes were backported to v0

FeeGrantKeeper *antetestutil.MockFeegrantKeeper
EncCfg moduletestutil.TestEncodingConfig
}

// SetupTest setups a new test, with new app, context, and AnteHandler.
Copy link
Contributor Author

@lcwik lcwik Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated from Cosmos 0.50 with v4 specific changes.

@@ -68,6 +68,16 @@ var (
Amount: 500_000_000, // $500
},
}
Msg_Transfer_Invalid_SameSenderAndRecipient = &sendingtypes.MsgCreateTransfer{
Copy link
Contributor Author

@lcwik lcwik Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ValidateBasic is now expected to not be implemented and users should be simulating their transactions before submitting them which is why I swapped to a message where we control the message type explicitly.

See cosmos/cosmos-sdk#18750

@lcwik lcwik marked this pull request as ready for review December 15, 2023 22:50
@lcwik lcwik changed the title [CORE-538] Upgrade to Cosmos 0.50 and CometBFT 0.38 [CORE-538] Upgrade to Cosmos 0.50.1 and CometBFT 0.38 Dec 15, 2023
@lcwik lcwik force-pushed the lukecore538 branch 3 times, most recently from d0c76b8 to 89ebd37 Compare December 18, 2023 19:44
Comment on lines +122 to +123
// TODO(CORE-538): Is there a cleaner way to check to see if this is genesis?
if ctx.BlockHeight() == 0 || ctx.BlockHeight() == 1 {
return
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for my understanding - why do we need to do this?

Copy link
Contributor Author

@lcwik lcwik Dec 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue that I ran into is for the first block is that there is no ProcessProposerMatches events during PrepareCheckState. Cosmos 0.47 didn't run PrepareCheckState for the genesis block while Cosmos 0.50 does.

So I keep the original behavior by skipping PrepareCheckState for the genesis block.

protocol/app/ante/sigverify_test.go Show resolved Hide resolved
protocol/app/ante/sigverify_test.go Show resolved Hide resolved
protocol/app/ante/sigverify_test.go Show resolved Hide resolved
protocol/app/ante/sigverify_test.go Show resolved Hide resolved
protocol/app/app.go Show resolved Hide resolved
@@ -59,8 +59,10 @@ func DecodeOtherMsgsTx(decoder sdk.TxDecoder, txBytes []byte) (*OtherMsgsTx, err
// Validate returns an error if one of the underlying msgs fails `ValidateBasic`.
func (omt *OtherMsgsTx) Validate() error {
for _, msg := range omt.msgs {
if err := msg.ValidateBasic(); err != nil {
return getValidateBasicError(msg, err)
if m, ok := msg.(sdk.HasValidateBasic); ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When do we NOT expect HasValidateBasic to be the case?

Should we handle else case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many of the Cosmos SDK messages have migrated away from using ValidateBasic which I filed cosmos/cosmos-sdk#18750 about. Cosmos SDK wants users to simulate their transactions to validate them instead of relying on ValidateBasic during CheckTx which is a change in expected user behavior going forward.

This is one of the points I brought up that we want to discuss in slack since this has ramifications to user experience.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking comment: what's the conclusion of this discussion?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conclusion was to simulate the transaction.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, nit: would you be able to add a comment explaining this?

protocol/app/process/process_proposal_test.go Outdated Show resolved Hide resolved
@@ -262,10 +261,22 @@
"threshold": "0.500000000000000000",
"veto_threshold": "0.334000000000000000",
"min_initial_deposit_ratio": "0.000000000000000000",
"proposal_cancel_ratio": "0.500000000000000000",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should get product (Corey) and potentially research team involved if we are writing migration logic for this

protocol/app/testdata/default_genesis_state.json Outdated Show resolved Hide resolved
@@ -98,9 +99,10 @@ func CreateUpgradeHandler(
configurator module.Configurator,
ak authkeeper.AccountKeeper,
) upgradetypes.UpgradeHandler {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as mentioned above, should we add the logic to init the new gov states? (i.e. expedited_voting_period)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can also add a ticket in appropriate P0 project. I'm following up on the default values here

@@ -48,6 +48,8 @@ message MsgDepositToSubaccount {
// MsgWithdrawFromSubaccount represents a single transfer from an
// `x/subaccounts` subaccount to an `x/bank` account.
message MsgWithdrawFromSubaccount {
option (cosmos.msg.v1.signer) = "sender";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that we are specifying the sender should be sender.owner in CustomGetSigner here.

Should we remove this option, given that sender is not a valid signer (i.e. it's not an address string)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cosmos SDK was meant to support these recursively but didn't do it quite right since sender is supposed to go into that message and then use owner to find the appropriate address string. I filed cosmos/cosmos-sdk#18722 and they have fixed this but it won't be available till a future Cosmos SDK release.

I'd like to leave this for now and once able we can remove the CustomGetSigners implementation.

@lcwik lcwik force-pushed the lukecore538 branch 2 times, most recently from e6c0d19 to ab6e05a Compare January 2, 2024 19:57
@@ -245,6 +248,7 @@ type App struct {
ParamsKeeper paramskeeper.Keeper
// IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
IBCKeeper *ibckeeper.Keeper
ICAControllerKeeper icacontrollerkeeper.Keeper
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we adding ICAControllerKeeper, for my understanding? For supporting interchain accounts we specifically wanted to avoid the controllerkeeper (context).

Copy link
Contributor Author

@lcwik lcwik Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ICAControllerKeeper is still disabled since Enabled is false in the upgrade (note the Enabled field is taking on the default value).

So instead of it being hard-coded disabled it is being disabled via parameters.

The simulation in IBC v8 expects that the controller module to exist otherwise the update params calls it generates fail with them being unroutable causing the sim tests to fail.

Copy link
Contributor

@teddyding teddyding Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of going with this approach, is it possible to simply exclude ICA module from simulation testing? Empirically, simulation testing is not very high signal for the dYdX chain, let alone a third-party module that is tested elsewhere.

We specifically preferred to explicitly disable (in code, instead of through gov-updatable params) the controller sub-module altogether to reduce surface of risk. This also eliminates the potential bugs in upgrade handler.

Simulation testing alone does not justify altering the original approach, IMO. Lmk if the above is possible and happy to huddle!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I swapped to exclude the interchainaccounts module from simulation as suggested.

protocol/app/app.go Show resolved Hide resolved
protocol/app/app.go Show resolved Hide resolved
protocol/app/app.go Show resolved Hide resolved
protocol/app/msgs/internal_msgs.go Outdated Show resolved Hide resolved
protocol/app/msgs/unsupported_msgs.go Outdated Show resolved Hide resolved
protocol/app/msgs/normal_msgs.go Show resolved Hide resolved
@@ -59,8 +59,10 @@ func DecodeOtherMsgsTx(decoder sdk.TxDecoder, txBytes []byte) (*OtherMsgsTx, err
// Validate returns an error if one of the underlying msgs fails `ValidateBasic`.
func (omt *OtherMsgsTx) Validate() error {
for _, msg := range omt.msgs {
if err := msg.ValidateBasic(); err != nil {
return getValidateBasicError(msg, err)
if m, ok := msg.(sdk.HasValidateBasic); ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking comment: what's the conclusion of this discussion?

protocol/app/module/interface_registry.go Outdated Show resolved Hide resolved
@lcwik
Copy link
Contributor Author

lcwik commented Jan 4, 2024

@ttl33 I couldn't comment on some of your comments for some reason so I commented here.

Would merging this PR make the main branch to be in a broken state? For example, if the route for the upgrade is not > registered, then upgrade via gov wouldn't work.

If there are no easy ways to resolve this in this PR, then I am okay. Just wanted to call out that we wanted to keep main always deployable and releasable.

We should be upgrading from the release branch with patches and backporting any fixes to it that need to be released immediately. There is no easy way to resolve this without implementing even more and this PR has been delayed due to RC0 and peoples vacation schedules so I want to get it in finally and not waste more time rebasing constantly.

Blocking comment: what's the conclusion of this discussion?

To rely on simulating transactions since CheckTx only does some of the work to validate things.

For MsgRecoverClient: yes, I think we should keep this in normal. This is because anyone should be able to submit the gov proposal to recover a client. See doc/comments here

For MsgIBCSoftwareUpgrade, yes, I also think we should keep this in normal. This is because it's replacing the MsgUpgradeClient which was the proposal submitted by users to upgrade.

Should we then move MsgUpdateClient and MsgUpgradeClient (note update vs upgrade here) to unsupported ones?

I added a TODO to handle this once I figure out how to get the upgrades done.

@@ -59,8 +59,10 @@ func DecodeOtherMsgsTx(decoder sdk.TxDecoder, txBytes []byte) (*OtherMsgsTx, err
// Validate returns an error if one of the underlying msgs fails `ValidateBasic`.
func (omt *OtherMsgsTx) Validate() error {
for _, msg := range omt.msgs {
if err := msg.ValidateBasic(); err != nil {
return getValidateBasicError(msg, err)
if m, ok := msg.(sdk.HasValidateBasic); ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, nit: would you be able to add a comment explaining this?

@@ -262,10 +261,22 @@
"threshold": "0.500000000000000000",
"veto_threshold": "0.334000000000000000",
"min_initial_deposit_ratio": "0.000000000000000000",
"proposal_cancel_ratio": "0.500000000000000000",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To match the suggested staging/prod value, can you use the following?

Suggested change
"proposal_cancel_ratio": "0.500000000000000000",
"proposal_cancel_ratio": "1.0"
"proposal_cancel_dest": "",
"expedited_voting_period": "86400s",
"expedited_threshold": "0.75",
"expedited_min_deposit": [
{
"denom": "stake",
"amount": "50000000"
}
],
"burn_vote_quorum": false,
"burn_proposal_deposit_prevote": false,
"burn_vote_veto": true,
"min_deposit_ratio": "0.20"
},
"constitution": ""
},

@lcwik lcwik merged commit f08e61a into main Jan 4, 2024
23 of 24 checks passed
@lcwik lcwik deleted the lukecore538 branch January 4, 2024 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

6 participants