@@ -310,14 +310,14 @@ evalGenerator generator txParams@TxGenTxParams{txParamFee = fee} era = do
310310 (toUTxOChange, addressChange) <- interpretPayMode payModeChange
311311 traceDebug $ " split change address : " ++ addressChange
312312 let
313- inToOut = return . Utils. includeChange fee coins
313+ fundSource = walletSource wallet 1
314+ inToOut = Utils. includeChange fee coins
314315 txGenerator = genTx (cardanoEra @ era ) protocolParameters (TxInsCollateralNone , [] ) feeInEra TxMetadataNone
315- inputFunds <- liftToAction $ walletSource wallet 1
316- sourceToStore <- withTxGenError . sourceToStoreTransactionNew txGenerator inputFunds inToOut $ mangleWithChange (liftIOCreateAndStore toUTxOChange) (liftIOCreateAndStore toUTxO)
317- return . Streaming. effect . pure . Streaming. yield $ Right sourceToStore
316+ sourceToStore = sourceToStoreTransactionNew txGenerator fundSource inToOut $ mangleWithChange toUTxOChange toUTxO
317+ return $ Streaming. effect (Streaming. yield <$> sourceToStore)
318318
319319 -- The 'SplitN' case's call chain is somewhat elaborate.
320- -- The division is done in 'Utils.inputsToOutputsWithFee'
320+ -- The division is done in 'Utils.inputsToOutputsWithFee'
321321 -- but things are threaded through
322322 -- 'Cardano.Benchmarking.Wallet.mangle' and packed into
323323 -- the transaction assembled by 'sourceToStoreTransactionNew'.
@@ -326,39 +326,37 @@ evalGenerator generator txParams@TxGenTxParams{txParamFee = fee} era = do
326326 (toUTxO, addressOut) <- interpretPayMode payMode
327327 traceDebug $ " SplitN output address : " ++ addressOut
328328 let
329- inToOut = withExceptT TxGenError . Utils. inputsToOutputsWithFee fee count
329+ fundSource = walletSource wallet 1
330+ inToOut = Utils. inputsToOutputsWithFee fee count
330331 txGenerator = genTx (cardanoEra @ era ) protocolParameters (TxInsCollateralNone , [] ) feeInEra TxMetadataNone
331- inputFunds <- liftToAction $ walletSource wallet 1
332- sourceToStore <- withTxGenError $ sourceToStoreTransactionNew txGenerator inputFunds inToOut (mangle . repeat $ liftIOCreateAndStore toUTxO)
333- return . Streaming. effect . pure . Streaming. yield $ Right sourceToStore
332+ sourceToStore = sourceToStoreTransactionNew txGenerator fundSource inToOut (mangle $ repeat toUTxO)
333+ return $ Streaming. effect (Streaming. yield <$> sourceToStore)
334334
335335 NtoM walletName payMode inputs outputs metadataSize collateralWallet -> do
336336 wallet <- getEnvWallets walletName
337337 collaterals <- selectCollateralFunds collateralWallet
338338 (toUTxO, addressOut) <- interpretPayMode payMode
339339 traceDebug $ " NtoM output address : " ++ addressOut
340340 let
341- inToOut = withExceptT TxGenError . Utils. inputsToOutputsWithFee fee outputs
341+ fundSource = walletSource wallet inputs
342+ inToOut = Utils. inputsToOutputsWithFee fee outputs
342343 txGenerator = genTx (cardanoEra @ era ) protocolParameters collaterals feeInEra (toMetadata metadataSize)
343- previewCatcher err = do
344- traceDebug $ " Error creating Tx preview: " ++ show err
345- throwE err
346- inputFunds <- liftToAction $ walletSource wallet inputs
347- sourceToStore <- withTxGenError $ sourceToStoreTransactionNew txGenerator inputFunds inToOut (mangle . repeat $ liftIOCreateAndStore toUTxO)
344+ sourceToStore = sourceToStoreTransactionNew txGenerator fundSource inToOut (mangle $ repeat toUTxO)
348345
349346 fundPreview <- liftIO $ walletPreview wallet inputs
350- preview <- withTxGenError (sourceTransactionPreview txGenerator fundPreview inToOut (mangle . repeat $ liftIOCreateAndStore toUTxO))
351- `catchE` previewCatcher
352- let txSize = txSizeInBytes preview
353- traceDebug $ " Projected Tx size in bytes: " ++ show txSize
354- summary_ <- getEnvSummary
355- forM_ summary_ $ \ summary -> do
356- let summary' = summary {projectedTxSize = Just txSize}
357- setEnvSummary summary'
358- traceBenchTxSubmit TraceBenchPlutusBudgetSummary summary'
359- dumpBudgetSummaryIfExisting
360-
361- return . Streaming. effect . pure . Streaming. yield $ Right sourceToStore
347+ case sourceTransactionPreview txGenerator fundPreview inToOut (mangle $ repeat toUTxO) of
348+ Left err -> traceDebug $ " Error creating Tx preview: " ++ show err
349+ Right tx -> do
350+ let txSize = txSizeInBytes tx
351+ traceDebug $ " Projected Tx size in bytes: " ++ show txSize
352+ summary_ <- getEnvSummary
353+ forM_ summary_ $ \ summary -> do
354+ let summary' = summary {projectedTxSize = Just txSize}
355+ setEnvSummary summary'
356+ traceBenchTxSubmit TraceBenchPlutusBudgetSummary summary'
357+ dumpBudgetSummaryIfExisting
358+
359+ return $ Streaming. effect (Streaming. yield <$> sourceToStore)
362360
363361 Sequence l -> do
364362 gList <- forM l $ \ g -> evalGenerator g txParams era
@@ -376,10 +374,6 @@ evalGenerator generator txParams@TxGenTxParams{txParamFee = fee} era = do
376374
377375 where
378376 feeInEra = Utils. mkTxFee fee
379- -- 'liftIOCreateAndStore' is supposed to be some indication that 'liftIO'
380- -- is applied to a 'CreateAndStore'.
381- -- This could be golfed as @((liftIO .) .)@ but it's unreadable.
382- liftIOCreateAndStore cas = second (\ f x y -> liftIO (f x y)) . cas
383377
384378selectCollateralFunds :: forall era . IsShelleyBasedEra era
385379 => Maybe String
@@ -403,8 +397,6 @@ dumpToFileIO filePath tx = appendFile filePath ('\n' : show tx)
403397initWallet :: String -> ActionM ()
404398initWallet name = liftIO Wallet. initWallet >>= setEnvWallets name
405399
406- -- The inner monad being 'IO' creates some programming overhead above.
407- -- Something like 'MonadIO' would be helpful, but the typing is tricky.
408400interpretPayMode :: forall era . IsShelleyBasedEra era => PayMode -> ActionM (CreateAndStore IO era , String )
409401interpretPayMode payMode = do
410402 networkId <- getEnvNetworkId
0 commit comments