-
Notifications
You must be signed in to change notification settings - Fork 86
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
Better Point type factoring, again #706
Conversation
The ouroboros-network library builds and tests pass. This does not fix the pointSlot mistake: it is still defined, and gives SlotNo 0 to the origin. This will be fixed in a forthcoming commit.
This package builds and tests pass. One perhaps controversial change is in the Byron ledger definition of ledgerTipPoint. If the ledger state has the genesis hash as its latest, then there are no blocks, so the tip point is set to Origin, rather than a point with slot number 0. I believe this is the how it ought to be.
Apparently an update to iohk-monitoring broke it. But how did that get past CI?
@@ -81,6 +81,8 @@ defaultLoggerConfig = Monitoring.Representation | |||
, Monitoring.hasPrometheus = Nothing | |||
, Monitoring.hasGUI = Nothing | |||
, Monitoring.options = mempty | |||
, Monitoring.hasGraylog = Nothing | |||
, Monitoring.logOutput = Nothing |
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.
Apparently a new build of iohk-monitoring has been brought in recently, and bryon-proxy wasn't updated. How did this pass CI?
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.
@jbgi could you take a look why this slipped through CI
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.
Looking good. I requested a few changes that will make my life easier.
Even without switching the slot and hash to WithOrigin
I was expecting a bigger diff.
Thanks for taking the time to do this.
, block | ||
) where | ||
|
||
data WithOrigin t = Origin | At t |
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.
Why Origin instead of Genesis?
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.
Because Genesis
is a constructor of Chain block
. I thought it better not to overload.
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.
Ok, fine for me. (What about data WithGenesis t = Gen | At t
? 😈)
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.
We might have places in haddock where we refer to Genesis
, which now becomes Origin
.
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.
The Chain
type is a model / mock impl. We shouldn't give it primacy in names. If we want Genesis
for the point types we can use it, and we can rename the Chain
one (e.g. GenesisBlock
) or use qualified names.
@@ -319,17 +321,30 @@ data UnknownRange blk = | |||
-- | |||
-- > StreamFromExclusive (Point { pointSlot = SlotNo 3 , .. } | |||
-- > StreamToInclusive (Point { pointSlot = SlotNo 3 , .. } | |||
-- | |||
-- FIXME StreamFrom and StreamTo can be refined to not admit origin points |
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.
Ok, I will do that when this is merged.
Suggested by mrBliss
fmap _ Origin = Origin | ||
fmap f (At t) = At (f t) | ||
|
||
data Block slot hash = Block |
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 calling this BlockPoint
?
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.
In this module it is clear that it is a point since (apart from the type, the module is named Point
), in most places we use unqualified imports so this might be confusing. Or maybe just leave a comment at the top that this module is supposed to be imported qualified.
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 see now it is imported qualified in other places, just dropping a comment at the top might be useful.
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.
My intuition is also for BlockPoint
and not using module-qualified names elsewhere.
at = At | ||
|
||
origin :: WithOrigin t | ||
origin = Origin |
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.
Is it worth to duplicate the api?
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.
Not clear it's worth using functions rather than constructors directly.
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.
LGTM, I left a two comments, feel free to decide upon them.
bors r+ |
706: Better Point type factoring, again r=avieth a=avieth Intended to replace #635 and #690 . It's factored into 2 commits that could be reviewed separately (the third one is a tiny unrelated fix to byron-proxy). The first commit introduces the `Ouroboros.Network.Point` module and uses it throughout ouroboros-network, making it build and tests pass. The second makes ouroboros-consensus build and tests pass. This commit retains the mistake `pointHash :: Point block -> SlotNo` rather than fixing it to be `pointHash :: Point block -> WithOrigin SlotNo`. The origin point is given `SlotNo 0`. It's kept this way so that the pull request will remain short and people will be willing to review it. Co-authored-by: Alexander Vieth <[email protected]>
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.
So I'm still not happy with the names and extra layers of indirection. The pattern synonyms are good, but this should just be the actual representation, and we can provide conversion functions when we need something else.
, block | ||
) where | ||
|
||
data WithOrigin t = Origin | At t |
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.
The Chain
type is a model / mock impl. We shouldn't give it primacy in names. If we want Genesis
for the point types we can use it, and we can rename the Chain
one (e.g. GenesisBlock
) or use qualified names.
fmap _ Origin = Origin | ||
fmap f (At t) = At (f t) | ||
|
||
data Block slot hash = Block |
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.
My intuition is also for BlockPoint
and not using module-qualified names elsewhere.
at = At | ||
|
||
origin :: WithOrigin t | ||
origin = Origin |
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.
Not clear it's worth using functions rather than constructors directly.
706: Better Point type factoring, again r=avieth a=avieth Intended to replace #635 and #690 . It's factored into 2 commits that could be reviewed separately (the third one is a tiny unrelated fix to byron-proxy). The first commit introduces the `Ouroboros.Network.Point` module and uses it throughout ouroboros-network, making it build and tests pass. The second makes ouroboros-consensus build and tests pass. This commit retains the mistake `pointHash :: Point block -> SlotNo` rather than fixing it to be `pointHash :: Point block -> WithOrigin SlotNo`. The origin point is given `SlotNo 0`. It's kept this way so that the pull request will remain short and people will be willing to review it. Co-authored-by: Alexander Vieth <[email protected]>
Intended to replace #635 and #690 .
It's factored into 2 commits that could be reviewed separately (the third one is a tiny unrelated fix to byron-proxy).
The first commit introduces the
Ouroboros.Network.Point
module and uses it throughout ouroboros-network, making it build and tests pass.The second makes ouroboros-consensus build and tests pass.
This commit retains the mistake
pointHash :: Point block -> SlotNo
rather than fixing it to bepointHash :: Point block -> WithOrigin SlotNo
. The origin point is givenSlotNo 0
. It's kept this way so that the pull request will remain short and people will be willing to review it.