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

chore: remove ssz_rs dependency #1671

Merged
merged 6 commits into from
Feb 13, 2025
Merged

chore: remove ssz_rs dependency #1671

merged 6 commits into from
Feb 13, 2025

Conversation

oac1771
Copy link
Contributor

@oac1771 oac1771 commented Feb 7, 2025

What was wrong?

FIxes #1417

light-client crate used ssz-rs crate for SSZ handling instead of ethereum-ssz crate

How was it fixed?

This PR removes the ssz-rs dependency and uses ethereum-ssz instead

To-Do

Copy link
Member

@ogenev ogenev left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM 👍 !

Comment on lines 20 to 19
trin-validation.workspace = true
ethereum_ssz.workspace = true
Copy link
Member

@KolbyML KolbyML Feb 7, 2025

Choose a reason for hiding this comment

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

can you sort these alphabetically

.expect("Unable to convert state root to bytes"),
)?;
let leaf_hash = leaf_object.tree_hash_root();
let state_root = bytes32_to_node(&Bytes32::from(attested_header.state_root.0.to_vec()))?;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let state_root = bytes32_to_node(&Bytes32::from(attested_header.state_root.0.to_vec()))?;
let state_root = B256::from_slice(&attested_header.state_root.0.to_vec()))?;

Comment on lines 68 to 69
genesis_root: Bytes32,
) -> Result<Bytes32> {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
genesis_root: Bytes32,
) -> Result<Bytes32> {
genesis_root: Bytes32,
) -> Result<B256> {

let d = [start, end].concat();
Ok(d.to_vec().try_into()?)
Ok(d.to_vec().into())
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Ok(d.to_vec().into())
Ok(B256::from_slice(d))

) -> Result<Node> {
let genesis_root = genesis_root.to_vec().try_into()?;
) -> Result<B256> {
let genesis_root = genesis_root.to_vec().into();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
let genesis_root = genesis_root.to_vec().into();
let genesis_root = B256::from_slice(genesis_root);

}

pub fn compute_domain(
domain_type: &[u8],
fork_version: Vector<u8, 4>,
fork_version: FixedVector<u8, U4>,
genesis_root: Bytes32,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
genesis_root: Bytes32,
genesis_root: B256,

Comment on lines 47 to 48
object_root: Bytes32,
domain: Bytes32,
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
object_root: Bytes32,
domain: Bytes32,
object_root: B256,
domain: B256,

genesis_validator_root: Bytes32,
}

pub fn compute_signing_root(object_root: Bytes32, domain: Bytes32) -> Result<Node> {
let mut data = SigningData {
pub fn compute_signing_root(object_root: Bytes32, domain: Bytes32) -> B256 {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
pub fn compute_signing_root(object_root: Bytes32, domain: Bytes32) -> B256 {
pub fn compute_signing_root(object_root: B256, domain: B256) -> B256 {


pub type Bytes32 = Vector<u8, 32>;
pub type Bytes32 = FixedVector<u8, U32>;
Copy link
Member

Choose a reason for hiding this comment

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

Might as well remove this type Bytes32 and replace all with B256

@oac1771
Copy link
Contributor Author

oac1771 commented Feb 9, 2025

@KolbyML, thanks for the feedback, I made the changes you suggested!

Copy link
Member

@KolbyML KolbyML left a comment

Choose a reason for hiding this comment

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

:shipit: looks good after the 2 last problems are fixed I will merge the PR.

This PR looks clean 🚀

@@ -17,6 +17,7 @@ anyhow.workspace = true
async-trait.workspace = true
chrono.workspace = true
ethportal-api.workspace = true
ethereum_ssz.workspace = true
Copy link
Member

Choose a reason for hiding this comment

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

this isn't worked alphabetically

Comment on lines 1 to 7
// pub fn bytes_to_bytes32(bytes: &[u8]) -> Bytes32 {
// FixedVector::from(bytes.to_vec())
// }

use crate::types::Bytes32;

pub fn bytes_to_bytes32(bytes: &[u8]) -> Bytes32 {
Vector::from_iter(bytes.to_vec())
}

pub fn bytes32_to_node(bytes: &Bytes32) -> Result<Node> {
Ok(Node::from_bytes(bytes.as_slice().try_into()?))
}
// pub fn bytes32_to_node(bytes: &Bytes32) -> Result<B256> {
// Ok(B256::from_slice(bytes.iter().as_slice()))
// }
Copy link
Member

Choose a reason for hiding this comment

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

please delete this code as it is no longer used

@KolbyML
Copy link
Member

KolbyML commented Feb 13, 2025

@oac1771 could you dm me on discord and I will help you fix your git history

@KolbyML KolbyML changed the title remove ssz_rs dependency chore: remove ssz_rs dependency Feb 13, 2025
@KolbyML KolbyML merged commit bea5b2f into ethereum:master Feb 13, 2025
14 checks passed
@KolbyML
Copy link
Member

KolbyML commented Feb 13, 2025

Thank you for your first contribution 🚀

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.

In light-client, use ethereum_ssz instead of ssz-rs
3 participants