Skip to content

Deposit validation fails for certificate transactions with 'value not conserved' error #1250

@wolf31o2

Description

@wolf31o2

Description

The gouroboros library incorrectly validates transactions containing certificates, reporting 'value not conserved' errors even when the transaction is actually valid.

Problem Details

When validating transactions that contain certificates requiring deposits (such as stake registration, pool registration, DRep registration, etc.), the validation function reports:

value not conserved: consumed X, produced Y

This occurs because the validation logic does not properly account for certificate deposits and refunds when checking transaction value conservation.

Affected Certificate Types

  • PoolRegistrationCertificate (requires pool deposit)
  • StakeRegistrationCertificate (requires key deposit)
  • RegistrationCertificate (requires key deposit)
  • RegistrationDrepCertificate (requires DRep deposit)
  • StakeRegistrationDelegationCertificate (requires key deposit)
  • VoteRegistrationDelegationCertificate (requires key deposit)
  • StakeVoteRegistrationDelegationCertificate (requires key deposit)

Impact

This causes valid Cardano mainnet transactions to fail validation, even though they are correctly formed and should be accepted by the network.

Workaround in Dingo

The dingo project (https://github.com/blinklabs-io/dingo) has implemented a workaround in ledger/state.go that:

  1. Pre-calculates certificate deposits using CalculateCertificateDeposits()
  2. Logs validation failures for certificate transactions as warnings instead of errors
  3. Continues processing despite the false positive validation failure

Expected Behavior

The validation should correctly account for certificate deposits/refunds when checking value conservation, allowing valid certificate transactions to pass validation.

Steps to Reproduce

  1. Create a transaction with a certificate that requires a deposit
  2. Validate the transaction using gouroboros ValidateTxFunc
  3. Observe the false 'value not conserved' error

Environment

  • gouroboros version: 0.138.0
  • Cardano era: Conway (and likely earlier eras)
  • Affected by: Certificate deposit accounting in validation logic

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions