Skip to content

cardano-strict-containers: add Data.Bitmap - #700

Open
gdeest wants to merge 5 commits into
IntersectMBO:masterfrom
gdeest:gdeest/data-bitmap
Open

gdeest wants to merge 5 commits into
IntersectMBO:masterfrom
gdeest:gdeest/data-bitmap

Conversation

@gdeest

@gdeest gdeest commented Sep 24, 2026 •

Copy link
Copy Markdown

Adds Data.Bitmap to cardano-strict-containers (moved from Ouroboros.Consensus.Util.Bitmap).

Now uses MSB-encoding so that it can be easily re-used by Leios BitField requirements.

Used by #701 .

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated
  • All visible changes are prepended to the latest section of a CHANGELOG.md for the affected packages.
    New section is never added with the code changes. (See RELEASING.md)
  • When applicable, versions are updated in .cabal and CHANGELOG.md files according to the
    versioning process.
  • The version bounds in .cabal files for all affected packages are updated.
    If you change the bounds in a cabal file, that package itself must have a version increase. (See RELEASING.md)
  • Self-reviewed the diff

@agustinmista agustinmista 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.

Looking good! Just some small nits.

Comment thread cardano-strict-containers/src/Data/Bitmap.hs Outdated
Comment thread cardano-strict-containers/test/Test/Data/Bitmap.hs Outdated
Comment thread cardano-strict-containers/testlib/Test/Cardano/StrictContainers/Instances.hs Outdated
@gdeest
gdeest force-pushed the gdeest/data-bitmap branch from fd59e15 to 7f29c17 Compare October 7, 2026 07:51
@gdeest
gdeest marked this pull request as ready for review October 7, 2026 08:06
@gdeest
gdeest requested review from a team and lehins as code owners October 7, 2026 08:06
@gdeest gdeest mentioned this pull request Oct 7, 2026
6 tasks done

@agustinmista agustinmista 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.

This looks great! Thanks for expanding the previous test suite 🧪

It looks like cabal-format is complaining in CI, though.

@gdeest
gdeest force-pushed the gdeest/data-bitmap branch from 7000c81 to e4bb2dd Compare October 14, 2026 08:52
@ch1bo

ch1bo commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Now uses MSB-encoding so that it can be easily re-used by Leios BitField requirements.

I think you should be doing this in this PR to prove that claim and so we end up with the same number of bitfield implementations.


-- | A compact bitmap representation using serialisation-ready ByteStrings.
--
-- Adapted from @Cardano.Leios.BitMapPV@ in the @leios-wfa-ls-demo@ package.

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.

This was a proof of concept. You should instead base your implementation on the production grade version introduced in cardano-crypto-leios


-- | A bitmap over a number of indexes known to its users: @⌈n/8⌉@ bytes,
-- MSB-first, bit @i@ set iff index @i@ is set.
newtype Bitmap = Bitmap {bitmapBytes :: ByteString}

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.

This is not a strict container if at its core is a lazy bytestring. Should be a strict bytestring or a ByteArray

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants