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

ICS3: Remove ability for multiple TRY msgs to succeed for single INIT msg #1723

Closed
wants to merge 9 commits into from

Conversation

AdityaSripal
Copy link
Member

@AdityaSripal AdityaSripal commented Jul 18, 2022

Description

  • bump to main
  • add genesis logic
  • e2e
  • needs queries?

closes: #1430 for connections. A separate PR will do the same logic for channels once the approach here is approved


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 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.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@@ -242,6 +247,10 @@ func (k Keeper) ConnOpenAck(
connection.Counterparty.ConnectionId = counterpartyConnectionID
k.SetConnection(ctx, connectionID, connection)

// delete generatedConnectionID mapping now that handshake attempt is successful
// we no longer need to store it for redundancy protection
k.DeleteGeneratedConnectionID(ctx, connection.ClientId, counterpartyConnectionID)
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if I should be deleting in ACK and CONFIRM. No longer strictly necessary for the state machine but may be useful as a query even after handshake is complete

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we only need to delete in the ConnOpenConfirm handler?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, theoretically we could have a crossing hello; where ACK gets called on both ends

Copy link
Member

Choose a reason for hiding this comment

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

In this case does CONFIRM not get called on both ends too?

Copy link
Member Author

@AdityaSripal AdityaSripal Jul 27, 2022

Choose a reason for hiding this comment

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

nope because both sides go to OPEN on ACK, there's no need for CONFIRM

modules/core/03-connection/keeper/handshake_test.go Outdated Show resolved Hide resolved
modules/core/03-connection/types/keys.go Outdated Show resolved Hide resolved
@AdityaSripal AdityaSripal changed the title Remove ability for multiple TRY msgs to succeed for single INIT msg ICS3: Remove ability for multiple TRY msgs to succeed for single INIT msg Jul 18, 2022
@AdityaSripal AdityaSripal marked this pull request as draft July 18, 2022 14:25
@AdityaSripal AdityaSripal marked this pull request as ready for review July 18, 2022 14:50
@codecov-commenter
Copy link

codecov-commenter commented Jan 23, 2023

Codecov Report

Merging #1723 (160d1ea) into main (afdc278) will increase coverage by 0.02%.
The diff coverage is 92.00%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1723      +/-   ##
==========================================
+ Coverage   78.54%   78.57%   +0.02%     
==========================================
  Files         181      181              
  Lines       12580    12604      +24     
==========================================
+ Hits         9881     9903      +22     
- Misses       2262     2264       +2     
  Partials      437      437              
Impacted Files Coverage Δ
modules/core/03-connection/types/keys.go 87.50% <0.00%> (-12.50%) ⬇️
modules/core/03-connection/keeper/handshake.go 89.50% <100.00%> (+0.72%) ⬆️
modules/core/03-connection/keeper/keeper.go 90.15% <100.00%> (+0.72%) ⬆️

Comment on lines +147 to +162
func (k Keeper) SetExistingConnectionID(ctx sdk.Context, clientID, counterpartyConnectionID, connectionID string) {
store := ctx.KVStore(k.storeKey)
store.Set([]byte(types.ExistingConnectionIDKey(clientID, counterpartyConnectionID)), []byte(connectionID))
}

// GetExistingConnectionID returns the generated connectionID for a given clientID and counterparty connectionID
func (k Keeper) GetExistingConnectionID(ctx sdk.Context, clientID, counterpartyConnectionID string) string {
store := ctx.KVStore(k.storeKey)
return string(store.Get([]byte(types.ExistingConnectionIDKey(clientID, counterpartyConnectionID))))
}

// DeleteExistingConnectionID removes the ExistingConnectionID mapping from the store
func (k Keeper) DeleteExistingConnectionID(ctx sdk.Context, clientID, counterpartyConnectionID string) {
store := ctx.KVStore(k.storeKey)
store.Delete([]byte(types.ExistingConnectionIDKey(clientID, counterpartyConnectionID)))
}
Copy link
Contributor

@colin-axner colin-axner Mar 9, 2023

Choose a reason for hiding this comment

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

requires genesis export/import logic. Maybe you could derive the mapping from the existing genesis fields?

@colin-axner colin-axner self-assigned this Mar 13, 2023
@colin-axner colin-axner removed their assignment Mar 13, 2023
Comment on lines +266 to +269
// delete existingConnectionID mapping now that handshake attempt is successful
// we no longer need to store it for redundancy protection
k.DeleteExistingConnectionID(ctx, connection.ClientId, counterpartyConnectionID)

Copy link
Contributor

Choose a reason for hiding this comment

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

This is unsafe? After the connection handshakes succeeds, in the tendermint client case, if the consensus height used to do proof init has not expired, there will still be a past state with a valid init proof which is not associated with a specific connection (on the try side). Unfortunate, but I believe the storage costs should be minimal? I don't think there is any in-protocol pruning we could do here without adding additional logic to the client layer to tell us when a past proof has expired

@colin-axner
Copy link
Contributor

Closing pr for now (to reduce noise) as we await for more information on the upstream issue. We can reopen when necessary

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.

Question about multiple OpenTry messages
6 participants