Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

[CBR-400] Fix wallet failing to start #3486

Merged
merged 1 commit into from
Aug 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions auxx/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import Ntp.Client (NtpConfiguration)
import Pos.Chain.Txp (TxpConfiguration)
import qualified Pos.Client.CLI as CLI
import Pos.Context (NodeContext (..))
import Pos.Core as Core (Config (..), ConfigurationError,
configGeneratedSecretsThrow, epochSlots)
import Pos.Core as Core (Config (..), ConfigurationError, epochSlots)
import Pos.Crypto (ProtocolMagic)
import Pos.DB.DB (initNodeDBs)
import Pos.DB.Txp (txpGlobalSettings)
Expand Down Expand Up @@ -107,10 +106,11 @@ action opts@AuxxOptions {..} command = do
runWithConfig printAction coreConfig txpConfig ntpConfig = do
printAction "Mode: with-config"
CLI.printInfoOnStart aoCommonNodeArgs ntpConfig txpConfig
generatedSecrets <- configGeneratedSecretsThrow coreConfig
(nodeParams, tempDbUsed) <-
correctNodeParams opts =<<
CLI.getNodeParams loggerName cArgs nArgs generatedSecrets
(nodeParams, tempDbUsed) <- correctNodeParams opts =<< CLI.getNodeParams
loggerName
cArgs
nArgs
(configGeneratedSecrets coreConfig)

let toRealMode :: AuxxMode a -> RealMode EmptyMempoolExt a
toRealMode auxxAction = do
Expand Down
9 changes: 6 additions & 3 deletions explorer/src/explorer/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Pos.Client.CLI (CommonNodeArgs (..), NodeArgs (..),
getNodeParams)
import qualified Pos.Client.CLI as CLI
import Pos.Context (NodeContext (..))
import Pos.Core (Config (..), configGeneratedSecretsThrow, epochSlots)
import Pos.Core (Config (..), epochSlots)
import Pos.Crypto (ProtocolMagic)
import Pos.Explorer.DB (explorerInitDB)
import Pos.Explorer.ExtraContext (makeExtraCtx)
Expand Down Expand Up @@ -63,8 +63,11 @@ action (ExplorerNodeArgs (cArgs@CommonNodeArgs{..}) ExplorerArgs{..}) =
withCompileInfo $ do
CLI.printInfoOnStart cArgs ntpConfig txpConfig
logInfo $ "Explorer is enabled!"
generatedSecrets <- configGeneratedSecretsThrow coreConfig
currentParams <- getNodeParams loggerName cArgs nodeArgs generatedSecrets
currentParams <- getNodeParams
loggerName
cArgs
nodeArgs
(configGeneratedSecrets coreConfig)

let vssSK = fromJust $ npUserSecret currentParams ^. usVss
let sscParams = CLI.gtSscParams cArgs vssSK (npBehaviorConfig currentParams)
Expand Down
6 changes: 3 additions & 3 deletions lib/src/Pos/Client/CLI/Params.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ getNodeParams ::
=> LoggerName
-> CommonNodeArgs
-> NodeArgs
-> GeneratedSecrets
-> Maybe GeneratedSecrets
-> m NodeParams
getNodeParams defaultLoggerName cArgs@CommonNodeArgs{..} NodeArgs{..} generatedSecrets = do
(primarySK, userSecret) <- prepareUserSecret cArgs generatedSecrets
getNodeParams defaultLoggerName cArgs@CommonNodeArgs{..} NodeArgs{..} mGeneratedSecrets = do
(primarySK, userSecret) <- prepareUserSecret cArgs mGeneratedSecrets
=<< peekUserSecret (getKeyfilePath cArgs)
userPublic <- peekUserPublic publicKeyfilePath
npNetworkConfig <- intNetworkConfigOpts networkConfigOpts
Expand Down
14 changes: 10 additions & 4 deletions lib/src/Pos/Client/CLI/Secrets.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,23 @@ import Pos.Client.CLI.NodeOptions (CommonNodeArgs (..))
prepareUserSecret
:: (MonadIO m, WithLogger m)
=> CommonNodeArgs
-> GeneratedSecrets
-> Maybe GeneratedSecrets
-> UserSecret
-> m (SecretKey, UserSecret)
prepareUserSecret CommonNodeArgs {devGenesisSecretI} generatedSecrets userSecret = do
prepareUserSecret CommonNodeArgs {devGenesisSecretI} mGeneratedSecrets userSecret = do
(_, userSecretWithVss) <-
fillUserSecretVSS (rsVssKeyPair <$> predefinedRichKeys) userSecret
fillPrimaryKey (rsPrimaryKey <$> predefinedRichKeys) userSecretWithVss
where
predefinedRichKeys :: Maybe RichSecrets
predefinedRichKeys =
devGenesisSecretI >>= \i -> gsRichSecrets generatedSecrets ^? ix i
predefinedRichKeys = do
i <- devGenesisSecretI
case mGeneratedSecrets of
Nothing -> error
$ "devGenesisSecretI is specified, but GeneratedSecrets are "
<> "missing from Core.Config. GenesisInitializer might be "
<> "incorrectly specified."
Just generatedSecrets -> gsRichSecrets generatedSecrets ^? ix i

-- Make sure UserSecret contains a primary key.
fillPrimaryKey ::
Expand Down
8 changes: 5 additions & 3 deletions node/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import Pos.Chain.Txp (TxpConfiguration)
import Pos.Client.CLI (CommonNodeArgs (..), NodeArgs (..),
SimpleNodeArgs (..))
import qualified Pos.Client.CLI as CLI
import Pos.Core as Core (Config (..), configGeneratedSecretsThrow)
import Pos.Core as Core (Config (..))
import Pos.Crypto (ProtocolMagic)
import Pos.Launcher (HasConfigurations, NodeParams (..),
loggerBracket, runNodeReal, withConfigurations)
Expand Down Expand Up @@ -59,8 +59,10 @@ action
action (SimpleNodeArgs (cArgs@CommonNodeArgs {..}) (nArgs@NodeArgs {..})) coreConfig txpConfig ntpConfig = do
CLI.printInfoOnStart cArgs ntpConfig txpConfig
logInfo "Wallet is disabled, because software is built w/o it"
generatedSecrets <- configGeneratedSecretsThrow coreConfig
currentParams <- CLI.getNodeParams loggerName cArgs nArgs generatedSecrets
currentParams <- CLI.getNodeParams loggerName
cArgs
nArgs
(configGeneratedSecrets coreConfig)

let vssSK = fromJust $ npUserSecret currentParams ^. usVss
let sscParams = CLI.gtSscParams cArgs vssSK (npBehaviorConfig currentParams)
Expand Down
9 changes: 5 additions & 4 deletions tools/src/dbgen/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import Options.Generic (getRecord)
import Pos.Chain.Txp (TxpConfiguration)
import Pos.Client.CLI (CommonArgs (..), CommonNodeArgs (..),
NodeArgs (..), getNodeParams, gtSscParams)
import Pos.Core as Core (Config (..), Timestamp (..),
configGeneratedSecretsThrow, epochSlots)
import Pos.Core as Core (Config (..), Timestamp (..), epochSlots)
import Pos.DB.DB (initNodeDBs)
import Pos.DB.Rocks.Functions (openNodeDBs)
import Pos.DB.Rocks.Types (NodeDBs)
Expand Down Expand Up @@ -110,8 +109,10 @@ newRealModeContext coreConfig txpConfig dbs confOpts publicKeyPath secretKeyPath
, cnaDumpConfiguration = False
}
loggerName <- askLoggerName
generatedSecrets <- configGeneratedSecretsThrow coreConfig
nodeParams <- getNodeParams loggerName cArgs nodeArgs generatedSecrets
nodeParams <- getNodeParams loggerName
cArgs
nodeArgs
(configGeneratedSecrets coreConfig)
let vssSK = fromJust $ npUserSecret nodeParams ^. usVss
let gtParams = gtSscParams cArgs vssSK (npBehaviorConfig nodeParams)
bracketNodeResources @() nodeParams gtParams (txpGlobalSettings pm txpConfig) (initNodeDBs pm epochSlots) $ \NodeResources{..} ->
Expand Down
16 changes: 8 additions & 8 deletions wallet-new/server/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Pos.Chain.Ssc (SscParams)
import Pos.Chain.Txp (TxpConfiguration)
import qualified Pos.Client.CLI as CLI
import Pos.Context (ncUserSecret)
import Pos.Core (Config (..), configGeneratedSecretsThrow, epochSlots)
import Pos.Core (Config (..), epochSlots)
import Pos.Core.Genesis (GeneratedSecrets)
import Pos.Crypto (ProtocolMagic)
import Pos.DB.DB (initNodeDBs)
Expand Down Expand Up @@ -174,10 +174,10 @@ actionWithNewWallet pm txpConfig sscParams nodeParams ntpConfig params =
startEdgeNode :: HasCompileInfo => WalletStartupOptions -> IO ()
startEdgeNode wso =
withConfigurations blPath conf $ \coreConfig txpConfig ntpConfig -> do
generatedSecrets <- configGeneratedSecretsThrow coreConfig
(sscParams, nodeParams) <- getParameters generatedSecrets
txpConfig
ntpConfig
(sscParams, nodeParams) <- getParameters
(configGeneratedSecrets coreConfig)
txpConfig
ntpConfig
case wsoWalletBackendParams wso of
WalletLegacy legacyParams -> actionWithWallet
(configProtocolMagic coreConfig)
Expand All @@ -195,13 +195,13 @@ startEdgeNode wso =
newParams
where
getParameters :: HasConfigurations
=> GeneratedSecrets
=> Maybe GeneratedSecrets
-> TxpConfiguration
-> NtpConfiguration
-> IO (SscParams, NodeParams)
getParameters generatedSecrets txpConfig ntpConfig = do
getParameters mGeneratedSecrets txpConfig ntpConfig = do

currentParams <- CLI.getNodeParams defaultLoggerName (wsoNodeArgs wso) nodeArgs generatedSecrets
currentParams <- CLI.getNodeParams defaultLoggerName (wsoNodeArgs wso) nodeArgs mGeneratedSecrets
let vssSK = fromJust $ npUserSecret currentParams ^. usVss
let gtParams = CLI.gtSscParams (wsoNodeArgs wso) vssSK (npBehaviorConfig currentParams)

Expand Down