1847: Track Stakepool Retirements in the DB r=jonathanknowles a=jonathanknowles
# Related Issues
- [x] Extends the pool DB schema to make it possible to store:
- [x] retirement certificates.
- [x] the _order_ of publication of certificates _within the same block_, for both registration and retirement certificates. This is necessary, as the intra-block order is _significant_.<br><br>
- [x] Adds the `PoolLifeCycleStatus` type, which indicates the current lifecycle stage of a pool.
There are currently _three_ possibilities:
(indicates that a pool has never been registered)
(indicates that a pool has been registered but _not_ retired)
(provides a registration certificate)
(indicates that a pool has been registered _and_ retired)
(provides both a registration and a retirement certificate)<br><br>
- [x] Adds the `readPoolLifeCycleStatus` function to the pool DB layer, making it possible to determine the current lifecycle status of a pool.
- [x] Updates the `retirement` field of `ApiStakePool` with live information.
# Property Tests
This PR adds property tests to ensure that:
- [x] the `determinePoolLifeCycleStatus` function respects the correct order of precedence for registration and retirement certificates:
- for a given pool, a registration certificate always _supercedes_ a prior retirement certificate.
- for a given pool, a retirement certificate always _augments_ the latest registration certificate.
- [x] `readPoolLifeCycleStatus` queries work correctly in the presence of blocks containing multiple certificates for the same pool.
- [x] database rollback works correctly in the presence of retirement certificates.
# Future Work
A **_future_** PR will add integration tests to ensure that:
- retiring a pool eventually results in a correct update to the `retirement` field of `ApiStakePool`, when read through the `ListStakePools` operation.
- retiring and then re-registering a pool clears the `retirement` field.
See QA section of https://github.com/input-output-hk/cardano-wallet/issues/1819.
Co-authored-by: Jonathan Knowles <[email protected]>