Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fa7e8a1
Implement BLS-based crypto helpers to instantiate voting committes
agustinmista Apr 9, 2026
e4d46e9
Implement BLS-based TestCrypto scheme for voting committee tests
agustinmista Apr 9, 2026
1823275
Add changelog
agustinmista Apr 13, 2026
bcb1c02
Add helpers for voting committee tests
agustinmista Apr 9, 2026
56e60d9
Tweak existing WFALS model and conformance tests
agustinmista Apr 9, 2026
1550571
Add conformance tests for WFALS implementation
agustinmista Apr 9, 2026
dc620e6
Add property tests for WFALS implementation
agustinmista Apr 9, 2026
7924d9e
Add property tests for EveryoneVotes implementation
agustinmista Apr 9, 2026
ed23ba7
Add property tests for UniqueVotesWithSameTarget
agustinmista Apr 15, 2026
4fd81d9
Introduce Bytes32RealPoint
agustinmista May 7, 2026
d780576
Introduce O.C.Util.Bitmap
agustinmista Mar 27, 2026
026f735
Define concrete Peras certs and votes using BLS signatures
agustinmista Mar 27, 2026
03bcc00
Define PerasCrypto and wire up voting committee instance using BLS
agustinmista Apr 10, 2026
a5a233b
Add conversions between Peras votes/certs and voting committee types
agustinmista Apr 21, 2026
3a37c2a
Add test helpers for PerasCrypto
agustinmista Apr 21, 2026
5016342
Add property tests for Bitmap library
agustinmista Apr 21, 2026
98dbfef
Add serialization roundtrip tests for PerasCert and PerasVote
agustinmista Mar 27, 2026
f81ff76
Add conversion roundtrip tests between Peras votes/certs and voting c…
agustinmista Apr 21, 2026
966acfc
Add changelog
agustinmista Apr 21, 2026
ae706cd
Split base Peras types into separate module
agustinmista May 5, 2026
e1f5820
Remove PerasCfg type family
agustinmista May 5, 2026
ca7a14e
Consolidate Peras vote and certificate projection type classes
agustinmista May 8, 2026
8a5fb1d
Introduce O.C.Peras.(Vote|Cert).Mock
agustinmista May 13, 2026
0a1ed3a
Split degenerate BlockSupportsPeras instance
agustinmista May 8, 2026
4197f46
Tweak TestBlock to use getPerasCertInBlock in tests
agustinmista May 18, 2026
1a6c36c
Re-change Peras target to use `Point blk` instead of `PerasBoostedBlock`
tbagrel1 May 18, 2026
037eb76
Define differentiated BlockSupportsPeras instances for ShelleyBlocks
tbagrel1 May 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
A new scriv changelog fragment.

Uncomment the section that is right (remove the HTML comment wrapper).
For top level release notes, leave all the headers commented out.
-->

<!--
### Breaking

- A bullet item for the Breaking category.

-->
### Non-Breaking

- Implemented BLS-based crypto helpers to instantiate voting committee implementations.

<!--
### Patch

- A bullet item for the Patch category.

-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!--
A new scriv changelog fragment.

Uncomment the section that is right (remove the HTML comment wrapper).
For top level release notes, leave all the headers commented out.
-->

<!--
### Breaking

- A bullet item for the Breaking category.

-->

### Non-Breaking

- Introduce `Ouroboros.Consensus.Util.Bitmap` providing `ByteString`-based compact bitmaps.
- Define `PerasBLSCrypto` scheme with support for all the voting committee superclasses.
- Define concrete `PerasVote` and `PerasCert` types using BLS signatures.
- Define `PerasVoteCompatibleWithVotingCommittee` and `PerasCertCompatibleWithVotingCommittee` type classes with conversions between concrete Peras types and their abstract voting committee counterparts.
- Instantiate `VotingCommitteeSupportsPeras` for both `WFALS` and `EveryoneVotes`.

<!--
### Patch

- A bullet item for the Patch category.

-->
23 changes: 23 additions & 0 deletions changelog.d/20260507_102103_agustin.mista_bytes32realpoint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!--
A new scriv changelog fragment.

Uncomment the section that is right (remove the HTML comment wrapper).
For top level release notes, leave all the headers commented out.
-->

<!--
### Breaking

- A bullet item for the Breaking category.

-->
### Non-Breaking

- Introduce `Bytes32RealPoint` for real points with 32byte header hashes.

<!--
### Patch

- A bullet item for the Patch category.

-->
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import Ouroboros.Consensus.Ledger.CommonProtocolParams
import Ouroboros.Consensus.Ledger.Extended
import Ouroboros.Consensus.Ledger.Query
import Ouroboros.Consensus.Ledger.SupportsPeerSelection
import Ouroboros.Consensus.Ledger.SupportsPeras (LedgerSupportsPeras)
import Ouroboros.Consensus.Ledger.SupportsProtocol
import Ouroboros.Consensus.Ledger.Tables.Utils
import Ouroboros.Consensus.Util (ShowProxy (..))
Expand Down Expand Up @@ -574,3 +575,10 @@ decodeByronResult query = case query of

instance CanUpgradeLedgerTables LedgerState ByronBlock where
upgradeTables _ _ = id

{-------------------------------------------------------------------------------
LedgerSupportsPeras
-------------------------------------------------------------------------------}

-- | Default instance with no Peras support
instance LedgerSupportsPeras ByronBlock
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ import Ouroboros.Consensus.Byron.Crypto.DSIGN
import Ouroboros.Consensus.Byron.Ledger
import Ouroboros.Consensus.Byron.Ledger.Conversions
import Ouroboros.Consensus.Byron.Ledger.Inspect ()
import Ouroboros.Consensus.Byron.Node.Peras ()
import Ouroboros.Consensus.Byron.Node.Serialisation ()
import Ouroboros.Consensus.Byron.Protocol
import Ouroboros.Consensus.Config
import Ouroboros.Consensus.Config.SupportsNode
import Ouroboros.Consensus.HeaderValidation
import Ouroboros.Consensus.Ledger.Abstract
import Ouroboros.Consensus.Ledger.Extended
import Ouroboros.Consensus.Ledger.SupportsPeras (LedgerSupportsPeras)
import Ouroboros.Consensus.Node.InitStorage
import Ouroboros.Consensus.Node.ProtocolInfo
import Ouroboros.Consensus.Node.Run
Expand Down Expand Up @@ -303,8 +303,6 @@ instance NodeInitStorage ByronBlock where
RunNode instance
-------------------------------------------------------------------------------}

instance LedgerSupportsPeras ByronBlock

