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

[Bug] Single-paremeter requests do not serialize correctly to array of items #12

Closed
Evalir opened this issue Oct 30, 2023 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@Evalir
Copy link
Contributor

Evalir commented Oct 30, 2023

Component

json-rpc

What version of Alloy are you on?

latest

Operating System

macOS (Apple Silicon)

Describe the bug

When issuing single-parameter json-rpc requests to endpoints like eth_getBalance, it seems they are not serialized correctly to still send an array of params in JSON, failing with the following error: ErrorPayload { code: -32600, message: "Invalid json-rpc request", data: None }

The workaround is to make Params be a Vec<_>, but this should not be necessary.

@Evalir Evalir added the bug Something isn't working label Oct 30, 2023
@prestwich
Copy link
Member

JSON-RPC2.0 spec is that params may be of arbitrary structure. the odd list encoding is ethereum-specific, and applies kinda unevenly across endpoints. Adding list-wrapping logic to the Request type would also cause some issues with Request<Box<RawValue>> I think?

This should probably be solved by adding a GetBalanceParams struct similar to this

struct GetBalanceParams {
    address: Address,
    height: Option<String>,
}

impl From<Address> for GetBalanceParams { ... }

impl Serialize for GetBalanceParams {
   fn serialize(s: S) {
     let seq = s.serialize_sequence();
     ...
  }
}

@prestwich
Copy link
Member

closing as resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants