Skip to content

feat(l2): exchange commit hash in node-prover communication #3339

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

Merged
merged 15 commits into from
Jun 30, 2025

Conversation

avilagaston9
Copy link
Contributor

@avilagaston9 avilagaston9 commented Jun 26, 2025

Motivation

We want to prevent a divergence between the code that is running in the L2 node and the prover.

Description

  • Updates the client version to use GIT_BRANCH and GIT_SHA instead of RUSTC_COMMIT_HASH.
  • Adds a build.rs script for both the node and prover, using vergen_git2 to export the git env vars.
  • Adds a code_version field to the BatchRequest message.
  • Introduces a new ProofData message: InvalidCodeVersion.

How to test

You can create an empty commit with:

git commit --allow-empty -m "empty commit"

Then run the node and the prover using different commits.

Warning

Remember to run make build-prover whenever you change the commit

Closes #3311

Copy link

github-actions bot commented Jun 26, 2025

Lines of code report

Total lines added: 70
Total lines removed: 0
Total lines changed: 70

Detailed view
+-------------------------------------------------+-------+------+
| File                                            | Lines | Diff |
+-------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/build.rs                      | 14    | +7   |
+-------------------------------------------------+-------+------+
| ethrex/cmd/ethrex/utils.rs                      | 145   | +1   |
+-------------------------------------------------+-------+------+
| ethrex/crates/l2/build.rs                       | 7     | +7   |
+-------------------------------------------------+-------+------+
| ethrex/crates/l2/prover/build.rs                | 7     | +7   |
+-------------------------------------------------+-------+------+
| ethrex/crates/l2/prover/src/prover.rs           | 126   | +11  |
+-------------------------------------------------+-------+------+
| ethrex/crates/l2/sequencer/proof_coordinator.rs | 523   | +20  |
+-------------------------------------------------+-------+------+
| ethrex/crates/l2/tee/quote-gen/build.rs         | 7     | +7   |
+-------------------------------------------------+-------+------+
| ethrex/crates/l2/tee/quote-gen/src/main.rs      | 106   | +2   |
+-------------------------------------------------+-------+------+
| ethrex/crates/l2/tee/quote-gen/src/sender.rs    | 80    | +8   |
+-------------------------------------------------+-------+------+

@avilagaston9 avilagaston9 self-assigned this Jun 26, 2025
@avilagaston9 avilagaston9 added the L2 Rollup client label Jun 26, 2025
@avilagaston9 avilagaston9 marked this pull request as ready for review June 26, 2025 20:37
@Copilot Copilot AI review requested due to automatic review settings June 26, 2025 20:37
@avilagaston9 avilagaston9 requested a review from a team as a code owner June 26, 2025 20:37
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures the node and prover exchange and verify the same git commit and branch information, preventing version divergence by embedding a code_version field in requests and responses.

  • Added build.rs scripts and build-dependencies in multiple crates to export VERGEN_GIT_BRANCH and VERGEN_GIT_SHA.
  • Extended ProofData and client/prover code to include a code_version in BatchRequest and handle InvalidCodeVersion responses.
  • Updated the CLI get_client_version and build scripts in cmd/ethrex to use the new git-based version fields.

Reviewed Changes

Copilot reviewed 13 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/l2/tee/quote-gen/src/sender.rs Propagate and handle code_version in get_batch
crates/l2/tee/quote-gen/src/main.rs Pass code_version into do_loop and initialize it
crates/l2/tee/quote-gen/build.rs Add build script for exporting git branch and SHA
crates/l2/tee/quote-gen/Cargo.toml Configure build.rs and add vergen-git2 dependency
crates/l2/sequencer/proof_coordinator.rs Extend ProofData, add mismatch handling, and DRY send_response
crates/l2/prover/src/prover.rs Include code_version in Prover and request logic
crates/l2/prover/build.rs Add build script for exporting git branch and SHA
crates/l2/prover/Cargo.toml Configure build.rs and add vergen-git2 dependency
crates/l2/build.rs Add build script for exporting git branch and SHA
crates/l2/Cargo.toml Add vergen-git2 to build-dependencies
cmd/ethrex/utils.rs Update get_client_version format to include git branch and SHA
cmd/ethrex/build.rs Merge Rustc and Git build steps, add git2 builder
cmd/ethrex/Cargo.toml Swap vergen to vergen-git2 for build-dependencies
Comments suppressed due to low confidence (3)

