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

Simplify SendPacket API #1703

Merged
merged 27 commits into from
Oct 6, 2022
Merged

Simplify SendPacket API #1703

merged 27 commits into from
Oct 6, 2022

Conversation

AdityaSripal
Copy link
Member

@AdityaSripal AdityaSripal commented Jul 14, 2022

Description

closes: #1395


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

@@ -375,7 +375,9 @@ func (endpoint *Endpoint) SendPacket(packet exported.PacketI) error {
channelCap := endpoint.Chain.GetChannelCapability(packet.GetSourcePort(), packet.GetSourceChannel())

// no need to send message, acting as a module
err := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.SendPacket(endpoint.Chain.GetContext(), channelCap, packet)
// TODO: Change Endpoint SendPacket to take in arguments directly
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 will address this in a subsequent PR to reduce diffs

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you open an issue to track this work?

Copy link
Member Author

Choose a reason for hiding this comment

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

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!! Looks super clean, love how much simpler the SendTx code in ICA is.
Left one question about telemetry, not sure how critical it really is tho.

🚀

telemetry.NewLabel(coretypes.LabelDestinationPort, destinationPort),
telemetry.NewLabel(coretypes.LabelDestinationChannel, destinationChannel),
}
labels := []metrics.Label{}
Copy link
Member

Choose a reason for hiding this comment

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

Are we losing this telemetry info now for destination port and channel?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. cc: @colin-axner

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 it is okay, so long as there is telemetry within core IBC showing where packets are being sent from/to, then the telemetry could filter on port ID to get the same info. This might break external UX though, so might make more sense to do in a followup

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 telemetry is used on external UX? Also I just think it makes sense to keep it clean here, rather than grabbing channel just so that we can emit the same telemetry.

Afaiu, breaking telemetry does not count as an api breaking or state machine breaking change. So i don't want to be so restrictive and conservative in this case.

I'm in favor of just removing it. We can add it in the changelog so that people who need this information are informed of it beforehand

Copy link
Contributor

@colin-axner colin-axner Oct 3, 2022

Choose a reason for hiding this comment

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

Changing any of the labels will break the telemetry counter. Thus any IBC apps reporting statistics via Prometheus would likely break. I think it makes sense to check with external apps to ensure we don't make a disruptive change out of the blue

Copy link
Contributor

Choose a reason for hiding this comment

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

We could remove this telemetry entirely and replace it with one in core IBC that emits per packet sent, rather than duplicating for every application

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.

Looks great! Nice cleanup. I just had a few small questions

modules/apps/transfer/keeper/relay.go Outdated Show resolved Hide resolved
modules/core/04-channel/keeper/packet.go Outdated Show resolved Hide resolved
Copy link
Contributor

@crodriguezvega crodriguezvega left a comment

Choose a reason for hiding this comment

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

Thanks, @AdityaSripal! I think we need to add also some documentation in the migration docs for app developers, right? And we should decide in what version this should be released...

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.

Concept ACK, see suggested feedback. Seems like a straightforward change. Nice improvement! 🦾

modules/apps/transfer/keeper/relay.go Outdated Show resolved Hide resolved
telemetry.NewLabel(coretypes.LabelDestinationPort, destinationPort),
telemetry.NewLabel(coretypes.LabelDestinationChannel, destinationChannel),
}
labels := []metrics.Label{}
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 it is okay, so long as there is telemetry within core IBC showing where packets are being sent from/to, then the telemetry could filter on port ID to get the same info. This might break external UX though, so might make more sense to do in a followup

