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: update IncentivzedAck + add channeltype helpers for Ack #749

Closed

Conversation

seantking
Copy link
Contributor

@seantking seantking commented Jan 17, 2022

Description

  • Rename result in IncentivizedAcknowledgement to ack or app_acknowledgement or underlying_acknowledgement
  • Change IncentivizedAcknowledgement ack field to be an Any (implement Acknowledgement interface)
  • Change the Success() function for IncentivizedAcknowledgement to take into account the success of the underlying acknowledgment

closes: #XXXX


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


// UnpackAcknowledgement unpacks an Any into an Acknowledgement. It returns an error if the
// acknowledgement can't be unpacked into a Acknowledgement.
func UnpackAcknowledgement(any *codectypes.Any) (exported.Acknowledgement, 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.

@colin-axner I will make a follow-up PR with these changes into main if we decide to go this route.

@@ -23,8 +23,15 @@ func (k Keeper) WriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.C

k.DeleteForwardRelayerAddress(ctx, packetId)

ack := types.NewIncentivizedAcknowledgement(relayer, acknowledgement)
bz := ack.Acknowledgement()
ack := channeltypes.Acknowledgement{}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AdityaSripal Is this what you meant?

Copy link
Contributor

Choose a reason for hiding this comment

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

update the WriteAcknowledgement API to take in exported.Acknowledgement and then the code will look good

@seantking
Copy link
Contributor Author

seantking commented Jan 17, 2022

I have made this a draft PR for now as I'm unsure if this is the approach we want to take and I would like some early feedback.

I have added PackAcknowledgement/UnpackAcknowledgement helper fns to channeltypes as per @AdityaSripal suggestion.

@colin-axner @damiannolan feedback appreciated.

// IncentivizedAcknowledgement is the acknowledgement format to be used by applications wrapped in the fee middleware
// It contains the raw acknowledgement bytes, as well as the forward relayer address
message IncentivizedAcknowledgement {
bytes result = 1;
google.protobuf.Any app_acknowledgement = 1 [(gogoproto.moretags) = "yaml:\"forward_relayer_address\""];
Copy link
Contributor

Choose a reason for hiding this comment

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

yaml tag is incorrect

@@ -16,7 +19,12 @@ func NewIncentivizedAcknowledgement(relayer string, ack []byte) IncentivizedAckn
// considered successful if the forward relayer address is empty. Otherwise it is
// considered a failed acknowledgement.
func (ack IncentivizedAcknowledgement) Success() bool {
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 IncentivizedAcknowledgement needs to implement UnpackInterfaces. It might be best to write a test first to determine if this is true. UnpackInterfaces is used when JSON marshalling/unmarshalling an Any. That's why we have this test case

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 have implemented this but it seems to not be working 🤔 Getting some failed tests for the reason you mention here.

@@ -23,8 +23,15 @@ func (k Keeper) WriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.C

k.DeleteForwardRelayerAddress(ctx, packetId)

ack := types.NewIncentivizedAcknowledgement(relayer, acknowledgement)
bz := ack.Acknowledgement()
ack := channeltypes.Acknowledgement{}
Copy link
Contributor

Choose a reason for hiding this comment

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

update the WriteAcknowledgement API to take in exported.Acknowledgement and then the code will look good

@seantking
Copy link
Contributor Author

Closing in favor of : #952

@seantking seantking closed this Feb 21, 2022
@seantking seantking deleted the sean/fix-incentifized-acknowledgement branch August 3, 2022 13:59
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.

2 participants