-
Notifications
You must be signed in to change notification settings - Fork 657
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
base: main
Are you sure you want to change the base?
feat: channel-v2 genesis #7933
Conversation
) | ||
|
||
// TestInitExportGenesis tests the import and export flow for the channel v2 keeper. | ||
func (suite *KeeperTestSuite) TestInitExportGenesis() { |
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.
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 |
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.
Needed for export genesis
@@ -6,22 +6,28 @@ import ( | |||
sdk "github.com/cosmos/cosmos-sdk/types" | |||
) | |||
|
|||
const ( | |||
PacketCommitmentBasePrefix = byte(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.
Done for clarity - can be reverted
3360b99
to
6459667
Compare
|
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.
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.
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.
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) |
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 happens if this byte slice is more than 64 bytes? Should never happen but perhaps we should add a defensive check
path := ibctesting.NewPath(suite.chainA, suite.chainB) | ||
path.SetupV2() |
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.
Set up a couple paths here so we have more than 1 client
Description
Wire up the genesis for the
channel/v2
moduleCreate 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.
docs/
).godoc
comments.Files changed
in the GitHub PR explorer.SonarCloud Report
in the comment section below once CI passes.