crates/l2/sequencer/proof_coordinator.rs:67

  • [nitpick] The numeric step annotation ("3.") is separated from the description for BatchRequest; consider merging the numeric label and its description into a single doc comment to keep the enum documentation consistent and clear.
    /// Code version is used to ensure the client and server are compatible.

crates/l2/sequencer/proof_coordinator.rs:432

  • This new mismatch branch for handling InvalidCodeVersion appears untested; consider adding unit or integration tests to verify that when the code versions differ, the server sends InvalidCodeVersion and the client reacts correctly.
    if code_version != state.code_version {

cmd/ethrex/build.rs:2

  • RustcBuilder is not provided by vergen_git2; it should be imported from the vergen crate (e.g., use vergen::{Emitter, RustcBuilder};) and then combined with the git2 instructions.
use vergen_git2::{Emitter, Git2Builder, RustcBuilder};

Copy link
Contributor

@LeanSerra LeanSerra left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link
Contributor

@fedacking fedacking left a comment

Choose a reason for hiding this comment

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

LGTM

@avilagaston9 avilagaston9 added this pull request to the merge queue Jun 30, 2025
Merged via the queue into main with commit 68f360f Jun 30, 2025
32 checks passed
@avilagaston9 avilagaston9 deleted the feat/add_version_to_node_prover_communication branch June 30, 2025 21:13
SDartayet pushed a commit that referenced this pull request Jul 1, 2025
**Motivation**

We want to prevent a divergence between the code that is running in the
L2 node and the prover.

**Description**

- Updates the client version to use `GIT_BRANCH` and `GIT_SHA` instead
of `RUSTC_COMMIT_HASH`.
- Adds a `build.rs` script for both the node and prover, using
`vergen_git2` to export the git env vars.
- Adds a `code_version` field to the `BatchRequest` message.
- Introduces a new `ProofData` message: `InvalidCodeVersion`.

## How to test

You can create an empty commit with:

```bash
git commit --allow-empty -m "empty commit"
```

Then run the node and the prover using different commits.

> [!WARNING]
> Remember to run `make build-prover` whenever you change the commit

Closes #3311
ElFantasma pushed a commit that referenced this pull request Jul 1, 2025
**Motivation**

We want to prevent a divergence between the code that is running in the
L2 node and the prover.

**Description**

- Updates the client version to use `GIT_BRANCH` and `GIT_SHA` instead
of `RUSTC_COMMIT_HASH`.
- Adds a `build.rs` script for both the node and prover, using
`vergen_git2` to export the git env vars.
- Adds a `code_version` field to the `BatchRequest` message.
- Introduces a new `ProofData` message: `InvalidCodeVersion`.

You can create an empty commit with:

```bash
git commit --allow-empty -m "empty commit"
```

Then run the node and the prover using different commits.

> [!WARNING]
> Remember to run `make build-prover` whenever you change the commit

Closes #3311
d-roak pushed a commit to 1sixtech/ethrex that referenced this pull request Jul 17, 2025
…ass#3339)

**Motivation**

We want to prevent a divergence between the code that is running in the
L2 node and the prover.

**Description**

- Updates the client version to use `GIT_BRANCH` and `GIT_SHA` instead
of `RUSTC_COMMIT_HASH`.
- Adds a `build.rs` script for both the node and prover, using
`vergen_git2` to export the git env vars.
- Adds a `code_version` field to the `BatchRequest` message.
- Introduces a new `ProofData` message: `InvalidCodeVersion`.

## How to test

You can create an empty commit with:

```bash
git commit --allow-empty -m "empty commit"
```

Then run the node and the prover using different commits.

> [!WARNING]
> Remember to run `make build-prover` whenever you change the commit

Closes lambdaclass#3311
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L2 Rollup client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

L2: check that both L2 node and Prover are running the same code
3 participants