IntersectMBO / IntersectMBO/ouroboros-consensus
Investigate whether singleEraTransition is (and should be) evaluated more than once when reapplying Shelley blocks
- Dominant language
- Haskell
- Stars
- 67
- Forks
- 43
- Avg merge
- 5d 13h
- Merged PRs (30d)
- 43
Description
We found that the singleEraTransition function for Shelley blocks might be evaluated multiple times when reapplying blocks. We should investigate whether this is the case, and if it is desired behaviour. If it is not desired behaviour, then we should fix it. The behaviour can be observed by running db-analyser on a sufficiently large ImmutableDB, and tracing the function.
See the `TODO` in the following PR:https://github.com/input-output-hk/ouroboros-network/pull/3814#discussion_r900289658. The relevant code is listed below as well:
```
instance
( ShelleyCompatible proto era,
LedgerSupportsProtocol (ShelleyBlock proto era)
) => SingleEraBlock (ShelleyBlock proto era) where
singleEraTransition pcfg _eraParams _eraStart ledgerState =
-- TODO: We might be evaluating 'singleEraTransition' more than once when
-- replaying blocks. We should investigate if this is the case, and if so,
-- whether this is the desired behaviour. If it is not, then we need to
-- fix it.
--
-- For evidence of this behaviour, replace the cased-on expression by:
-- > @traceShowId $ shelleyTriggerHardFork pcf@
case shelleyTriggerHardFork pcfg of
TriggerHardForkNever -> Nothing
TriggerHardForkAtEpoch epoch -> Just epoch
TriggerHardForkAtVersion shelleyMajorVersion ->
shelleyTransition
pcfg
shelleyMajorVersion
ledgerState
```
Contributor guide
Assessment
This issue has not been assessed yet.