0

When I used "eth_getLogs" to query logs of a pending transaction, the log info showed up as below, but after the tx was confirmed, the logs are not available on etherescan. This tx used the delegate call. Could anyone advise on why the logs disappeared?

log info by querying ""eth_getLogs"" when the tx is pending:

  topics: [
    '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
    '0x0000000000000000000000006463bd6026a2e7bfab5851b62969a92f7cca0eb6',
    '0x000000000000000000000000860bd2dba9cd475a61e6d1b45e16c365f6d78f66'
  ],
  data: '0x00000000000000000000000000000000000000000000058677bb9e53cb507ddd',
  blockNumber: '0xb117d6',
  transactionHash: '0x9b51d7093c4507fa96af3fd4418c508700cb9f69f3cea9d7f5a192afa30cd1bf',
  transactionIndex: '0x41',
  blockHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
  logIndex: '0x4f',
  removed: false
}

transaction on etherscan after confirmation: https://etherscan.io/tx/0x9b51d7093c4507fa96af3fd4418c508700cb9f69f3cea9d7f5a192afa30cd1bf

0xdev
  • 51
  • 1
  • 3

2 Answers2

1

Since the results of the transaction execution, including the generated events, depend on the state of the contract and the account at the time of execution, then, apparently, the shown log corresponds to the state if the transaction were included in block 0xb117d6, but at the time of real execution in the context of block 0xb117d8, the state block / account were already different, which led to a different result.

In addition, the prediction of the execution of pending transactions is based on the data of your specific node, which, in the presence of forks, may differ from the data of the main chain.

Mad Jackal
  • 1,219
  • 1
  • 7
  • 9
  • Thanks @Mad Jackal for the answer, I posted my understanding in another answer above. Is my understanding correct? – 0xdev Jan 08 '21 at 01:45
0

@Mad Jacal Thanks for your answer! Is my understanding bellow correct?

Let's say there's a contract like this:

contract test {
    bool isTrue = true;
    function foo() public {
        if (isTrue) {
            emit Event(..)
        } else {
            return;
        }
    }
    function changeToFalse() public {
        isTrue = false;
    }
}

The first caller called "foo" function and second caller called "changeToFalse" function. The two txs are in the same block but the second caller's tx is in front of the first caller's tx due to higher gas price. The pending logs will show the event log if the node does not hear about the second caller's tx yet. Is this what you mean?

0xdev
  • 51
  • 1
  • 3
  • Yes, it can have that effect. Strictly speaking, it is impossible to predict the order of execution of transactions by a miner if they are both in the queue. – Mad Jackal Jan 08 '21 at 13:19