cardano-ledger icon indicating copy to clipboard operation
cardano-ledger copied to clipboard

Add CDDLs for ConwayLedgerPredFailure

Open jasagredo opened this issue 7 months ago • 2 comments

I came up with this CDDL hierarchy inspecting the tree of datatypes:

conway.ledgerPredFailure = &(
  utxowFailure: [ 1, conway.utxowFailure ],
  certsFailure: [ 2, conway.certsFailure ],
  govFailure: [ 3, conway.govFailure ],
  wdrlNotDelegatedToDRep: [ 4, wdrlNotDelegatedToDRep: [ * keyhash] ]
  treasuryValueMismatch: [ 5, swappedMismatch<coin> ]
  txRefScriptsSizeTooBig: [ 6, mismatch<coin> ]
  mempoolFailure: [ 7, text ]
  )

mismatch<a> = ( supplied: a, expected: a)
swappedMismatch<a> = ( expected: a, supplied: a)

conway.utxowFailure = &(
  utxoFailure: [ 0, conway.utxoFailure ],
  invalidWitnesses: [ 1, [ * vkey ] ],
  missingVKeyWitnesses: [ 2, set<keyhash> ],
  missingScriptWitnesses: [ 3, set<scripHash> ],
  scriptWitnessNotValidating: [ 4, set<scriptHash> ],
  missingTxBodyMetadata: [ 5, txauxDataHash ],
  missingTxMetadata: [ 6, txauxDataHash ],
  conflictingMetadata: [ 7, mismatch<txauxDataHash> ],
  invalidMetadata: [ 8 ],
  extraneousScriptWitneeses: [ 9, set<scriptHash> ],
  missingRedeemers: [ 10, [ * (putusPurpose<asItem>, scriptHash) ],
  missingRequiredDatums: [ 11, missing: set<dataHash>, received: set<dataHash> ],
  notAllowedSupplementalDatums: [ 12, unallowed: set<dataHash>, acceptable: set<dataHash> ],
  ppViewHashesDontMatch: [ 13, ? supplied: scriptIntegrityHash, ? expected: scriptIntegrityHash ],
  unspendableUTxONoDatumHash: [ 14, set<txin> ],
  extraRedeemers: [ 15, [ plutusPurpose<asIx> ],
  malformedScriptWitnesses: [ 16, set<scriptHash> ],
  malformedReferenceScripts: [ 17, set<scriptHash> ]
  )

conway.certsFailure = &(
  withdrwawalsNotInRewards: [ 0, { * reward_account => coin }],
  certFailure: [ 1, conway.certFailure ]
  )

conway.certFailure = &(
  delegFailure: [ 1, conway.delegFailure ],
  poolFailure: [ 2, conway.poolFailure ],
  govCertFailure: [ 3, conway.govCertFailure ],
  )

conway.delegFailure = &(
  incorrectDeposit: [ 1, coin ],
  stakeKeyRegistered: [ 2, credential ],
  stakeKeyNotRegistered: [ 3, credential ],
  stakeKeyHasNonZeroRewardAccountBalance: [ 4, coin ],
  delegateeDRepNotRegistered: [ 5, credential ],
  delegateeStakePoolNotRegistered: [ 6, keyhash ]
  )

conway.poolFailure = &(
  stakePoolNotRegisteredOnKey: [ 0, keyhash ],
  stakePoolRetirementWrongEpoch: [ 1, gtExpected: epochno, ltSupplied: epochno, ltExpected: epochno ],
  stakePoolCostTooLow: [ 3, mismatch<coin> ],
  wrongNetwork: [ 4, swappedMismatch<network>, stakePoolId: keyhash ],
  poolMetadataHashTooBig: [ 5, stakePoolId: keyhash, sizeOfHash: int ]
  )

conway.govCertFailure = &(
  drepAlreadyRegistered: [ 0, credential ],
  drepNotRegistered: [ 1, credential ],
  drepIncorrectDeposit: [ 2, mismatch<coin> ],
  committeeHasPreviouslyResigned: [ 3, credential ],
  drepIncorrectRefund: [ 4, msimatch<coin> ],
  commiteeIsUnknown: [ 5, credential ],
  )

Would it be possible to include this in the conway.cddl so that we can use it when defining LocalTxSubmission in Consensus? It would be necessary to convert this to Huddle and fill in the missing basic types.

jasagredo avatar May 23 '25 09:05 jasagredo

Related ticket: #3392

lehins avatar Jul 03 '25 06:07 lehins

Would it be possible to include this in the conway.cddl so that we can use it when defining LocalTxSubmission in Consensus?

I would rather have a separate cddl file generated for predicate failures. We do not want to pollute the most important CDDL specification, which is data that lives on chain.

lehins avatar Jul 03 '25 06:07 lehins