Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Can no longer filter transactions with RPC API #11189

Closed
lamafab opened this issue Oct 22, 2019 · 4 comments · Fixed by #11192
Closed

Can no longer filter transactions with RPC API #11189

lamafab opened this issue Oct 22, 2019 · 4 comments · Fixed by #11192
Assignees

Comments

@lamafab
Copy link
Contributor

lamafab commented Oct 22, 2019

  • Parity Ethereum version: v2.7.0-nightly-6960d35ab-20191019
  • Operating system: Ubuntu 19.04
  • Installation: built from source
  • Fully synchronized: no
  • Network: ethereum
  • Restarted: yes

Yesterday I was contacted by a stranger about a PR I did a few months ago #10506. The RPC API parity_pendingTransactions was able to accept filtering parameters in the following form:

{
    "from": {
        "eq": "0x5f3dffcf347944d3739b0805c934d86c8621997f"
    },
    "to": {
        "eq": "0xe8b2d01ffa0a15736b2370b6e5064f9702c891b6"
    },
}

This no longer seems to be the case. It's also not documented in the docs. The changed I made are still part of the codebase.

How to reproduce

  1. Run the parity node
  2. Make the following RPC request:
curl --data '{"method":"parity_pendingTransactions","params":[{"from":{"eq":"0x5f3dffcf347944d3739b0805c934d86c8621997f"},"to": {"eq":"0xe8b2d01ffa0a15736b2370b6e5064f9702c891b6"}}],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545
  1. The node returns the following error message:
{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params: invalid type: map, expected usize."},"id":1}

Expected behavior
The node should return the filtered transactions (if any).

Please clarify whether this feature is actually intended to work/should have been implemented.

Thanks.

@lamafab
Copy link
Contributor Author

lamafab commented Oct 22, 2019

I assume it has to do with the following definitions/parameters:

rpc/src/v1/traits/parity.rs

#[rpc(name = "parity_pendingTransactions")]
fn pending_transactions(&self, _: Option<usize>, _: Option<FilterOptions>) -> Result<Vec<Transaction>>

rpc/src/v1/impls/parity.rs

fn pending_transactions(&self, limit: Option<usize>, filter: Option<FilterOptions>) -> Result<Vec<Transaction>> {

With limit does not seem to work either (limit does work on its own, however)...

By specifying parameters like this:

[
    5,
    {
        "from": {
            "eq": "0x5f3dffcf347944d3739b0805c934d86c8621997f"
        },
        "to": {
            "eq": "0xe8b2d01ffa0a15736b2370b6e5064f9702c891b6"
        },
    }
]

I get:

{"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params: invalid type: string \"from\", expected a borrowed string."},"id":1}

@grbIzl grbIzl self-assigned this Oct 22, 2019
@niklasad1
Copy link
Collaborator

niklasad1 commented Oct 22, 2019

Hey @lamafab

Thank you such awesome bug report, however, it seems like the bug was introduced by 3f61f2d
and has nothing to do with removal of anonymous traits params

curl --data '{"method":"parity_pendingTransactions","params":[{"from":{"eq":"0x5f3dffcf347944d3739b0805c934d86c8621997f"},"to": {"eq":"0xe8b2d01ffa0a15736b2370b6e5064f9702c891b6"}}],"id":1,"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545

I think that deserialization will never work because it will be deserialized to Array[FilterOptions] in that case so either params: [null, {}] or group limit and FilterOptions into a separate type

[
    5,
    {
        "from": {
            "eq": "0x5f3dffcf347944d3739b0805c934d86c8621997f"
        },
        "to": {
            "eq": "0xe8b2d01ffa0a15736b2370b6e5064f9702c891b6"
        },
    }
]

Don't know really but must be something sneaky with deserialization

@lamafab
Copy link
Contributor Author

lamafab commented Oct 22, 2019

Thanks for the feedback. When I implemented and tested it, the curl requests went just fine. Maybe some upstream changes with the deserialization process? I don't know, I can look into this some more later.

EDIT:
Looks to be related to this: serde-rs/serde#1413 . Give me a sec.

@lamafab
Copy link
Contributor Author

lamafab commented Oct 22, 2019

@niklasad1 Here you go #11192. Fixing this was much easier than expected :)

EDIT:

This works now.

Example

"params": [
  15,
  {
    "to": {
        "eq": "0xe8b2d01ffa0a15736b2370b6e5064f9702c891b6"
    },
    "gas": {
        "gt": "0x493e0"
    },
  }
]

curl example:

curl --data '{"method":"parity_pendingTransactions","id": 1,"params":[5,{"from":{"eq":"0x5f3dffcf347944d3739b0805c934d86c8621997f"},"to": {"eq":"0xe8b2d01ffa0a15736b2370b6e5064f9702c891b6"}}],"jsonrpc":"2.0"}' -H "Content-Type: application/json" -X POST localhost:8545

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants