IntersectMBO / cardano-ledger

The ledger implementation and specifications of the Cardano blockchain.
Apache License 2.0
262 stars 155 forks source link

Fix drep delegation invariant preservation #4709

Closed lehins closed 1 month ago

lehins commented 1 month ago

Description

This PR fixes two bugs that where introduced in #4652:

  1. Delegating to an SPO by a stake credential that was already delegated to a DRep violated the internal invariant leading to an inconsistency in which upon this DRep unregistration the delegation would not get cleaned up. Thus it would lead to a way to surpass the protection of delegation to a non-registered DRep
  2. For testing and benchmarking we have ability to inject DReps and their delegations through the Genesis file. This injection was broken for DReps, since it did not maintain the internal invariant of DRep delegations

Checklist