-
Notifications
You must be signed in to change notification settings - Fork 23
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
[WIP] Annotate headers with time #1288
base: main
Are you sure you want to change the base?
Conversation
Introduce a new `HeaderWithTime` data type which associates the relative slot time the header was received by the chain sync client mini-protocol.
...oros-consensus-diffusion/src/ouroboros-consensus-diffusion/Ouroboros/Consensus/NodeKernel.hs
Outdated
Show resolved
Hide resolved
-- REVIEW: is it ok to drop time here? | ||
= peerSimStateDiagramSTMTracerDebug gtBlockTree getCurrentChain (undefined getCandidates) getPoints |
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 think so; only performance could theoretically be a concern here, but I don't think so.
-- REVIEW: we should avoid this linear computation, but I don't see an alternative to changing the type of the LoE fragment. | ||
pure $ dropTime loeFrag |
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 think the approach here would be to make the logic work on AnchoredFragment (HeaderWithTime blk)
(or even AnchoredFragment a
where a
is suitably constrained). This will e.g. also require changing the type of cdbLoE
in the ChainDB.
@@ -349,7 +359,9 @@ densityDisconnect (GenesisWindow sgen) (SecurityParam k) states candidateSuffixe | |||
-- If not, it is not qualified to compete by density (yet). | |||
offersMoreThanK = totalBlockCount > k | |||
|
|||
pure (peer, DensityBounds {clippedFragment, offersMoreThanK, lowerBound, upperBound, hasBlockAfter, latestSlot, idling}) | |||
pure (peer, DensityBounds { | |||
clippedFragment = (dropTime clippedFragment), -- REVIEW: should we change the type of the clipped fragment? |
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.
Yes 👍
-> [(peer, AnchoredFragment (HeaderWithTime blk))] -- REVIEW: add a comment here? (in addition to the haddock above) | ||
-> AnchoredFragment (HeaderWithTime blk) -- REVIEW: add a comment here? |
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.
Yeah, moving the Haddocks to the individual parameters from the docs above sounds good, but seems orthogonal to this PR.
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.
It is indeed; however, I don't think we'll ever do if we don't improve the haddocks while working on other tasks. I can use a separate commit for this, of course :)
readCandidateChains = undefined getCandidates | ||
-- REVIWE: Should we change the 'BlockFetchConsensusInterface' s that 'readCandidateChains' return 'HeaderWithTime'? |
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.
That's exactly the idea of step 3b) in the corresponding draft issue 👍 As BlockFetchConsensusInterface
is polymorphic in what type header
is used for headers, it doesn't even require changing BlockFetchConsensusInterface
for this purpose. Concretely, mkBlockFetchConsensusInterface
would return BlockFetchConsensusInterface peer (HeaderWithTime blk) blk m
.
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. This would change the type of readCurrentChain
, which I'm unsure it is intended (since now the current chain will need to incorporate the times).
-- 'ValidatedHeader' however this seems to be a misnomer since the | ||
-- header is not validated at the point at which we construct this | ||
-- value in 'Ouroboros.Consensus.MiniProtocol.ChainSync.Client'. |
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 think that depends on where you construct HeaderWithTime
/ValidatedHeader
.
(Generally, HeaderWithTime
sounds good though 👍)
$ ( case isPipeliningEnabled version of | ||
ReceivingTentativeBlocks -> drop 1 | ||
ReceivingTentativeBlocks -> drop 1 -- REVIEW: we could also use this opportunity to explain this. |
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.
Does the comment above clear it up?
Lines 2008 to 2012 in 43e04df
-- As of block diffusion pipelining, their tip header might be | |
-- tentative. Since they do not yet have a way to explicitly say | |
-- whether it is tentative, we assume it is and therefore skip their | |
-- tip here. TODO once it's explicit, only skip it if it's annotated as | |
-- tentative |
Maybe we could move the comment directly above the
drop 1
?
@@ -281,7 +281,7 @@ runBlockFetchTest BlockFetchClientTestSetup{..} = withRegistry \registry -> do | |||
BlockFetchClientInterface.mkBlockFetchConsensusInterface | |||
(TestBlockConfig numCoreNodes) | |||
chainDbView | |||
getCandidates | |||
(undefined getCandidates) -- TODO: adapt 'getCandidates' if the change to 'mkBlockFetchConsensusInterface' is correct. |
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.
For this test, the annotated times should be irrelevant.
-- TODO: this should be a library function if the idea of dropping time on the candidate fragment makes sense. | ||
dropTime = undefined |
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.
Dropping time here seems fine 👍
From ``` BlockFetchConsensusInterface (ConnectionId addrNTN) (Header blk) blk m ``` to ``` BlockFetchConsensusInterface (ConnectionId addrNTN) (HeaderWithTime blk) blk m ``` The next commits will start implementing the `undefined` in the code.
This is semantically identical (as the LoE fragment is anchored in a recent immutable tip), but it is nice to use a more familiar function, and it is also potentially useful for a planned change.
... from `AnchoredFragment (Header blk)` to `AnchoredFragment (HeaderWithTime blk)`.
... which contains an `AddBogusTime` type class, which allows to add bogus times to headers. This type class and its instances are meant to be used in test code.
b76d77c
to
2b11f09
Compare
... from `AnchoredFragment (Header TestBlock))` to `AnchoredFragment (HeaderWithTime TestBlock))`.
... from `AnchoredFragment (Header TestBlock))` to `AnchoredFragment (HeaderWithTime TestBlock))`.
... in the density disconnect tests.
Introduce a new
HeaderWithTime
data type, which associates the relative slot time the chain sync client mini-protocol received the header.