'removed' could be true in the response of eth_getLogs?

When using eth_getLogs to get logs of minted blocks, could ‘removed’ field of the returned logs be true?

hi @jason.kim, I might not be completely following your question. That is a field is true when the log was removed, due to a chain reorganization, false if it’s a valid log. Is that missing completely in your output ?

When using eth_getLogs to get logs of a block, this block should be a valid block at that time even if it will be replaced because of a chain reorganization. So I think ‘removed’ should be false in the response of eth_getLogs.

I am trying to use eth_getLogs to get logs and persist them to database block by block. I saw the ‘removed’ field and am thinking about whether I need to handle it.

Another thing that I am not sure is that whether the logs returned by eth_getLogs are final, will they change in future due to a chain reorganization?

So I think ‘removed’ should be false in the response of eth_getLogs.

Not necessary, think about that you’re querying an old block that has logs that were moved because of a reorg, removed = true will specifically tell you to take care of that.

Another thing that I am not sure is that whether the logs returned by eth_getLogs are final, will they change in future due to a chain reorganization?

There is always inconsistency around the chain head but if you take the data a few blocks deeper you’ll probably avoid seeing reorgs. In ethereum -10 blocks should be safe to assume that there won’t be any reorgs but with other chains you might need to go deeper.

These are good discussions about this topic:

Thank you very much.

hi @traian.vila may I know why would an old block contain logs that were removed? I suppose reorgs would remove a block and everything inside the block. For example, if log 124667 in block 7777 and if block 7777 was removed during reorgs, the log was removed as well. thanks in advance

It’s not a matter of a specific block but filters querying for logs in block ranges. Removed it’s the node’s way of telling you that within that block range there was a blockhash that is not longer part of the canonical chain see https://github.com/ethereum/go-ethereum/pull/17743

I see, thanks a lot. I was confused cause when I use eth_getLogs with a block hash of forked block as the parameter, It would return block not found. So I am wondering how to get the log with remove = true.

Thanks for the insightful comments. Do you know if it is possible to see a log whose remove = false becomes removed = true and gets reverted back to false again?