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

Configure relayers to watch only channels associated with an individual test #6685

Conversation

chatton
Copy link
Contributor

@chatton chatton commented Jun 24, 2024

Description

This PR replaces the single relayer associated with a test suite, and replaces it with a pool of relayers so each test can have its own.

At the moment, relayers need to be specified before the chain is created. For this reason it does not seem possible to lazily create a relayer when a test needs one. I created this issue which when resolved, we should be able to create relayers as needed, rather than pre-loading them.

Each of these relayers has been configured to only watch the channel(s) for a single test with the caveat that it is only configured for hermes (no-op for other relayers currently)

The tests will still be running 1 test per host, however the relayer will be unique to that test, as well as configured to watch only the channels created for that test.

There is an exception for ICA channels at the moment, a wild card is used which means some additional work will need to be done to update the packet filter while the relayer is running. This might be tricky as I believe we only get the ica channelID after the relayer has performed the channel handshake 🤔

closes: #6634

ref: strangelove-ventures/interchaintest#1153


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.

@chatton chatton marked this pull request as ready for review June 24, 2024 13:32
@chatton chatton marked this pull request as draft June 24, 2024 13:32
@chatton chatton changed the title [WIP] Configure relayers to watch only channels associated with an individual test Configure relayers to watch only channels associated with an individual test Jun 24, 2024
@chatton chatton marked this pull request as ready for review June 24, 2024 15:14
@chatton chatton added the priority PRs that need prompt reviews label Jun 24, 2024
Comment on lines +100 to +102
// TODO(chatton): explicitly enable watching of ICA channels
// this will ensure the ICA tests pass, but this will need to be modified to make sure
// ICA tests will succeed in parallel.
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 won't create another issue for this since it will be implicitly required to fix before our tests will pass in parallel

…only-channels-associated-with-an-individual-test
}

// modifyHermesConfigFile reads the hermes config file, applies a modification function and returns an error if any.
func modifyHermesConfigFile(ctx context.Context, h *hermes.Relayer, modificationFn func(map[string]interface{}) error) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if it would be any better or not, but interchaintest has some utility functions for modifying Toml files:
https://github.com/strangelove-ventures/interchaintest/blob/main/testutil/toml.go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good call, I think I reinvented the wheel here!

Copy link
Contributor 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.

This is a great improvement for the e2e tests!

Comment on lines 235 to 238
channels, err := r.GetChannels(ctx, s.GetRelayerExecReporter(), c.Config().ChainID)
s.Require().NoError(err)

if s.channels[s.T().Name()] == nil {
s.channels[s.T().Name()] = make(map[ibc.Chain][]ibc.ChannelOutput)
}
s.channels[s.T().Name()][c] = channels
Copy link
Contributor Author

Choose a reason for hiding this comment

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

just realised this is wrong! We are currently fetching all channels associated with the chain, not just the one that was created. It means every relayer is still watching all channels, we need to identify the exact channel for this test. I think it is channels[len(channels)-1]

Copy link
Member

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

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

Awesome work! Thanks for diving into the depths again! 🫡

Happy to approve and move forward with this if it will improve things for us wrt to runners 🙏🏻

return fmt.Errorf("failed to find chain with id %s", chainID)
}

var channelIDs [][]string
Copy link
Member

Choose a reason for hiding this comment

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

caught me off guard a bit with the 2d slice. Each []string contained within is a portID/channelID tuple?

little nit, but could name this channelEndpoints or something similar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah good call, it's not actually the ids :D

Comment on lines +74 to +78
// relayerPool is a pool of relayers that can be used in tests.
relayerPool []ibc.Relayer
// testRelayerMap is a map of test suite names to relayers that are used in the test suite.
// this is used as a cache after a relayer has been assigned to a test suite.
testRelayerMap map[string]ibc.Relayer
Copy link
Member

Choose a reason for hiding this comment

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

So another way of saying this would be that the relayerPool is essentially cold - available relayers. And the testRelayerMap is hot - a relayer is in use under a particular test name key!

Seems like we can go with this until we can add new relayers on the fly, hopefully! 👍🏻

@@ -557,6 +558,9 @@ func DefaultChainOptions() ChainOptions {

return ChainOptions{
ChainSpecs: []*interchaintest.ChainSpec{chainASpec, chainBSpec},
// arbitrary number that will not be required if https://github.com/strangelove-ventures/interchaintest/issues/1153 is resolved.
// It can be overridden in individual test suites in SetupSuite if required.
RelayerCount: 10,
Copy link
Member

Choose a reason for hiding this comment

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

Suppose we could always do the AST way as a somewhat improvement if we need to, and initialise the count based on test funcs in the suite in some other setup func

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, we definitely can improve this arbitrary number.

@chatton chatton enabled auto-merge June 26, 2024 08:17
@chatton chatton added this pull request to the merge queue Jun 26, 2024
Copy link

sonarcloud bot commented Jun 26, 2024

Quality Gate Failed Quality Gate failed for 'ibc-go'

Failed conditions
63.1% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

Merged via the queue into main with commit dd23cf9 Jun 26, 2024
83 of 84 checks passed
@chatton chatton deleted the cian/issue#6634-configure-relayers-to-watch-only-channels-associated-with-an-individual-test branch June 26, 2024 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority PRs that need prompt reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configure relayers to watch only channels associated with an individual test #2
3 participants