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

feat(core/eureka): add packet handler #7048

Merged
merged 8 commits into from
Aug 6, 2024

Conversation

AdityaSripal
Copy link
Member

@AdityaSripal AdityaSripal commented Aug 5, 2024

Description

closes: #6999


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.

@AdityaSripal AdityaSripal changed the base branch from main to feat/ibc-eureka August 5, 2024 11:39
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.

looks great! left some initial comments

modules/core/packet-server/types/expected_keepers.go Outdated Show resolved Hide resolved
Comment on lines +93 to +96
channel := channeltypes.Channel{
Ordering: channeltypes.ORDERED,
ConnectionHops: []string{sourceChannel},
}
Copy link
Contributor

@DimitrisJim DimitrisJim Aug 6, 2024

Choose a reason for hiding this comment

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

I guess this is slightly nicer since it doesn't involve changing channel arg to pointer. Might be nice to move this into a sentinelChannel helper func that takes client id as arg to put in connection hops.

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, tho I think we will want to eventually break the event function signature

Copy link
Member Author

Choose a reason for hiding this comment

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

Also I did it this way, since once we add aliasing, sourceChannelID may not necessarily equal sourceClientID

}

// check that the client of receiver chain is still active
status := k.clientKeeper.GetClientStatus(ctx, sourceChannel)
Copy link
Contributor

Choose a reason for hiding this comment

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

if status := ...; status != exported.Active as an alt since we don't use status elsewhere.


// retrieve the sequence send for this channel
// if no packets have been sent yet, initialize the sequence to 1.
sequence, found := k.channelKeeper.GetNextSequenceSend(ctx, sourcePort, sourceChannel)
Copy link
Contributor

Choose a reason for hiding this comment

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

nice, basically handling chan handshake initialization here. No point in setting ones for ordered channels, I'd assume.

Copy link
Member Author

Choose a reason for hiding this comment

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

we need SequenceSend in UNORDERED also. But we don't need SequenceRecv or SequenceAck so i don't initialize those here

_ *capabilitytypes.Capability,
sourceChannel string,
sourcePort string,
destPort string,
Copy link
Member Author

Choose a reason for hiding this comment

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

destPort must be passed in but destChannel does not since we have it in the counterparty

Comment on lines +93 to +96
channel := channeltypes.Channel{
Ordering: channeltypes.ORDERED,
ConnectionHops: []string{sourceChannel},
}
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, tho I think we will want to eventually break the event function signature

Comment on lines +93 to +96
channel := channeltypes.Channel{
Ordering: channeltypes.ORDERED,
ConnectionHops: []string{sourceChannel},
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Also I did it this way, since once we add aliasing, sourceChannelID may not necessarily equal sourceClientID

return 0, errorsmod.Wrap(timeout.ErrTimeoutElapsed(latestHeight, latestTimestamp), "invalid packet timeout")
}

commitment := channeltypes.CommitPacket(packet)
Copy link
Member Author

Choose a reason for hiding this comment

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

This will commit with Eureka since PacketWithVersion always creates a Eureka packet

@AdityaSripal AdityaSripal marked this pull request as ready for review August 6, 2024 09:00
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.

lgtm! will defo do some reformatting of the test spacing on the side at some point 😅

// set the counterparties
path.SetupCounterparties()
}, nil},
{"counterparty not found", func() {}, channeltypes.ErrChannelNotFound},
Copy link
Contributor

Choose a reason for hiding this comment

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

could set source channel to ibctesting.FirstChannelID instead, this will also make it so that all SetupCounterparties calls can be removed (and SetupV2 can be used)

Comment on lines +70 to +78
latestHeight := k.ClientKeeper.GetClientLatestHeight(ctx, sourceChannel)
if latestHeight.IsZero() {
return 0, errorsmod.Wrapf(clienttypes.ErrInvalidHeight, "cannot send packet using client (%s) with zero height", sourceChannel)
}

latestTimestamp, err := k.ClientKeeper.GetClientTimestampAtHeight(ctx, sourceChannel, latestHeight)
if err != nil {
return 0, err
}
Copy link
Contributor

Choose a reason for hiding this comment

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

would be nice to get cov for these

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm seems a bit hard given that I'd have to manually write a zero consensus height and remove the ones automatically created.

Let's leave off for now

Copy link

sonarqubecloud bot commented Aug 6, 2024

@AdityaSripal AdityaSripal merged commit 567e730 into feat/ibc-eureka Aug 6, 2024
61 of 65 checks passed
@AdityaSripal AdityaSripal deleted the aditya/send-packet-eureka branch August 6, 2024 11:45
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