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

move packet executed call to ibc handler #6312

Merged
merged 6 commits into from
Jun 4, 2020

Conversation

colin-axner
Copy link
Contributor

@colin-axner colin-axner commented Jun 2, 2020

Description

I am leaving the check that the msg recv is in the correct order in PacketExecuted rather than doing this check in RecvPacket because after this check is made, the nextRecvSeq is incremented, so it is cleaner to leave it in the ...Executed func. The downside of this is application logic will be executed (but not persisted) even if the packet is to fail because it was received out of order. Any opinions on this?

closes: #6301


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

@codecov
Copy link

codecov bot commented Jun 2, 2020

Codecov Report

Merging #6312 into master will decrease coverage by 0.00%.
The diff coverage is 33.33%.

@@            Coverage Diff             @@
##           master    #6312      +/-   ##
==========================================
- Coverage   55.61%   55.61%   -0.01%     
==========================================
  Files         448      448              
  Lines       26941    26947       +6     
==========================================
+ Hits        14984    14987       +3     
- Misses      10883    10886       +3     
  Partials     1074     1074              

@@ -61,7 +61,7 @@ type IBCModule interface {
OnRecvPacket(
ctx sdk.Context,
packet channeltypes.Packet,
) (*sdk.Result, error)
) (*sdk.Result, []byte, error)
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 decided to modify the callback interface because

  • it is more clear to the application developer the contract required to fulfill this function securely
  • using sdk.Result.Data would be messy because you would need to require some specified format for the ack such as being prefixed by some string ie []byte("acknowledgement")+ack.GetBytes()

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, I think this is cleaner for the time being.

@colin-axner colin-axner marked this pull request as ready for review June 2, 2020 14:46
@colin-axner colin-axner added R4R and removed WIP labels Jun 2, 2020
@colin-axner colin-axner changed the title move packet executed to within ibc handler move packet executed call to ibc handler Jun 2, 2020
@cwgoes
Copy link
Contributor

cwgoes commented Jun 4, 2020

The downside of this is application logic will be executed (but not persisted) even if the packet is to fail because it was received out of order.

Can we just also check (but not increment) in RecvPacket, or would that be awkward?

Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

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

ACK although see comment. It's not a correctness requirement to check in RecvPacket but it might be nice.

@@ -61,7 +61,7 @@ type IBCModule interface {
OnRecvPacket(
ctx sdk.Context,
packet channeltypes.Packet,
) (*sdk.Result, error)
) (*sdk.Result, []byte, error)
Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, I think this is cleaner for the time being.

@fedekunze fedekunze added the A:automerge Automatically merge PR once all prerequisites pass. label Jun 4, 2020
@mergify mergify bot merged commit b1f483f into master Jun 4, 2020
@mergify mergify bot deleted the colin/6301-recvpacket-refactor branch June 4, 2020 11:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move PacketExecuted functionality to RecvPacket in channel keeper
3 participants