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

geth takes over an hour to start with a lot of keys in the keystore #16874

Open
Crypto2 opened this issue Jun 4, 2018 · 21 comments
Open

geth takes over an hour to start with a lot of keys in the keystore #16874

Crypto2 opened this issue Jun 4, 2018 · 21 comments

Comments

@Crypto2
Copy link

Crypto2 commented Jun 4, 2018

Hi,

This has been going on for a long time but geth takes longer and longer to start up. Currently using the pre-compiled 1.8.10 on Linux 64-bit. Pretty beefy machine with 128GB of RAM, NVMe storage, 3 GHz Xeon w/ 8 cores / 16 threads.

My best guess is it's because we have a lot of keys since it's for a wallet provider.

Quick example from today showing timestamps between these 2 lines of geth output:

INFO [06-04|04:26:23] Maximum peer count ETH=25 LES=0 total=25
INFO [06-04|05:38:10] Starting peer-to-peer node instance=Geth/v1.8.10-stable-eae63c51/linux-amd64/go1.10.

@jsvisa
Copy link
Contributor

jsvisa commented Jun 4, 2018

The time before node starting is the sync time, you can check out #16875 (comment) to see more

@Crypto2
Copy link
Author

Crypto2 commented Jun 6, 2018

This is before syncing ever starts. These are the 1st two lines of geth output.

@timnugent
Copy link

Same issue here with 1.8.10 - also a powerful machine and previously synced up to block ~5770000. Only a few keys on this one.

@Crypto2
Copy link
Author

Crypto2 commented Jul 27, 2018

Any update on this? It persists in 1.8.12.

@Crypto2
Copy link
Author

Crypto2 commented Jul 29, 2018

At least in my case it does seem to be related to having a lot of keys, I renamed my keystore folder and it started up right away as would be expected.

@Crypto2
Copy link
Author

Crypto2 commented Aug 8, 2018

@jsvisa Yep, just tried this on another machine with the same result.
with keystore = over an hour to start, without keystore = immediate start

@jsvisa
Copy link
Contributor

jsvisa commented Aug 9, 2018

@Crypto2 How much keys under keystore do you have? I'm try to start geth with 100 keys and no more much time to start in my local macOS.

@Crypto2
Copy link
Author

Crypto2 commented Aug 11, 2018

Several million, they should be loaded/scanned in another thread or something?

@Crypto2
Copy link
Author

Crypto2 commented Nov 22, 2018

Any updates on this?

@Crypto2
Copy link
Author

Crypto2 commented Jan 14, 2019

Any updates? Still takes hours to start.

If I start it with keystore renamed then move the files back in will it at least scan them in the background then even if it takes a long time? So we can process the blockchain and do things besides sending at least?

@Crypto2
Copy link
Author

Crypto2 commented Feb 25, 2019

@jsvisa Any updates? I can do the rename as indicated in my last post but it takes nearly a day for the keys to scan in the background. There has to be some way to speed this up?

@ligi
Copy link
Member

ligi commented May 21, 2019

How many keys do you have in your keystore? And what are your cache settings?

@holiman
Copy link
Contributor

holiman commented May 21, 2019

@Crypto2 could you provide your startup flags ?

@Crypto2
Copy link
Author

Crypto2 commented May 21, 2019

~4.5 million keys

Using: geth --ipcdisable --rpc --rpcapi "eth,net,web3,personal,admin,debug" --cache 16384 --syncmode fast --gcmode archive

@ligi ligi changed the title geth takes over an hour to start geth takes over an hour to start with a lot of keys in the keystore May 21, 2019
@ligi
Copy link
Member

ligi commented May 21, 2019

@Crypto2 thanks for the info - this is most likely the cause of the delay then. Can you elaborate a bit on your use-case? Why do you need 4.5 million keys in your keystore?

@holiman
Copy link
Contributor

holiman commented May 21, 2019

So, fun fact, although the filename contains the address, geth doesn't rely on that. Instead, geth opens every one of those 4.5 million keys and checks the address within, and places them in a cache, to provide mappings from address to file.

But I'm also curious why 4.5 million keys would be useful. A crypto exchange might want to consider using custom software to manage accounts in bulk -- geth is mainly trying to be a general usecase node. If there were some simple way of optimizing away that check, that'd be one thing, but that's not really feasible.

@ligi
Copy link
Member

ligi commented May 21, 2019

one thing that could be done for sure:

  • print a warning when the keystore contains too many files so users know this is the culprit

I could imagine optimizations that could be done there - e.g. cache the address->file mapping - but I am not sure this should be done as it really looks like the wrong tool is used for the job in this case.

@Crypto2
Copy link
Author

Crypto2 commented May 21, 2019

Yes it's a hosted wallet. If we knew it was going to be an issue beforehand we would have tried to do something different; it wasn't until years in that it became a problem. I would say there for sure should be some kind of address <-> file mapping since addresses have to be unlocked before use that's the perfect time for it to actually try to load and decrypt the key.

@Crypto2
Copy link
Author

Crypto2 commented Jun 28, 2019

Any update on this to load the keys faster and/or in the background?

@adamschmideg
Copy link
Contributor

This is a feature that could be implemented in Clef but it's far from obvious.

@Crypto2
Copy link
Author

Crypto2 commented Feb 14, 2020

Any updates on this? Such as:

  1. Saving the mapping to a file periodically that can be reloaded on the next start or into an LMDB table.
  2. Scanning the filenames into a list 1st before trying to load them, that way if a key is needed that hasn't been checked yet it can try based on the filename on demand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants