Skip to content

Commit

Permalink
Refactor: remove remaining hardcoded key deposits
Browse files Browse the repository at this point in the history
  • Loading branch information
carbolymer committed Oct 23, 2024
1 parent 0c453b6 commit 83c9405
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 21 deletions.
1 change: 0 additions & 1 deletion cardano-testnet/src/Testnet/Components/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import Cardano.Ledger.Api (ConwayGovState)
import qualified Cardano.Ledger.Api as L
import qualified Cardano.Ledger.Coin as L
import qualified Cardano.Ledger.Conway.Governance as L
import Cardano.Ledger.Conway.PParams (ConwayEraPParams)
import qualified Cardano.Ledger.Conway.PParams as L
import qualified Cardano.Ledger.Shelley.LedgerState as L
import qualified Cardano.Ledger.UTxO as L
Expand Down
18 changes: 9 additions & 9 deletions cardano-testnet/src/Testnet/Process/Cli/SPO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,10 @@ createStakeKeyRegistrationCertificate
=> TmpAbsolutePath
-> AnyShelleyBasedEra
-> File (VKey StakeKey) In -- ^ Stake verification key file
-> Int -- ^ deposit amount used only in Conway
-> L.Coin -- ^ deposit amount used only in Conway
-> FilePath -- ^ Output file path
-> m ()
createStakeKeyRegistrationCertificate tempAbsP asbe (File stakeVerKey) deposit outputFp = GHC.withFrozenCallStack $ do
AnyShelleyBasedEra sbe <- return asbe
createStakeKeyRegistrationCertificate tempAbsP (AnyShelleyBasedEra sbe) (File stakeVerKey) (L.Coin deposit) outputFp = GHC.withFrozenCallStack $ do
let tempAbsPath' = unTmpAbsPath tempAbsP
extraArgs = monoidForEraInEon @ConwayEraOnwards (toCardanoEra sbe) $
const ["--key-reg-deposit-amt", show deposit]
Expand Down Expand Up @@ -221,11 +220,11 @@ createStakeKeyDeregistrationCertificate
:: (MonadTest m, MonadCatch m, MonadIO m, HasCallStack)
=> TmpAbsolutePath
-> ShelleyBasedEra era
-> FilePath -- ^ Stake verification key file
-> File (VKey StakeKey) In -- ^ Stake verification key file
-> Int -- ^ deposit amount used only in Conway
-> FilePath -- ^ Output file path
-> m ()
createStakeKeyDeregistrationCertificate tempAbsP sbe stakeVerKey deposit outputFp =
createStakeKeyDeregistrationCertificate tempAbsP sbe (File stakeVerKey) deposit outputFp =
GHC.withFrozenCallStack $ do
let tempAbsPath' = unTmpAbsPath tempAbsP
extraArgs = monoidForEraInEon @ConwayEraOnwards (toCardanoEra sbe) $
Expand All @@ -248,17 +247,18 @@ registerSingleSpo
-> SocketPath
-> EpochNo -- ^ Termination epoch
-> Int -- ^ Testnet magic
-> L.Coin -- ^ key deposit
-> ExecConfig
-> (TxIn, FilePath, String)
-> (TxIn, File (SKey PaymentKey) In, String)
-> m ( String
, KeyPair StakeKey
, KeyPair VrfKey
) -- ^ Result tuple:
-- 1. String: Registered stake pool ID
-- 2. Stake pool cold keys
-- 3. Stake pool VRF keys
registerSingleSpo asbe identifier tap@(TmpAbsolutePath tempAbsPath') nodeConfigFile socketPath termEpoch testnetMag execConfig
(fundingInput, fundingSigninKey, changeAddr) = GHC.withFrozenCallStack $ do
registerSingleSpo asbe identifier tap@(TmpAbsolutePath tempAbsPath') nodeConfigFile socketPath termEpoch testnetMag keyDeposit execConfig
(fundingInput, File fundingSigninKey, changeAddr) = GHC.withFrozenCallStack $ do
workDir <- H.note tempAbsPath'

-- In order to register a stake pool we need two certificates:
Expand Down Expand Up @@ -344,7 +344,7 @@ registerSingleSpo asbe identifier tap@(TmpAbsolutePath tempAbsPath') nodeConfigF
-- Create pledger registration certificate
createStakeKeyRegistrationCertificate tap asbe
(verificationKey poolOwnerStakeKeys)
400_000
keyDeposit
(workDir </> "pledger.regcert")

void $ execCli' execConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ module Cardano.Testnet.Test.Cli.KesPeriodInfo
) where

import Cardano.Api as Api
import Cardano.Api.Ledger (Coin (..))

import Cardano.CLI.Types.Output
import Cardano.Node.Configuration.Topology
Expand Down Expand Up @@ -79,7 +78,7 @@ hprop_kes_period_info = integrationRetryWorkspace 2 "kes-period-info" $ \tempAbs

-- We get our UTxOs from here
let utxoAddr = Text.unpack $ paymentKeyInfoAddr wallet0
utxoSKeyFile = signingKeyFp $ paymentKeyInfoPair wallet0
utxoSKeyFile = signingKey $ paymentKeyInfoPair wallet0
void $ execCli' execConfig
[ eraString, "query", "utxo"
, "--address", utxoAddr
Expand All @@ -94,12 +93,14 @@ hprop_kes_period_info = integrationRetryWorkspace 2 "kes-period-info" $ \tempAbs
let node1SocketPath = Api.File $ IO.sprocketSystemName node1sprocket
termEpoch = EpochNo 3
epochStateView <- getEpochStateView configurationFile node1SocketPath
keyDeposit <- getKeyDeposit epochStateView ceo
(stakePoolId, KeyPair{signingKey=File stakePoolColdSigningKey, verificationKey=File stakePoolColdVKey}, _)
<- registerSingleSpo asbe 1 tempAbsPath
configurationFile
node1SocketPath
termEpoch
testnetMagic
keyDeposit
execConfig
(txin1, utxoSKeyFile, utxoAddr)

Expand Down Expand Up @@ -141,7 +142,6 @@ hprop_kes_period_info = integrationRetryWorkspace 2 "kes-period-info" $ \tempAbs
, "--testnet-magic", show @Int testnetMagic
]

keyDeposit <- fromIntegral . unCoin <$> getKeyDeposit epochStateView ceo
-- Test stake address registration cert
createStakeKeyRegistrationCertificate
tempAbsPath
Expand Down Expand Up @@ -193,7 +193,7 @@ hprop_kes_period_info = integrationRetryWorkspace 2 "kes-period-info" $ \tempAbs
[ "latest", "transaction", "sign"
, "--tx-body-file", delegRegTestDelegatorTxBodyFp
, "--testnet-magic", show @Int testnetMagic
, "--signing-key-file", utxoSKeyFile
, "--signing-key-file", unFile utxoSKeyFile
, "--signing-key-file", signingKeyFp testDelegatorKeys
, "--out-file", delegRegTestDelegatorTxFp
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ module Cardano.Testnet.Test.Cli.LeadershipSchedule

import Cardano.Api
import qualified Cardano.Api as Api
import Cardano.Api.Ledger (Coin (..))

import Cardano.Node.Configuration.Topology
import Cardano.Testnet
Expand Down Expand Up @@ -87,7 +86,7 @@ hprop_leadershipSchedule = integrationRetryWorkspace 2 "leadership-schedule" $ \

----------------Need to register an SPO------------------
let utxoAddr = Text.unpack $ paymentKeyInfoAddr wallet0
utxoSKeyFile = signingKeyFp $ paymentKeyInfoPair wallet0
utxoSKeyFile = signingKey $ paymentKeyInfoPair wallet0
void $ execCli' execConfig
[ eraString, "query", "utxo"
, "--address", utxoAddr
Expand All @@ -101,12 +100,14 @@ hprop_leadershipSchedule = integrationRetryWorkspace 2 "leadership-schedule" $ \
let node1SocketPath = Api.File $ IO.sprocketSystemName node1sprocket
termEpoch = EpochNo 15
epochStateView <- getEpochStateView configurationFile node1SocketPath
keyDeposit <- getKeyDeposit epochStateView ceo
(stakePoolIdNewSpo, KeyPair{signingKey=File stakePoolColdSigningKey, verificationKey=File stakePoolColdVKey}, KeyPair{signingKey=File vrfSkey})
<- registerSingleSpo asbe 1 tempAbsPath
configurationFile
node1SocketPath
(EpochNo 10)
testnetMagic
keyDeposit
execConfig
(txin1, utxoSKeyFile, utxoAddr)

Expand Down Expand Up @@ -146,7 +147,6 @@ hprop_leadershipSchedule = integrationRetryWorkspace 2 "leadership-schedule" $ \
, "--testnet-magic", show @Int testnetMagic
]

keyDeposit <- fromIntegral . unCoin <$> getKeyDeposit epochStateView ceo
-- Test stake address registration cert
createStakeKeyRegistrationCertificate
tempAbsPath
Expand Down Expand Up @@ -198,7 +198,7 @@ hprop_leadershipSchedule = integrationRetryWorkspace 2 "leadership-schedule" $ \
[ "latest", "transaction", "sign"
, "--tx-body-file", delegRegTestDelegatorTxBodyFp
, "--testnet-magic", show @Int testnetMagic
, "--signing-key-file", utxoSKeyFile
, "--signing-key-file", unFile utxoSKeyFile
, "--signing-key-file", signingKeyFp testDelegatorKeys
, "--out-file", delegRegTestDelegatorTxFp
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ hprop_tx_register_deregister_stake_address = integrationWorkspace "register-dere

let ceo = ConwayEraOnwardsConway
sbe = conwayEraOnwardsToShelleyBasedEra ceo
era = toCardanoEra sbe
cEra = AnyCardanoEra era
eraName = eraToString sbe
fastTestnetOptions = def { cardanoNodeEra = AnyShelleyBasedEra sbe }
shelleyOptions = def { genesisEpochLength = 200 }
Expand Down Expand Up @@ -144,7 +142,6 @@ hprop_tx_register_deregister_stake_address = integrationWorkspace "register-dere
]

H.noteShowM_ $ waitForBlocks epochStateView 1
-- H.noteShowM_ $ waitForEpochs epochStateView (EpochInterval 2)

do
(_, stdout', stderr') <- execCliAny execConfig
Expand Down

0 comments on commit 83c9405

Please sign in to comment.