Skip to content

Commit

Permalink
fix: implement a temporary proxy layer for get requests (#1940)
Browse files Browse the repository at this point in the history
  • Loading branch information
carneiro-cw authored Jan 7, 2025
1 parent a22f796 commit 7ee665a
Show file tree
Hide file tree
Showing 8 changed files with 262 additions and 34 deletions.
57 changes: 30 additions & 27 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,15 @@ rlp = "=0.5.2"
triehash = "=0.8.4"

# network
jsonrpsee = { version = "=0.24.6", features = ["server", "client"] }
jsonrpsee = { version = "=0.24.7", features = ["server", "client"] }
reqwest = { version = "=0.12.4", features = ["json"] }
tonic = "=0.11.0"
tower = "=0.4.13"
tower-http = { version = "=0.5.2", features = ["cors"] }
http = "=1.1.0"
http-body = "=1.0.1"
http-body-util = "=0.1.2"
bytes = "=1.9.0"

# observability
console-subscriber = "=0.2.0"
Expand Down
6 changes: 6 additions & 0 deletions e2e/test/automine/e2e-json-rpc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ describe("JSON-RPC", () => {
const error = await sendAndGetError("eth_blockNumber");
expect(error.code).eq(1003);

// GET request to health endpoint should fail when unknown clients are disallowed
const healthResponseErr = await fetch("http://localhost:3000/health");
expect(healthResponseErr.status).eq(500);

// Requests with client identification should succeed
const validHeaders = {
"x-app": "test-client",
Expand All @@ -76,6 +80,8 @@ describe("JSON-RPC", () => {

// URL parameters should also work
const validUrlParams = ["app=test-client", "client=test-client"];
const healthResponse = await fetch(`http://localhost:3000/health?app=test-client`);
expect(healthResponse.status).eq(200);
for (const param of validUrlParams) {
const providerWithParam = new JsonRpcProvider(`http://localhost:3000?${param}`);
const blockNumber = await providerWithParam.getBlockNumber();
Expand Down
1 change: 1 addition & 0 deletions src/eth/primitives/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ pub use slot::Slot;
pub use slot_index::SlotIndex;
pub use slot_value::SlotValue;
pub use stratus_error::ConsensusError;
pub use stratus_error::ErrorCode;
pub use stratus_error::ImporterError;
pub use stratus_error::RpcError;
pub use stratus_error::StateError;
Expand Down
1 change: 1 addition & 0 deletions src/eth/rpc/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Ethereum JSON-RPC server.
pub mod proxy_get_request;
mod rpc_client_app;
mod rpc_config;
mod rpc_context;
Expand Down
Loading

0 comments on commit 7ee665a

Please sign in to comment.