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

WIP karknu/acceptance workarounds #3657

Closed
wants to merge 2 commits into from
Closed
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
35 changes: 28 additions & 7 deletions lib/src/Pos/Network/Block/Retrieval.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ module Pos.Network.Block.Retrieval

import Universum

import Control.Concurrent.STM (putTMVar, swapTMVar, tryReadTBQueue,
tryReadTMVar, tryTakeTMVar)
import Control.Concurrent.STM (TVar, newTVar, putTMVar, swapTMVar,
swapTVar, tryReadTBQueue, tryReadTMVar, tryTakeTMVar)
import Control.Exception.Safe (handleAny)
import Control.Lens (to)
import Control.Monad.STM (retry)
Expand Down Expand Up @@ -341,16 +341,37 @@ streamProcessBlocks
-> m ()
streamProcessBlocks genesisConfig txpConfig diffusion nodeId desired checkpoints = do
logInfo "streaming start"
r <- Diffusion.streamBlocks diffusion nodeId desired checkpoints writeCallback
mostDifficultBlock <- atomically $ newTVar Nothing
r <- Diffusion.streamBlocks diffusion nodeId desired checkpoints (writeCallback mostDifficultBlock)
case r of
Nothing -> do
logInfo "streaming not supported, reverting to batch mode"
getProcessBlocks genesisConfig txpConfig diffusion nodeId desired checkpoints
Just _ -> do
logInfo "streaming done"
return ()

recHeaderVar <- view (lensOf @RecoveryHeaderTag)
exitedRecovery <- atomically $ do
mbMostDifficult <- readTVar mostDifficultBlock
mbRecHeader <- tryReadTMVar recHeaderVar
case (mbMostDifficult, mbRecHeader) of
(Nothing, _) -> pure False -- We have not gotten a single block
(Just _, Nothing) -> pure False -- We where not in recovery?
(Just mostDifficult, Just (_, recHeader)) ->
if (mostDifficult ^. difficultyL) >= (recHeader ^. difficultyL)
then isJust <$> tryTakeTMVar recHeaderVar
else pure False

if exitedRecovery
then do
logInfo "Recovery mode exited gracefully on receiving block we needed"
return ()
else do -- Streaming stopped but we didn't make any progress
_ <- dropRecoveryHeaderAndRepeat genesisConfig diffusion nodeId
return ()
where
writeCallback :: [Block] -> m ()
writeCallback [] = return ()
writeCallback (block:blocks) =
writeCallback :: (TVar (Maybe Block)) -> [Block] -> m ()
writeCallback _ [] = return ()
writeCallback mostDifficultBlock (block:blocks) = do
_ <- atomically $ swapTVar mostDifficultBlock (Just block)
handleBlocks genesisConfig txpConfig (OldestFirst (NE.reverse $ block :| blocks)) diffusion
6 changes: 3 additions & 3 deletions scripts/launch/connect-to-cluster/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
, system ? builtins.currentSystem
, pkgs ? import localLib.fetchNixPkgs { inherit system config; }
, gitrev ? localLib.commitIdFromGitRepo ./../../../.git
, walletListen ? "127.0.0.1:8090"
, walletDocListen ? "127.0.0.1:8091"
, ekgListen ? "127.0.0.1:8000"
, walletListen ? "localhost:8090"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer needed because #3658 fixed the issue.
It's also good to sometimes test IP addresses rather than hostnames because this is something users (exchanges) like to do.

, walletDocListen ? "localhost:8091"
, ekgListen ? "localhost:8000"
, ghcRuntimeArgs ? "-N2 -qg -A1m -I0 -T"
, additionalNodeArgs ? ""
, confFile ? null
Expand Down
2 changes: 1 addition & 1 deletion scripts/test/acceptance/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ in

${utf8LocaleSetting}
echo Launching wallet node: ${wallet}
${wallet} &> ${stateDir}/logs/wallet.log &
${wallet} --runtime-args " --legacy-wallet +RTS -M6G" &> ${stateDir}/logs/wallet.log &
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already implemented by #3626

wallet_pid=$!

start_time=$(date +%s)
Expand Down