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

feat: add runtime Env to icacontroller and fix v0.52 e2e tests #7587

Merged
merged 34 commits into from
Dec 6, 2024

Conversation

damiannolan
Copy link
Member

@damiannolan damiannolan commented Nov 21, 2024

Description

Initially adding runtime Environment to ica to address events propagation issue with unwrapping context.
All tests seem to be now passing on this branch, except for some build err in e2e unit tests which we will address separately.

Update: E2E and unit tests passing on this branch. Issues created for follow up items.

ref: #7223


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.

  • Targeted PR against the correct branch (see CONTRIBUTING.md).
  • Linked to GitHub issue with discussion and accepted design, OR link to spec that describes this work.
  • Code follows the module structure standards and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/).
  • Added relevant godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

@damiannolan
Copy link
Member Author

Maybe we need to update linter versions or something in CI. Not sure what the arm64 build failure is too. Probably need to look into it

@damiannolan damiannolan changed the title feat: adding runtime Environment feat: adding runtime Environment to icacontroller Nov 25, 2024
@chatton chatton marked this pull request as ready for review November 27, 2024 12:02
@chatton chatton changed the title feat: adding runtime Environment to icacontroller [WIP] feat: adding runtime Environment to icacontroller Nov 27, 2024
@damiannolan
Copy link
Member Author

damiannolan commented Dec 2, 2024

Module safe query e2e test via interchain accounts is failing with:

 key: ibccallbackerror-error
 value: 'failed to execute interchain account transaction: rpc error: code = InvalidArgument
              desc = invalid address: decoding bech32 failed: string not all lowercase or
              all uppercase'

This looks like something is malformed when executing the interchain accounts tx via MsgRecvPacket

edit: looks like its coming from here -> https://github.com/cosmos/cosmos-sdk/blob/main/x/bank/keeper/grpc_query.go#L40-L43

Fixed in f9b7314. Looks like some address change crept in here. There was a TODO inline which needed to be fixed. The address must be bech32.

@damiannolan
Copy link
Member Author

damiannolan commented Dec 2, 2024

Remaining test failures:

  1. IBCGenesisTest (for export state) is failing on CI but this test passes locally. Its failing with some docker connection refused errors when attempting to restart all nodes. Not sure on best path for fixing this atm.

Solved: InitChain was missing a sorting of validators looked up from the statemachine. cosmos/cosmos-sdk#22757

  1. TestClientRecovery is failing reporting that the subject client is still active. I have run this test locally and exec'd into the chainA container and run cli queries for client status where the client (07-tendermint-1) is reported correctly as expired. Very strange behaviour...

Solved: Query context was missing time via header info. cosmos/cosmos-sdk#22732

  1. TestScheduleIBCUpgrade is failing due to some protobuf Any encoding error. I have not yet debugged this in detail but also seems to be quite odd. The test fails x/gov proposal with the following:
cannot unpack client state: cannot unpack Any into ClientState *types.Any: failed unpacking protobuf message from Any: invalid client type: failed waiting for condition after 30.000000 seconds

Other than this its just linters that need to be fixed.. which looks like another can of worms

@damiannolan
Copy link
Member Author

damiannolan commented Dec 4, 2024

Update on 1. above. The TestIBCGenesis failure is reproducible locally by using multiple validator and full nodes. The error occurs when restarting all nodes.

ERR failure when running app err="error during handshake: error on replay: genesisValidators[0] != req.Validators[0] "
    setup.go:124: 

I think the failure is possibly related to export.go in simapp. Particularly the ExportAppStateAndValidators func. We can look into it there

Solved: InitChain was missing a sorting of validators looked up from the statemachine. cosmos/cosmos-sdk#22757

@damiannolan damiannolan changed the title [WIP] feat: adding runtime Environment to icacontroller feat: add runtime Env to icacontroller and fix v0.52 e2e tests Dec 5, 2024
modules/core/keeper/msg_server.go Outdated Show resolved Hide resolved
Comment on lines 81 to 82
// TODO(damian): revert this extra err info
return nil, errorsmod.Wrapf(ibcerrors.ErrUnpackAny, "cannot unpack Any into ClientState %T, typeURL: %s, cachedValue: %v", protoAny, protoAny.TypeUrl, protoAny.GetCachedValue())
Copy link
Member Author

Choose a reason for hiding this comment

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

Revert this

Copy link
Contributor

Choose a reason for hiding this comment

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

Does it need an issue to make sure we don't forget, or will you remember? :)

@@ -642,3 +643,59 @@ func (suite *KeeperTestSuite) TestIBCSoftwareUpgrade() {
})
}
}

