Skip to content

Commit

Permalink
IntersectMBO/cardano-cli#299 Sprinkle with debugging prints
Browse files Browse the repository at this point in the history
  • Loading branch information
carbolymer committed Sep 25, 2023
1 parent 14d8475 commit 1e93ecf
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ library internal
, plutus-ledger-api:{plutus-ledger-api, plutus-ledger-api-testlib} ^>= 1.9
, prettyprinter
, prettyprinter-configurable ^>= 1.9
, pretty-simple
, random
, scientific
, serialise
Expand Down
5 changes: 4 additions & 1 deletion cardano-api/internal/Cardano/Api/Fees.hs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ import qualified Data.Text as Text
import Lens.Micro ((^.))
import Prettyprinter
import Prettyprinter.Render.String
import Debug.Trace
import Text.Pretty.Simple (pShow)
import qualified Data.Text.Lazy as T

{- HLINT ignore "Redundant return" -}
--- ----------------------------------------------------------------------------
Expand Down Expand Up @@ -1045,7 +1048,7 @@ makeTransactionBodyAutoBalance systemstart history lpp@(LedgerProtocolParameters
-- that simply creates a transaction body because we have already
-- validated the transaction body earlier within makeTransactionBodyAutoBalance
createAndValidateTransactionBody finalTxBodyContent
return (BalancedTxBody finalTxBodyContent txbody3 (TxOut changeaddr balance TxOutDatumNone ReferenceScriptNone) fee)
trace ">>>> F1048" $ trace (T.unpack $ pShow txbody3) $ return (BalancedTxBody finalTxBodyContent txbody3 (TxOut changeaddr balance TxOutDatumNone ReferenceScriptNone) fee)
where
-- Essentially we check for the existence of collateral inputs. If they exist we
-- create a fictitious collateral return output. Why? Because we need to put dummy values
Expand Down
11 changes: 6 additions & 5 deletions cardano-api/internal/Cardano/Api/ReexposeLedger.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module Cardano.Api.ReexposeLedger
, pattern ResignCommitteeColdTxCert
, pattern RegTxCert
, pattern UnRegTxCert
, pattern DelegStakeTxCert
, pattern RegDepositDelegTxCert
, pattern RegDRepTxCert

Expand Down Expand Up @@ -91,11 +92,11 @@ module Cardano.Api.ReexposeLedger
import Cardano.Crypto.Hash.Class (hashFromBytes, hashToBytes)
import Cardano.Ledger.Alonzo.Core (CoinPerWord (..))
import Cardano.Ledger.Alonzo.Scripts (Prices (..))
import Cardano.Ledger.Api.Tx.Cert (pattern AuthCommitteeHotKeyTxCert, pattern DelegTxCert,
pattern RegDRepTxCert, pattern RegDepositDelegTxCert, pattern RegDepositTxCert,
pattern RegPoolTxCert, pattern RegTxCert, pattern ResignCommitteeColdTxCert,
pattern RetirePoolTxCert, pattern UnRegDRepTxCert, pattern UnRegDepositTxCert,
pattern UnRegTxCert)
import Cardano.Ledger.Api.Tx.Cert (pattern AuthCommitteeHotKeyTxCert,
pattern DelegStakeTxCert, pattern DelegTxCert, pattern RegDRepTxCert,
pattern RegDepositDelegTxCert, pattern RegDepositTxCert, pattern RegPoolTxCert,
pattern RegTxCert, pattern ResignCommitteeColdTxCert, pattern RetirePoolTxCert,
pattern UnRegDRepTxCert, pattern UnRegDepositTxCert, pattern UnRegTxCert)
import Cardano.Ledger.Babbage.Core (CoinPerByte (..))
import Cardano.Ledger.BaseTypes (DnsName, Network (..), StrictMaybe (..), Url,
boundRational, dnsToText, maybeToStrictMaybe, portToWord16, strictMaybeToMaybe,
Expand Down
4 changes: 3 additions & 1 deletion cardano-api/internal/Cardano/Api/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ import Data.Type.Equality (TestEquality (..), (:~:) (Refl))
import qualified Data.Vector as Vector
import Lens.Micro

import Debug.Trace

-- ----------------------------------------------------------------------------
-- Signed transactions
--
Expand Down Expand Up @@ -662,7 +664,7 @@ makeShelleyBasedBootstrapWitness :: forall era.
makeShelleyBasedBootstrapWitness sbe nwOrAddr txbody (ByronSigningKey sk) =
ShelleyBootstrapWitness sbe $
-- Byron era witnesses were weird. This reveals all that weirdness.
Shelley.BootstrapWitness {
trace "API 665" $ traceShowId $ Shelley.BootstrapWitness {
Shelley.bwKey = vk,
Shelley.bwSig = signature,
Shelley.bwChainCode = chainCode,
Expand Down
12 changes: 10 additions & 2 deletions cardano-api/internal/Cardano/Api/TxBody.hs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ import qualified Data.Set as Set
import Data.String
import Data.Text (Text)
import qualified Data.Text as Text
import qualified Data.Text.Lazy as T
import Data.Type.Equality (TestEquality (..), (:~:) (Refl))
import Data.Word (Word16, Word32, Word64)
import GHC.Generics
Expand All @@ -279,6 +280,9 @@ import Lens.Micro.Extras (view)
import qualified Text.Parsec as Parsec
import Text.Parsec ((<?>))
import qualified Text.Parsec.String as Parsec
import Text.Pretty.Simple (pShow)

import Debug.Trace

-- | Indicates whether a script is expected to fail or pass validation.
data ScriptValidity
Expand Down Expand Up @@ -3880,7 +3884,7 @@ makeShelleyTransactionBody sbe@ShelleyBasedEraBabbage
txScriptValidity
where
witnesses :: [(ScriptWitnessIndex, AnyScriptWitness BabbageEra)]
witnesses = collectTxBodyScriptWitnesses sbe txbodycontent
witnesses = collectTxBodyScriptWitnesses sbe $ trace ">>>> TXB 3886" $ traceWith (T.unpack . pShow) txbodycontent

scripts :: [Ledger.Script StandardBabbage]
scripts = List.nub $ catMaybes
Expand Down Expand Up @@ -3908,7 +3912,7 @@ makeShelleyTransactionBody sbe@ShelleyBasedEraBabbage

redeemers :: Alonzo.Redeemers StandardBabbage
redeemers =
Alonzo.Redeemers $
trace "WITT" $ traceWith (T.unpack . pShow ) $ Alonzo.Redeemers $
Map.fromList
[ (toAlonzoRdmrPtr idx, (toAlonzoData d, toAlonzoExUnits e))
| (idx, AnyScriptWitness
Expand All @@ -3930,6 +3934,7 @@ makeShelleyTransactionBody sbe@ShelleyBasedEraBabbage
txAuxData :: Maybe (L.TxAuxData StandardBabbage)
txAuxData = toAuxiliaryData sbe txMetadata txAuxScripts


makeShelleyTransactionBody sbe@ShelleyBasedEraConway
txbodycontent@TxBodyContent {
txIns,
Expand Down Expand Up @@ -4030,6 +4035,7 @@ makeShelleyTransactionBody sbe@ShelleyBasedEraConway
txAuxData :: Maybe (L.TxAuxData StandardConway)
txAuxData = toAuxiliaryData sbe txMetadata txAuxScripts

traceWith f a = trace (f a) a


-- | A variant of 'toShelleyTxOutAny that is used only internally to this module
Expand Down Expand Up @@ -4097,6 +4103,8 @@ toBabbageTxOutDatum' (TxOutDatumInline _ sd) = scriptDataToInlineDatum sd
data AnyScriptWitness era where
AnyScriptWitness :: ScriptWitness witctx era -> AnyScriptWitness era

deriving instance Show (AnyScriptWitness era)

-- | Identify the location of a 'ScriptWitness' within the context of a
-- 'TxBody'. These are indexes of the objects within the transaction that
-- need or can use script witnesses: inputs, minted assets, withdrawals and
Expand Down

0 comments on commit 1e93ecf

Please sign in to comment.