cardano-ledger icon indicating copy to clipboard operation
cardano-ledger copied to clipboard

`GenesisData`'s `FromJSON` instance may be insufficiently strict, resulting in unevaluated thunks in `gdStartTime`

Open fraser-iohk opened this issue 2 years ago • 1 comments

Link to relevant source: https://github.com/IntersectMBO/cardano-ledger/blob/14f8c026da66d9bc50cb4ec1147abb368256769a/eras/byron/ledger/impl/src/Cardano/Chain/Genesis/Data.hs#L96

When deserializing a GenesisData using fromJSON, the resulting record will contain unevaluated thunks in its gdStartTime :: UTCTime field, which can be discovered using its NoThunks instance.

I'm not sure whether this should be considered a bug, though, or if it's just unexpected behaviour, especially when it's a situation like this that's ultimately unlikely to result in a space leak.

  • Should the FromJSON instance force its result completely?
  • Should the NoThunks instance accept unevaluated thunks within gdStartTime?
  • Should we (i.e. consensus) just force the value after we fromJSON it?

fraser-iohk avatar Aug 02 '23 11:08 fraser-iohk

Either of these approach will work just fine, since Byron era has very little overhead and any space leaks that could have happen can't pose a problem for us. That being said, can make the nothunks tests happy.

  • Should the FromJSON instance force its result completely?
  • Should the NoThunks instance accept unevaluated thunks within gdStartTime?

I am leaning towards the simplest solution of just forcing the field in FromJSON instance with (id <$!!> fromJSField obj "startTime")

lehins avatar Aug 23 '24 22:08 lehins