Skip to content

db-analyser: fix --trace-ledger across eras #48

Open
@amesgen

Description

@amesgen

When crossing an era boundary while using --trace-ledger, db-analyser crashes due to

To see why, consider the signature of the offending function (that is used in emitTraces):

-- | Lift a function polymorphic over all block types supporting `HasAnalysis`
-- into a corresponding function over `CardanoBlock.`
analyseWithLedgerState ::
forall a.
(forall blk. HasAnalysis blk => WithLedgerState blk -> a) ->
WithLedgerState (CardanoBlock StandardCrypto) ->
a

with
data WithLedgerState blk = WithLedgerState
{ wlsBlk :: blk
, wlsStateBefore :: LedgerState blk
, wlsStateAfter :: LedgerState blk
}

where wlsState{Before,After} are ledger states of the same block/era, but when comparing the ledger states just before/after an era transition, that is not the case.

The minimum goal of this ticket is to make sure that we don't crash on era transitions.

  • The straightforward approach would be to return Maybe a from analyseWithLedgerState and emit no traces on era transitions.
  • Going further slightly, we might want to modify the emitTraces interface slightly such that one can also compare ledger states from different eras to e.g. still be able to mark the start of an epoch at the point of the era transition. Conceptually, that would involve providing functions WithLedgerState blk blk' -> a for all subsequent pairs of blocks in CardanoEras, cf. the existing InPairs combinator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions