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

fix(l1): support multiple rpc requests in a single request #2006

Merged
merged 9 commits into from
Feb 25, 2025

Conversation

LeanSerra
Copy link
Contributor

@LeanSerra LeanSerra commented Feb 19, 2025

Motivation

The hive tests from engine-withdrawals were failing with a panic because we were asuming only a single RLPRequest could be received but the test sent an array of requets

Description

Introduce a wrapper struct that contains a Single type for single RPCRequest and Multiple for an array of requests, so serde can deserialize into the correct one.
If we have an array of request we execute them sequentially. Then return a json encoded array of responses.
The function rpc_response was also changed to return serde_json::Value because it was returning an incorrect value when using it to create the array of responses.

This PR fixes the following tests from engine-withdrawals:

  • "Withdrawals Fork on Block 1 - 1 Block Re-Org"
  • "Withdrawals Fork on Block 1 - 8 Block Re-Org NewPayload"
  • "Withdrawals Fork on Block 8 - 10 Block Re-Org NewPayload"
  • "Withdrawals Fork on Canonical Block 8 / Side Block 7 - 10 Block Re-Org"
  • "Withdrawals Fork on Canonical Block 8 / Side Block 9 - 10 Block Re-Org"

Advances #1586

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
now serde can deserialize both into an intermediate enum then match if
the value is a single rpcRequest or a vec of requests
@LeanSerra LeanSerra added the L1 Ethereum client label Feb 19, 2025
@LeanSerra LeanSerra self-assigned this Feb 19, 2025
@LeanSerra LeanSerra requested a review from a team as a code owner February 19, 2025 13:18
Copy link

github-actions bot commented Feb 19, 2025

| File                                                         | Lines | Diff |
+--------------------------------------------------------------+-------+------+
| /home/runner/work/ethrex/ethrex/crates/networking/rpc/rpc.rs | 611   | +15  |
+--------------------------------------------------------------+-------+------+

Total lines added: +15
Total lines removed: 0
Total lines changed: 15

}
.unwrap()
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

can you add a unit test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@mpaulucci mpaulucci left a comment

Choose a reason for hiding this comment

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

+1 after adding unit test

@@ -576,4 +594,64 @@ mod tests {
let expected_response = to_rpc_response_success_value(&expected_response_string);
assert_eq!(response.to_string(), expected_response.to_string());
}

#[test]
fn map_http_requests_single_item_then_array_json_test() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

you're not calling handle_http_request , which is the function you want to test. Let's better remove this test and merge without a test. Seems we need to create some test utils to easily test endpoints

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mpaulucci mpaulucci changed the title fix(l1): handle_http_request could receive arrays of requests fix(l1): support multiple rpc requests in a single request Feb 24, 2025
@LeanSerra LeanSerra enabled auto-merge February 25, 2025 18:33
@LeanSerra LeanSerra added this pull request to the merge queue Feb 25, 2025
Merged via the queue into main with commit 86b6bda Feb 25, 2025
24 checks passed
@LeanSerra LeanSerra deleted the l1/fix_handle_http_request branch February 25, 2025 18:58
JereSalo pushed a commit that referenced this pull request Feb 28, 2025
**Motivation**

The hive tests from `engine-withdrawals` were failing with a panic
because we were asuming only a single RLPRequest could be received but
the test sent an array of requets

**Description**

Introduce a wrapper struct that contains a `Single` type for single
`RPCRequest` and `Multiple` for an array of requests, so serde can
deserialize into the correct one.
If we have an array of request we execute them sequentially. Then return
a json encoded array of responses.
The function `rpc_response` was also changed to return
`serde_json::Value` because it was returning an incorrect value when
using it to create the array of responses.

This PR fixes the following tests from `engine-withdrawals`:

- "Withdrawals Fork on Block 1 - 1 Block Re-Org"
- "Withdrawals Fork on Block 1 - 8 Block Re-Org NewPayload"
- "Withdrawals Fork on Block 8 - 10 Block Re-Org NewPayload"
- "Withdrawals Fork on Canonical Block 8 / Side Block 7 - 10 Block
Re-Org"
- "Withdrawals Fork on Canonical Block 8 / Side Block 9 - 10 Block
Re-Org"

Advances #1586
fkrause98 pushed a commit that referenced this pull request Mar 5, 2025
**Motivation**

The hive tests from `engine-withdrawals` were failing with a panic
because we were asuming only a single RLPRequest could be received but
the test sent an array of requets

**Description**

Introduce a wrapper struct that contains a `Single` type for single
`RPCRequest` and `Multiple` for an array of requests, so serde can
deserialize into the correct one.
If we have an array of request we execute them sequentially. Then return
a json encoded array of responses.
The function `rpc_response` was also changed to return
`serde_json::Value` because it was returning an incorrect value when
using it to create the array of responses.

This PR fixes the following tests from `engine-withdrawals`:

- "Withdrawals Fork on Block 1 - 1 Block Re-Org"
- "Withdrawals Fork on Block 1 - 8 Block Re-Org NewPayload"
- "Withdrawals Fork on Block 8 - 10 Block Re-Org NewPayload"
- "Withdrawals Fork on Canonical Block 8 / Side Block 7 - 10 Block
Re-Org"
- "Withdrawals Fork on Canonical Block 8 / Side Block 9 - 10 Block
Re-Org"

Advances #1586
fkrause98 pushed a commit that referenced this pull request Mar 5, 2025
**Motivation**

The hive tests from `engine-withdrawals` were failing with a panic
because we were asuming only a single RLPRequest could be received but
the test sent an array of requets

**Description**

Introduce a wrapper struct that contains a `Single` type for single
`RPCRequest` and `Multiple` for an array of requests, so serde can
deserialize into the correct one.
If we have an array of request we execute them sequentially. Then return
a json encoded array of responses.
The function `rpc_response` was also changed to return
`serde_json::Value` because it was returning an incorrect value when
using it to create the array of responses.

This PR fixes the following tests from `engine-withdrawals`:

- "Withdrawals Fork on Block 1 - 1 Block Re-Org"
- "Withdrawals Fork on Block 1 - 8 Block Re-Org NewPayload"
- "Withdrawals Fork on Block 8 - 10 Block Re-Org NewPayload"
- "Withdrawals Fork on Canonical Block 8 / Side Block 7 - 10 Block
Re-Org"
- "Withdrawals Fork on Canonical Block 8 / Side Block 9 - 10 Block
Re-Org"

Advances #1586
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
L1 Ethereum client
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants