optimism
optimism copied to clipboard
Events not available immediately after transactions are processed
Describe the bug Events are not available until a short time after the block is processed. Requesting events for a given block returns an empty array for a short period of time after the block is processed.
To Reproduce Use this. It will send transactions and try to retrieve logs immediately when it learns of a new block, and 10 seconds after. The immediate retrieval almost always returns nothing, the delayed retrieval sometimes returns nothing.
I observed a case where partial events were returned for a block but have been unable to reproduce. There were two transactions in the block and I got logs from one of them but not the other. There was a single transaction that caused 2 separate contracts to emit events, I got events from one of the contracts but not the other.
Expected behavior All logs are returned or an error status is returned.
Screenshots n/a
System Specs: n/a
Additional context
For anyone else running into this issue, events on Arbitrum are immediately available when a new block is reported.
I think this is a result of the current network architecture. When you send a transaction to kovan.optimism.io, your request is being routed directly to the Sequencer node. The Sequencer then returns a result back to you which acts like a commitment of your transaction being included in the chain. However, when you send a read request (like querying events), your requests are being handled by some verifier (not the Sequencer). It usually takes a few seconds for the verifier to get block data from the Sequencer, so there's a delay in when the tx is made and when the event is available.
Ah interesting. Confirmed, the issue is not present on an Alchemy node. This might a good thing to put in the docs for the public infra.
Yeah just checked Alchemy. I think we're planning to start routing some (maybe all?) requests to Alchemy/Infura. Need to check on a timeline for that.