Skip to content

feat: add tx body diagnostic dump utility #37

@paolino

Description

@paolino

Context

During debugging of E2E script transaction submission (cardano-foundation/cardano-mpfs-onchain#37), we wrote a diagnoseTxBody function that dumps tx body fields and CBOR hex to stderr. It was instrumental in diagnosing collateral, fee, and conservation issues.

Current implementation

In cardano-mpfs-onchain/e2e-test/CageTxBuilder.hs:

diagnoseTxBody :: String -> Tx ConwayEra -> IO ()
diagnoseTxBody label tx = do
    let body = tx ^. bodyTxL
        collateral = body ^. collateralInputsTxBodyL
        inputs = body ^. inputsTxBodyL
        fee = body ^. feeTxBodyL
        mintVal = body ^. mintTxBodyL
        bodyBytes = BSL.toStrict
            $ serialize (eraProtVerLow @ConwayEra) body
        hexStr = bytesToHex bodyBytes
    hPutStrLn stderr $ "DIAG [" <> label <> "] inputs=" <> ...

Proposal

Add to Cardano.Node.Client.Balance or a new Cardano.Node.Client.Diagnostics module:

  • diagnoseTxBody :: String -> Tx ConwayEra -> IO () — dump body fields + CBOR hex to stderr
  • Gate behind an env var (CARDANO_TX_DIAG=1) or accept a Bool flag
  • Optionally decode CBOR map keys to report which fields are present (especially key 13 = collateral)

Useful for anyone debugging tx construction, submission failures, or script evaluation issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions