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

refactor: replace ack interface with result type for OnRecvPacket #7093

Merged
merged 13 commits into from
Aug 8, 2024

Conversation

damiannolan
Copy link
Member

@damiannolan damiannolan commented Aug 8, 2024

Description

Removes the exported.Acknowledgement interface and introduces a new concrete RecvPacketResult type.

closes: #7042


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/).
  • Added relevant godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

Copy link
Member Author

Choose a reason for hiding this comment

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

small bit of restructuring to the code here

@damiannolan damiannolan marked this pull request as ready for review August 8, 2024 14:30
@damiannolan damiannolan added the priority PRs that need prompt reviews label Aug 8, 2024
suite.SetupTest() // reset
path = ibctesting.NewPath(suite.chainA, suite.chainB)

tc.malleate()

err := suite.chainB.App.GetIBCKeeper().ChannelKeeper.WriteAcknowledgement(suite.chainB.GetContext(), packet, ack)

if tc.expPass {
expPass := tc.expError == nil
Copy link
Contributor

Choose a reason for hiding this comment

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

epic test refactor

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.

Woo!! Fantastic work my friend! Just as I expected 🙂 Everything LGTM. As mentioned we can tackle the WriteAcknowledgement another day. Only thing I noticed is docs on RecvPacketResult would be great!

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.

Squeaky clean PR, really nice job, just a few mega nits but happy to get this merged 💪

modules/apps/29-fee/ibc_middleware.go Outdated Show resolved Hide resolved

// String implements the fmt.Stringer interface.
func (r RecvPacketStatus) String() string {
return [...]string{"Success", "Failure", "Async"}[r]
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need the [...] ? Can this just be a return []string{"Success", "Failure", "Async"}[r]

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think its needed but I think its an optimisation(?).

Using the ... is essentially the same as having [3]string{"Success", "Failure", "Async"}[r] which makes an array with fixed size rather than a slice 🤷🏻‍♂️

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.

ACK doc updates :)

Comment on lines +21 to +27
// Success instructs that the IBC application state should be persisted.
Success RecvPacketStatus = iota
// Failure instructs that the IBC application state should be discarded.
Failure
// Async instructs that the IBC application state should be persisted
// and acknowledgement data will be written later asynchronously.
Async
Copy link
Member Author

Choose a reason for hiding this comment

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

Note for follow up, we might want these as RecvStatusSuccess, RecvStatusFailure or something like that..

Copy link

sonarqubecloud bot commented Aug 8, 2024

@damiannolan damiannolan merged commit 48b6a3f into feat/port-router Aug 8, 2024
62 of 65 checks passed
@damiannolan damiannolan deleted the damian/7042-recv-packet-result branch August 8, 2024 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority PRs that need prompt reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants