-
Notifications
You must be signed in to change notification settings - Fork 727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix qKesKesKeyExpiry to not always be null #4909
Conversation
hoistEpochInfo (first (Text.pack . show) . runExcept) | ||
$ Consensus.interpreterToEpochInfo (Consensus.unsafeExtendSafeZone interpreter) | ||
|
||
newtype Unsafe a = Unsafe { unsafe :: a } deriving (Eq, Show) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this use of a newtype. I think Unsafe
is a bit too scary/general of a name though. Perhaps AssumingNoUpcomingHardfork
(or something like that)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about newtype BeyondHorizonEpochInfo = BeyondHorizonEpochInfo (EpochInfo (Either Text))
? And we can put a comment with a brief explanation behind the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've decided to replace the word Unsafe
to Tentative
because that captures the meaning I wanted to convey.
|
||
newtype Unsafe a = Unsafe { unsafe :: a } deriving (Eq, Show) | ||
|
||
unsafeToEpochInfo :: EraHistory CardanoMode -> Unsafe (EpochInfo (Either Text)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, I'd suggest naming this toEpochAssumingNoUpcomingHardFork
or something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
toBeyondHorizonEpochInfo
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now toTentativeEpochInfo
.
eacb364
to
a7637c1
Compare
49d13e1
to
77d274f
Compare
-- | A value that is tentative or produces a tentative value if used. These values | ||
-- are considered accurate only if some future event such as a hard fork does not | ||
-- render them invalid. | ||
newtype Tentative a = Tentative { tentative :: a } deriving (Eq, Show) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What other values do we expect to be tentative besides EpochInfo
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially anything derived from Tentative EpochInfo
is a candidate.
77d274f
to
e5e4564
Compare
-- tentative because it uses an interpreter that is extended past the horizon. | ||
-- This interpreter will compute accurate values into the future as long as a | ||
-- a hard fork does not happen in the intervening time. Those values are thus | ||
-- "tentative" because they can change in the event of a hard fork. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify my understanding, they can change in the event of a hardfork occurring within the horizon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They can change in the event of a hardfork occurring after the horizon. Normally the interpreter refuses to give an answer beyond the horizon so we construct a different interpreter that ignores the horizon.
Values before the horizon still won't change.
However, because the type allows for values beyond the horizon to change, it is annotated as Tentative
regardless of whether the value can change or not.
Note that
qKesKesKeyExpiry
is only an estimate that is usually correct, but it could be wrong due to a hard fork that changes KES parameters.The fix involves uses an unsafe query interpreter that ignores forecasting horizon. Therefore a new
Unsafe
newtype
has been introduced to clearly show all the code that uses the unsafe query interpreter so that it doesn't accidentally get used where it shouldn't.Resolves #4396