Skip to content

Introduce the Praos2 protocol: ie Praos plus the Leios overlay - #2386

Merged
nfrisby merged 19 commits into
mainfrom
nfrisby/leios-main-proto
Oct 9, 2026
Merged

nfrisby merged 19 commits into
mainfrom
nfrisby/leios-main-proto

Conversation

@nfrisby

@nfrisby nfrisby commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

This is an alternative to PR #2354

The key differences are that we don't define the new protocol by composing various Praos pieces with their various Leios addenda. Instead, we have one holistic definition of "PolyPraos" and then the Praos and Praos2 (ie Praos plus the Leios extension) variants are defined in terms of that one. Notably, and by design, Praos2 is essentially PolyPraos: PolyPraos will always be the richest/"latest and greatest"/fully-extended Praos variant running on Cardano. But it's defined in such a way that the previous Praos variants (starting after TPraos) can also be defined in terms of it.

The first commit is best read using diff -w (or the equivalent setting the PR's settings cog): it most directly shows that the old Praos methods have been floated out to become PolyPraos definitions. The subsequent commits then merely reorg around that idea.

Comment thread cabal.project Outdated

@ch1bo ch1bo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I only request changes because I want this PR to be done on top of #2354, so we don't do things double (fixing CDDL, passing era into mkHeader, drop seedInitialStakeSnapshots, ...)

The other comments are only Should's.

In any case: we must resolve this today and move on

@jasagredo jasagredo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I also don't enjoy Praos2, I preferred PraosLeios or PraosWithLeios or Leios.

Comment thread cabal.project Outdated
@ch1bo
ch1bo added this pull request to stack #2391 October 9, 2026 11:59
@ch1bo ch1bo added the Leios label Oct 9, 2026

@jasagredo jasagredo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Discussed both PRs with Nick on a call and I am approving the combination of both. Thanks!

@nfrisby
nfrisby force-pushed the nfrisby/leios-main-proto branch from ba337d7 to fe6b559 Compare October 9, 2026 14:39
nfrisby and others added 16 commits October 9, 2026 11:09
This commit is best reviewed with `git diff -w`, to suppress the whitespace
changes.

This incurs some duplication (notably signatures), but it's worth it.

- The duplication is not overly burdensome to compensate for by factoring the
  Praos impl so its types and functions can be reused as much as possible. For
  Leios, at least, that's easy since Leios only adds a few independent fields to
  the header semantics.

- Duplicating instances between Praos and PraosWithLeios instead of having them
  share some instances (ala a shared-head `BasePraos leiosFlag` protocol type)
  has a couple benefits. First, most code outside of the PolyPraos functions are
  either monomorphic or reuses the existing parameterizations over `proto`,
  which is already ubiquitous. Second, it avoids _implicit_ reuse of today's
  Praos's rules for Leios, which makes _accidental_ reuse less likely---compare
  to type class method defaults.

We do _not_ duplicate more than we need to, though. In particular, many of
Praos's data types and some of its classes gain a `proto` parameter, which is
used so that the single data type definition can be reused for Praos with and
without Leios. The benefit is that there is just one constructor/field per Praos
concept, regardless of whether Leios is enabled.

This is not a fully modular design: subsequent additional extensions will also
need to add to these same definitions (eg adding fields for Ouroboros
Phalanx). That is intentional. This code does not need to be classically
extensible, since there is, unfortunately, no such thing as an extensible
security proof. Our protocol changes are well studied before implemented, and
have never happened concurrently.

In other words: it's a very important benefit that there is _one definition_ to
look at in order to see everything all of the Praos extensions _cumulatively_
do. The type-level DSL used to isolate extension components is simple and
legible; see the `LeiosOnly` data family.
This prepares for the PolyPraos definitions to be defined before Praos.
This commit is merely reorg.
Co-authored-by: Sebastian Nagel <sebastian.nagel@ncoding.at>
@nfrisby
nfrisby force-pushed the nfrisby/leios-main-proto branch from fe6b559 to ca727c6 Compare October 9, 2026 15:15
@nfrisby

nfrisby commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author
  • I made the type of TypeSwitch methods slighty less scary.
  • I removed the _ from pure_LeiosOnly.
  • I rebased Javier's suggestions PR into this one.
  • I added the WhenLeios proto = LeiosOnly proto () and VoidUnlessLeios proto = LeiosOnly proto Void type synonyms.
  • I copied the blockMatchesHeader update from PR Leios: new proto and header validation #2354 --- I overlooked that when migrating my design from PR 2282.

@nfrisby nfrisby changed the title Introduce the Praos2 protocol Introduce the Praos2 protocol: ie Praos with the Leios overlay Oct 9, 2026
@nfrisby nfrisby changed the title Introduce the Praos2 protocol: ie Praos with the Leios overlay Introduce the Praos2 protocol: ie Praos plus the Leios overlay Oct 9, 2026
@nfrisby

nfrisby commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

I've resolved all comments, somewhat unilaterally. We didn't reach unanimity be we did reach plurality :/

@nfrisby

nfrisby commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

@ch1bo said

I only request changes because I want this PR to be done on top of #2354, so we don't do things double (fixing CDDL, passing era into mkHeader, drop seedInitialStakeSnapshots, ...

I just looked through git diff origin/ch1bo/leios-header-validation origin/nfrisby/leios-main-proto. So has Claude. Neither of us sees any unexpected differences.

I had misunderstood the scope of your PR; didn't realize there were parts unrelated to the divergent approach---I should have developed on top, I agree. The main benefit of having not developed on top of another PR is that I was able to minimize the first commit's diff against main (see mention of diff -w in the PR description), which I hope was helpful for reviewers who live on main.

@ch1bo ch1bo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Closing my PR then #2354. Let's move on

transLeiosLS ::
LedgerState (ShelleyBlock (Praos c) ConwayEra) mk ->
LedgerState (ShelleyBlock (Praos2 c) ConwayEra) mk
transLeiosLS (ShelleyLedgerState wo nes st tb) =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nitpick: Naming is off here

The protocols have no Leios in their name, so why should this be called transLeiosLS?

@ch1bo ch1bo linked an issue Oct 9, 2026 that may be closed by this pull request
2 of 3 tasks
@nfrisby
nfrisby merged commit 35d0289 into main Oct 9, 2026
19 checks passed
@nfrisby
nfrisby deleted the nfrisby/leios-main-proto branch October 9, 2026 22:17
@nfrisby

nfrisby commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

I did a pass through PR #2354, since I interrupted its in-progress review. I replied to the open threads there. I don't think any (yet?)deserve follow-up work to this merged PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Production-grade chain selection and block validation

3 participants