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

remove ssz_rs dependency #1671

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

remove ssz_rs dependency #1671

wants to merge 5 commits into from

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 21
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!

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