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

Fix bug in ICA SendTx #812

Merged
merged 2 commits into from
Jun 12, 2023
Merged

Fix bug in ICA SendTx #812

merged 2 commits into from
Jun 12, 2023

Conversation

sampocs
Copy link
Collaborator

@sampocs sampocs commented Jun 1, 2023

Closes: #XXX

Context

The Problem

With ibc-go v7, the keeper function SendTx was deprecated in favor of the msg_server function...

// from keeper function
k.ICAControllerKeeper.SendTx(...) 

// to msg_server function
msg := icacontrollertypes.NewMsgSendTx(...)
msgServer.SendTx(ctx, msg)

Whereas the timestamp in the keeper function was an absolute timestamp (i.e. the timeout in unix nano), the timestamp that should be passed into NewMsgSendTx is a relative timestamp (i.e. the offset in nano seconds between the current time and the timeout timestamp).

As the code lives on main, the absolute timestamp is being passed into NewMsgSendTx, which is causing the end timestamp to be essentially doubled:

# Ex: 
Current Time: 1000
Desired Timeout: 1010
NewMsgSendTx(1010) → Returns absolute timestamp of 2010

The Solution

There are two solutions here:

  1. Continue to use the new msg server API and adjust all invocations of SubmitTxs to pass the relative timestamp instead of the absolute timestamp
  2. Revert back to the legacy API

Considering option (1) would involve a big refactor, I think it makes sense to move forward with option (2) in the short term.

Brief Changelog

  • Reverted ICA SendTx call to legacy api


res, err := msgServer.SendTx(ctx, msg)
// TODO: SendTx is deprecated and MsgServer should used going forward
// IMPORTANT: When updating to MsgServer, the timestamp passed to NewMsgSendTx is the relative timeout offset,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch

@riley-stride
Copy link
Contributor

Great catch on the timeout, added a small issue to track it here

@sampocs sampocs added the A:automerge Automatically merge PR once checks pass label Jun 12, 2023
@mergify mergify bot merged commit b49bf45 into main Jun 12, 2023
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 checks pass C:stakeibc v10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants