Skip to content

Store latest cert on chain #198

@agustinmista

Description

@agustinmista

The voting rules need access to the latest Peras certificate stored on chain. That is, the certificate with the highest round number. To give them access to it, there are a couple of issues that need to be addressed:

  1. To coordinate the end of a cooldown period, Peras certificates will (sometimes) appear in the block body of blocks starting with Dijkstra (cf. Add Peras certificate to the block body IntersectMBO/cardano-ledger#5439). This means that BlockSupportsPeras (and the plumbing defined by Implement BlockSupportsPeras for all blocks (including HFC) #73) will have to be extended with a getter to extract these certificates. Something like:
class ... => BlockSupportsPeras blk where
  ...
  getPerasCertInBlock :: blk -> Maybe (PerasCert blk)

Defaulting to Nothing for any block type that doesn't support Peras.

  1. We need to extend the PerasCertDB API with a method:
data PerasCertDB m blk where
  ...
  getLatestCertOnChain :: STM m (Maybe (WithArrivalTime (ValidatedPerasCert blk)))

(The implementation of this method can probably be copied from that of getLatestCertSeen

  1. We need to find a way to inject some sort of callback that updates the latest cert on chain in the PerasCertDB whenever a new block containing a Peras certificate becomes old enough*. For this, we could add:
data PerasCertDB m blk where
  ...
  setLatestCertOnChain :: WithArrivalTime (ValidatedPerasCert blk) -> STM m () 

And hook it up to the routine that copies blocks from the volatile to the immutable DB (see comment below first), see O.C.Storage.ChainDB.Impl.Background.copyToImmutableDB.

[*] The concrete definition for "old enough" is not very clear at this point, as it might depend on the concrete parameterization being used. One starting point could be the boundary between the volatile and immutable DBs, though it remains to be seen if crossing this boundary would always happen early enough so that every latest coordination cert stored on chain is visible to the voting rules before evaluating if nodes should resume voting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    chaindbRelated to the ChainDB

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions