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

ICS4: Write ErrorReceipt for previous upgrade on Reinitialization #5732

Merged
merged 7 commits into from
Jan 25, 2024

Conversation

AdityaSripal
Copy link
Member

Description

Writes error receipt for previous upgrade attempt if we initialize a new one. This allows the counterparty to cancel their upgrade and retry on the latest attempt
closes: #XXXX

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.

@codecov-commenter
Copy link

codecov-commenter commented Jan 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (310a4bd) 81.49% compared to head (000468f) 81.49%.
Report is 3 commits behind head on main.

❗ Current head 000468f differs from pull request most recent head 5131bc1. Consider uploading reports for the commit 5131bc1 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #5732   +/-   ##
=======================================
  Coverage   81.49%   81.49%           
=======================================
  Files         199      199           
  Lines       15203    15208    +5     
=======================================
+ Hits        12389    12394    +5     
  Misses       2348     2348           
  Partials      466      466           
Files Coverage Δ
modules/core/04-channel/keeper/upgrade.go 92.36% <100.00%> (+0.05%) ⬆️

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.

Looks great! Nice tests :)

Left one suggestion for a HasUpgrade function (which I don't think we have in keeper atm) which would save on some gas and look a little bit cleaner.

Comment on lines 56 to 60
_, priorUpgradeExists := k.GetUpgrade(ctx, portID, channelID)
if priorUpgradeExists {
// invalidating previous upgrade
k.WriteErrorReceipt(ctx, portID, channelID, types.NewUpgradeError(channel.UpgradeSequence, types.ErrInvalidUpgrade))
}
Copy link
Member

Choose a reason for hiding this comment

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

I think we can add HasUpgrade to keeper to save on minimal gas

if k.HasUpgrade(ctx, portId, channelID) {
    k.WriteErrorReceipt(ctx, portID, channelID, upgradeErr)
}

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.

Beautiful! 🚀

Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

Great work!! LGTM

@colin-axner colin-axner added priority PRs that need prompt reviews channel-upgradability Channel upgradability feature backport-to-v8.1.x labels Jan 25, 2024
@colin-axner colin-axner added this to the 04-channel upgrades RC milestone Jan 25, 2024
Copy link
Contributor

@DimitrisJim DimitrisJim left a comment

Choose a reason for hiding this comment

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

perfect! left one comment re API

modules/core/04-channel/keeper/keeper.go Outdated Show resolved Hide resolved
@colin-axner colin-axner enabled auto-merge (squash) January 25, 2024 16:57
@colin-axner colin-axner merged commit 574a639 into main Jan 25, 2024
60 of 62 checks passed
@colin-axner colin-axner deleted the aditya/fix-reinitialize branch January 25, 2024 17:02
mergify bot pushed a commit that referenced this pull request Jan 25, 2024
* fix reinitialization

* write error receipt on reinitialization

* gofumpt

* switch to Has instead of Get

* imp: HasUpgrade -> hasUpgrade

---------

Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
(cherry picked from commit 574a639)
DimitrisJim pushed a commit that referenced this pull request Jan 25, 2024
…) (#5743)

* fix reinitialization

* write error receipt on reinitialization

* gofumpt

* switch to Has instead of Get

* imp: HasUpgrade -> hasUpgrade

---------

Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
(cherry picked from commit 574a639)

Co-authored-by: Aditya <adityasripal@gmail.com>
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
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants