IntersectMBO / IntersectMBO/cardano-ledger

Subsume `InstantStake` by `Accounts`

Open
#5,583 0 comments 0 reactions 0 assignees View on GitHub
:floppy_disk: LedgerHD performance
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.