From 52adf6975c1f7499d57e09375538303affb45530 Mon Sep 17 00:00:00 2001 From: Joshua Gutow Date: Wed, 26 Jun 2019 11:33:05 -0700 Subject: [PATCH] Trianglesphere/oom fix (#297) * Adds UseLightweightKDF option to mobile config The mobile geth config options were pared down tp reduce complexity, but the UseLightweightKDF option was not added. Because we use Geth to store our keys on mobile, we want to use the lightweight KDF otherwise we get OOM crashes on certain phones. * Sets node config KDF parameter correctly It needed to be passed through from mobile config to node config. * Adds links for reference --- mobile/geth.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/mobile/geth.go b/mobile/geth.go index 41c23fdac194..2f0e4624ba37 100644 --- a/mobile/geth.go +++ b/mobile/geth.go @@ -90,6 +90,11 @@ type NodeConfig struct { // This has to be integer since Enum exports to Java are not supported by "gomobile" // See getSyncMode(syncMode int) SyncMode int + + // UseLightweightKDF lowers the memory and CPU requirements of the key store + // scrypt KDF at the expense of security. + // See https://geth.ethereum.org/doc/Mobile_Account-management for reference + UseLightweightKDF bool } // defaultNodeConfig contains the default node configuration values to use if all @@ -132,11 +137,12 @@ func NewNode(datadir string, config *NodeConfig) (stack *Node, _ error) { // Create the empty networking stack nodeConf := &node.Config{ - Name: clientIdentifier, - Version: params.VersionWithMeta, - DataDir: datadir, - KeyStoreDir: filepath.Join(datadir, "keystore"), // Mobile should never use internal keystores! - IPCPath: "geth.ipc", + Name: clientIdentifier, + Version: params.VersionWithMeta, + DataDir: datadir, + KeyStoreDir: filepath.Join(datadir, "keystore"), // Mobile should never use internal keystores! + UseLightweightKDF: config.UseLightweightKDF, + IPCPath: "geth.ipc", P2P: p2p.Config{ NoDiscovery: true, DiscoveryV5: false,