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

eth_getFilterChanges of eth_newBlockFilter returns empty log #829

Closed
frozeman opened this issue Apr 29, 2015 · 9 comments
Closed

eth_getFilterChanges of eth_newBlockFilter returns empty log #829

frozeman opened this issue Apr 29, 2015 · 9 comments
Labels
Milestone

Comments

@frozeman
Copy link
Contributor

When i create a filter with eth_newBlockFilter:

{"jsonrpc":"2.0","method":"eth_newBlockFilter","params":["latest"],"id":2}

And a new block arrives i get:

[
    {
        "id": 35,
        "jsonrpc": "2.0",
        "result": [
            {
                "address": "0x0000000000000000000000000000000000000000",
                "topics": [],
                "data": "0x",
                "blockNumber": "0x0",
                "logIndex": "0x0",
                "blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "transactionHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
                "transactionIndex": "0x0"
            }
        ]
    }
]

The RPC specs state: "For filters created with eth_newBlockFilter log objects are [null]."
This means when you

  • created the filter with "latest" it should return [null] when a new block was mined, otherwise [].
  • create a filter with "pending" it should return [null] when a new pending transaction comes in, otherwise [].
@frozeman frozeman added the RPC label Apr 29, 2015
@frozeman frozeman added this to the Frontier milestone Apr 29, 2015
@tgerring tgerring removed their assignment Apr 29, 2015
@tgerring
Copy link
Contributor

I have a fix prepared but am not certain that the output I'm getting is what is expected.

First I ran:

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newBlockFilter","params":["pending"],"id":73}' http://127.0.0.1:8545

Then

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getFilterChanges","params":["pending"],"id":73}' http://127.0.0.1:8545

Output is

{
    "id": 73,
    "jsonrpc": "2.0",
    "result": []
}

After my fix, output is instead

{
    "id": 73,
    "jsonrpc": "2.0",
    "result": [
        null
    ]
}

This doesn't quite match the examples you provided, so can you supply a minimum test case (using curl commands) and expected result?

@frozeman
Copy link
Contributor Author

your test case is fine. though [null], should only come, if a pending transaction was incoming in the last time since you polled. Otherwise it should still be []

@frozeman
Copy link
Contributor Author

When you call:

curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getFilterChanges","params":["pending"],"id":73}' http://127.0.0.1:8545

multiple times, you should definitely get [] back, as there was likely no pending transaction add in between.

@frozeman
Copy link
Contributor Author

btw. sometimes the blockfilter "latest" is fired multiple times on the same block. @obscuren do you know why this could be?

@tgerring
Copy link
Contributor

The specification states the following functionality:

Array - Array of log objects, or an empty array (if nothing has changed since last poll).
For filters created with eth_newBlockFilter log objects are null.
For filters created with eth_newFilter logs are objects with following params:

This is exceedingly confusing, can we clean it up to make more sense?

@obscuren Logs are stored as map[int]*logFilter in XEth. Is there some natural meaning to the types of logFilters stored that can be checked when returned to match the above functionality?

@frozeman
Copy link
Contributor Author

its actually clearly described imho, but the fact that the log object is null is confusing, yes.

null just means, "yes there was an update", but it doesn't show you what updated.

I will try to write it a bit more clear.

@frozeman
Copy link
Contributor Author

frozeman commented May 4, 2015

I wrote up a proposal of how i think it should better work:
https://github.com/ethereum/wiki/wiki/newBlockFilter-Improvement-Proposal

Please have a look. Especially at the example. The described return value of block filters will be actual useful for developers, while the current ones are only limited useful.

@frozeman
Copy link
Contributor Author

frozeman commented May 6, 2015

Actually this issue is solved when the newBlockFilter proposal is implemented. https://github.com/ethereum/wiki/wiki/newBlockFilter-Improvement-Proposal#new-proposal

@frozeman
Copy link
Contributor Author

frozeman commented May 8, 2015

Fixed through #864

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