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

WalletScanner skips accounts with createdAt until createdAt sequence is reached #5652

Conversation

danield9tqh
Copy link
Member

@danield9tqh danield9tqh commented Nov 13, 2024

Summary

When an account has the following
createdAt: 10
head: null

the wallet scanner should not take any action on this account until it reaches block 10. Currently the wallet scanner will still connect blocks 1-10 (without decrypting transactions) but it still takes some time and it doesn't provide any value over just connecting block 10 directly

Testing Plan

Unit tests + running local wallet tests

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 label it with breaking-change-rpc or breaking-change-sdk.

[ ] Yes

@danield9tqh danield9tqh changed the title WIP Have wallet scanner skip accounts with createdAt and no head until createdAt sequence is reached Nov 13, 2024
@danield9tqh danield9tqh changed the title Have wallet scanner skip accounts with createdAt and no head until createdAt sequence is reached WalletScanner skips accounts with createdAt until createdAt sequence is reached Nov 13, 2024
Copy link
Contributor

@hughy hughy left a comment

Choose a reason for hiding this comment

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

Based on the description it seems like this should be getting rid of connectOnlyAccounts altogether -- if there's no reason to decrypt there's no reason to connect

@danield9tqh danield9tqh force-pushed the dont-scan-empty-accounts-with-birthday branch from 79100c2 to 6c2f87a Compare November 14, 2024 21:41
ironfish/src/wallet/scanner/walletScanner.ts Outdated Show resolved Hide resolved
@danield9tqh danield9tqh marked this pull request as ready for review November 20, 2024 19:46
@danield9tqh danield9tqh requested a review from a team as a code owner November 20, 2024 19:46
ironfish/src/wallet/scanner/walletScanner.ts Outdated Show resolved Hide resolved
for (const { scanFrom: head } of this.scanningAccounts) {
if (!head) {
return null
private async getEarliestHead(): Promise<HeadValue | null | 'none'> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does 'none' mean that all of the scanFroms are ahead of the chain head?

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it work to return the chain head in that case instead of the special 'none' value?

Copy link
Member Author

@danield9tqh danield9tqh Nov 20, 2024

Choose a reason for hiding this comment

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

I think its either

  1. earliest is ahead of the chain
  2. there are no scanning accounts

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure if returning the head would work for this case where we break https://github.com/iron-fish/ironfish/pull/5652/files#diff-4a43e4a9c484bea01d7248d51bc40948e7bbdd13c5bef3fdbfe0a02c7210f85dR138. If we set chain processor to head of the chain then maybe that's not the same as the chain processor's head (because it was set previously)

Idk its a good thought. I think I'll keep it as none for now though so don't have to think through / refactor that break statement

private scanningAccounts = new Array<{ account: Account; scanFrom: HeadValue | null }>()
private scanningAccounts = new Array<{
account: Account
scanFrom: { sequence: number; hash?: Buffer } | 'cursor'
Copy link
Contributor

Choose a reason for hiding this comment

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

Does 'cursor' mean that scanFrom is equal to the head of the wallet scanner?

Copy link
Member Author

Choose a reason for hiding this comment

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

yea, any thoughts on better name?

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 cursor is good, but it does make me wonder whether we should have an explicit head value on the walletScanner that we set and compare these to

Mostly I'm worried that we'll forget what these special string values mean 😅

@danield9tqh danield9tqh merged commit 0f88a51 into iron-fish:staging Nov 20, 2024
12 checks passed
@danield9tqh danield9tqh deleted the dont-scan-empty-accounts-with-birthday branch November 20, 2024 22:15
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