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

Allow zero proof height packet recv ack timeout #2781

Conversation

chatton
Copy link
Contributor

@chatton chatton commented Nov 17, 2022

Description

closes: #2751

Commit Message / Changelog Entry

type: commit message

see the guidelines for commit messages. (view raw markdown for examples)


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.
  • Provide a commit message to be used for the changelog entry in the PR description for review.
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

Comment on lines -806 to -801
name: "get timestamp at height not exists",
clientState: suite.solomachine.ClientState(),
height: suite.solomachine.ClientState().GetLatestHeight().Increment(),
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this test case was testing the behaviour of GetTimestampAtHeight which would error out when !cs.GetLatestHeight().EQ(height) , which means a zero proof would never be valid.

I'm not sure exactly how to go ahead with this test case or if it's still valid. cc @damiannolan @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.

We can change the behaviour of GetTimestampAtHeight() to ignore the passed in height, the timestamp returned should simply be the latest timestamp, thus this test case can be removed

Comment on lines -49 to -51
if !cs.GetLatestHeight().EQ(height) {
return 0, sdkerrors.Wrapf(ErrInvalidSequence, "not latest height (%s)", height)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this is correct 👍

@@ -46,7 +54,7 @@ func TestSoloMachineTestSuite(t *testing.T) {
suite.Run(t, new(SoloMachineTestSuite))
}

func (suite *SoloMachineTestSuite) TestSolomachineSetup() {
func (suite *SoloMachineTestSuite) SetupSolomachine() string {
Copy link
Member

Choose a reason for hiding this comment

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

I think we should maybe return a SolomachineConfig struct from this function which encapsulates the client/connection/channel/port IDs.

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 make use of ibctesting.Endpoint

Copy link
Member

Choose a reason for hiding this comment

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

That would nice!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looking into this now, is looks like the endpoints in all the other tests are constructed using a suite.chainA and suite.chainB, for this will we need to fully create instances of ibctesting.Endpoint that are referencing solomachine and chainA?

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 do you think we should do this in this PR or are you happy with a follow up issue? This PR is already pretty big!

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 any change to use endpoint can be made in a followup pr. I would not recommend modifying the testing package to handle solo machine endpoints, I was primarily thinking that you could manually fill in the endpoint with the correct values without supporting the ability to do suite.coordinator.Setup(path). I see the difficulty though since when you call NewEndpoint you provide quite a bit of information. What do you think about having a NewSolomachineEndpoint, also very open to just creating a new solomachine endpoint struct which contains less information (if that makes sense). I figure we can always consolidate the two types in the future if there is enough overlap

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 think a new type may work well here, I will create a follow up issue for this and look into after this is merged into your branch! 👍

@damiannolan
Copy link
Member

damiannolan commented Nov 18, 2022

I think this is more or less r4r. Pushed some additional changes for MsgTimeoutOnClose and grouped the functions together logically in testing/solomachine.go.

Maybe we should add a similar test which updates the solomachine client as well. Can be done in another PR.

@chatton chatton marked this pull request as ready for review November 18, 2022 13:41
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.

Yea, wahoo!! 🚀 This is so cool to have :) Thank you!!!

@@ -46,7 +54,7 @@ func TestSoloMachineTestSuite(t *testing.T) {
suite.Run(t, new(SoloMachineTestSuite))
}

func (suite *SoloMachineTestSuite) TestSolomachineSetup() {
func (suite *SoloMachineTestSuite) SetupSolomachine() string {
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 make use of ibctesting.Endpoint

// SendPacket mocks sending a packet by setting a packet commitment directly.
func (solo *Solomachine) SendPacket(chain *TestChain, packet channeltypes.Packet) {
commitmentHash := channeltypes.CommitPacket(chain.Codec, packet)
chain.GetSimApp().IBCKeeper.ChannelKeeper.SetPacketCommitment(chain.GetContext(), packet.GetSourcePort(), packet.GetSourceChannel(), packet.GetSequence(), commitmentHash)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally we actually send like an ics20 transfer. There was a bug in ibc core channel keeper in relation to solution machine which wouldn't be caught by this, but would be caught by calling ics20 send. I think other clients might look at these tests as inspiration, so might be useful to have a full test. Totally fine with creating a followup issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great suggestion, I'll create a follow up issue for this 👍

@colin-axner
Copy link
Contributor

colin-axner commented Nov 22, 2022

@chatton You may merge into my branch whenever you feel comfortable (also feel free to set my branch to automerge if I'm away when you do). If you'd like me to merge my branch into main first, just let me know. If you are waiting for an official approval from @damiannolan , that's totally fine, no rush

@chatton chatton merged commit 7cb3068 into colin/1874-sm-proof-height Nov 22, 2022
@chatton chatton deleted the damian/cian/2751-allow-zero-proof-height-packet-recv-ack-timeout branch November 22, 2022 16:14
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.

4 participants