Skip to content

Commit

Permalink
Revert "try to use p2p topology - fail"
Browse files Browse the repository at this point in the history
This reverts commit d55973a225c61688336827db8097b0916530dad1.
  • Loading branch information
carbolymer committed Sep 30, 2024
1 parent 33b4d42 commit 5faedcb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 29 deletions.
4 changes: 3 additions & 1 deletion cardano-testnet/cardano-testnet.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ library
, cardano-ledger-shelley
, cardano-node
, cardano-ping ^>= 0.4
, contra-tracer
, containers
, data-default-class
, cborg
, containers
, contra-tracer
Expand All @@ -60,7 +63,6 @@ library
, filepath
, hedgehog
, hedgehog-extras ^>= 0.6.4
, iproute
, lens-aeson
, microlens
, mtl
Expand Down
35 changes: 8 additions & 27 deletions cardano-testnet/src/Testnet/Start/Cardano.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ import Cardano.Api.Ledger (StandardCrypto)
import Cardano.Ledger.Alonzo.Genesis (AlonzoGenesis)
import Cardano.Ledger.Conway.Genesis (ConwayGenesis)
import Cardano.Node.Configuration.Topology
import qualified Cardano.Node.Configuration.TopologyP2P as P2P
import qualified Ouroboros.Network.PeerSelection.Bootstrap as P2P
import qualified Ouroboros.Network.PeerSelection.LedgerPeers as P2P
import qualified Ouroboros.Network.PeerSelection.PeerTrustable as P2P

import Prelude hiding (lines)

Expand All @@ -44,7 +40,6 @@ import qualified Data.Aeson as Aeson
import Data.Bifunctor (first)
import qualified Data.ByteString.Lazy as LBS
import Data.Either
import Data.IP as IP
import qualified Data.List as L
import Data.Maybe
import qualified Data.Text as Text
Expand All @@ -54,7 +49,6 @@ import qualified Data.Time.Clock as DTC
import Data.Word (Word64)
import GHC.Stack
import qualified GHC.Stack as GHC
import qualified System.Directory as IO
import System.FilePath ((</>))
import qualified System.Info as OS
import Text.Printf (printf)
Expand Down Expand Up @@ -197,7 +191,8 @@ cardanoTestnet
let (CardanoTestnetOptions _cardanoNodes asbe maxSupply _p2p nodeLoggingFormat _numDReps newEpochStateLogging) = testnetOptions
startTime = sgSystemStart shelleyGenesis
testnetMagic = fromIntegral $ sgNetworkMagic shelleyGenesis
nPools@(NumPools numPoolNodes) = numPools testnetOptions
numPoolNodes = length $ cardanoNodes testnetOptions
nPools = numPools testnetOptions
nDReps = numDReps testnetOptions
AnyShelleyBasedEra sbe <- pure asbe

Expand Down Expand Up @@ -236,15 +231,15 @@ cardanoTestnet

configurationFile <- H.noteShow . File $ tmpAbsPath </> "configuration.yaml"

_ <- createSPOGenesisAndFiles 1 nDReps maxSupply asbe shelleyGenesis alonzoGenesis conwayGenesis (TmpAbsolutePath tmpAbsPath)
_ <- createSPOGenesisAndFiles nPools nDReps maxSupply asbe shelleyGenesis alonzoGenesis conwayGenesis (TmpAbsolutePath tmpAbsPath)

-- TODO: This should come from the configuration!
let poolKeyDir :: Int -> FilePath
poolKeyDir i = "pools-keys" </> mkNodeName i
mkNodeName :: Int -> String
mkNodeName i = "pool" <> show i

poolKeys <- H.noteShow $ flip fmap [1..1] $ \n ->
poolKeys <- H.noteShow $ flip fmap [1..numPoolNodes] $ \n ->
-- TODO: use Testnet.Defaults.defaultSpoKeys here
PoolNodeKeys
{ poolNodeKeysCold =
Expand Down Expand Up @@ -313,10 +308,8 @@ cardanoTestnet
-- Byron related
forM_ (zip [1..] portNumbers) $ \(i, portNumber) -> do
let iStr = printf "%03d" (i - 1)
when (i == 1) $ do
H.renameFile (tmpAbsPath </> "byron-gen-command" </> "delegate-keys." <> iStr <> ".key") (tmpAbsPath </> poolKeyDir i </> "byron-delegate.key")
H.renameFile (tmpAbsPath </> "byron-gen-command" </> "delegation-cert." <> iStr <> ".json") (tmpAbsPath </> poolKeyDir i </> "byron-delegation.cert")
H.evalIO $ IO.createDirectoryIfMissing True $ tmpAbsPath </> poolKeyDir i
H.renameFile (tmpAbsPath </> "byron-gen-command" </> "delegate-keys." <> iStr <> ".key") (tmpAbsPath </> poolKeyDir i </> "byron-delegate.key")
H.renameFile (tmpAbsPath </> "byron-gen-command" </> "delegation-cert." <> iStr <> ".json") (tmpAbsPath </> poolKeyDir i </> "byron-delegation.cert")
H.writeFile (tmpAbsPath </> poolKeyDir i </> "port") (show portNumber)

-- Make topology files
Expand All @@ -327,21 +320,9 @@ cardanoTestnet
, raPort = otherProducerPort
, raValency = 1
}

H.lbsWriteFile (tmpAbsPath </> poolKeyDir i </> "topology.json") . encode $
RealNodeTopology producers
-- P2P.RelayAccessAddress
-- (IP.IPv4 $ IP.fromHostAddress testnetDefaultIpv4Address)
-- otherProducerPort
-- rootConfig = P2P.RootConfig peers P2P.DoNotAdvertisePeer
-- peersGroup = P2P.LocalRootPeersGroup rootConfig 2 2 P2P.IsTrustable
-- H.lbsWriteFile (tmpAbsPath </> poolKeyDir i </> "topology.json") . encode $
-- P2P.RealNodeTopology
-- (P2P.LocalRootPeersGroups [peersGroup])
-- []
-- (if i == 1
-- then P2P.DontUseLedgerPeers
-- else P2P.UseLedgerPeers P2P.Always)
-- P2P.DontUseBootstrapPeers

let keysWithPorts = L.zip3 [1..] poolKeys portNumbers
ePoolNodes <- H.forConcurrently keysWithPorts $ \(i, key, port) -> do
Expand Down Expand Up @@ -412,7 +393,7 @@ cardanoTestnet

stakePoolsFp <- H.note $ tmpAbsPath </> "current-stake-pools.json"

assertExpectedSposInLedgerState stakePoolsFp 1 execConfig
assertExpectedSposInLedgerState stakePoolsFp nPools execConfig

when newEpochStateLogging $
TR.startLedgerNewEpochStateLogging runtime tempBaseAbsPath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ prop_check_if_treasury_is_growing = integrationRetryWorkspace 0 "growing-treasur
}

TestnetRuntime{testnetMagic, configurationFile, poolNodes} <- cardanoTestnetDefault options shelleyOptions conf
H.failure

(execConfig, socketPathAbs) <- do
PoolNode{poolRuntime} <- H.headM poolNodes
Expand Down

0 comments on commit 5faedcb

Please sign in to comment.