3

While working with log filters i've noticed interesting behavior of logs during chain reorganizations. Sometimes same event (log) can have different logIndex in transaction after chain reorganizations.

My question is: can logIndex change in the same block? For example: it happens that sometimes you can get duplicate events from listening eth_getFilterChanges, can it be that event you get as Duplicate (has same tx hash and blocknum) can have another logIndex than before?

Second question is: why do logIndex change at all?!

1 Answer 1

2

In a chain reorganization the order of the transaction can change, some transactions can be removed, and new ones added replacing others.

Since the log order follows the order of the transactions a chain reorganization can cause the logIndex to be different.

Moreover it is possible some events disappear from a block and appear again later if the transaction that generated the event was removed from a block.

The reverse also happens, a new event can appear if a new transaction was added to the block.

5
  • Thanks for your answer, but can logIndex change in same block while i'm listening for logChanges from geth?
    – Coder
    Commented Jan 26, 2018 at 10:11
  • And also how many blocks later can happen reorganization?
    – Coder
    Commented Jan 26, 2018 at 10:14
  • In a chain reorg a block can be replaced by another, so the transaction order can be different, and the logindex will change accordingly. A chain reorg has no limit on how many blocks it will affect. Most wallets use a 12 blocks as confirmation, meaning a chain reorg of more than 12 blocks is unlikely.
    – Ismael
    Commented Jan 26, 2018 at 14:31
  • Thanks for your reply, so there is no guarantee that there wont be any chain reorganizations even after 12 blocks?
    – Coder
    Commented Jan 26, 2018 at 14:34
  • 1
    There aren't any guarantee. A reorg can have an arbitrary length, although it is very unlikely because you need to have more computing power than the whole network.
    – Ismael
    Commented Nov 28, 2019 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.