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: channel-v2 genesis #7933

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

feat: channel-v2 genesis #7933

wants to merge 2 commits into from

Conversation

aljo242
Copy link
Collaborator

@aljo242 aljo242 commented Feb 7, 2025

Description

Wire up the genesis for the channel/v2 module
Create keeper functions for getting all of the state per Client ID
Keeper-level testing

closes: #7922


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.

)

// TestInitExportGenesis tests the import and export flow for the channel v2 keeper.
func (suite *KeeperTestSuite) TestInitExportGenesis() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This testing setup is what I feel the least confident about. There was not a previous testing setup in the v1 module for genesis, so this is what I rolled with.

The intricacy is that the ibctesting suite already has initialized genesis for things like the client keeper and some actions have led to state existing. So for creating a valid genesis that will be exported properly, we have to use existing state to set it

@@ -25,4 +25,6 @@ type ClientKeeper interface {
GetClientConsensusState(ctx context.Context, clientID string, height exported.Height) (exported.ConsensusState, bool)
// GetClientCounterparty returns the counterpartyInfo given a clientID
GetClientCounterparty(ctx context.Context, clientID string) (clienttypes.CounterpartyInfo, bool)
// GetAllGenesisClients returns all the clients in state with their client ids returned as IdentifiedClientState
GetAllGenesisClients(ctx context.Context) clienttypes.IdentifiedClientStates
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Needed for export genesis

@@ -6,22 +6,28 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)

const (
PacketCommitmentBasePrefix = byte(1)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done for clarity - can be reverted

Base automatically changed from feat/ibc-eureka to main February 7, 2025 17:48
@aljo242 aljo242 force-pushed the feat/channel-v2-genesis branch from 3360b99 to 6459667 Compare February 7, 2025 18:52
Copy link

sonarqubecloud bot commented Feb 7, 2025

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.

After checking this more carefully, I believe it needs some changes to work the same way as v1.
If you look at how genesis and the whole module is set up in v1, it is all done through the core IBC module. So InitGenesis and all of that is called from there. This is also where it is tested in v1.

Copy link
Member

@AdityaSripal AdityaSripal left a comment

Choose a reason for hiding this comment

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

Generally looks good!! Think the testing setup can be improved either here or in subsequent PR

var commitments []types.PacketState
for ; iterator.Valid(); iterator.Next() {
sequenceBz := bytes.TrimPrefix(iterator.Key(), storePrefix)
sequence := sdk.BigEndianToUint64(sequenceBz)
Copy link
Member

Choose a reason for hiding this comment

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

What happens if this byte slice is more than 64 bytes? Should never happen but perhaps we should add a defensive check

Comment on lines +10 to +11
path := ibctesting.NewPath(suite.chainA, suite.chainB)
path.SetupV2()
Copy link
Member

Choose a reason for hiding this comment

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

Set up a couple paths here so we have more than 1 client

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.

Wire up genesis for 04-channel v2
3 participants