IntersectMBO / IntersectMBO/cardano-ledger
Subsume `InstantStake` by `Accounts`
- Dominant language
- Haskell
- Stars
- 295
- Forks
- 179
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 29
Description
The only reason why we have `InstantStake` defined as a separate Map is because it can contain `Credential`s that are not registered.
Taking into consideration our future plans of LedgerHD I believe it will be better to move stake of a registered account into `AccountState` and stake for unregistred accounts keep in a separate much smaller Map `NotRegisteredStake`
At a high level plan is to add a field to `AccountState`:
```haskell
stakeAccountStateL :: Lens' (AccountState era) (CompactForm Coin)`
```
which will be updated in the same way as `InstantStake` is updated today for registered `AccountId`s and in `NotRegisteredStake` for accounts that are not registered.
We will also need to update Ledger rules that handle registration/unregistration of accounts that will move possible stake value during registration in from `NotRegisteredStake` and move any non-zero stake to `NotRegisteredStake` upon unregistration.
This approach will not only speed up stake resolution, since we will no longer have a separate step that resolves active stake, but we will also simplify future LedgerHD implementation, since it will remove the need for an extra `InstanStake` table
Contributor guide
Assessment
This issue has not been assessed yet.