-
Notifications
You must be signed in to change notification settings - Fork 672
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
Update E2E infra to support more than 2 chains #6524
Update E2E infra to support more than 2 chains #6524
Conversation
…based on arbitrary number of chains
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configration File (
|
|
||
relayer, channelA := s.SetupChainsRelayerAndChannel(ctx, s.TransferChannelOptions(), func(options *testsuite.ChainOptions) { | ||
// copy all values of existing chains and tweak to make unique to new chain. | ||
chainCSpec := *options.ChainSpecs[0] // nolint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was complaining about copying a lock, I think we can ignore since we'll be refactoring this entire test later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering about this API to set up chains. Rather than having to do this manipulation of the options, couldn't we simply have a couple of configs that we could use (two-chain, three-chain, whatever) where we use two-chain by default and we can just have something like s.UseTestConfig(testsuite.ThreeChainConfig)
. It would make the intent a little clearer (and shorter). I guess it depends how much we will use different configs, but just an idea.
(This is more on side of this PR, just wanted to write it while I had it in mind...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that's a nice idea, I think we can do something similar to where we have s.TransferChannelOptions()
. The 3rd chain will likely be the same in every test that needs it, so we can default to 2. Then provide a standard default for the 3 chain setup.
…-be-able-to-spin-up-3-or-more-chains
…-be-able-to-spin-up-3-or-more-chains
…-be-able-to-spin-up-3-or-more-chains
|
||
relayer, channelA := s.SetupChainsRelayerAndChannel(ctx, s.TransferChannelOptions(), func(options *testsuite.ChainOptions) { | ||
// copy all values of existing chains and tweak to make unique to new chain. | ||
chainCSpec := *options.ChainSpecs[0] // nolint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering about this API to set up chains. Rather than having to do this manipulation of the options, couldn't we simply have a couple of configs that we could use (two-chain, three-chain, whatever) where we use two-chain by default and we can just have something like s.UseTestConfig(testsuite.ThreeChainConfig)
. It would make the intent a little clearer (and shorter). I guess it depends how much we will use different configs, but just an idea.
(This is more on side of this PR, just wanted to write it while I had it in mind...)
@gjermundgaraba I created a re-usable function relayer, channelA := s.SetupChainsRelayerAndChannel(ctx, s.TransferChannelOptions(), testsuite.ThreeChainSetup()) How does this look to you? |
Yeah, that reads much better :) |
the new way broke the setup, looking into it now |
…-be-able-to-spin-up-3-or-more-chains
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK, thanks @chatton for updating this flow! Happy with the changes and we can iterate as needed
@@ -240,8 +292,9 @@ func (s *E2ETestSuite) GetPathName(idx int64) string { | |||
} | |||
|
|||
// generatePath generates the path name using the test suites name | |||
func (s *E2ETestSuite) generatePath(ctx context.Context, ibcrelayer ibc.Relayer) string { | |||
chainA, chainB := s.GetChains() | |||
func (s *E2ETestSuite) generatePath(ctx context.Context, ibcrelayer ibc.Relayer, chainAIdx, chainBIdx int) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we update godoc? The idea here is that if we want to generate a path between chainA and chainC, we provide the args 0, 2?
@@ -143,13 +131,76 @@ func (s *E2ETestSuite) GetRelayerUsers(ctx context.Context, chainOpts ...ChainOp | |||
// with E2ETestSuite.StartRelayer if needed. | |||
// This should be called at the start of every test, unless fine grained control is required. | |||
func (s *E2ETestSuite) SetupChainsRelayerAndChannel(ctx context.Context, channelOpts func(*ibc.CreateChannelOptions), chainSpecOpts ...ChainOptionConfiguration) (ibc.Relayer, ibc.ChannelOutput) { | |||
chainA, chainB := s.GetChains(chainSpecOpts...) | |||
r := s.ConfigureRelayer(ctx, chainA, chainB, channelOpts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we still need the ConfigureRelayer
function if its contents have been moved here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we still need it for now as it's used in the wasm tests here
This can be refactored in a follow up I think.
e2e/testsuite/testsuite.go
Outdated
channelOptions := ibc.DefaultChannelOpts() | ||
// For now, set the version to the latest transfer module version | ||
// DefaultChannelOpts uses V1 at the moment | ||
channelOptions.Version = transfertypes.V2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the previous code path handled backwards compatibility, this is still needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, will pull in those changes here
var chainHeighters []test.ChainHeighter | ||
for _, c := range chains { | ||
chainHeighters = append(chainHeighters, c) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are chain heighters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a type defined in interchain test which is an argument for the WaitForBlocks
function. the ibc.Chain
interface implemnts the ChainHeighter
interface, however it does not seem to be possible to pass in a list of ibc.Chain
.
For example this is valid
s.Require().NoError(test.WaitForBlocks(ctx, 10, chains[0], chains[1]), "failed to wait for blocks")
but this in invalid
s.Require().NoError(test.WaitForBlocks(ctx, 10, chains...), "failed to wait for blocks")
A conversion to the interface seems to be required for variable argument functions.
testsuite.E2ETestSuite | ||
} | ||
|
||
// TODO: replace this with actual tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue link?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
ctx := context.TODO() | ||
t := s.T() | ||
|
||
// TODO: note the ThreeChainSetup fn needs to be passed to TransferChannelOptions since it calls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue link?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
…-be-able-to-spin-up-3-or-more-chains
func defaultChannelOpts(chains []ibc.Chain) ibc.CreateChannelOptions { | ||
channelOptions := ibc.DefaultChannelOpts() | ||
channelOptions.Version = determineDefaultTransferVersion(chains) | ||
return channelOptions | ||
} | ||
|
||
// determineDefaultTransferVersion determines the version of transfer that should be used with an arbitrary number of chains. | ||
// the default is V2, but if any chain does not support V2, then V1 is used. | ||
func determineDefaultTransferVersion(chains []ibc.Chain) string { | ||
for _, chain := range chains { | ||
chainVersion := chain.Config().Images[0].Version | ||
if !testvalues.ICS20v2FeatureReleases.IsSupported(chainVersion) { | ||
return transfertypes.V1 | ||
} | ||
} | ||
return transfertypes.V2 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored the code which determines the default transfer v2 version to account for multiple chains. I think this reads a lot nicer and is easier to reason about.
cc @colin-axner
chains := s.GetAllChains() | ||
chainA, chainB := chains[0], chains[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this still equivalent to s.GetChains
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I think I refactored this to remove get chains then actually re-added it to cause less disruption in existing tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, idea is to completely rm afterwards? Fine with that approach, the flow of GetAllChains and then grabbing what you need serves as a guide of how many chains you'll use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wizardly as always! fine to address minor things in follow ups!
…-be-able-to-spin-up-3-or-more-chains
|
Description
This PR removes a lot of the ChainA/ChainB assumptions within our E2Es to allow for tests with more than 2 chains to be spun up.
Note: this is not exhaustive, there are still some helper/utility functions that assume a 2 chain environment. This PR enables N chains to be created, and for them to be linked via connections/channels by the relayer.
A stub test has been added which verifies that this works, and can be reworked as part of the transfer forwarding work.
closes: #6242
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.
docs/
).godoc
comments.Files changed
in the GitHub PR explorer.SonarCloud Report
in the comment section below once CI passes.