Skip to content

Conversation

@tomip01
Copy link
Contributor

@tomip01 tomip01 commented Nov 26, 2025

Motivation

We want this new functions that will be useful for rex and future use.

Description

Add get_batch_number() function to call ethrex_batchNumber
Add send_ethrex_transaction() function to call ethrex_sendTransaction

Copilot AI review requested due to automatic review settings November 26, 2025 20:21
@tomip01 tomip01 requested a review from a team as a code owner November 26, 2025 20:21
@tomip01 tomip01 added the L2 Rollup client label Nov 26, 2025
Copy link
Contributor

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 adds a helper function get_batch_number() to retrieve the current batch number from the L2 RPC endpoint ethrex_batchNumber, which will be useful for rex and future components.

  • Adds get_batch_number() function to query the ethrex_batchNumber RPC endpoint
  • Introduces GetBatchNumberError enum with variants for JSON serialization, RPC errors, and integer parsing
  • Integrates the new error type into the main EthClientError enum

Reviewed changes

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

File Description
crates/networking/rpc/clients/eth/errors.rs Adds GetBatchNumberError enum with SerdeJSONError, RPCError, and ParseIntError variants, and integrates it into EthClientError
crates/l2/networking/rpc/clients.rs Implements get_batch_number() function that calls ethrex_batchNumber RPC endpoint and parses the hex-encoded batch number response

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

github-actions bot commented Nov 26, 2025

Lines of code report

Total lines added: 82
Total lines removed: 0
Total lines changed: 82

Detailed view
+----------------------------------------------------+-------+------+
| File                                               | Lines | Diff |
+----------------------------------------------------+-------+------+
| ethrex/crates/common/types/transaction.rs          | 3207  | +2   |
+----------------------------------------------------+-------+------+
| ethrex/crates/l2/networking/rpc/clients.rs         | 185   | +58  |
+----------------------------------------------------+-------+------+
| ethrex/crates/networking/rpc/clients/eth/errors.rs | 369   | +22  |
+----------------------------------------------------+-------+------+

Comment on lines +332 to +341
#[derive(Debug, thiserror::Error)]
pub enum GetBatchNumberError {
#[error("{0}")]
SerdeJSONError(#[from] serde_json::Error),
#[error("{0}")]
RPCError(String),
#[error("{0}")]
ParseIntError(#[from] std::num::ParseIntError),
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I see the enum above this has a TODO that says Move to L2, do you know if there's an issue created for that? Would it be easy to achieve?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't find any. The closes was this

Copy link
Contributor

@JereSalo JereSalo left a comment

Choose a reason for hiding this comment

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

Looks good, idk if it was tested but it would be good if it was

@tomip01
Copy link
Contributor Author

tomip01 commented Nov 26, 2025

Looks good, idk if it was tested but it would be good if it was

It tested it manually

@tomip01 tomip01 changed the title feat(l2): add helper function for the batch number endpoint feat(l2): add helper functions for l2 eth client Nov 27, 2025
@tomip01 tomip01 requested a review from JereSalo November 27, 2025 14:49
@ilitteri ilitteri enabled auto-merge November 27, 2025 16:01
@ilitteri ilitteri added this pull request to the merge queue Nov 27, 2025
@tomip01 tomip01 removed this pull request from the merge queue due to a manual request Nov 27, 2025
@ilitteri ilitteri added this pull request to the merge queue Nov 27, 2025
Merged via the queue into main with commit d7470b7 Nov 27, 2025
44 checks passed
@ilitteri ilitteri deleted the batch_number_function branch November 27, 2025 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L2 Rollup client

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants