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

sets chainProcessor sequence on wallet load #3660

Merged
merged 2 commits into from
Mar 20, 2023
Merged

Conversation

hughy
Copy link
Contributor

@hughy hughy commented Mar 17, 2023

Summary

the chainProcessor tracks the head of the chain using both the hash and sequence of a block. when the wallet loads we currently only set the has of the chainProcessor equal to the latest headd hash from among the accounts in the wallet.

one consequence of not setting the sequence at load time is that if a user creates an account while the node is offline, the chainProcessor is not fully initialized and the newly created account has its head set to null instead of set equal to the latest head in the wallet. the new account then needs to scan the whole chain to sync, even though it was just created and won't have any transactions earlier in the chain.

  • defines getLatestHead to load the latest head (hash and sequence) from among all accounts
  • sets both the hash and sequence of the chainProcessor from the latest head

Testing Plan

  • adds unit test for wallet load
  • manual testing:
    • use a node that has synced at least some blocks in a chain
    • with the node offline, run 'wallet:create' to create a new account
    • run 'wallet:status' to see that the head of the new account is equal to the latest head in the wallet

Documentation

Does this change require any updates to the Iron Fish Docs (ex. the RPC API
Reference
)? If yes, link a
related documentation pull request for the website.

[ ] Yes

Breaking Change

Is this a breaking change? If yes, add notes below on why this is breaking and
what additional work is required, if any.

[ ] Yes

the chainProcessor tracks the head of the chain using both the hash and sequence
of a block. when the wallet loads we currently only set the has of the
chainProcessor equal to the latest headd hash from among the accounts in the
wallet.

one consequence of not setting the sequence at load time is that if a user
creates an account while the node is offline, the chainProcessor is not fully
initialized and the newly created account has its head set to null instead of
set equal to the latest head in the wallet. the new account then needs to scan
the whole chain  to sync, even though it was just created and won't have any
transactions earlier in the chain.

- defines getLatestHead to load the latest head (hash and sequence) from among
  all accounts
- sets both the hash and sequence of the chainProcessor from the latest head
@hughy hughy marked this pull request as ready for review March 17, 2023 01:06
@hughy hughy requested a review from a team as a code owner March 17, 2023 01:06
Copy link
Contributor

@EvanJRichard EvanJRichard left a comment

Choose a reason for hiding this comment

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

Seems straightforward to me! 🚢

@hughy hughy merged commit 67c76f1 into staging Mar 20, 2023
@hughy hughy deleted the fix/load-chain-processor branch March 20, 2023 20:19
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