modules/core/04-channel/keeper/packet.go Outdated Show resolved Hide resolved
modules/core/05-port/types/module.go Outdated Show resolved Hide resolved
@@ -375,7 +375,9 @@ func (endpoint *Endpoint) SendPacket(packet exported.PacketI) error {
channelCap := endpoint.Chain.GetChannelCapability(packet.GetSourcePort(), packet.GetSourceChannel())

// no need to send message, acting as a module
err := endpoint.Chain.App.GetIBCKeeper().ChannelKeeper.SendPacket(endpoint.Chain.GetContext(), channelCap, packet)
// TODO: Change Endpoint SendPacket to take in arguments directly
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you open an issue to track this work?

modules/core/04-channel/keeper/packet.go Outdated Show resolved Hide resolved
@colin-axner colin-axner marked this pull request as draft September 28, 2022 11:31
@colin-axner
Copy link
Contributor

Marking as draft just so it is easier to know when suggestions and merge conflicts have been addressed and the pr is ready for a full review again

@codecov-commenter
Copy link

codecov-commenter commented Sep 30, 2022

Codecov Report

Merging #1703 (2faf51e) into main (8c7c655) will increase coverage by 0.02%.
The diff coverage is 77.50%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1703      +/-   ##
==========================================
+ Coverage   78.65%   78.67%   +0.02%     
==========================================
  Files         178      178              
  Lines       12367    12311      -56     
==========================================
- Hits         9727     9686      -41     
+ Misses       2208     2197      -11     
+ Partials      432      428       -4     
Impacted Files Coverage Δ
...7-interchain-accounts/controller/ibc_middleware.go 70.96% <0.00%> (ø)
...27-interchain-accounts/controller/keeper/keeper.go 92.53% <ø> (ø)
.../apps/27-interchain-accounts/host/keeper/keeper.go 83.80% <ø> (ø)
modules/apps/29-fee/ibc_middleware.go 91.83% <0.00%> (ø)
modules/apps/29-fee/keeper/keeper.go 92.48% <ø> (ø)
modules/apps/29-fee/keeper/relay.go 88.23% <0.00%> (ø)
modules/apps/transfer/keeper/keeper.go 91.17% <ø> (ø)
.../27-interchain-accounts/controller/keeper/relay.go 75.00% <66.66%> (+0.53%) ⬆️
modules/apps/transfer/keeper/relay.go 88.07% <80.00%> (-0.64%) ⬇️
modules/core/04-channel/keeper/packet.go 98.20% <92.59%> (+1.61%) ⬆️
... and 2 more

@@ -25,7 +26,7 @@ type Keeper struct {
cdc codec.BinaryCodec
paramSpace paramtypes.Subspace

ics4Wrapper icatypes.ICS4Wrapper
ics4Wrapper porttypes.ICS4Wrapper
Copy link
Member Author

Choose a reason for hiding this comment

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

No reason for us to duplicate ICS4Wrapper in the expected keepers. the interface already exists in port types. This also prevents accidentally missing a function. Done for all apps

modules/apps/29-fee/types/expected_keepers.go Outdated Show resolved Hide resolved
modules/apps/transfer/types/expected_keepers.go Outdated Show resolved Hide resolved
@@ -20,7 +20,7 @@ import (
var (
disabledTimeoutTimestamp = uint64(0)
disabledTimeoutHeight = clienttypes.ZeroHeight()
timeoutHeight = clienttypes.NewHeight(1, 100)
defaultTimeoutHeight = clienttypes.NewHeight(1, 100)
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 had to change this back since it was conflicting with the local var in TestSendPacket. I also just find it makes more sense, since there are some non default values I put in the test cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

There's a function on the destination chain now. suite.chainB.GetTimeoutHeight()

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.

I added back telemetry. Would prefer to intentionally remove it in a followup pr

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.

LGTM! Nice work 🚀

docs/migrations/v5-to-v6.md Outdated Show resolved Hide resolved
modules/core/04-channel/keeper/packet.go Show resolved Hide resolved
timeoutHeight clienttypes.Height,
timeoutTimestamp uint64,
data []byte,
) (sequence uint64, err error)
Copy link
Member

Choose a reason for hiding this comment

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

Should we leave these as unnamed return args as they are in other methods such as GetAppVersion?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is good as is in my opinion. OnChanOpenInit has named returns. GetAppVersion probably should have had a named return

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can make them all consistent in housekeeping followup.

@colin-axner
Copy link
Contributor

@crodriguezvega Are there any changes left you think we should make? With regards to your current suggestions, I think it probably makes sense to continue using the packet variables so as to ensure we are referencing the correct values

Otherwise I think this pr is ready to be merged

@@ -238,10 +238,21 @@ DecodePacketData(encoded []byte) (CustomPacketData) {
Then a module must encode its packet data before sending it through IBC.
Copy link
Contributor

Choose a reason for hiding this comment

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

I realized that this file is actually not used in the docs website, so could probably be removed...

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, looks like we took this info and split it up into separate files? Lets open an issue whose task is to see if any info in here should be moved before deleting the file

Copy link
Contributor

Choose a reason for hiding this comment

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

@crodriguezvega
Copy link
Contributor

@crodriguezvega Are there any changes left you think we should make?

Yes, I just updated the documentation. I would appreciate a review to check it all looks ok. After that, I agree we can merge it.

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.

Thanks @crodriguezvega for updating docs! I re-reviewed all changes

@colin-axner colin-axner removed their assignment Oct 6, 2022
@mergify mergify bot merged commit 88525d2 into main Oct 6, 2022
@mergify mergify bot deleted the aditya/send-packet-api branch October 6, 2022 11:11
mergify bot pushed a commit that referenced this pull request Oct 6, 2022
## Description

closes: #1395

---

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.

- [x] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting))
- [x] Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
- [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md).
- [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing)
- [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`)
- [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code).
- [ ] 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

(cherry picked from commit 88525d2)

# Conflicts:
#	modules/apps/29-fee/keeper/keeper.go
#	modules/core/04-channel/keeper/packet.go
#	modules/core/04-channel/keeper/packet_test.go
colin-axner added a commit that referenced this pull request Oct 11, 2022
* Simplify SendPacket API (#1703)

## Description

closes: #1395

---

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.

- [x] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#pr-targeting))
- [x] Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
- [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md).
- [ ] Wrote unit and integration [tests](https://github.com/cosmos/ibc-go/blob/master/CONTRIBUTING.md#testing)
- [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`)
- [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code).
- [ ] 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

(cherry picked from commit 88525d2)

# Conflicts:
#	modules/apps/29-fee/keeper/keeper.go
#	modules/core/04-channel/keeper/packet.go
#	modules/core/04-channel/keeper/packet_test.go

* fix conflicts

* Update develop.md

* remove test that was added for 02-client refactor (and therefore before v6.0.x was branched off)

Co-authored-by: Aditya <adityasripal@gmail.com>
Co-authored-by: crodriguezvega <carlos@interchain.io>
Co-authored-by: Carlos Rodriguez <crodveg@gmail.com>
Co-authored-by: colin axnér <25233464+colin-axner@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simplify SendPacket interface
7 participants