instance BlockSupportsMetrics ByronBlock where
isSelfIssued = isSelfIssuedConstUnknown

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{-# LANGUAGE FlexibleInstances #-}
{-# OPTIONS_GHC -Wno-orphans #-}

-- | Empty Peras support for Byron.
--
-- NOTE: this module exists solely because the orphan module
-- 'Ouroboros.Consensus.Byron.Node.Serialisation' needs this instance, but
-- defining it there would be too confusing.
module Ouroboros.Consensus.Byron.Node.Peras () where

import Ouroboros.Consensus.Block.SupportsPeras (BlockSupportsPeras)
import Ouroboros.Consensus.Byron.Ledger.Block (ByronBlock)

{-------------------------------------------------------------------------------
BlockSupportsPeras
-------------------------------------------------------------------------------}

-- NOTE: Byron does not support Peras, so we can use the empty instance here.
instance BlockSupportsPeras ByronBlock
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import Data.Word
import Ouroboros.Consensus.Block
import Ouroboros.Consensus.Byron.Ledger
import Ouroboros.Consensus.Byron.Ledger.Conversions
import Ouroboros.Consensus.Byron.Node.Peras ()
import Ouroboros.Consensus.Byron.Protocol
import Ouroboros.Consensus.HeaderValidation
import Ouroboros.Consensus.Ledger.Query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ class
HasPartialConsensusConfig proto
, DecCBOR (SL.PState era)
, Crypto (ProtoCrypto proto)
, -- Peras constraints
BlockSupportsPeras (ShelleyBlock proto era)
, -- Backwards compatibility
Plain.FromCBOR (LegacyPParams era)
, Plain.ToCBOR (LegacyPParams era)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import Ouroboros.Consensus.Node.ProtocolInfo
import Ouroboros.Consensus.Node.Run
import Ouroboros.Consensus.Protocol.Abstract
import Ouroboros.Consensus.Protocol.TPraos
import Ouroboros.Consensus.Shelley.Eras
import Ouroboros.Consensus.Shelley.Ledger
import Ouroboros.Consensus.Shelley.Ledger.Inspect ()
import Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion ()
Expand Down Expand Up @@ -115,11 +116,71 @@ instance ConsensusProtocol proto => BlockSupportsSanityCheck (ShelleyBlock proto
configAllSecurityParams = pure . protocolSecurityParam . topLevelConfigProtocol

instance
( ShelleyCompatible proto era
, LedgerSupportsProtocol (ShelleyBlock proto era)
, BlockSupportsSanityCheck (ShelleyBlock proto era)
, TxLimits (ShelleyBlock proto era)
, SerialiseNodeToClientConstraints (ShelleyBlock proto era)
( ShelleyCompatible proto ShelleyEra
, LedgerSupportsProtocol (ShelleyBlock proto ShelleyEra)
, BlockSupportsSanityCheck (ShelleyBlock proto ShelleyEra)
, TxLimits (ShelleyBlock proto ShelleyEra)
, SerialiseNodeToClientConstraints (ShelleyBlock proto ShelleyEra)
, Crypto (ProtoCrypto proto)
) =>
RunNode (ShelleyBlock proto era)
RunNode (ShelleyBlock proto ShelleyEra)

instance
( ShelleyCompatible proto AllegraEra
, LedgerSupportsProtocol (ShelleyBlock proto AllegraEra)
, BlockSupportsSanityCheck (ShelleyBlock proto AllegraEra)
, TxLimits (ShelleyBlock proto AllegraEra)
, SerialiseNodeToClientConstraints (ShelleyBlock proto AllegraEra)
, Crypto (ProtoCrypto proto)
) =>
RunNode (ShelleyBlock proto AllegraEra)

instance
( ShelleyCompatible proto MaryEra
, LedgerSupportsProtocol (ShelleyBlock proto MaryEra)
, BlockSupportsSanityCheck (ShelleyBlock proto MaryEra)
, TxLimits (ShelleyBlock proto MaryEra)
, SerialiseNodeToClientConstraints (ShelleyBlock proto MaryEra)
, Crypto (ProtoCrypto proto)
) =>
RunNode (ShelleyBlock proto MaryEra)

instance
( ShelleyCompatible proto AlonzoEra
, LedgerSupportsProtocol (ShelleyBlock proto AlonzoEra)
, BlockSupportsSanityCheck (ShelleyBlock proto AlonzoEra)
, TxLimits (ShelleyBlock proto AlonzoEra)
, SerialiseNodeToClientConstraints (ShelleyBlock proto AlonzoEra)
, Crypto (ProtoCrypto proto)
) =>
RunNode (ShelleyBlock proto AlonzoEra)

instance
( ShelleyCompatible proto BabbageEra
, LedgerSupportsProtocol (ShelleyBlock proto BabbageEra)
, BlockSupportsSanityCheck (ShelleyBlock proto BabbageEra)
, TxLimits (ShelleyBlock proto BabbageEra)
, SerialiseNodeToClientConstraints (ShelleyBlock proto BabbageEra)
, Crypto (ProtoCrypto proto)
) =>
RunNode (ShelleyBlock proto BabbageEra)

instance
( ShelleyCompatible proto ConwayEra
, LedgerSupportsProtocol (ShelleyBlock proto ConwayEra)
, BlockSupportsSanityCheck (ShelleyBlock proto ConwayEra)
, TxLimits (ShelleyBlock proto ConwayEra)
, SerialiseNodeToClientConstraints (ShelleyBlock proto ConwayEra)
, Crypto (ProtoCrypto proto)
) =>
RunNode (ShelleyBlock proto ConwayEra)

instance
( ShelleyCompatible proto DijkstraEra
, LedgerSupportsProtocol (ShelleyBlock proto DijkstraEra)
, BlockSupportsSanityCheck (ShelleyBlock proto DijkstraEra)
, TxLimits (ShelleyBlock proto DijkstraEra)
, SerialiseNodeToClientConstraints (ShelleyBlock proto DijkstraEra)
, Crypto (ProtoCrypto proto)
) =>
RunNode (ShelleyBlock proto DijkstraEra)
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wno-orphans #-}

-- | Mocked Peras support for Shelley.
--
-- NOTE: this module exists solely because the orphan module
-- 'Ouroboros.Consensus.Shelley.Node.Serialisation' needs this instance, but
-- defining it there would be too confusing.
module Ouroboros.Consensus.Shelley.Node.Peras () where

import Cardano.Ledger.Api
import Ouroboros.Consensus.Block.SupportsPeras
( BlockSupportsPeras (..)
, VoidPerasError
)
import Ouroboros.Consensus.Peras.Cert.Mock
( MockPerasCert (..)
, forgeMockPerasCert
, validateMockPerasCert
)
import Ouroboros.Consensus.Peras.Vote.Mock
( MockPerasVote (..)
, validateMockPerasVote
)
import Ouroboros.Consensus.Shelley.Ledger.Block
( ShelleyBlock
, ShelleyCompatible
)

{-------------------------------------------------------------------------------
BlockSupportsPeras
-------------------------------------------------------------------------------}

-- Peras support starts with DijkstraEra, so earlier eras use the default void
-- implementation.

instance ShelleyCompatible proto ShelleyEra => BlockSupportsPeras (ShelleyBlock proto ShelleyEra)
instance ShelleyCompatible proto AllegraEra => BlockSupportsPeras (ShelleyBlock proto AllegraEra)
instance ShelleyCompatible proto MaryEra => BlockSupportsPeras (ShelleyBlock proto MaryEra)
instance ShelleyCompatible proto AlonzoEra => BlockSupportsPeras (ShelleyBlock proto AlonzoEra)
instance ShelleyCompatible proto BabbageEra => BlockSupportsPeras (ShelleyBlock proto BabbageEra)
instance ShelleyCompatible proto ConwayEra => BlockSupportsPeras (ShelleyBlock proto ConwayEra)

-- NOTE: this is a mocked up implementation without crypto!
-- TODO: replace this with a concrete implementation using 'Peras.Vote.V1' and
-- 'Peras.Cert.V1' for era >= DijkstraEra.
instance
ShelleyCompatible proto DijkstraEra =>
BlockSupportsPeras (ShelleyBlock proto DijkstraEra)
where
type PerasVote (ShelleyBlock proto DijkstraEra) = MockPerasVote (ShelleyBlock proto DijkstraEra)
type PerasCert (ShelleyBlock proto DijkstraEra) = MockPerasCert (ShelleyBlock proto DijkstraEra)
type PerasError (ShelleyBlock proto DijkstraEra) = VoidPerasError (ShelleyBlock proto DijkstraEra)

validatePerasVote = validateMockPerasVote
validatePerasCert = validateMockPerasCert
forgePerasCert = forgeMockPerasCert

-- TODO: extract actual Peras certificates from blocks
getPerasCertInBlock _ = Nothing
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import Ouroboros.Consensus.Protocol.TPraos
import Ouroboros.Consensus.Shelley.Eras
import Ouroboros.Consensus.Shelley.Ledger
import Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion ()
import Ouroboros.Consensus.Shelley.Node.Peras ()
import Ouroboros.Consensus.Shelley.Protocol.Abstract
( pHeaderBlockSize
, pHeaderSize
Expand Down Expand Up @@ -128,22 +129,47 @@ instance
SerialiseNodeToNode
-------------------------------------------------------------------------------}

instance
-- | Shared implementation of 'estimateBlockSize' for all Shelley-based eras.
estimateBlockSizeShelley ::
ShelleyCompatible proto era =>
SerialiseNodeToNodeConstraints (ShelleyBlock proto era)
Header (ShelleyBlock proto era) ->
SizeInBytes
estimateBlockSizeShelley hdr = overhead + hdrSize + bodySize
where
-- The maximum block size is 65536, the CBOR-in-CBOR tag for this block
-- is:
--
-- > D8 18 # tag(24)
-- > 1A 00010000 # bytes(65536)
--
-- Which is 7 bytes, enough for up to 4294967295 bytes.
overhead = 7 {- CBOR-in-CBOR -} + 1 {- encodeListLen -}
bodySize = fromIntegral . pHeaderBlockSize . shelleyHeaderRaw $ hdr
hdrSize = fromIntegral . pHeaderSize . shelleyHeaderRaw $ hdr

instance ShelleyCompatible proto ShelleyEra => SerialiseNodeToNodeConstraints (ShelleyBlock proto ShelleyEra) where
estimateBlockSize = estimateBlockSizeShelley

instance ShelleyCompatible proto AllegraEra => SerialiseNodeToNodeConstraints (ShelleyBlock proto AllegraEra) where
estimateBlockSize = estimateBlockSizeShelley

instance ShelleyCompatible proto MaryEra => SerialiseNodeToNodeConstraints (ShelleyBlock proto MaryEra) where
estimateBlockSize = estimateBlockSizeShelley

instance ShelleyCompatible proto AlonzoEra => SerialiseNodeToNodeConstraints (ShelleyBlock proto AlonzoEra) where
estimateBlockSize = estimateBlockSizeShelley

instance ShelleyCompatible proto BabbageEra => SerialiseNodeToNodeConstraints (ShelleyBlock proto BabbageEra) where
estimateBlockSize = estimateBlockSizeShelley

instance ShelleyCompatible proto ConwayEra => SerialiseNodeToNodeConstraints (ShelleyBlock proto ConwayEra) where
estimateBlockSize = estimateBlockSizeShelley

instance
ShelleyCompatible proto DijkstraEra =>
SerialiseNodeToNodeConstraints (ShelleyBlock proto DijkstraEra)
where
estimateBlockSize hdr = overhead + hdrSize + bodySize
where
-- The maximum block size is 65536, the CBOR-in-CBOR tag for this block
-- is:
--
-- > D8 18 # tag(24)
-- > 1A 00010000 # bytes(65536)
--
-- Which is 7 bytes, enough for up to 4294967295 bytes.
overhead = 7 {- CBOR-in-CBOR -} + 1 {- encodeListLen -}
bodySize = fromIntegral . pHeaderBlockSize . shelleyHeaderRaw $ hdr
hdrSize = fromIntegral . pHeaderSize . shelleyHeaderRaw $ hdr
estimateBlockSize = estimateBlockSizeShelley

-- | CBOR-in-CBOR for the annotation. This also makes it compatible with the
-- wrapped ('Serialised') variant.
Expand Down
Loading