-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: apply view_tag to reduce sync time #32
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How much of the speed up is due to threading and how much due to view tags. Just wondering why implementing view tags depends on adding threadpool support?
Did I see correctly that we always choose only one thread, so the above question doesn't make sense?
@feri42 , good question.
They are pretty much the same as each other. No significant benefit from batching process (parallel handling)
The duration is ~29 mins |
Another question about view tags. Are we able to fetch all transactions using view tags? It it seems to me like sent transactions to different addresses would all have different view tags and during a refresh or an initial scan we do not know all of those view tags. So there are scenarios where we do not fetch all transactions. |
Yes, we must fetch all transactions. We don't know exactly which view-tag belongs to the sender. We have to let the wallet loop for each output of a transaction and then do compare the output's view-tag with the derived view-tag from the sender's keys. This is exactly the way that Monero Wallet is doing. The view-tag is just the checkpoint to quickly decide to skip some EC operators, and we could reduce ~30% time to sync. |
Ahh. I see. We look at every transaction. From the transaction we know the sender (?) and once we have the sender we can get the view tag for this sender (sender/recipient). And once we have the view tags we can skip non-matching outputs. Is that it? |
1 similar comment
Ahh. I see. We look at every transaction. From the transaction we know the sender (?) and once we have the sender we can get the view tag for this sender (sender/recipient). And once we have the view tags we can skip non-matching outputs. Is that it? |
Yes @feri42 , it's correct. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK
Summary
One of the most common complaints around using Monero day-to-day is the time that it can take to sync up a wallet before being able to send Monero. It seems important to speed up scan times. I think we can easily reduce the sync timing ~30-40% with 1 additional byte per output; call it the 'view tag’.
The principle is simple (and has likely been suggested before), make a shared secret between the sender and receiver, hash it, then record the first 1 byte in the chain (the view tag). Recipients calculate the shared secret, hash it, and check if it matches any view tags in the tx. If it does match, then continue checking for owned outputs in the normal way. It will only match about 1/256 of the time, so scan time will be primarily a function of checking view tags.
I did many timing tests and saw the difference between before and after applying view_tag. The duration of sync has been reduced around by around 30 -> 40%.
Depending on adding the threadpool module in monero-core-custom
Screenshots
Here is my test when syncing +30k blocks before and after using view_tag
Before
After