func (suite *KeeperTestSuite) TestIBCScheduledUpgradeProposal() {
Copy link
Member Author

Choose a reason for hiding this comment

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

This can also be deleted I think once cosmos/cosmos-sdk#22779 is solved, but its also no harm keeping around as it routes a msg for scheduleIBCUpgrade through gov

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a comment with a link to that for context?

Comment on lines +29 to +31
if err := k.EventService.EventManager(ctx).EmitKV(icatypes.EventTypePacket, attributes...); err != nil {
panic(err)
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This error should be propagated and returned from this func.

The likelihood of these errors surfacing from EventManager are pretty much zero, but at some point in a future far away it may be possible for it to error - given a different impl of event service.

None the less, its good practise to actually return the errors and not panic and rely on grpc recovery interceptor

Copy link
Contributor

Choose a reason for hiding this comment

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

Should it have a todo comment for that, then?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@gjermundgaraba gjermundgaraba left a comment

Choose a reason for hiding this comment

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

LGTM! Left a couple of questions and minor comments, but looks great to me otherwise 🔥

.github/workflows/callbacks.yml Outdated Show resolved Hide resolved
@@ -74,22 +74,13 @@ func (s *UpgradeTestSuite) UpgradeChain(ctx context.Context, chain *cosmos.Cosmo
Info: fmt.Sprintf("upgrade version test from %s to %s", currentVersion, upgradeVersion),
}

if testvalues.GovV1MessagesFeatureReleases.IsSupported(chain.Config().Images[0].Version) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this just not needed anymore, or will this break compatibility tests in any way we need to deal with later?

Copy link
Member Author

Choose a reason for hiding this comment

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

Pretty sure it should be fine. As 0.47 (ibc-go/v7) has govv1 msg execution.

@@ -558,6 +558,18 @@ func (s *E2ETestSuite) createWalletOnChainIndex(ctx context.Context, amount, cha
wallet := interchaintest.GetAndFundTestUsers(s.T(), ctx, strings.ReplaceAll(s.T().Name(), " ", "-"), sdkmath.NewInt(amount), chain)[0]
// note the GetAndFundTestUsers requires the caller to wait for some blocks before the funds are accessible.
s.Require().NoError(test.WaitForBlocks(ctx, 2, chain))

Copy link
Contributor

Choose a reason for hiding this comment

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

💀 ooof

Is this the only way to do this now?

Copy link
Member Author

Choose a reason for hiding this comment

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

SendCoins to an account no longer creates the account in x/auth. It just stores the coins to the address space in x/bank.

The account only gets created when there has been an action/tx made with the key.
You could probably exec any kind of tx here but this is what @chatton done and it works.

Instances where this came up in unit tests (where SendCoins to account was being used to create an account) I just swapped to directly using the x/auth keeper but that's only possible in unit testing where you have that kind of control

Comment on lines +29 to +31
if err := k.EventService.EventManager(ctx).EmitKV(icatypes.EventTypePacket, attributes...); err != nil {
panic(err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it have a todo comment for that, then?

@@ -29,11 +31,10 @@ func (suite *KeeperTestSuite) TestMigratorMigrateParams() {
func() {
suite.chainA.GetSimApp().ICAControllerKeeper = icacontrollerkeeper.NewKeeper(
suite.chainA.Codec,
runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(icacontrollertypes.StoreKey)),
runtime.NewEnvironment(runtime.NewKVStoreService(suite.chainA.GetSimApp().GetKey(icacontrollertypes.StoreKey)), log.NewNopLogger()),
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess we'll have to do some upgrade doc changes for this. Are we tracking that anywhere?

Copy link
Contributor

Choose a reason for hiding this comment

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

Typically in an epic we'd have for an sdk upgrade we'd have a bullet point for keeping track of this.

@@ -642,3 +643,59 @@ func (suite *KeeperTestSuite) TestIBCSoftwareUpgrade() {
})
}
}

func (suite *KeeperTestSuite) TestIBCScheduledUpgradeProposal() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a comment with a link to that for context?

modules/core/keeper/msg_server.go Outdated Show resolved Hide resolved
Copy link
Contributor

@DimitrisJim DimitrisJim left a comment

Choose a reason for hiding this comment

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

Quickly skimmed, looking good. Trusting the tests. Thanks for shifting through the upgrade swamp 🙏

Copy link

sonarcloud bot commented Dec 6, 2024

@damiannolan damiannolan merged commit 5cf7d7e into marko/gomod_change Dec 6, 2024
67 checks passed
@damiannolan damiannolan deleted the damian/runtime-env branch December 6, 2024 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants