-
Notifications
You must be signed in to change notification settings - Fork 21
Description
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:
- Pre-calculates certificate deposits using CalculateCertificateDeposits()
- Logs validation failures for certificate transactions as warnings instead of errors
- 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
- Create a transaction with a certificate that requires a deposit
- Validate the transaction using gouroboros ValidateTxFunc
- 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
- Dingo workaround: https://github.com/blinklabs-io/dingo/blob/main/ledger/state.go#L878-L886
- Certificate deposit calculation: https://github.com/blinklabs-io/dingo/blob/main/ledger/certs.go#L37