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

Use timeout_height from signed amino doc #3772

Closed

Conversation

sam-utila
Copy link

What is the purpose of the change:

In institutional cases, the signature process may take a while.

This is why we override:

  sequence: signedSequence

Since maybe the sequence number has changes since the dApp sent its requested sign doc to the wallet - the wallet may update the sequence number to a new value, and the dApp should use the returned value - which was signed on.

The same reasoning should follow for timeout_height which is a newer addition to the protocol than sequence number.

Linear Task

N/A

Brief Changelog

Use timeout_height from signed amino doc

Testing and Verifying

This change has been tested locally using our own extension wallet that modifies timeout height

In institutional cases, the signature process may take a while.

This is why we override:

```
  sequence: signedSequence
```

Since maybe the sequence number has changes since the dApp sent its
requested sign doc to the wallet - the wallet may update the
sequence number to a new value, and the dApp should use the returned
value - which was signed on.

The same reasoning should follow for `timeout_height` which is a newer
addition to the protocol than sequence number.
Copy link

vercel bot commented Aug 20, 2024

@sam-utila is attempting to deploy a commit to the OsmoLabs Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Aug 20, 2024

Walkthrough

The change modifies the AccountStore class by updating the assignment of the timeoutHeight property. It now sources the value from the signed object instead of signDoc. This adjustment likely affects how timeout values are managed within the class, though the overall structure and behavior remain unchanged.

Changes

Files Change Summary
packages/stores/src/account/base.ts Updated assignment of timeoutHeight from signDoc.timeout_height to signed.timeout_height.

Sequence Diagram(s)

sequenceDiagram
    participant AccountStore
    participant SignDoc
    participant Signed

    AccountStore->>SignDoc: Retrieve timeout_height
    SignDoc-->>AccountStore: signDoc.timeout_height
    AccountStore->>Signed: Retrieve timeout_height
    Signed-->>AccountStore: signed.timeout_height
Loading

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 62c01ac and 797d913.

Files selected for processing (1)
  • packages/stores/src/account/base.ts (1 hunks)
Additional comments not posted (1)
packages/stores/src/account/base.ts (1)

1114-1114: LGTM! Ensure consistent usage of timeoutHeight.

The change to use signed.timeout_height ensures that the timeoutHeight reflects the latest value from the signed document, aligning with the PR objectives.

Verify that all references to timeoutHeight in the codebase are consistent with this change.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range, codebase verification and nitpick comments (3)
packages/stores/src/account/base.ts (3)

Line range hint 287-293: Improve error handling in getWalletRepo.

Consider adding more specific error messages or handling for cases where the wallet repository is not found.

- throw new Error(`Chain ${chainNameOrId} is not provided.`);
+ throw new Error(`Wallet repository for chain '${chainNameOrId}' is not found. Please ensure the chain ID is correct and the wallet is connected.`);

Line range hint 374-377: Check for nullability in getWallet.

Ensure that the wallet variable is not null before accessing properties. Consider adding a null check or handling for the wallet variable.

- const walletInfo = wallet.walletInfo as CosmosRegistryWallet;
+ const walletInfo = wallet?.walletInfo as CosmosRegistryWallet;

Line range hint 1024-1027: Clarify error message in signDirect.

The error message "Failed to retrieve account from signer" could be more informative by including the signer address.

- throw new Error("Failed to retrieve account from signer");
+ throw new Error(`Failed to retrieve account from signer for address: ${signerAddress}`);

Copy link

vercel bot commented Aug 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
osmosis-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 30, 2024 5:03am

@jonator
Copy link
Member

jonator commented Aug 30, 2024

@sam-utila how did you notice this?

@sam-utila
Copy link
Author

Basically timeout_height bytes are part of the body not the auth_info (where sequence is located) - and generally they should not be touched by the wallet.

But memo is also in body.

So if there are multiple signers for the transactions - the wallet is not allowed to touch memo or timeout_height.

However - if I'm the only signer - why not?
I want to update the timeout_height to be something close to the point of the actual signing of the transaction.
In institutional wallets (like Utila) the TX may live for a while before it is approved and signed - so editing the timeout_height should be okay.

@kamal-sutra
Copy link
Contributor

@sam-utila can you update to the latest branch of stage please

@jonator jonator closed this Oct 8, 2024
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.

3 participants