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

Drop duplicate spawn/stop proposals #155

Closed
danwt opened this issue Jun 16, 2022 · 7 comments · Fixed by #254
Closed

Drop duplicate spawn/stop proposals #155

danwt opened this issue Jun 16, 2022 · 7 comments · Fixed by #254
Assignees
Labels
type: bug Issues that need priority attention -- something isn't working

Comments

@danwt
Copy link
Contributor

danwt commented Jun 16, 2022

Edit: see #155 (comment)

When a proposal gets handled it will be added to a pending list if spawnTime has not yet passed.

func (k Keeper) CreateConsumerChainProposal(ctx sdk.Context, p *types.CreateConsumerChainProposal) error {
	if ctx.BlockTime().After(p.SpawnTime) {
		return k.CreateConsumerClient(ctx, p.ChainId, p.InitialHeight)
	}

	k.SetPendingClientInfo(ctx, p.SpawnTime, p.ChainId, p.InitialHeight)
	return nil
}

I'm suspicious of what might happen if we allow multiple entries in pending for a given chain. I cannot think of any situation where this would be beneficial. It could only lead to strange behavior.

I think we should ensure that SetPendingClientInfo only has at most one entry per chainID and updates the existing entry if it already exists instead of creating a new entry.

@mpoke
Copy link
Contributor

mpoke commented Jun 21, 2022

@danwt This should be the same behavior regardless of the outcome of the if condition currentTimestamp() > p.spawnTime. This means that this logic should be implemented in CreateConsumerClient. For now, we could just drop here all proposals that are for an existing chainID (i.e., there is already a client stored for that chainID, see

func (k Keeper) SetConsumerClient(ctx sdk.Context, chainID, clientID string) {
).

This brings me to another potential issue. What happens if GetConsumerClient is called for a non-existing chainID (see here)? What does string(nil) return?

@danwt
Copy link
Contributor Author

danwt commented Jun 21, 2022

Nice catch re.

func (k Keeper) GetConsumerClient(ctx sdk.Context, chainID string) string {

@mpoke
Copy link
Contributor

mpoke commented Jun 21, 2022

Yeah, we need to have a look through all the setters and getters and make sure that they can handle edge cases. I've opened an issue #160

@mpoke
Copy link
Contributor

mpoke commented Jun 21, 2022

For now, we could just drop all proposals that are for an existing chainID

Of course, this means that if for some reason a consumer chain is removed and the state is not cleaned, that chain cannot join as a consumer chain with the same chainID. This should be handled by #125 though.

@mpoke
Copy link
Contributor

mpoke commented Jul 11, 2022

The fix was specified in cosmos/ibc#775

@mpoke mpoke self-assigned this Jul 11, 2022
@mpoke mpoke changed the title Remove existing pending spawn/stop proposals when adding new ones for a given consumer chain ID Drop duplicate spawn/stop proposals Aug 5, 2022
@mpoke mpoke moved this from Todo to Next in Replicated Security Aug 5, 2022
@mpoke mpoke moved this from Next to Waiting for review in Replicated Security Aug 8, 2022
@jtremback
Copy link
Contributor

jtremback commented Aug 8, 2022

For future reference, the final fix proposed in this thread is to disable creation of a duplicate client for an existing consumer chainId. We may also want to error when someone tries to create a governance proposal for new consumer chain with the same chainId, to avoid getting into this state in the first place.

@mpoke
Copy link
Contributor

mpoke commented Aug 9, 2022

We may also want to error when someone tries to create a governance proposal for new consumer chain with the same chainId, to avoid getting into this state in the first place.

Is there a way to check gov proposals when they are submitted, like a handler or something?

@mpoke mpoke closed this as completed in #254 Aug 9, 2022
Repository owner moved this from Waiting for review to Done in Replicated Security Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Issues that need priority attention -- something isn't working
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants