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

Parity RPC filter treating topic filters strangely #2485

Closed
danfinlay opened this issue Oct 6, 2016 · 2 comments
Closed

Parity RPC filter treating topic filters strangely #2485

danfinlay opened this issue Oct 6, 2016 · 2 comments
Assignees
Labels
F2-bug 🐞 The client fails to follow expected behavior. M4-core ⛓ Core client code / Rust.
Milestone

Comments

@danfinlay
Copy link

I've spent a lot of the last two days hunting for this bug, I'm not sure I understand it, but I think I've isolated it.

The RPC API specifies that a topic filter object can specify a topic array that is order-dependent, and can include null values to represent wildcards.

While it is true that submitting all null topics to Parity returns all logs, and returning a null after a valid topic returns valid logs, it seems that adding any topics after a null topic (wildcard value) will always return an empty array of logs.

To see for yourself, here are a series of experiments (I'm pointing at a hosted Parity node in archive mode, you can point it at your own local node if you'd like):

  1. An empty topic query of the DAO contract at a specific block returns two results:
curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","id":12345,"method":"eth_getLogs","params":[{"topics":[null, "0x000000000000000000000000684cc7b2c5e666fdf0bd677b5ecd195eeb949353"],"address":"0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413","fromBlock":"0x247379","toBlock":"0x247379"}]}' https://mainnet.infura.io

Notice the returned items have these two topic arrays:

  1. ["0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925","0x000000000000000000000000684cc7b2c5e666fdf0bd677b5ecd195eeb949353","0x000000000000000000000000bf4ed7b27f1d666546e30d74d50d173d20bca754"]
  2. ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x000000000000000000000000684cc7b2c5e666fdf0bd677b5ecd195eeb949353","0x000000000000000000000000bf4ed7b27f1d666546e30d74d50d173d20bca754"]

First let's do a simple query for just the first one, so just that first topic, which is unique to it, 0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925.

curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","id":12345,"method":"eth_getLogs","params":[{"topics":[ "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925"],"address":"0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413","fromBlock":"0x247379","toBlock":"0x247379"}]}' https://mainnet.infura.io

No problem, we got our owe log back. Now, since they both share their second item, let's try querying for it, by constructing a filter object with a null first argument, followed by the shared filter, 0x000000000000000000000000684cc7b2c5e666fdf0bd677b5ecd195eeb949353.

curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","id":12345,"method":"eth_getLogs","params":[{"topics":[null, "0x000000000000000000000000684cc7b2c5e666fdf0bd677b5ecd195eeb949353"],"address":"0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413","fromBlock":"0x247379","toBlock":"0x247379"}]}' https://mainnet.infura.io

Now we get no results back.

Maybe we can't use null values at all, you say?

Let's now try two null values, just to check if nulls are respected at all:

curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","id":12345,"method":"eth_getLogs","params":[{"topics":[null, null],"address":"0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413","fromBlock":"0x247379","toBlock":"0x247379"}]}' https://mainnet.infura.io

I won't bore you with more examples. A few things I'll tell you:

  • A null can follow a valid filter.
  • A valid filter cannot follow a null.

Anyways, I hope this is enough to debug the issue, thanks!

@gavofyork
Copy link
Contributor

A perfect bug report. If only there were all more like this!

@gavofyork gavofyork added F2-bug 🐞 The client fails to follow expected behavior. M4-core ⛓ Core client code / Rust. labels Oct 6, 2016
@gavofyork gavofyork added this to the 1.4 Civility milestone Oct 6, 2016
@gavofyork
Copy link
Contributor

@tomusdrw could you look into this one? @debris did the filter code so can probably assist where necessary.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
F2-bug 🐞 The client fails to follow expected behavior. M4-core ⛓ Core client code / Rust.
Projects
None yet
Development

No branches or pull requests

4 participants