Skip to content

Commit

Permalink
generate Proposal + Vote transactions for clusters
Browse files Browse the repository at this point in the history
Some of the parameters added may be able to be inferred from a smaller
set of parameters.
  • Loading branch information
NadiaYvette committed Nov 12, 2024
1 parent 6bd61f0 commit 5316d74
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
34 changes: 27 additions & 7 deletions bench/tx-generator/src/Cardano/Benchmarking/Compiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Cardano.Benchmarking.Compiler
where

import Cardano.Api
import Cardano.Api.Shelley (Vote (..))

import Cardano.Benchmarking.Script.Types
import qualified Cardano.Ledger.BaseTypes as L
Expand Down Expand Up @@ -145,12 +146,16 @@ splittingPhase srcWallet = do
anchorUrl = fromJust $ L.textToUrl 999 "example.com"
anchorDataHash = L.hashAnchorData . L.AnchorData . encodeUtf8 $
L.urlToText anchorUrl
stakeCredCount = case split of
SplitWithChange _ count -> count
FullSplits count -> count
govActGen = RoundRobin $ Take stakeCredCount . Cycle <$>
[Propose dstWallet payMode (L.Coin 1) stakeCredIdx anchor | stakeCredIdx <- [0 .. stakeCredCount]]
emit . Submit era LocalSocket txParams $ RoundRobin [generator, govActGen]
askNixOption _nix_govAct >>= \case
Just TxGenGovActParams {..}
| gapStakeKeys' <- fromIntegral gapStakeKeys
, totalProposals <- fromIntegral $ gapBatchSize * gapProposalBatches
, coin <- L.Coin 1
, mkProposal <- \idx ->
Propose dstWallet payMode coin (idx `mod` gapStakeKeys') anchor
-> emit . Submit era LocalSocket txParams . RoundRobin $
generator : map mkProposal [0 .. totalProposals - 1]
Nothing -> emit $ Submit era LocalSocket txParams generator
delay
logMsg "Splitting step: Done"

Expand Down Expand Up @@ -223,7 +228,22 @@ benchmarkingPhase wallet collateralWallet = do
then LocalSocket
else Benchmark targetNodes tps txCount
generator = Take txCount $ Cycle $ NtoM wallet payMode inputs outputs (Just $ txParamAddTxSize txParams) collateralWallet
emit $ Submit era submitMode txParams generator
askNixOption _nix_govAct >>= \case
Just TxGenGovActParams {..}
| mkVote <- \propIdx drepIdx ->
Vote wallet payMode propIdx Yes drepIdx Nothing
, mkBatchDRep <- \propIdx ->
Take (fromIntegral gapQuorum) . Cycle . Sequence $
map (mkVote propIdx) [0 .. fromIntegral gapDRepKeys - 1]
, mkBatchProp <- \batchIdx ->
let batchLo = batchIdx * fromIntegral gapBatchSize
batchHi = batchLo + fromIntegral gapBatchSize - 1
in RoundRobin $ map mkBatchDRep [batchLo .. batchHi]
, voteGen <- Sequence $
map mkBatchProp [0 .. fromIntegral gapProposalBatches - 1]
-> emit . Submit era submitMode txParams $
RoundRobin [generator, voteGen]
Nothing -> emit $ Submit era submitMode txParams generator
unless debugMode $ do
emit WaitBenchmark
return doneWallet
Expand Down
3 changes: 3 additions & 0 deletions bench/tx-generator/src/Cardano/TxGenerator/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ data TxGenConfig = TxGenConfig

data TxGenGovActParams = TxGenGovActParams
{ gapBatchSize :: Natural
, gapDRepKeys :: Natural
, gapStakeKeys :: Natural
, gapProposalBatches :: Natural
, gapQuorum :: Natural
} deriving (Eq, Read, Show, Generic, FromJSON, ToJSON)

Expand Down

0 comments on commit 5316d74

Please sign in to comment.