IntersectMBO / cardano-ledger

The ledger implementation and specifications of the Cardano blockchain.
Apache License 2.0
256 stars 158 forks source link

Create a HARDFORK rule #4621

Open lehins opened 1 week ago

lehins commented 1 week ago

This is a rule that could be used to change the state in some ways on a epoch transition that handles intra-era hardforks. It could be useful for things like:

Probably many use case will come to mind once we have this rule implemented in Ledger.

Implementation would be pretty straightforward. EPOCH rule would invoke the HARDFORK rule if protocol version in prevPParams is different from curPParams after they have been rotated at the end of the EPOCH rule, but before we setup the pulser. Signal for the rule would be the new ProtocolVersion.

lehins commented 1 week ago

CC @WhatisRT What do you think of this idea?

WhatisRT commented 1 week ago

Is the issue here that intra-era HFs don't have a translation function? Because otherwise I'd have expected these things to live there. Is it difficult to have such a translation function? If that's the issue, then that seems reasonable to me.

lehins commented 1 week ago

Is the issue here that intra-era HFs don't have a translation function?

Yes, precisely.

Is it difficult to have such a translation function?

Yes, in fact it is impossible, because translation is parametrized on era transition. It is implemented in terms of type class instances on the era we are translating into. Moreover, those translation functions are called by consensus' hard fork combinator, so we don't even have a way to indicate that we need to have a piece of code executed on an intra-era hard fork.

If that's the issue, then that seems reasonable to me.

Perfect. Thank you.