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

log filter by topic not working properly #725

Closed
frozeman opened this issue Apr 15, 2015 · 5 comments
Closed

log filter by topic not working properly #725

frozeman opened this issue Apr 15, 2015 · 5 comments
Assignees
Labels
Milestone

Comments

@frozeman
Copy link
Contributor

If i filter logs by topic and i provide the topics in the filter options not in the same order as the topics in the result logs, it doesn't match the log an therefor doesn't return it.

E.g. assuming you loaded the test blockchain from the test repo as follows:

geth --rpccorsdomain "http://localhost:3000" blocktest <pathToTestRepo>/tests/BlockTests/bcRPC_API_Test.json RPC_API_Test rpc

If you call:

{"jsonrpc":"2.0","method":"eth_newFilter","params":[{"topics":['0x0000000000000000000000000000000000000000000000000000000000000001'],"fromBlock":"0x0","toBlock":"latest"}],"id":3}

And then the eth_getFilterLogs with the filter id:

{"jsonrpc":"2.0","method":"eth_getFilterLogs","params":["0x19"],"id":4}

You get 4 Logs back, even though 8 have that topic too.

See the full list of possible logs in this test chain:

"[
  {
    "address": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
    "topics": [
      "0x0000000000000000000000000000000000000000000000000000000000000001",
      "0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
      "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
    ],
    "data": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe9000000000000000000000000000000000000000000000000000000000000002a",
    "blockNumber": 32,
    "logIndex": 0,
    "blockHash": "0xd153907eccbb699e569ba2d07833aec324785be70bbccc22008aed5d08993235",
    "transactionHash": "0xf9be3eaf451bc4a33e3f2f6451ea34771e93bbcd04b7ba34a6290a2edbef0ff3",
    "transactionIndex": 0
  },
  {
    "address": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
    "topics": [
      "0xd5f0a30e4be0c6be577a71eceb7464245a796a7e6a55c0d971837b250de05f4e",
      "0x0000000000000000000000000000000000000000000000000000000000000001",
      "0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
      "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
    ],
    "data": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe9000000000000000000000000000000000000000000000000000000000000002a",
    "blockNumber": 31,
    "logIndex": 0,
    "blockHash": "0x4454afa5c6805f17106dd476bd029a357df9e37effce0acbdac5afda92eff25a",
    "transactionHash": "0x629052cc68c6a06a5f2b77e77aca5dff365a9a067f581f19321bdec3425d9a95",
    "transactionIndex": 0
  },
  {
    "address": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
    "topics": [
      "0x0000000000000000000000000000000000000000000000000000000000000001",
      "0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
      "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
    ],
    "data": "0x000000000000000000000000000000000000000000000000000000000000002a",
    "blockNumber": 30,
    "logIndex": 0,
    "blockHash": "0x82e12f65ce1381610bb1a5b1d76f72396e52f859b2c1d576ff45c52e0e4b2f1e",
    "transactionHash": "0x41fcc90e5c92a34d05da00445643d0326fb515c7ffe2d03ce9a4e13c24bfa6af",
    "transactionIndex": 0
  },
  {
    "address": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
    "topics": [
      "0x317b31292193c2a4f561cc40a95ea0d97a2733f14af6d6d59522473e1f3ae65f",
      "0x0000000000000000000000000000000000000000000000000000000000000001",
      "0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
      "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
    ],
    "data": "0x000000000000000000000000000000000000000000000000000000000000002a",
    "blockNumber": 29,
    "logIndex": 0,
    "blockHash": "0x29468b28f7dab0d61ed4c467816e8a8222242bbf4a0dffec3f6bcd7fb79b4267",
    "transactionHash": "0x6156f7531aabee57c9f5dafc9d10babfbe28fa93edac4604f52cef6943c729ad",
    "transactionIndex": 0
  },
  {
    "address": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
    "topics": [
      "0x0000000000000000000000000000000000000000000000000000000000000001",
      "0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b"
    ],
    "data": "0x000000000000000000000000000000000000000000000000000000000000002a",
    "blockNumber": 28,
    "logIndex": 0,
    "blockHash": "0x3409ca9c70c1e729592b8cc7845457d1bd7a319e89200af249bb517c56b3f46b",
    "transactionHash": "0x50ddec638c0eefce884a4d32f222f22da00edef1a01ef69e83ed1ad0c37eb048",
    "transactionIndex": 0
  },
  {
    "address": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
    "topics": [
      "0x0e216b62efbb97e751a2ce09f607048751720397ecfb9eef1e48a6644948985b",
      "0x0000000000000000000000000000000000000000000000000000000000000001",
      "0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b"
    ],
    "data": "0x000000000000000000000000000000000000000000000000000000000000002a",
    "blockNumber": 27,
    "logIndex": 0,
    "blockHash": "0x76397ef48a05c4aac791330025f60bf8a75a31d89d5fa20118e6715ce293cb4b",
    "transactionHash": "0x6b14525fd65d861008e858a1f142e620d0bee53c49c20889473e080b9896c29e",
    "transactionIndex": 0
  },
  {
    "address": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
    "topics": [
      "0x0000000000000000000000000000000000000000000000000000000000000001"
    ],
    "data": "0x000000000000000000000000000000000000000000000000000000000000002a",
    "blockNumber": 26,
    "logIndex": 0,
    "blockHash": "0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238",
    "transactionHash": "0xc6690f190205060f7f5a99f1c8fae2d134f2cc27b9af46365e113b12f72dcc3f",
    "transactionIndex": 0
  },
  {
    "address": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
    "topics": [
      "0x81933b308056e7e85668661dcd102b1f22795b4431f9cf4625794f381c271c6b",
      "0x0000000000000000000000000000000000000000000000000000000000000001"
    ],
    "data": "0x000000000000000000000000000000000000000000000000000000000000002a",
    "blockNumber": 25,
    "logIndex": 0,
    "blockHash": "0xf715a597e843da8061fa43282541c9f06603e0367352fec8ea1558c0d65b5307",
    "transactionHash": "0xd2cf5ef4da57649184da0fdc94a7a1feaa16c2cf94267770245807ef5007df64",
    "transactionIndex": 0
  },
  {
    "address": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
    "topics": [],
    "data": "0x000000000000000000000000000000000000000000000000000000000000002a",
    "blockNumber": 24,
    "logIndex": 0,
    "blockHash": "0xe8c22cfb77aa8ae1c5349f83207f095df1d1bbd1f3472721cd992d6f1000674a",
    "transactionHash": "0x0f26964273dba4b7a1973310411234b711b903e3f8cd9e823aa08ec1b7d2ae4e",
    "transactionIndex": 0
  },
  {
    "address": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
    "topics": [
      "0x65c9ac8011e286e89d02a269890f41d67ca2cc597b2c76c7c69321ff492be580"
    ],
    "data": "0x000000000000000000000000000000000000000000000000000000000000002a",
    "blockNumber": 23,
    "logIndex": 0,
    "blockHash": "0xca80200a53fae63ce61c0a60c6ed90dd01d61c87ee9defc92210632d85c96938",
    "transactionHash": "0x7379b1b8c875a9737ae503b2ea5c75d5f3b50b409345c998dbce15ab439ecc14",
    "transactionIndex": 0
  }
]"
@frozeman frozeman added the RPC label Apr 15, 2015
@frozeman frozeman added this to the Frontier milestone Apr 15, 2015
@obscuren
Copy link
Contributor

It will only give you 4 blocks because it can only match the first topic. Topics shouldn't auto magic match on all topics.

@frozeman
Copy link
Contributor Author

Actually the index parameter is always the same, though the first topic is always the signature except when its an anonymous function. But i guess the current way is still more valid.

@obscuren
Copy link
Contributor

If you'd like to ignore specific fields use something like

{"jsonrpc":"2.0","method":"eth_newFilter","params":[{"topics":[null, '0x0000000000000000000000000000000000000000000000000000000000000001'],"fromBlock":"0x0","toBlock":"latest"}],"id":3}

@frozeman
Copy link
Contributor Author

ok, passing null doesn't work:
Im getting an invalid params error:

Invalid type on field : not a number or string

@obscuren obscuren mentioned this issue Apr 20, 2015
3 tasks
obscuren added a commit to obscuren/go-ethereum that referenced this issue Apr 21, 2015
You can now specify `null` as a way of saying "not interested in this
topic, match all". core.Filter assumes the zero'd address to be the
wildcard. JSON rpc assumes empty strings to be wildcards.
@frozeman
Copy link
Contributor Author

The problem persists. Now we don't get the "should be string" error anymore, as you "let" in null. But the returned logs are [], so no match.

e.g. i send:

{"jsonrpc":"2.0","method":"eth_newFilter","params":[{
                        "fromBlock": '0x0',
                        "toBlock": 'latest',
                        "topics": [null, null, '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff']
                    }],"id":4}

and would expect to get this log back:

{
    "address": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
    "topics": [
      "0x0000000000000000000000000000000000000000000000000000000000000001",
      "0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b",
      "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
    ],
    "data": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe9000000000000000000000000000000000000000000000000000000000000002a",
    "blockNumber": 32,
    "logIndex": 0,
    "blockHash": "0xfa1f5bd36066b12b181d62caf8ec98c764beab18448e3b23beb351e9ae4b2d4e",
    "transactionHash": "0xf9be3eaf451bc4a33e3f2f6451ea34771e93bbcd04b7ba34a6290a2edbef0ff3",
    "transactionIndex": 0
  }

the same goes for an non-anonymous log, which has a signature at topicp[0], so we would just append a null more to the topics array.

@frozeman frozeman reopened this Apr 23, 2015
@obscuren obscuren self-assigned this Apr 24, 2015
obscuren added a commit that referenced this issue Apr 24, 2015
core: fixed wildcard topic filters. Closes #725
tony-ricciardi pushed a commit to tony-ricciardi/go-ethereum that referenced this issue Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants