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

Add key for storing counterparty next sequence send during WriteUpgradeOpen. #5460

Merged
merged 6 commits into from
Dec 20, 2023

Conversation

DimitrisJim
Copy link
Contributor

@DimitrisJim DimitrisJim commented Dec 19, 2023

Description

to be merged after #5438

This value is then used as the upper bound for pruning packet acks/receipts. Also did a rename of the previous path/key to PruningSequence instead of AcknowledgementPruningSequence

Commit Message / Changelog Entry

type: commit message

see the guidelines for commit messages. (view raw markdown for examples)


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/) or specification (x/<module>/spec/).
  • Added relevant godoc comments.
  • Provide a commit message to be used for the changelog entry in the PR description for review.
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

KeyPacketAckPrefix = "acks"
KeyPacketReceiptPrefix = "receipts"
KeyPruningSequence = "pruningSequence"
KeyCounterpartyNextSeqSend = "counterpartyNextSequenceSend"
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 don't particularly like the key name here, looking for better suggestions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PruningSequenceEnd?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think KeyCounterpartyNextSeqSend sounds good to me.

@DimitrisJim DimitrisJim force-pushed the jim/set-key-for-max-pruning-limit branch from 91b3201 to 658c298 Compare December 19, 2023 15:48
@crodriguezvega crodriguezvega added channel-upgradability Channel upgradability feature priority PRs that need prompt reviews labels Dec 19, 2023
@DimitrisJim

This comment was marked as outdated.

@@ -553,6 +553,16 @@ func (k Keeper) WriteUpgradeOpenChannel(ctx sdk.Context, portID, channelID strin
k.SetNextSequenceAck(ctx, portID, channelID, upgrade.NextSequenceSend)
}

// set the counterparty next sequence send in order to have upper bound to prune to
k.SetNextSequenceSend(ctx, portID, channelID, counterpartyUpgrade.NextSequenceSend)
Copy link
Contributor

Choose a reason for hiding this comment

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

ref aditya's comment in the other pr, the test can be updated to make sure these are set (pruning and next seq send)

Copy link
Contributor

@crodriguezvega crodriguezvega Dec 19, 2023

Choose a reason for hiding this comment

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

This should be k.SetCounterpartyNextSequenceSend, right?

Copy link
Contributor Author

@DimitrisJim DimitrisJim Dec 19, 2023

Choose a reason for hiding this comment

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

🤦‍♂️ the perils of similarly named things

@codecov-commenter
Copy link

codecov-commenter commented Dec 19, 2023

Codecov Report

Attention: 11 lines in your changes are missing coverage. Please review.

Comparison is base (7d7f60a) 80.77% compared to head (ff2b170) 80.82%.

Additional details and impacted files

Impacted file tree graph

@@                    Coverage Diff                     @@
##           charly/set_nextseqrecv    #5460      +/-   ##
==========================================================
+ Coverage                   80.77%   80.82%   +0.05%     
==========================================================
  Files                         197      197              
  Lines                       15133    15159      +26     
==========================================================
+ Hits                        12223    12253      +30     
+ Misses                       2443     2438       -5     
- Partials                      467      468       +1     
Files Coverage Δ
modules/core/04-channel/keeper/upgrade.go 92.59% <100.00%> (+0.08%) ⬆️
modules/core/04-channel/keeper/keeper.go 88.74% <83.33%> (+2.60%) ⬆️
modules/core/24-host/packet_keys.go 0.00% <0.00%> (ø)

Copy link
Member

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

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

Nice and clean!

I'm unsure how I feel about the naming of the two different naming conventions for keys and getters/setters. Both sequences are used for pruning but they're naming doesn't lend them to be considered all that related imo!

The way I see it is:

  • PruningSequence: The current sequence (lower bound) at which all previous acks and receipts have already been deleted.
  • CounterpartyNextSequenceSend: The current sequence (upper bound) for which it is safe to delete all previous acks and receipts.

Comment on lines 559 to 593
// First upgrade for this channel will set the pruning sequence to 1, the starting sequence for pruning.
// Subsequent upgrades will not modify the pruning sequence thereby allowing pruning to continue from the last
// pruned sequence.
if !k.HasPruningSequence(ctx, portID, channelID) {
k.SetPruningSequence(ctx, portID, channelID, 1)
}
Copy link
Member

Choose a reason for hiding this comment

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

Little bit unclear here as to when and where else the pruning sequence is mutated, exactly? Is it supposed to be in the pruning msg server handler?

its here, right? https://github.com/cosmos/ibc-go/pull/5444/files#diff-b225d8b78960f1ed19ccabcbdcda5ff708075790adac8463fbb0a83a8a63b78aR1145

Copy link
Contributor Author

@DimitrisJim DimitrisJim Dec 20, 2023

Choose a reason for hiding this comment

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

Yes! I would totally be up for this being set during first execution of a pruning message instead. The good thing of having it here is that we can see in 10 lines of code the initial bounds being set.

@damiannolan
Copy link
Member

damiannolan commented Dec 20, 2023

Following from the last comment on naming. We could also consider:

  • PruningSequence -> PruningSequenceStart / PruningStartSequence
  • CounterpartyNextSequenceSend -> PruningSequenceEnd / PruningEndSequence

Any thoughts? cc. @colin-axner @charleenfei @chatton

note: the field on the upgrade itself can remain as NextSequenceSend but when we store it within a counterparty, should we consider storing under name that is reflective of what it is used for.

@AdityaSripal
Copy link
Member

I'm pro the naming change @damiannolan suggests as well, these sequences are only stored after the upgrade completes for the sole purpose of pruning. So i don't think you have to keep the name the same as it is in the upgrade field.

Store it under a pruning key that describes its particular purpose in the pruning logic

Copy link
Contributor

@chatton chatton left a comment

Choose a reason for hiding this comment

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

I'm in favour of PruningSequenceStart & PruningSequenceEnd suggested by @damiannolan to make things a little more explicit!

Otherwise everything else LGM

@charleenfei
Copy link
Contributor

I am pro the naming changes as well as suggested by @damiannolan ~thanks!

@DimitrisJim
Copy link
Contributor Author

beautiful suggestion @damiannolan, very much in favor,

@DimitrisJim DimitrisJim force-pushed the jim/set-key-for-max-pruning-limit branch from a3d5f27 to ff2b170 Compare December 20, 2023 12:15
@@ -1476,32 +1476,53 @@ func (suite *KeeperTestSuite) TestWriteUpgradeOpenChannel_Ordering() {
path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Ordering = types.UNORDERED
},
preUpgrade: func() {
ctx := suite.chainA.GetContext()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry for additional noise, couldn't help myself.

@DimitrisJim DimitrisJim force-pushed the jim/set-key-for-max-pruning-limit branch from 989e0b1 to 7a14704 Compare December 20, 2023 12:27
modules/core/04-channel/keeper/upgrade_test.go Outdated Show resolved Hide resolved
modules/core/04-channel/keeper/upgrade_test.go Outdated Show resolved Hide resolved
Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
@DimitrisJim DimitrisJim merged commit 608d9e2 into charly/set_nextseqrecv Dec 20, 2023
56 checks passed
@DimitrisJim DimitrisJim deleted the jim/set-key-for-max-pruning-limit branch December 20, 2023 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
channel-upgradability Channel upgradability feature priority PRs that need prompt reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants