Skip to content
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

SSZ implementation for alloy primitives #407

Merged
merged 10 commits into from
Nov 8, 2023

Conversation

loocapro
Copy link
Contributor

@loocapro loocapro commented Nov 7, 2023

Motivation

I found my self needing to wrap alloy primitives types and implement SSZ on it. I thought it could be useful to have those trait implementations downstream.

Solution

Implementing SSZ as a conditional flag for alloy primitives.

  • Fixed bytes
  • Bytes
  • Address
  • Bloom

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@loocapro loocapro marked this pull request as ready for review November 7, 2023 16:00
@prestwich
Copy link
Member

Do you mind sharing more about your usecase? Are there other primitive types that would be useful with SSZ? We have so far restricted alloy to EL-layer tooling.

@loocapro
Copy link
Contributor Author

loocapro commented Nov 7, 2023

Do you mind sharing more about your usecase? Are there other primitive types that would be useful with SSZ? We have so far restricted alloy to EL-layer tooling.

Hi @prestwich, we are running a custom reth implementation and we had to implement SSZ traits for alloy types.

So we thought that it might be useful to share our implementation and just consume it from alloy-primitives.

Other 2 types that we also implemented are U64 and U256 from reth::primitives which re-exports from ruint.

@prestwich
Copy link
Member

Cool, let me sync with the other maintainers and get back to this

Separately, I'd be in favor of a PR for SSZ support in the ruint support modules

Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

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

Fine with me

crates/primitives/src/bits/macros.rs Outdated Show resolved Hide resolved
crates/primitives/src/bits/macros.rs Outdated Show resolved Hide resolved
@loocapro
Copy link
Contributor Author

loocapro commented Nov 7, 2023

Cool, let me sync with the other maintainers and get back to this

Separately, I'd be in favor of a PR for SSZ support in the ruint support modules

Sure will also take care of it.

@loocapro loocapro changed the title feat: encode and decode for fixed bytes SSZ implementation for alloy primitives Nov 7, 2023
crates/primitives/src/bits/macros.rs Outdated Show resolved Hide resolved
crates/primitives/src/bits/macros.rs Outdated Show resolved Hide resolved
crates/primitives/src/bits/macros.rs Outdated Show resolved Hide resolved
crates/primitives/Cargo.toml Outdated Show resolved Hide resolved
Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

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

Thanks!

@loocapro
Copy link
Contributor Author

loocapro commented Nov 8, 2023

Thanks!

Thank you!

@DaniPopes DaniPopes merged commit 814181e into alloy-rs:main Nov 8, 2023
20 checks passed
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