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

sonarqubecloud 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
github-merge-queue bot pushed a commit that referenced this pull request Dec 17, 2024
* go mod changes

* remove cometabci direct dep

* fix all errors

* appmodule & simapp cleanup

* 08wasm fixes

* get 08-wasm compiling

* another simapp

* another simapp

* pass in environment

* fix compilation errors

* some fixes

* build

* fix other simapps

* linting

* remove unsed code

* go mod changes

* add pool module

* anothersimapp

* linting fixes

* protocol pool module accounts

* callback fixes

* simapp fixes

* register interfaces

* fix feeibc

* changes++

* fix missed conflict

* fix wasm client

* linting fixes

* fix tests

* linting

* fix simapp tests

* fix some tests

* fix e2e go mod

* go mod changes

* remove grandpa

* Gomod changes and minor updates (#7549)

* Remove module.HasProposalMsgs

* Update ante handler

* Bump versions

* x

* Cleanup

* chore: use same tags for all go mods

* chore: update go mod files, revert callbacks simapp changes

* chore: fix tendermint client test suite

* chore: fix tests in TestAnteDecoratorCheckTx

* chore: fix event tests

* chore: fix compiler error in simapp

* deps: update to latest of cosmossdk.io/store main to fix proofs test

* chore: tidy all

* fix: remove ibcmock module acc from blocked addrs

* chore: fix proto failures and Gov errors

* chore: fix ica test

* chore: fix a few compiler errs in 08-wasm

* fix: update ica account already exists test to front run account creation correctly

* chore: fix ica test for address gen

* chore: re-add log to returned error

* chore: update go mods

* chore: fixed build errors in wasm app.go

* chore: cleanup callbacks simapp

* chore: fixing simulation functions

* chore: reconfigure simd cmd and fix TestInitCmd

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

* feat: adding runtime Environment

* chore: run make lint-fix

* chore: remove duplicate import

* chore: rm duplicate import

* chore: migrate to env KVStoreService in icacontroller

* chore: fix duplicate import

* chore: rm kv store service

* chore: refactor events to use environment

* chore: make lint-fix

* chore: make tidy-all

* chore: rm msg service router from icacontroller

* fix: remove 32 bit arm arch from callbacks ci builds

* test: try cache false for callbacks linter

* chore: pin to updated interchaintest fork

* chore: revert relayer count to 10

* chore: continued work on upgrading e2e tests to 0.52

* chore: transfer e2e passing

* chore: fix upgrade build errors

* chore: bump interchaintest

* chore: update  sample config

* chore: reconfigure protoany to use gogoproto any in favour of codec types

* chore: tidy imports in e2e

* fix: address failure in module safe query ica e2e test

* bump golangci version to 1.60

* lint: remove duplicate import

* chore: use gogoprotoany in favour of codec types any. rm ProtoCodecMarshaler for Codec iface

* chore: bump go version in Dockerfile

* chore: add todo

* lint: fix unnecessary cast

* deps: upgrade sdk to head of release/v0.52.x, upgrade store to latest main

* deps: bump to head of release/v0.52

* fix: add unit test to reproduce e2e test failure for ScheduleIBCUpgrade, update code to expect tendermint client temporarily

* fix: error in tests

* chore: address comments from pr

---------

Co-authored-by: chatton <[email protected]>
Co-authored-by: Nikolas De Giorgis <[email protected]>

* chore: linter fixes

* lint: ignore redunant import alias

* chore: rm redudant semi-colon in tendermint.proto

* chore: rm redundant doc string regarding e2e-compatibility tests - tests now use annoations for compatibility checks

* chore: update dead links

* fix: apply fix for x/tx cosmos-sdk #22574

* chore: make lint-fix

* fix: use hermes v1.10.4 for ci configs

* fix: apply fix for cosmos-sdk #22779 and update dependencies

* fix: unpin local sdk to HEAD of release/v0.52 in simapp go.mod

* chore: revert docs/versioned_docs to main

* chore: ammendments to linter configs

* chore: update var name in expected keeper

* chore: revert diffs in clienttypes/height_test

* chore: propagate error from event emission in icacontroller

* test: revert unnecessary diffs in test fn

* chore: update comment in test chain

* Update e2e/tests/interchain_accounts/base_test.go

Co-authored-by: DimitrisJim <[email protected]>

* chore: nit on import aliasing

* refactor: rename instances of expected keepers from accountKeeper -> authKeeper where apt

* chore: readd TestABCICodeDeterminism to 04-channel types

* refactor: remove redundant AppModuleBasics

* chore: rm GetStakingKeeper api from testing app

* chore: update version in wasm dockerfile

* chore: update the go work example file version

* chore: rm UnwrapSDKContext in ica where possible

* fix: import path in e2e from suggestion

---------

Co-authored-by: Alexander Peters <[email protected]>
Co-authored-by: chatton <[email protected]>
Co-authored-by: Damian Nolan <[email protected]>
Co-authored-by: Nikolas De Giorgis <[email protected]>
Co-authored-by: DimitrisJim <[email protected]>
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