web3swift icon indicating copy to clipboard operation
web3swift copied to clipboard

Keystore Initialization - 100% CPU Usage

Open virus-zip opened this issue 3 years ago • 5 comments
trafficstars

The initialization of a Keystore freezes the whole application and apparently throws a load of work onto the CPU - 100%.

let keystore = try! EthereumKeystoreV3(privateKey: dataKey, password: password)!

This line is completely copied from the examples and uses simple strings. The function itself is the cause of the issue.

virus-zip avatar Jan 29 '22 04:01 virus-zip

Experiencing this as well, the whole device locks up. BIP32Keystore suffers from the same issue. I believe the issue is coming from scrypt, line 103 in EthereumKeyStoreV3.swift. Have not found a workaround yet.

johnCbogil avatar Feb 06 '22 22:02 johnCbogil

Can confirm. Best workaround right now is to run in the background via DispatchQueue. Obviously it would be better if this would happen in the key store classes directly.

janndriessen avatar Feb 12 '22 15:02 janndriessen

confirmed issue is in scrypt and all its calls to the function rotateLeft

pharms-eth avatar Mar 20 '22 22:03 pharms-eth

This should only be an issue in debug builds when using SPM. Can someone please confirm if this is still an issue using the latest version of web3swift and building/running in release mode?

mloit avatar Apr 28 '22 23:04 mloit

This should only be an issue in debug builds when using SPM. Can someone please confirm if this is still an issue using the latest version of web3swift and building/running in release mode?

Can confirm. Have no issues for release builds.

janndriessen avatar Jun 14 '22 09:06 janndriessen