Skip to content

transaction assemble cannot read the witnesses that transaction witness writes in Dijkstra #1422

Description

@mkoura

Summary

cardano-cli transaction witness writes a text envelope of type
TxWitness DijkstraEra, but cardano-cli transaction assemble (alias
sign-witness) only accepts TxWitness ShelleyEra through
TxWitness ConwayEra. The witness round-trip is broken inside a single binary
whenever the era is Dijkstra.

Steps to reproduce

Against a Dijkstra testnet (protocol version 12), with cardano-cli 11.1.0.0:

cardano-cli dijkstra transaction build-raw ... --out-file tx.body
cardano-cli dijkstra transaction witness --tx-body-file tx.body --signing-key-file payment.skey --out-file tx.witness
cardano-cli dijkstra transaction assemble --tx-body-file tx.body --witness-file tx.witness --out-file tx.signed

Actual

Error: Failed to decode the ledger's CDDL serialisation format. TextEnvelope type error:  Expected one of: TxWitness ShelleyEra, TxWitness AllegraEra, TxWitness MaryEra, TxWitness AlonzoEra, TxWitness BabbageEra, TxWitness ConwayEra Actual: TxWitness DijkstraEra
CallStack (from HasCallStack):
  fromExceptTCli, called at src/Cardano/CLI/EraBased/Transaction/Run.hs:119:41 in cardano-cli-11.1.0.0:Cardano.CLI.EraBased.Transaction.Run
  runTransactionCmds, called at src/Cardano/CLI/EraBased/Run.hs:61:5 in cardano-cli-11.1.0.0:Cardano.CLI.EraBased.Run
  runCmds, called at src/Cardano/CLI/EraBased/Run.hs:35:35 in cardano-cli-11.1.0.0:Cardano.CLI.EraBased.Run
  runAnyEraCommand, called at src/Cardano/CLI/Run.hs:56:5 in cardano-cli-11.1.0.0:Cardano.CLI.Run
  runClientCommand, called at app/cardano-cli.hs:58:14 in cardano-cli-11.1.0.0:Main

with tx.witness containing exactly what the previous command wrote:

{
    "type": "TxWitness DijkstraEra",
    "description": "Key Witness ShelleyEra",
    "cborHex": "8258..."
}

Expected

transaction assemble accepts a witness produced by transaction witness of
the same binary and era.

Cause

readFileInAnyShelleyBasedEra in cardano-cli/src/Cardano/CLI/Read.hs:619-638
hardcodes the accepted eras, and the list was not extended for Dijkstra:

readFileInAnyShelleyBasedEra
  :: ( HasTextEnvelope (thing ShelleyEra)
     , HasTextEnvelope (thing AllegraEra)
     , HasTextEnvelope (thing MaryEra)
     , HasTextEnvelope (thing AlonzoEra)
     , HasTextEnvelope (thing BabbageEra)
     , HasTextEnvelope (thing ConwayEra)
     )
  => (forall era. AsType era -> AsType (thing era))
  -> FileOrPipe
  -> IO (Either (FileError TextEnvelopeError) (InAnyShelleyBasedEra thing))
readFileInAnyShelleyBasedEra asThing =
  readFileOrPipeTextEnvelopeAnyOf
    [ FromSomeType (asThing AsShelleyEra) (InAnyShelleyBasedEra ShelleyBasedEraShelley)
    , FromSomeType (asThing AsAllegraEra) (InAnyShelleyBasedEra ShelleyBasedEraAllegra)
    , FromSomeType (asThing AsMaryEra) (InAnyShelleyBasedEra ShelleyBasedEraMary)
    , FromSomeType (asThing AsAlonzoEra) (InAnyShelleyBasedEra ShelleyBasedEraAlonzo)
    , FromSomeType (asThing AsBabbageEra) (InAnyShelleyBasedEra ShelleyBasedEraBabbage)
    , FromSomeType (asThing AsConwayEra) (InAnyShelleyBasedEra ShelleyBasedEraConway)
    ]

That list is what the "Expected one of:" in the error is built from. The call
chain is short and has exactly one entry point:

readFileInAnyShelleyBasedEra (Read.hs:630)
-> readFileTxKeyWitness (Read.hs:339-344, its only caller)
-> runTransactionSignWitnessCmd (EraBased/Transaction/Run.hs:1752, its only caller)
= transaction assemble / transaction sign-witness (EraBased/Transaction/Option.hs:80,146)

so transaction assemble is the only affected command.

cardano-api is not at fault here. At the revision this was found with
(f5ee53d4c26bd0d36540a2a6d06899ff9376aa9b) it is Dijkstra-complete:

  • Cardano/Api/Era/Internal/Eon/ShelleyBasedEra.hs:286 - maxBound = AnyShelleyBasedEra ShelleyBasedEraDijkstra
  • Cardano/Api/Serialise/TextEnvelope/Internal.hs:355,362,369,376 - all four * DijkstraEra envelope types are mapped
  • Cardano/Api/Tx/Internal/Sign.hs:295,847 - the writers emit Tx DijkstraEra and TxWitness DijkstraEra

That is also why the rest of the tx workflow is fine: readFileTx and
readFileTxBody go through fromSomeShelleyTx (Read.hs:328-331), which
derives its list from [minBound .. maxBound] and therefore picked Dijkstra up
automatically. Only the hand-written list did not.

Versions

  • cardano-cli 11.1.0.0
  • Reproduced with cardano-cli de786557757db816af2dcf56b0a667cecfced011, the leios-prototype revision pinned by cardano-node cabal.project
  • Present unchanged on cardano-cli master 174b30d14, so this is not specific to the leios branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working correctly or outputting unintended results.leios

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions