Skip to content

local_filter_middleware is different from geth filter when to_block is specified #2352

Open
@yiteng-guo

Description

@yiteng-guo

What was wrong?

# local filter
fltr = w3.eth.filter(
{
    "fromBlock": 14231060,
    "toBlock": 14231065,
})
fltr.get_new_entries() # Return [], assuming current block number 14231070
fltr.get_new_entries() # Return [logs between block number 14231070 and 14231072], assuming current block number 14231072

# geth filter
fltr = w3.eth.filter(
{
    "fromBlock": 14231060,
    "toBlock": 14231065,
})
fltr.get_new_entries() # Return [], assuming current block number 14231070
fltr.get_new_entries() # Return [], assuming current block number 14231072

Okay, I have to say this is very confusing. The local middleware output is different from geth and both of them are counter-intuitive IMO. I think the most intuitive output should be

fltr.get_new_entries() # Return  [logs between block number 14231060 and 14231065], assuming current block number 14231070
fltr.get_new_entries() # Return [], assuming current block number 14231072

but geth doesn't think so. I guess web3.py should probably just follow what geth does for the sake of consistency.

How can it be fixed?

The fix is very simple. We just need to add continue here https://github.com/ethereum/web3.py/blob/master/web3/middleware/filter.py#L155.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions