input-output-hk / hermes

🏛️ Hermes is a high-availability blockchain voting database that acts as a distributed storage and event processor for voting events, proposals, and actions.
https://input-output-hk.github.io/hermes
Apache License 2.0
13 stars 2 forks source link

🛠️ [TASK] : Decode a Cardano block uniformly and in a single place #265

Closed stevenj closed 2 weeks ago

stevenj commented 2 weeks ago

Summary

Wrangle the lifetime issues with decoded cardano blocks

Description

The Pallas library has a function to convert a raw block to a decoded block. We need to decode the block to use or reason through it, and to ensure blockchain integrity. Decoding the block is not cheap. Pallas places a lifetime on the decoded block which causes issues with an implementation that decodes the block once and attempts to reuse the decoded block.

Block data once read from chain is effectively immutable. Individual blocks don't change. So there is no reason why a block can't just be decoded once and the decoded version be used everywhere.

Decoding the block can also trigger errors, which need to be handled everywhere, even though the raw block data may already have been validated.

This task is to see if the decoding of the block can be encapsulated in such a way that a single decode can be reused without triggering an explosion of lifetime annotations throughout all of the code which uses it.

It will make the code cleaner, simpler and less error-prone.

The task is time boxed to a day and a half, if it cannot be solved in that time, it is to be deferred.