Skip to content
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

consensus: HFC now provides EpochInfo in Except monad #3098

Merged
merged 1 commit into from
Apr 29, 2021

Conversation

nfrisby
Copy link
Contributor

@nfrisby nfrisby commented Apr 28, 2021

Fixes #2126. Also resolves the first draft of CAD-2713 on Jira.

This PR is a single commit; see the message.

The ledger is about to expect an EpochInfo that can fail. Previously, the
ledger did not expect EpochInfo to ever fail, since the ledger only used it
under controlled circumstances (ie on slots that Consensus provided).

But as of Alonzo, the ledger must apply EpochInfo to slots provided by the
user: script transactions have a validity interval specified as a pair of
slots. The Plutus interpreter expects the validity interval as a pair of UTC
times. Since the user provides the slots, the ledger is now applying EpochInfo
in a way that might fail. They want to notice that an invalidate the
transaction if so. Hence this commit prepares for that.

The HFC has always created EpochInfos that might fail. However, until now it
converted those failures to pure exceptions ASAP. As of this commit, the
conversion happens at the latest possible moment. And soon a
cardano-ledger-specs will allow us to remove the conversion that this commit
does just before passing the EpochInfo to the ledger.

There are some places in Consensus itself where we continue to use the pure
EpochInfo. As before, those places indicate bugs if the error is thrown, so
using a pure exception was and still is appropriate.
@nfrisby nfrisby added the consensus issues related to ouroboros-consensus label Apr 28, 2021
@nfrisby
Copy link
Contributor Author

nfrisby commented Apr 28, 2021

@nc6 @polinavino -- FYI this PR will provide the EpochInfo needed for the Alonzo validity interval translation.

Copy link
Contributor

@jasagredo jasagredo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

@nfrisby
Copy link
Contributor Author

nfrisby commented Apr 29, 2021

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Apr 29, 2021

@iohk-bors iohk-bors bot merged commit a5ca9bc into master Apr 29, 2021
@iohk-bors iohk-bors bot deleted the nfrisby/CAD-2713-fixup branch April 29, 2021 13:01
coot pushed a commit that referenced this pull request May 16, 2022
3098: consensus: HFC now provides EpochInfo in Except monad r=nfrisby a=nfrisby

Fixes #2126. Also resolves the first draft of CAD-2713 on Jira.

This PR is a single commit; see the message.

Co-authored-by: Nicolas Frisby <nick.frisby@iohk.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus issues related to ouroboros-consensus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace EpochInfo Identity by EpochInfo (Except PastHorizonException)
2 participants