Closed barnabasbusa closed 2 weeks ago
@barnabasbusa I don't think this will be needed, did some investigation and it looks like the high decryption time is mostly related to us spawning cpu count workers + warm up inside worker running crypto operations. While the worker pool makes sense for a lot of keys, I noticed that Kurtosis uses pbkdf2 keystores with a lower c=2 param while most normal users use scrypt which is much slower per decrypt operation, like 1000x slower than that.
With workers disabled, and some optimization we did in our keystore library
Jul-15 09:11:56.107[] info: Connecting to LevelDB database path=/root/.local/share/lodestar/testnet/validator-db
Jul-15 09:11:56.614[] info: 100% of local keystores imported. current=64 total=64 rate=7664.67keys/m
Jul-15 09:11:57.514[] info: 64 local keystores
This is on par with other clients, around 1 sec to decrypt 64 keystores.
My idea is to add a CLI flag to disable the worker pool, you can than just set this in Kurtosis and would benefit from the speed up there, while for normal users, mostly using scrypt, it would still spawn the workers.
For anyone running Lodestar in a testing environment with insecure keys (pbkdf2 with c=2), we now have a new validator client CLI flag --disableKeystoresThreadPool
in our unstable / next release which will speed up key import by more than 10x.
Currently loading in lodestar validator keys one by one takes too long ~ 0.3 sec/key on an M1 macbook pro.
This means that on an average kurtosis run where the default validator will have 64 validator keys, each validator process will add an additional 20 seconds to start up.
Once the key loaded in once, lodestar stores it in a cache at
<dataDir>/cache
(default to~/.local/share/lodestar/<network_name>
).Example local_keystores.cache:
The keyfetching from this cache file takes a constant time of ~4 seconds (even if the number of keys is increased significantly). - Majority of the time still spent on decrypting this file, as this cached file is still enrypted.
Would it be possible to add functionality to generate this cache file during key generation? To derive this format this code bit is used: https://github.com/ChainSafe/lodestar/blob/unstable/packages/cli/src/cmds/validator/keymanager/keystoreCache.ts#L65-L85