-
Notifications
You must be signed in to change notification settings - Fork 579
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
Add sentinel localhost connection end to genesis state #3040
Merged
chatton
merged 11 commits into
09-localhost
from
cian/issue#3031-add-sentinel-localhost-connectionend-to-genesis-state
Jan 30, 2023
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
373075c
chore: writing localhost connection end to state in InitGenesis
chatton 4760dbc
test: adding test to ensure sentinel connection end is created
chatton 3192280
chore: added migration function to enable localhost connection end
chatton 4b021db
chore: fix linting issues
chatton 68a57fb
chore: remove boolean field to specify create localhost and automatic…
chatton 9b1ca7b
chore: updated unit tests to account for new localhost connection end
chatton d10b790
chore: adding docstring
chatton 96732cb
chore: addressing PR feedback
chatton ee5b0b1
chore: merge feature branch
chatton 926a026
chore: ran linter
chatton bda0bce
chore: performing multiple migrations in module.go
chatton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package keeper | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
connectionv7 "github.com/cosmos/ibc-go/v7/modules/core/03-connection/migrations/v7" | ||
) | ||
|
||
// Migrator is a struct for handling in-place store migrations. | ||
type Migrator struct { | ||
keeper Keeper | ||
} | ||
|
||
// NewMigrator returns a new Migrator. | ||
func NewMigrator(keeper Keeper) Migrator { | ||
return Migrator{keeper: keeper} | ||
} | ||
|
||
// Migrate3to4 migrates from version 3 to 4. | ||
// This migration writes the sentinel localhost connection end to state. | ||
func (m Migrator) Migrate3to4(ctx sdk.Context) error { | ||
connectionv7.MigrateLocalhostConnection(ctx, m.keeper) | ||
return nil | ||
} |
13 changes: 13 additions & 0 deletions
13
modules/core/03-connection/migrations/v7/expected_keepers.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package v7 | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" | ||
) | ||
|
||
// ConnectionKeeper expected IBC connection keeper | ||
type ConnectionKeeper interface { | ||
CreateSentinelLocalhostConnection() types.ConnectionEnd | ||
SetConnection(ctx sdk.Context, connectionID string, connection types.ConnectionEnd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package v7 | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
connectiontypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" | ||
) | ||
|
||
// MigrateLocalhostConnection creates the sentinel localhost connection end to enable | ||
// localhost ibc functionality. | ||
func MigrateLocalhostConnection(ctx sdk.Context, connectionKeeper ConnectionKeeper) { | ||
localhostConnection := connectionKeeper.CreateSentinelLocalhostConnection() | ||
connectionKeeper.SetConnection(ctx, connectiontypes.LocalhostID, localhostConnection) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
Maybe this is due to my lack of knowledge of how migrations work, but if we replace
Migrate2to3
withMigration3to4
and a chain upgrades from v6.0.0 to v7.1.0, wouldn't it miss theMigrate2to3
migration?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.
right, my understanding was that chains needed to update to each version one by one in order to run all the migrations. I feel like it should be possible, to just register all migrations at once (as they should be idempotent) however I'm not sure if this is the case. Maybe @AdityaSripal has an answer to this?
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, I am also not sure if the chains really need to upgrade to each version of ibc-go or if they can jump versions as long as they run the migrations of the versions in between.
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.
if this is the case then we would preferably just add it as a migration instead of replace
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, it should be possible to register multiple migrations.