Skip to content

Binary sv2 cleanup#2200

Open
Shourya742 wants to merge 22 commits into
stratum-mining:mainfrom
Shourya742:2026-06-16-binary-sv2-cleanup
Open

Binary sv2 cleanup#2200
Shourya742 wants to merge 22 commits into
stratum-mining:mainfrom
Shourya742:2026-06-16-binary-sv2-cleanup

Conversation

@Shourya742

@Shourya742 Shourya742 commented Jun 16, 2026

Copy link
Copy Markdown
Member

closes: #2171 #2173 #2175 #2176 #2177 #2178 #2179

Apart from the issues mentioned above, this PR introduces several additional improvements:

  1. Removes a significant amount of redundant code.
  2. Expands the API surface. In particular, conversions for copy types are now lossless, while conversions for variable-sized types are performed through TryFrom. (More details can be found in the companion sv2-apps PR. I'm open to suggestions for alternative APIs these additions are primarily based on my experience working with the sv2-apps codebase.)
  3. Introduces a dedicated MAC type, bringing us into full compliance with the specification.
  4. Replaces a large number of handwritten From implementations with MBE macros, significantly reducing duplication.
  5. Fixes issues in the streaming APIs. Previously, certain code paths could lead to unbounded reads, creating potential attack vectors. Reads are now properly bounded, and recursion-related bounds have been removed from the writer implementation.
  6. Removes U32Ref and U8Owned, as they do not provide any meaningful structural advantages.
  7. Adds iterator support for Seq types, allowing users to iterate over elements and perform in-place modifications more ergonomically.

companion stratum-mining/sv2-apps#576

@Shourya742

Copy link
Copy Markdown
Member Author

Awesome, the test are passing, atleast I have not broken any invariants. Need to improve API ergonomics and should be good to go.

@Shourya742 Shourya742 force-pushed the 2026-06-16-binary-sv2-cleanup branch 3 times, most recently from 2f82c63 to 4a79675 Compare June 22, 2026 15:25
@Shourya742 Shourya742 force-pushed the 2026-06-16-binary-sv2-cleanup branch from 4a79675 to 07b0f31 Compare June 22, 2026 15:28
@Shourya742 Shourya742 marked this pull request as ready for review June 22, 2026 15:39
@Shourya742 Shourya742 requested review from GitGab19 and plebhash June 22, 2026 15:39
@Shourya742

Copy link
Copy Markdown
Member Author

I will open issues for all the extra points mentioned in the description.

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

Labels

None yet

Projects

None yet

1 participant