Skip to content

consensus-testlib: add Test.CsjModel #1466

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

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

consensus-testlib: add Test.CsjModel #1466

wants to merge 16 commits into from

Conversation

nfrisby
Copy link
Contributor

@nfrisby nfrisby commented Apr 15, 2025

A single commit, and essentially a single file.

While this is being reviewed, I'll see if it's easy to integrate into the existing tests.

This PR model is the result of troubleshooting some test failures. I found a minor non-optimality in CSJ (recall that CSJ is fundamentally an optimization), and with the non-centralized definition of the existing CSJ implementation it was challenging for me to establish confidence that there weren't similar issues. I developed this centralized model for more legibility/clarity, and I intend for it to be used at least to test the non-centralized CSJ implementation.

@nfrisby nfrisby added the Genesis PRs related to Genesis testing and implementation label Apr 15, 2025
import qualified Data.Sequence as Seq

-- | A non-empty 'Seq'
newtype NonEmptySeq a = UnsafeNonEmptySeq (Seq a)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This type doesn't use AnchoredFragment for two reasons.

  • As a model, I'm trying to keep it as simple as possible: so far, I don't need headers at all. And I can't put points in an AnchoredFragment because of the HasHeader constraint.

  • So far, the model deals with chains that reach all the way back to Origin, not fragments. As long as that's true, it seems misleading to use AnchoredFragment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code no longer reaches all the way back to Genesis. It still doesn't involve headers explicitly, but perhaps AnchoredSeq could still be reused?

@nfrisby nfrisby requested a review from jorisdral as a code owner April 22, 2025 00:10
@nfrisby nfrisby force-pushed the nfrisby/csj-model branch 2 times, most recently from d0c427c to d408094 Compare April 22, 2025 00:24
@nfrisby nfrisby moved this to 🏗 In progress in Consensus Team Backlog Apr 22, 2025
@nfrisby nfrisby force-pushed the nfrisby/csj-model branch 5 times, most recently from e1444da to ebd743b Compare April 22, 2025 14:40
@nfrisby nfrisby force-pushed the nfrisby/csj-model branch 2 times, most recently from edc4bc0 to 27c8abe Compare April 30, 2025 13:53
nfrisby and others added 6 commits May 2, 2025 07:55
This commit adds the CSJ model but does not yet use it to test the
implementation.
This small alteration accomodate the fact that the ChainSync client cannot necessarily a MsgFindIntersect _immediately_ when the CSJ governor emits it.
Payloads and connecting peers forced me ot figure out how to not always persist
chains all the way back to Origin. Which forced me to realize and handle some
weird corner cases.

I'm optimistic, but I do expect friction once this is finally connected to the
actual tests.
@nfrisby nfrisby force-pushed the nfrisby/csj-model branch from 27c8abe to 833d6bf Compare May 2, 2025 15:02
@nfrisby nfrisby force-pushed the nfrisby/csj-model branch from 833d6bf to 7652046 Compare May 2, 2025 15:05
@nfrisby nfrisby force-pushed the nfrisby/csj-model branch from 4f93d02 to 3b46944 Compare May 4, 2025 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Genesis PRs related to Genesis testing and implementation
Projects
Status: 🏗 In progress
Development

Successfully merging this pull request may close these issues.

1 participant