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
Faster wallet refreshes #3716
Faster wallet refreshes #3716
Conversation
28f42cd
to
9875f12
Compare
Here are some test results of a wallet scanning the whole blockchain: computer
master branch (4b728d7)
master branch + PR3716
master branch + PR3716 + refresh-type=no-coinbase
|
9875f12
to
c4fda6d
Compare
Now ready for review. |
Computer:
Master (25e7a7d):
PR-3716 (c4fda6d):
I can do two more tests on OSX machines with SSD and HDD. |
Note for testers: if you are to measure the time of scanning the entire blockchain from genesis, not only the restore height has to be set to 0, but also the wallet creation time must not be set to current. That is, if you create a new wallet and |
Computer:
Master:
PR-3716:
|
Computer:
Master:
PR-3716:
|
|
Computer: Purism Librem 13 Master:
PR-3716:
|
c4fda6d
to
286d4ff
Compare
src/rpc/core_rpc_server.cpp
Outdated
@@ -593,7 +597,7 @@ namespace cryptonote | |||
return true; | |||
} | |||
sorted_txs.push_back(std::move(txs.front())); | |||
txs.pop_front(); | |||
txs.erase(txs.begin()); |
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.
Isn't this an unneeded burden which can be avoided by having a counter and doing sorted_txs.push_back(std::move(txs[counter]));
?
src/wallet/wallet2.cpp
Outdated
{ | ||
error = false; | ||
|
||
try | ||
{ | ||
drop_from_short_history(short_chain_history, 3); | ||
|
||
// prepend the last 3 blocks, should be enough to guard against a block or two's reorg |
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.
This comment seems still relevant. Why remove?
src/wallet/wallet2.cpp
Outdated
hw::reset_mode rst(hwdev); | ||
|
||
hwdev.set_mode(hw::device::TRANSACTION_PARSE); | ||
if (!hwdev.generate_key_derivation(tx_pub_key, keys.m_view_secret_key, derivation)) |
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.
Since the line 1133(before) tx_pub_key = pub_key_field.pub_key;
was deleted, where does tx_pub_key
get its value?
src/wallet/wallet2.cpp
Outdated
hwdev.set_mode(hw::device::TRANSACTION_PARSE); | ||
const cryptonote::account_keys &keys = m_account.get_keys(); | ||
|
||
auto gender = [&](wallet2::is_out_data &iod) { |
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.
Had to wonder for a while what this name means :D
src/wallet/wallet2.h
Outdated
@@ -1282,6 +1295,8 @@ namespace tools | |||
std::string m_ring_database; | |||
bool m_ring_history_saved; | |||
std::unique_ptr<ringdb> m_ringdb; | |||
boost::optional<crypto::chacha_key> m_ringdb_key; | |||
unsigned int m_ringdb_key_refs; |
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.
Unused?
src/wallet/wallet2.cpp
Outdated
@@ -5791,6 +5810,7 @@ bool wallet2::get_ring(const crypto::chacha_key &key, const crypto::key_image &k | |||
|
|||
bool wallet2::get_rings(const crypto::hash &txid, std::vector<std::pair<crypto::key_image, std::vector<uint64_t>>> &outs) | |||
{ | |||
key_ref kref(*this); |
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.
Is this needed?
@@ -2332,6 +2333,8 @@ bool wallet2::delete_address_book_row(std::size_t row_id) { | |||
//---------------------------------------------------------------------------------------------------- | |||
void wallet2::refresh(uint64_t start_height, uint64_t & blocks_fetched, bool& received_money) | |||
{ | |||
key_ref kref(*this); |
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.
Is this needed?
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.
No, but it speeds up saving rings from incoming txes if there are several.
also use reserve where appropriate
Processing typically is the bottleneck
key derivation and checking for incoming outputs are threaded in batch before adding blocks to the local blockchain. Other minor bits and bobs are also cached.
Decrease the number of worker threads by one to account for the fact the calling thread acts as a worker thread now
Speeds up syncing with a lot of outgoing outputs as key generation runs Cryptonight.
286d4ff
to
0e4c7d0
Compare
Motivated by https://monero.stackexchange.com/questions/10483 Some exchanges appear to have customized the wallet software in an inappropriate way, making the tx extra field partially unreadable. PR monero-project#3716 changed the wallet behavior disallowing such partially valid tx extra. An example tx reported by the user is e87c675a85f34ecac58a8846613d25062f1813e1023c552b705afad32b972c38 where the normal tx pubkey appears again with the aditional tx pubkeys tag `04` which is inappropriate.
Motivated by https://monero.stackexchange.com/questions/10483 Some exchanges appear to have customized the wallet software in an inappropriate way, making the tx extra field partially unreadable. PR monero-project#3716 changed the wallet behavior disallowing such partially valid tx extra. An example tx reported by the user is e87c675a85f34ecac58a8846613d25062f1813e1023c552b705afad32b972c38 where the normal tx pubkey appears again with the aditional tx pubkeys tag `04` which is inappropriate.
Motivated by https://monero.stackexchange.com/questions/10483 Some exchanges appear to have customized the wallet software in an inappropriate way, making the tx extra field partially unreadable. PR monero-project#3716 changed the wallet behavior disallowing such partially valid tx extra. An example tx reported by the user is e87c675a85f34ecac58a8846613d25062f1813e1023c552b705afad32b972c38 where the normal tx pubkey appears again with the aditional tx pubkeys tag `04` which is inappropriate.
This has random stuff in it, because I need random stuff that's not merged, so all this has to be plonked in this tree for me to hack on it. I'll rebase once those things are merged.
Warning:
If you run this, your blockchain DB will upgrade to v2, which means you won't be able to run any daemon that does not have this patch (I'll get it merged once 0.12.1.0 is out of the way).
Speeds up between 2x and 5x. Speed tests welcome.
If your wallet is not a mining wallet (ie, you never got any coinbase output on it), setting refresh-type=no-coinbase now gives a pretty good speed boost.
vtnerd's wallet asm patch will give more speedup, as the wallet is using 90% of its time in the fe API.