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: annotate headers with their slot's RelativeTime #1288

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dnadales
Copy link
Member

@dnadales dnadales commented Oct 22, 2024

Introduce a new HeaderWithTime data type, which annotates each received header with the relative time of its slot as calculated by the ChainSync client.

Partially addresses #1301

@dnadales dnadales force-pushed the dnadales/annotate-headers-with-time branch from b76d77c to 2b11f09 Compare November 19, 2024 13:11
@dnadales dnadales force-pushed the dnadales/annotate-headers-with-time branch from 1b5a867 to 6f9c71b Compare November 27, 2024 15:52
@nfrisby nfrisby force-pushed the dnadales/annotate-headers-with-time branch 2 times, most recently from 7296216 to f40c927 Compare December 10, 2024 23:26
@nfrisby
Copy link
Contributor

nfrisby commented Dec 12, 2024

I pushed up some commits that improve some names&Haddock and also hide HeaderWithTime from some tracers (to avoid extra work for downstream integration etc).

@nfrisby nfrisby force-pushed the dnadales/annotate-headers-with-time branch from ccc97d4 to 566d1e5 Compare December 12, 2024 16:28
@nfrisby
Copy link
Contributor

nfrisby commented Dec 12, 2024

I changed the representation of the fragment pair based on the conversation we had in today's office hours.

I confirmed that the statemachine test fails (nicely) when I insert bugs in either ChainSel or Background's maintenance of the fragment with times. I introduced a bespoke strict pair type for clarity and to most easily satisfy the NoThunks tests (which are also enabled by the Cabal flags that enable the new invariant checking logic for the fragment pair).

@@ -339,6 +341,39 @@ initNodeKernel args@NodeKernelArgs { registry, cfg, tracers
blockForging' <- traverse (forkBlockForging st) blockForging
go blockForging'

castTraceFetchClientState ::
Copy link
Contributor

Choose a reason for hiding this comment

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

I opened IntersectMBO/ouroboros-network#5025 to upstream this function

@nfrisby nfrisby force-pushed the dnadales/annotate-headers-with-time branch 5 times, most recently from c625852 to 4cb2c5e Compare December 18, 2024 17:34
@nfrisby
Copy link
Contributor

nfrisby commented Dec 18, 2024

I squashed in order to rebase. I also minized the diff. The next step is to split it into two or three separate commits.

@nfrisby nfrisby force-pushed the dnadales/annotate-headers-with-time branch 4 times, most recently from ff91b8a to 0ffd370 Compare December 18, 2024 20:58
This PR will add ImmutableEraParams instances for test blocks without needing
the SingleEraBlock omnibus.
GHC 9.4+ "erroneously" requires HasHeader blk. This patch prevents that. I
_think_ the new local signature forces GHC to invoke the HeaderHash (Header
blk) ~ HeaderHash blk rewrite _later_, thereby avoiding that undesirable Wanted
constraint.
It's declared upstream in Control.ResourceRegistry now.
@nfrisby nfrisby force-pushed the dnadales/annotate-headers-with-time branch from 0ffd370 to 2effa46 Compare December 18, 2024 21:16
- Define HeaderWithTime.

- Maintain time annotations on the ChainSync candidates.

- Maintain a parallel selection with time annotations since the
  ConsensusBlockFetch interface uses the same type argument for ChainSync
  candidates and the current selection.

- Note that HeaderWithTime is hidden from the tracer events, at least for now.

Co-authored-by: Damian Nadales <[email protected]>
Co-authored-by: amesgen <[email protected]>
@nfrisby nfrisby force-pushed the dnadales/annotate-headers-with-time branch from 2effa46 to ee2f301 Compare December 18, 2024 21:17

instance ( HasHeader (Header blk)
, StandardHash (HeaderWithTime blk)
, Typeable blk
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the root cause of all the additional Typeable blk contexts in this commit. It's required to satisfy the superclass on the (upstream) HasHeader. I don't see how to avoid it, sadly.

@nfrisby nfrisby force-pushed the dnadales/annotate-headers-with-time branch from ee2f301 to ba54272 Compare December 18, 2024 21:20
@nfrisby nfrisby force-pushed the dnadales/annotate-headers-with-time branch from ba54272 to b4424eb Compare December 18, 2024 21:21
@nfrisby nfrisby changed the title [WIP] Annotate headers with time consensus: annotate headers with their slot's RelativeTime Dec 18, 2024
@nfrisby nfrisby marked this pull request as ready for review December 18, 2024 21:21
@nfrisby nfrisby added the technical debt Technical debt label Dec 18, 2024
@nfrisby nfrisby self-assigned this Dec 18, 2024
@nfrisby
Copy link
Contributor

nfrisby commented Dec 18, 2024

UTxO HD takes priority over this, if the conflicts are non-trivial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
technical debt Technical debt
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

3 participants