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

simplify consumer addition and removal propsal handling #460

Closed
wants to merge 2 commits into from

Conversation

MSalopek
Copy link
Contributor

@MSalopek MSalopek commented Nov 9, 2022

Immediate execution of CreateConsumerClient and StopConsumerClient is not necessary because all pending proposals are already handled in BeginBlock.

Closes: #458
Closes: #390

@MSalopek MSalopek marked this pull request as ready for review November 9, 2022 21:57
@danwt
Copy link
Contributor

danwt commented Nov 10, 2022

Hey, looks like excellent work

Any chance we can incorporate

Or perhps #463 should go in a different pr

Copy link
Contributor

@danwt danwt left a comment

Choose a reason for hiding this comment

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

Hey, nice work!

I just noticed that the content of the tests have changed somewhat because the actual addition/removal parts are no longer tested. Thus, somewhere, it's needed to do BeginBlock() and process the pendings.

// Note: This method implements SpawnConsumerChainProposalHandler in spec.
// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-spccprop1
// Spec tag: [CCV-PCF-SPCCPROP.1]
// The proposal is stored into state and if spawn time has passed the client will be created set in the next BeginBlocker.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// The proposal is stored into state and if spawn time has passed the client will be created set in the next BeginBlocker.
// The proposal is stored into state and will be executed in BeginBlocker once the spawn time has passed.


err := k.SetPendingConsumerAdditionProp(ctx, p)
if err != nil {
if err := k.SetPendingConsumerAdditionProp(ctx, p); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should be a little careful about the error semantics because the err is used in the gov module when the proposal is submitted.

See #463

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'm not sure what you mean? The behaviour is the same with regards to error handling.

// This method implements StopConsumerChainProposalHandler from spec.
// See: https://github.com/cosmos/ibc/blob/main/spec/app/ics-028-cross-chain-validation/methods.md#ccv-pcf-stccprop1
// Spec tag: [CCV-PCF-STCCPROP.1]
// If the stop time has passed the proposal will be executed in BeginBlocker.
Copy link
Contributor

Choose a reason for hiding this comment

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

We could consolidate comments on 90-91

The proposal is stored into state and will be executed in BeginBlocker once the spawn time has passed.

Comment on lines -375 to -378
found := providerKeeper.GetPendingConsumerRemovalProp(ctx, tc.prop.ChainId, tc.prop.StopTime)
require.False(t, found)

testProviderStateIsCleaned(t, ctx, providerKeeper, tc.prop.ChainId, "channelID")
Copy link
Contributor

Choose a reason for hiding this comment

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

In replacing these lines we want to maintain the same amount of coverage. Here the proposal actually was processed so testProviderStateIsCleaned checks that the consumer was removed. An equivalent should be added. ie.

BeginBlocker()
testProviderStateIsCleaned

to check the same thing.

tc.prop.LockUnbondingOnTimeout = false // Full functionality not implemented yet.

err := providerKeeper.HandleConsumerAdditionProposal(ctx, tc.prop)
require.NoError(t, err)

if tc.expCreatedClient {
testCreatedConsumerClient(t, ctx, providerKeeper, tc.prop.ChainId, "clientID")
Copy link
Contributor

Choose a reason for hiding this comment

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

Similiar to another comment, an equivalent check should probably be tested

BeginBlocker()
testCreatedConsumerClient

@MSalopek
Copy link
Contributor Author

Let's keep this on ice for a little bit. It is implemented per the spec. The issue remains open for further investigation.

Closing.

@MSalopek MSalopek closed this Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants