@@ -30,6 +30,10 @@ import Cardano.Api.Ledger (StandardCrypto)
30
30
import Cardano.Ledger.Alonzo.Genesis (AlonzoGenesis )
31
31
import Cardano.Ledger.Conway.Genesis (ConwayGenesis )
32
32
import Cardano.Node.Configuration.Topology
33
+ import qualified Cardano.Node.Configuration.TopologyP2P as P2P
34
+ import qualified Ouroboros.Network.PeerSelection.Bootstrap as P2P
35
+ import qualified Ouroboros.Network.PeerSelection.LedgerPeers as P2P
36
+ import qualified Ouroboros.Network.PeerSelection.PeerTrustable as P2P
33
37
34
38
import Prelude hiding (lines )
35
39
@@ -40,6 +44,7 @@ import qualified Data.Aeson as Aeson
40
44
import Data.Bifunctor (first )
41
45
import qualified Data.ByteString.Lazy as LBS
42
46
import Data.Either
47
+ import Data.IP as IP
43
48
import qualified Data.List as L
44
49
import Data.Maybe
45
50
import qualified Data.Text as Text
@@ -49,6 +54,7 @@ import qualified Data.Time.Clock as DTC
49
54
import Data.Word (Word64 )
50
55
import GHC.Stack
51
56
import qualified GHC.Stack as GHC
57
+ import qualified System.Directory as IO
52
58
import System.FilePath ((</>) )
53
59
import qualified System.Info as OS
54
60
import Text.Printf (printf )
@@ -191,8 +197,7 @@ cardanoTestnet
191
197
let (CardanoTestnetOptions _cardanoNodes asbe maxSupply _p2p nodeLoggingFormat _numDReps newEpochStateLogging) = testnetOptions
192
198
startTime = sgSystemStart shelleyGenesis
193
199
testnetMagic = fromIntegral $ sgNetworkMagic shelleyGenesis
194
- numPoolNodes = length $ cardanoNodes testnetOptions
195
- nPools = numPools testnetOptions
200
+ nPools@ (NumPools numPoolNodes) = numPools testnetOptions
196
201
nDReps = numDReps testnetOptions
197
202
AnyShelleyBasedEra sbe <- pure asbe
198
203
@@ -231,15 +236,15 @@ cardanoTestnet
231
236
232
237
configurationFile <- H. noteShow . File $ tmpAbsPath </> " configuration.yaml"
233
238
234
- _ <- createSPOGenesisAndFiles nPools nDReps maxSupply asbe shelleyGenesis alonzoGenesis conwayGenesis (TmpAbsolutePath tmpAbsPath)
239
+ _ <- createSPOGenesisAndFiles 1 nDReps maxSupply asbe shelleyGenesis alonzoGenesis conwayGenesis (TmpAbsolutePath tmpAbsPath)
235
240
236
241
-- TODO: This should come from the configuration!
237
242
let poolKeyDir :: Int -> FilePath
238
243
poolKeyDir i = " pools-keys" </> mkNodeName i
239
244
mkNodeName :: Int -> String
240
245
mkNodeName i = " pool" <> show i
241
246
242
- poolKeys <- H. noteShow $ flip fmap [1 .. numPoolNodes ] $ \ n ->
247
+ poolKeys <- H. noteShow $ flip fmap [1 .. 1 ] $ \ n ->
243
248
-- TODO: use Testnet.Defaults.defaultSpoKeys here
244
249
PoolNodeKeys
245
250
{ poolNodeKeysCold =
@@ -308,8 +313,10 @@ cardanoTestnet
308
313
-- Byron related
309
314
forM_ (zip [1 .. ] portNumbers) $ \ (i, portNumber) -> do
310
315
let iStr = printf " %03d" (i - 1 )
311
- H. renameFile (tmpAbsPath </> " byron-gen-command" </> " delegate-keys." <> iStr <> " .key" ) (tmpAbsPath </> poolKeyDir i </> " byron-delegate.key" )
312
- H. renameFile (tmpAbsPath </> " byron-gen-command" </> " delegation-cert." <> iStr <> " .json" ) (tmpAbsPath </> poolKeyDir i </> " byron-delegation.cert" )
316
+ when (i == 1 ) $ do
317
+ H. renameFile (tmpAbsPath </> " byron-gen-command" </> " delegate-keys." <> iStr <> " .key" ) (tmpAbsPath </> poolKeyDir i </> " byron-delegate.key" )
318
+ H. renameFile (tmpAbsPath </> " byron-gen-command" </> " delegation-cert." <> iStr <> " .json" ) (tmpAbsPath </> poolKeyDir i </> " byron-delegation.cert" )
319
+ H. evalIO $ IO. createDirectoryIfMissing True $ tmpAbsPath </> poolKeyDir i
313
320
H. writeFile (tmpAbsPath </> poolKeyDir i </> " port" ) (show portNumber)
314
321
315
322
-- Make topology files
@@ -320,9 +327,21 @@ cardanoTestnet
320
327
, raPort = otherProducerPort
321
328
, raValency = 1
322
329
}
323
-
324
330
H. lbsWriteFile (tmpAbsPath </> poolKeyDir i </> " topology.json" ) . encode $
325
331
RealNodeTopology producers
332
+ -- P2P.RelayAccessAddress
333
+ -- (IP.IPv4 $ IP.fromHostAddress testnetDefaultIpv4Address)
334
+ -- otherProducerPort
335
+ -- rootConfig = P2P.RootConfig peers P2P.DoNotAdvertisePeer
336
+ -- peersGroup = P2P.LocalRootPeersGroup rootConfig 2 2 P2P.IsTrustable
337
+ -- H.lbsWriteFile (tmpAbsPath </> poolKeyDir i </> "topology.json") . encode $
338
+ -- P2P.RealNodeTopology
339
+ -- (P2P.LocalRootPeersGroups [peersGroup])
340
+ -- []
341
+ -- (if i == 1
342
+ -- then P2P.DontUseLedgerPeers
343
+ -- else P2P.UseLedgerPeers P2P.Always)
344
+ -- P2P.DontUseBootstrapPeers
326
345
327
346
let keysWithPorts = L. zip3 [1 .. ] poolKeys portNumbers
328
347
ePoolNodes <- H. forConcurrently keysWithPorts $ \ (i, key, port) -> do
@@ -393,7 +412,7 @@ cardanoTestnet
393
412
394
413
stakePoolsFp <- H. note $ tmpAbsPath </> " current-stake-pools.json"
395
414
396
- assertExpectedSposInLedgerState stakePoolsFp nPools execConfig
415
+ assertExpectedSposInLedgerState stakePoolsFp 1 execConfig
397
416
398
417
when newEpochStateLogging $
399
418
TR. startLedgerNewEpochStateLogging runtime tempBaseAbsPath
0 commit comments