|
3 | 3 |
|
4 | 4 | -- | All Byron and Shelley Genesis related functionality
|
5 | 5 | module Testnet.Commands.Genesis
|
6 |
| - ( defaultByronGenesisJsonValue |
7 |
| - , createShelleyGenesisInitialTxIn |
| 6 | + ( createShelleyGenesisInitialTxIn |
| 7 | + , createByronGenesis |
| 8 | + , defaultByronGenesisJsonValue |
8 | 9 | ) where
|
9 | 10 |
|
10 | 11 | import Prelude
|
11 | 12 |
|
12 | 13 | import Control.Monad.Catch
|
13 | 14 | import Control.Monad.IO.Class
|
14 | 15 | import Data.Aeson
|
| 16 | +import Data.Time.Clock (UTCTime) |
| 17 | +import GHC.Stack (HasCallStack, withFrozenCallStack) |
15 | 18 |
|
| 19 | +import Hedgehog.Extras.Stock.Time (showUTCTimeSeconds) |
16 | 20 | import Hedgehog.Internal.Property
|
17 | 21 |
|
| 22 | +import Testnet.Options |
18 | 23 | import Testnet.Util.Process
|
19 | 24 |
|
| 25 | +-- | Creates a default Byron genesis. This is required for any testnet, predominantly because |
| 26 | +-- we inject our ADA supply into our testnet via the Byron genesis. |
| 27 | +createByronGenesis |
| 28 | + :: (MonadTest m, MonadCatch m, MonadIO m, HasCallStack) |
| 29 | + => Int |
| 30 | + -> UTCTime |
| 31 | + -> BabbageTestnetOptions |
| 32 | + -> String |
| 33 | + -> String |
| 34 | + -> m () |
| 35 | +createByronGenesis testnetMagic startTime testnetOptions pParamFp genOutputDir = |
| 36 | + withFrozenCallStack $ execCli_ |
| 37 | + [ "byron", "genesis", "genesis" |
| 38 | + , "--protocol-magic", show testnetMagic |
| 39 | + , "--start-time", showUTCTimeSeconds startTime |
| 40 | + , "--k", show (babbageSecurityParam testnetOptions) |
| 41 | + , "--n-poor-addresses", "0" |
| 42 | + , "--n-delegate-addresses", show @Int (babbageNumSpoNodes testnetOptions) |
| 43 | + , "--total-balance", show @Int (babbageTotalBalance testnetOptions) |
| 44 | + , "--delegate-share", "1" |
| 45 | + , "--avvm-entry-count", "0" |
| 46 | + , "--avvm-entry-balance", "0" |
| 47 | + , "--protocol-parameters-file", pParamFp |
| 48 | + , "--genesis-output-dir", genOutputDir |
| 49 | + ] |
| 50 | + |
| 51 | +-- | The Shelley initial UTxO is constructed from the 'sgInitialFunds' field which |
| 52 | +-- is not a full UTxO but just a map from addresses to coin values. Therefore this |
| 53 | +-- command creates a transaction input that defaults to the 0th index and therefore |
| 54 | +-- we can spend spend this tx input in a transaction. |
| 55 | +createShelleyGenesisInitialTxIn |
| 56 | + :: (MonadTest m, MonadCatch m, MonadIO m, HasCallStack) |
| 57 | + => Int -> FilePath -> m String |
| 58 | +createShelleyGenesisInitialTxIn testnetMagic vKeyFp = |
| 59 | + withFrozenCallStack $ execCli |
| 60 | + [ "genesis", "initial-txin" |
| 61 | + , "--testnet-magic", show @Int testnetMagic |
| 62 | + , "--verification-key-file", vKeyFp |
| 63 | + ] |
20 | 64 |
|
21 | 65 | -- | We need a Byron genesis in order to be able to hardfork to the later Shelley based eras.
|
22 | 66 | -- The values here don't matter as the testnet conditions are ultimately determined
|
@@ -47,16 +91,3 @@ defaultByronGenesisJsonValue =
|
47 | 91 | , "updateVoteThd" .= toJSON @String "1000000000000"
|
48 | 92 | ]
|
49 | 93 |
|
50 |
| --- | The Shelley initial UTxO is constructed from the 'sgInitialFunds' field which |
51 |
| --- is not a full UTxO but just a map from addresses to coin values. Therefore this |
52 |
| --- command creates a transaction input that defaults to the 0th index and therefore |
53 |
| --- we can spend spend this tx input in a transaction. |
54 |
| -createShelleyGenesisInitialTxIn |
55 |
| - :: (MonadTest m, MonadCatch m, MonadIO m) |
56 |
| - => Int -> FilePath -> m String |
57 |
| -createShelleyGenesisInitialTxIn testnetMagic vKeyFp = |
58 |
| - execCli |
59 |
| - [ "genesis", "initial-txin" |
60 |
| - , "--testnet-magic", show @Int testnetMagic |
61 |
| - , "--verification-key-file", vKeyFp |
62 |
| - ] |
|
0 commit comments