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

feat(sidecar): constraints client #212

Merged
merged 15 commits into from
Sep 9, 2024

Conversation

namn-grg
Copy link
Contributor

@namn-grg namn-grg commented Sep 5, 2024

Context

This PR update the mevboost client to constraint client with support of the new updated constraints api
Closes #208

@namn-grg namn-grg added C: bolt-sidecar Component: bolt-sidecar T: feature Type: Feature labels Sep 5, 2024
@namn-grg namn-grg self-assigned this Sep 5, 2024
Base automatically changed from feat/bolt-boost to unstable September 5, 2024 13:51
@namn-grg namn-grg marked this pull request as ready for review September 6, 2024 06:47
@namn-grg namn-grg requested a review from mempirate September 6, 2024 06:47
Copy link
Contributor

@mempirate mempirate left a comment

Choose a reason for hiding this comment

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

Great work! Requested some small changes

bolt-sidecar/src/client/constraint_client.rs Outdated Show resolved Hide resolved
bolt-sidecar/src/crypto/bls.rs Show resolved Hide resolved
bolt-sidecar/src/driver.rs Outdated Show resolved Hide resolved
Comment on lines 70 to 71
fn total_leaves(&self) -> usize {
4 + self.constraints.len()
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we start at 4?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure, I took it from the bolt-boost impl by @mempirate

Copy link
Contributor

@thedevbirb thedevbirb Sep 6, 2024

Choose a reason for hiding this comment

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

My bad I haven't noticed it in his PR, but I'm pretty sure it is because the way you encode the struct (which has $$4$$ properties, along with a list) in a binary merkle tree.
@mempirate could you please confirm and document the number in the bolt-boost impl as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also I'm not sure about this computation since it should take into account chunking and padding: https://github.com/ethereum/consensus-specs/blob/dev/ssz/simple-serialize.md#merkleization

Copy link
Contributor

Choose a reason for hiding this comment

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

We have 3 "unit" types + a list, which will add another leaf for the length + leaves for each individual elements! Will document

Copy link
Contributor

Choose a reason for hiding this comment

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

I realized I haven't tested this - @namn-grg could you add a quick test that generates a random ConstraintsMessage and calculates the hash tree root?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mempirate added lmk how it looks?

Copy link
Collaborator

@merklefruit merklefruit Sep 6, 2024

Choose a reason for hiding this comment

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

LGTM, we can improve it with the use of arbitrary and arbtest for prop testing but random is good enough for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

This test only asserts that hash_root is 32 bytes long but that's trivial due to the signature of the hash_tree_root method. @mempirate how do we intend to test this?
In my opinion we should compare the output of this implementation with what fastssz outputs once having generated the hash tree root implementation for this struct using codegen: https://github.com/ferranbt/fastssz/blob/main/sszgen/main.go

@namn-grg namn-grg requested a review from mempirate September 6, 2024 08:28
@thedevbirb thedevbirb changed the base branch from unstable to feat/new-constraints-api September 6, 2024 10:09
Copy link
Contributor

@mempirate mempirate left a comment

Choose a reason for hiding this comment

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

Some final perf improvements requested

bolt-sidecar/src/primitives/mod.rs Outdated Show resolved Hide resolved
bolt-sidecar/src/primitives/mod.rs Outdated Show resolved Hide resolved
@mempirate mempirate merged commit 9d599d6 into feat/new-constraints-api Sep 9, 2024
3 checks passed
@mempirate mempirate deleted the naman/feat/constraints-client branch September 9, 2024 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: bolt-sidecar Component: bolt-sidecar T: feature Type: Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update constraints-API client
4 participants